aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui
diff options
context:
space:
mode:
authorJP Rosevear <jpr@ximian.com>2002-01-03 23:01:46 +0800
committerJP Rosevear <jpr@src.gnome.org>2002-01-03 23:01:46 +0800
commit0fe2d5201603163b11341cb3719500fa762bc532 (patch)
tree3441593f37dc1a3de3bc534fdc969060e6cdf987 /calendar/gui
parentc3cc401ac8aee97bd9625ea5d420ce2bf70363bd (diff)
downloadgsoc2013-evolution-0fe2d5201603163b11341cb3719500fa762bc532.tar
gsoc2013-evolution-0fe2d5201603163b11341cb3719500fa762bc532.tar.gz
gsoc2013-evolution-0fe2d5201603163b11341cb3719500fa762bc532.tar.bz2
gsoc2013-evolution-0fe2d5201603163b11341cb3719500fa762bc532.tar.lz
gsoc2013-evolution-0fe2d5201603163b11341cb3719500fa762bc532.tar.xz
gsoc2013-evolution-0fe2d5201603163b11341cb3719500fa762bc532.tar.zst
gsoc2013-evolution-0fe2d5201603163b11341cb3719500fa762bc532.zip
confirm expunging of the tasks (tasks_control_expunge_cmd): verb callback
2002-01-03 JP Rosevear <jpr@ximian.com> * gui/tasks-control.c (confirm_expunge): confirm expunging of the tasks (tasks_control_expunge_cmd): verb callback * gui/calendar-config.c (config_read): read confirm expunge value (calendar_config_write): write confirm expunge value (calendar_config_write_on_exit): ditto (calendar_config_get_confirm_expunge): get value (calendar_config_set_confirm_expunge): set value * gui/calendar-config.h: new proto * gui/e-itip-control.c (start_calendar_server): kill warning * gui/e-tasks.c (e_tasks_init): init query member to NULL (set_status_message): util function to set status message (e_tasks_open): use above (cal_opened_cb): ditto (create_sexp): create sexp of items to be deleted (query_obj_updated_cb): remove any items found (query_eval_error_cb): bail out on error (query_query_done_cb): tidy when done (e_tasks_delete_completed): set up query * gui/e-tasks.h: new proto * gui/calendar-model.c (query_query_done_cb): use g_warning instead of printing to stderr (query_eval_error_cb): ditto (update_query): clear the status message if we can't create the query * gui/tag-calendar.c (resolve_tzid_cb): make this static svn path=/trunk/; revision=15233
Diffstat (limited to 'calendar/gui')
-rw-r--r--calendar/gui/calendar-config.c33
-rw-r--r--calendar/gui/calendar-config.h3
-rw-r--r--calendar/gui/calendar-model.c5
-rw-r--r--calendar/gui/calendar-summary.c777
-rw-r--r--calendar/gui/calendar-summary.h35
-rw-r--r--calendar/gui/e-itip-control.c1
-rw-r--r--calendar/gui/e-tasks.c137
-rw-r--r--calendar/gui/e-tasks.h1
-rw-r--r--calendar/gui/tag-calendar.c2
-rw-r--r--calendar/gui/tasks-control.c94
10 files changed, 266 insertions, 822 deletions
diff --git a/calendar/gui/calendar-config.c b/calendar/gui/calendar-config.c
index 57347709a4..e0313fe3a7 100644
--- a/calendar/gui/calendar-config.c
+++ b/calendar/gui/calendar-config.c
@@ -70,6 +70,7 @@ typedef struct
CalUnits hide_completed_tasks_units;
gint hide_completed_tasks_value;
gboolean confirm_delete;
+ gboolean confirm_expunge;
gboolean use_default_reminder;
int default_reminder_interval;
CalUnits default_reminder_units;
@@ -246,6 +247,8 @@ config_read (void)
/* Confirmation */
config->confirm_delete = bonobo_config_get_boolean_with_default (
db, "/Calendar/Other/ConfirmDelete", TRUE, NULL);
+ config->confirm_expunge = bonobo_config_get_boolean_with_default (
+ db, "/Calendar/Other/ConfirmExpunge", TRUE, NULL);
/* Default reminders */
config->use_default_reminder = bonobo_config_get_boolean_with_default (
@@ -358,6 +361,7 @@ calendar_config_write (void)
config->hide_completed_tasks_value, NULL);
bonobo_config_set_boolean (db, "/Calendar/Other/ConfirmDelete", config->confirm_delete, NULL);
+ bonobo_config_set_boolean (db, "/Calendar/Other/ConfirmExpunge", config->confirm_expunge, NULL);
bonobo_config_set_boolean (db, "/Calendar/Other/UseDefaultReminder",
config->use_default_reminder, NULL);
@@ -403,6 +407,9 @@ calendar_config_write_on_exit (void)
bonobo_config_set_float (db, "/Calendar/Display/MonthVPanePosition",
config->month_vpane_pos, NULL);
+ bonobo_config_set_boolean (db, "/Calendar/Other/ConfirmExpunge",
+ config->confirm_expunge, NULL);
+
Bonobo_ConfigDatabase_sync (db, &ev);
bonobo_object_release_unref (db, NULL);
@@ -798,6 +805,32 @@ calendar_config_set_confirm_delete (gboolean confirm)
config->confirm_delete = confirm;
}
+/**
+ * calendar_config_get_confirm_expunge:
+ *
+ * Queries the configuration value for whether a confirmation dialog is
+ * presented when expunging calendar/tasks items.
+ *
+ * Return value: Whether confirmation is required when expunging items.
+ **/
+gboolean
+calendar_config_get_confirm_expunge (void)
+{
+ return config->confirm_expunge;
+}
+
+/**
+ * calendar_config_set_confirm_expunge:
+ * @confirm: Whether confirmation is required when expunging items.
+ *
+ * Sets the configuration value for whether a confirmation dialog is presented
+ * when expunging calendar/tasks items.
+ **/
+void
+calendar_config_set_confirm_expunge (gboolean confirm)
+{
+ config->confirm_expunge = confirm;
+}
/* This sets all the common config settings for an ECalendar widget.
These are the week start day, and whether we show week numbers. */
diff --git a/calendar/gui/calendar-config.h b/calendar/gui/calendar-config.h
index 7bba7fc7a2..83f21d3f0b 100644
--- a/calendar/gui/calendar-config.h
+++ b/calendar/gui/calendar-config.h
@@ -161,6 +161,9 @@ char* calendar_config_get_hide_completed_tasks_sexp (void);
gboolean calendar_config_get_confirm_delete (void);
void calendar_config_set_confirm_delete (gboolean confirm);
+gboolean calendar_config_get_confirm_expunge (void);
+void calendar_config_set_confirm_expunge (gboolean confirm);
+
/* Default reminder options */
gboolean calendar_config_get_use_default_reminder (void);
void calendar_config_set_use_default_reminder (gboolean value);
diff --git a/calendar/gui/calendar-model.c b/calendar/gui/calendar-model.c
index f2b9d8b428..e8317402ac 100644
--- a/calendar/gui/calendar-model.c
+++ b/calendar/gui/calendar-model.c
@@ -1891,7 +1891,7 @@ query_query_done_cb (CalQuery *query, CalQueryDoneStatus status, const char *err
calendar_model_set_status_message (model, NULL);
if (status != CAL_QUERY_DONE_SUCCESS)
- fprintf (stderr, "query done: %s\n", error_str);
+ g_warning ("query done: %s\n", error_str);
}
/* Callback used when an evaluation error occurs when running a query */
@@ -1906,7 +1906,7 @@ query_eval_error_cb (CalQuery *query, const char *error_str, gpointer data)
calendar_model_set_status_message (model, NULL);
- fprintf (stderr, "eval error: %s\n", error_str);
+ g_warning ("eval error: %s\n", error_str);
}
/* Builds a complete query sexp for the calendar model by adding the predicates
@@ -1987,6 +1987,7 @@ update_query (CalendarModel *model)
if (!priv->query) {
g_message ("update_query(): Could not create the query");
+ calendar_model_set_status_message (model, NULL);
return;
}
diff --git a/calendar/gui/calendar-summary.c b/calendar/gui/calendar-summary.c
deleted file mode 100644
index 461260ac1f..0000000000
--- a/calendar/gui/calendar-summary.c
+++ /dev/null
@@ -1,777 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-/* calendar-summary.c
- *
- * Authors: Iain Holmes <iain@ximian.com>
- *
- * Copyright (C) 2000 Ximian, Inc.
- * Copyright (C) 2000 Ximian, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <time.h>
-
-#include <bonobo/bonobo-persist-stream.h>
-#include <bonobo/bonobo-property-control.h>
-#include <bonobo/bonobo-stream-client.h>
-#include <liboaf/liboaf.h>
-
-#include <evolution-services/executive-summary-component.h>
-#include <evolution-services/executive-summary-html-view.h>
-#include <gal/widgets/e-unicode.h>
-
-#include <gnome-xml/parser.h>
-#include <gnome-xml/xmlmemory.h>
-
-#include <cal-util/cal-component.h>
-#include <cal-util/timeutil.h>
-#include "alarm-notify/alarm.h"
-#include "calendar-model.h"
-#include "calendar-summary.h"
-
-typedef struct {
- ExecutiveSummaryComponent *component;
- ExecutiveSummaryHtmlView *view;
- BonoboPropertyControl *property_control;
- CalClient *client;
-
- GtkWidget *show_appointments;
- GtkWidget *show_tasks;
-
- gboolean appointments;
- gboolean tasks;
-
- char *title;
- char *icon;
-
- guint32 idle;
-
- gpointer alarm;
-} CalSummary;
-
-enum {
- PROPERTY_TITLE,
- PROPERTY_ICON
-};
-
-extern gchar *evolution_dir;
-
-static int running_views = 0;
-static BonoboGenericFactory *factory;
-#define CALENDAR_SUMMARY_ID "OAFIID:GNOME_Evolution_Calendar_Summary_ComponentFactory"
-
-/* list_sort_merge, and list_sort are copied from GNOME-VFS.
- Author: Sven Oliver <sven.over@ob.kamp.net>
- Modified by Ettore Perazzoli <ettore@comm2000.it> to let the compare
- functions get an additional gpointer parameter.
-
- Included here as using gnome-vfs for 1 20 line function
- seems a bit of overkill.
-*/
-
-typedef gint (* CalSummaryListCompareFunc) (gconstpointer a,
- gconstpointer b,
- gpointer data);
-static GList *
-cal_list_sort_merge (GList *l1,
- GList *l2,
- CalSummaryListCompareFunc compare_func,
- gpointer data)
-{
- GList list, *l, *lprev;
-
- l = &list;
- lprev = NULL;
-
- while (l1 && l2) {
- if (compare_func (l1->data, l2->data, data) < 0) {
- l->next = l1;
- l = l->next;
- l->prev = lprev;
- lprev = l;
- l1 = l1->next;
- } else {
- l->next = l2;
- l = l->next;
- l->prev = lprev;
- lprev = l;
- l2 = l2->next;
- }
- }
-
- l->next = l1 ? l1 : l2;
- l->next->prev = l;
-
- return list.next;
-}
-
-static GList *
-cal_list_sort (GList *list,
- CalSummaryListCompareFunc compare_func,
- gpointer data)
-{
- GList *l1, *l2;
-
- if (!list)
- return NULL;
- if (!list->next)
- return list;
-
- l1 = list;
- l2 = list->next;
-
- while ((l2 = l2->next) != NULL) {
- if ((l2 = l2->next) == NULL)
- break;
- l1 = l1->next;
- }
-
- l2 = l1->next;
- l1->next = NULL;
-
- return cal_list_sort_merge (cal_list_sort (list, compare_func, data),
- cal_list_sort (l2, compare_func, data),
- compare_func, data);
-}
-
-static int
-sort_uids (gconstpointer a,
- gconstpointer b,
- gpointer user_data)
-{
- CalComponent *comp_a, *comp_b;
- CalSummary *summary = user_data;
- CalClientGetStatus status;
- CalComponentDateTime start_a, start_b;
-
- /* a after b then return > 0 */
-
- status = cal_client_get_object (summary->client, a, &comp_a);
- if (status != CAL_CLIENT_GET_SUCCESS)
- return -1;
-
- status = cal_client_get_object (summary->client, b, &comp_b);
- if (status != CAL_CLIENT_GET_SUCCESS)
- return 1;
-
- cal_component_get_dtstart (comp_a, &start_a);
- cal_component_get_dtstart (comp_b, &start_b);
-
- return icaltime_compare (*start_a.value, *start_b.value);
-}
-
-static gboolean
-generate_html_summary (gpointer data)
-{
- CalSummary *summary;
- time_t t, day_begin, day_end;
- struct tm *timeptr;
- GList *uids, *l;
- char *ret_html, *datestr;
- char *tmp, *tmp2;
-
- summary = data;
-
- t = time (NULL);
- day_begin = time_day_begin (t);
- day_end = time_day_end (t);
-
- datestr = g_new (char, 256);
- timeptr = localtime (&t);
- strftime (datestr, 255, _("%A, %e %B %Y"),
- timeptr);
- tmp = g_strdup_printf ("<b>%s</b>", datestr);
- ret_html = e_utf8_from_locale_string (tmp);
- g_free (tmp);
- g_free (datestr);
-
- if (summary->appointments) {
- tmp = ret_html;
- tmp2 = e_utf8_from_locale_string (_("Appointments"));
- ret_html = g_strconcat (tmp, "<p align=\"center\">",
- tmp2, "</p><hr><ul>", NULL);
- g_free (tmp);
- g_free (tmp2);
-
- uids = cal_client_get_objects_in_range (summary->client,
- CALOBJ_TYPE_EVENT, day_begin,
- day_end);
- uids = cal_list_sort (uids, sort_uids, summary);
-
- for (l = uids; l; l = l->next){
- CalComponent *comp;
- CalComponentText text;
- CalClientGetStatus status;
- CalComponentDateTime start, end;
- struct icaltimetype *end_time;
- time_t start_t, end_t;
- struct tm *start_tm, *end_tm;
- char *start_str, *end_str;
- char *uid;
-
- uid = l->data;
- status = cal_client_get_object (summary->client, uid, &comp);
- if (status != CAL_CLIENT_GET_SUCCESS)
- continue;
-
- cal_component_get_summary (comp, &text);
- cal_component_get_dtstart (comp, &start);
- cal_component_get_dtend (comp, &end);
-
- g_print ("text.value: %s\n", text.value);
- end_time = end.value;
-
- start_t = icaltime_as_timet (*start.value);
-
- start_str = g_new (char, 20);
- start_tm = localtime (&start_t);
- strftime (start_str, 19, _("%I:%M%p"), start_tm);
-
- if (end_time) {
- end_str = g_new (char, 20);
- end_t = icaltime_as_timet (*end_time);
- end_tm = localtime (&end_t);
- strftime (end_str, 19, _("%I:%M%p"), end_tm);
- } else {
- end_str = g_strdup ("...");
- }
-
- tmp2 = g_strdup_printf ("<li>%s:%s -> %s</li>", text.value, start_str, end_str);
- g_free (start_str);
- g_free (end_str);
-
- tmp = ret_html;
- ret_html = g_strconcat (ret_html, tmp2, NULL);
- g_free (tmp);
- g_free (tmp2);
- }
-
- cal_obj_uid_list_free (uids);
-
- tmp = ret_html;
- ret_html = g_strconcat (ret_html, "</ul>", NULL);
- g_free (tmp);
- }
-
- if (summary->tasks) {
- tmp = ret_html;
- tmp2 = e_utf8_from_locale_string (_("Tasks"));
- ret_html = g_strconcat (tmp, "<p align=\"center\">",
- tmp2, "</p><hr><ul>", NULL);
- g_free (tmp);
- g_free (tmp2);
-
- /* Generate a list of tasks */
- uids = cal_client_get_uids (summary->client, CALOBJ_TYPE_TODO);
- for (l = uids; l; l = l->next){
- CalComponent *comp;
- CalComponentText text;
- CalClientGetStatus status;
- struct icaltimetype *completed;
- char *uid;
-
- uid = l->data;
- status = cal_client_get_object (summary->client, uid, &comp);
- if (status != CAL_CLIENT_GET_SUCCESS)
- continue;
-
- cal_component_get_summary (comp, &text);
- cal_component_get_completed (comp, &completed);
-
- if (completed == NULL) {
- tmp2 = g_strdup_printf ("<li>%s</li>", text.value);
- } else {
- tmp2 = g_strdup_printf ("<li><strike>%s</strike></li>",
- text.value);
- cal_component_free_icaltimetype (completed);
- }
-
- tmp = ret_html;
- ret_html = g_strconcat (ret_html, tmp2, NULL);
- g_free (tmp);
- g_free (tmp2);
- }
-
- cal_obj_uid_list_free (uids);
-
- tmp = ret_html;
- ret_html = g_strconcat (ret_html, "</ul>", NULL);
- g_free (tmp);
- }
-
- executive_summary_html_view_set_html (summary->view, ret_html);
- g_free (ret_html);
-
- summary->idle = 0;
- return FALSE;
-}
-
-static void
-get_property (BonoboPropertyBag *bag,
- BonoboArg *arg,
- guint arg_id,
- CORBA_Environment *ev,
- gpointer data)
-{
- CalSummary *summary = (CalSummary *) data;
-
- switch (arg_id) {
- case PROPERTY_TITLE:
- g_warning ("Get property: %s", summary->title);
- BONOBO_ARG_SET_STRING (arg, summary->title);
- break;
-
- case PROPERTY_ICON:
- BONOBO_ARG_SET_STRING (arg, summary->icon);
- break;
-
- default:
- break;
- }
-}
-
-static void
-set_property (BonoboPropertyBag *bag,
- const BonoboArg *arg,
- guint arg_id,
- CORBA_Environment *ev,
- gpointer user_data)
-{
- CalSummary *summary = (CalSummary *) user_data;
-
- switch (arg_id) {
- case PROPERTY_TITLE:
- if (summary->title)
- g_free (summary->title);
-
- summary->title = g_strdup (BONOBO_ARG_GET_STRING (arg));
- bonobo_property_bag_notify_listeners (bag, "window_title",
- arg, NULL);
- break;
-
- case PROPERTY_ICON:
- if (summary->icon)
- g_free (summary->icon);
-
- summary->icon = g_strdup (BONOBO_ARG_GET_STRING (arg));
- bonobo_property_bag_notify_listeners (bag, "window_icon",
- arg, NULL);
- break;
-
- default:
- break;
- }
-}
-
-static void
-component_destroyed (GtkObject *object,
- gpointer data)
-{
- CalSummary *summary = (CalSummary *) data;
-
- g_free (summary->title);
- g_free (summary->icon);
- gtk_object_destroy (GTK_OBJECT (summary->client));
-
- g_free (summary);
-
- running_views--;
-
- if (running_views <= 0) {
- bonobo_object_unref (BONOBO_OBJECT (factory));
- }
-}
-
-static void
-obj_updated_cb (CalClient *client,
- const char *uid,
- CalSummary *summary)
-{
- /* FIXME: Maybe cache the uid's in the summary and only call this if
- uid is in this cache??? */
-
- if (summary->idle != 0)
- return;
-
- summary->idle = g_idle_add (generate_html_summary, summary);
-}
-
-static void
-obj_removed_cb (CalClient *client,
- const char *uid,
- CalSummary *summary)
-{
- /* See FIXME: above */
- if (summary->idle != 0)
- return;
-
- summary->idle = g_idle_add (generate_html_summary, summary);
-}
-
-static void
-cal_opened_cb (CalClient *client,
- CalClientOpenStatus status,
- CalSummary *summary)
-{
- switch (status) {
- case CAL_CLIENT_OPEN_SUCCESS:
- if (summary->idle != 0)
- return;
-
- summary->idle = g_idle_add (generate_html_summary, summary);
- break;
-
- case CAL_CLIENT_OPEN_ERROR:
- executive_summary_html_view_set_html (summary->view,
- _("<b>Error loading calendar</b>"));
- break;
-
- case CAL_CLIENT_OPEN_NOT_FOUND:
- /* We did not use only_if_exists when opening the calendar, so
- * this should not happen.
- */
- g_assert_not_reached ();
- break;
-
- case CAL_CLIENT_OPEN_METHOD_NOT_SUPPORTED:
- executive_summary_html_view_set_html (summary->view,
- _("<b>Error loading calendar:<br>Method not supported"));
- break;
-
- default:
- break;
- }
-}
-
-static void
-alarm_fn (gpointer alarm_id,
- time_t trigger,
- gpointer data)
-{
- CalSummary *summary;
- time_t t, day_end;
-
- summary = data;
-
- t = time (NULL);
- day_end = time_day_end (t);
- summary->alarm = alarm_add (day_end, alarm_fn, summary, NULL);
-
- /* Now redraw the summary */
- generate_html_summary (summary);
-}
-
-/* PersistStream callbacks */
-static void
-load_from_stream (BonoboPersistStream *ps,
- Bonobo_Stream stream,
- Bonobo_Persist_ContentType type,
- gpointer data,
- CORBA_Environment *ev)
-{
- CalSummary *summary = (CalSummary *) data;
- char *str;
- xmlChar *xml_str;
- xmlDocPtr doc;
- xmlNodePtr root, children;
-
- if (*type && g_strcasecmp (type, "application/x-evolution-calendar-summary") != 0) {
- CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
- ex_Bonobo_Persist_WrongDataType, NULL);
- return;
- }
-
- bonobo_stream_client_read_string (stream, &str, ev);
- if (ev->_major != CORBA_NO_EXCEPTION || str == NULL) {
- CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
- ex_Bonobo_Persist_WrongDataType, NULL);
- return;
- }
-
- doc = xmlParseDoc ((xmlChar *) str);
-
- if (doc == NULL) {
- g_warning ("Bad data: %s!", str);
- CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
- ex_Bonobo_Persist_WrongDataType, NULL);
- g_free (str);
- return;
- }
-
- g_free (str);
- root = doc->root;
- children = root->childs;
- while (children) {
- if (strcasecmp (children->name, "showappointments") == 0) {
- xml_str = xmlNodeListGetString (doc, children->childs, 1);
- if (strcmp (xml_str, "TRUE") == 0)
- summary->appointments = TRUE;
- else
- summary->appointments = FALSE;
- xmlFree (xml_str);
-
- children = children->next;
- continue;
- }
-
- if (strcasecmp (children->name, "showtasks") == 0) {
- xml_str = xmlNodeListGetString (doc, children->childs, 1);
- if (strcmp (xml_str, "TRUE") == 0)
- summary->tasks = TRUE;
- else
- summary->tasks = FALSE;
- xmlFree (xml_str);
-
- children = children->next;
- continue;
- }
-
- g_print ("Unknown name: %s\n", children->name);
- children = children->next;
- }
- xmlFreeDoc (doc);
-
- summary->idle = g_idle_add (generate_html_summary, summary);
-}
-
-static char *
-summary_to_string (CalSummary *summary)
-{
- xmlChar *out_str;
- int out_len = 0;
- xmlDocPtr doc;
- xmlNsPtr ns;
-
- doc = xmlNewDoc ("1.0");
- ns = xmlNewGlobalNs (doc, "www.ximian.com", "calendar-summary");
- doc->root = xmlNewDocNode (doc, ns, "calendar-summary", NULL);
-
- xmlNewChild (doc->root, ns, "showappointments",
- summary->appointments ? "TRUE" : "FALSE");
- xmlNewChild (doc->root, ns, "showtasks", summary->tasks ? "TRUE" : "FALSE");
-
- xmlDocDumpMemory (doc, &out_str, &out_len);
- return out_str;
-}
-
-static void
-save_to_stream (BonoboPersistStream *ps,
- const Bonobo_Stream stream,
- Bonobo_Persist_ContentType type,
- gpointer data,
- CORBA_Environment *ev)
-{
- CalSummary *summary = (CalSummary *) data;
- char *str;
-
- if (*type && g_strcasecmp (type, "application/x-evolution-calendar-summary") != 0) {
- CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
- ex_Bonobo_Persist_WrongDataType, NULL);
- return;
- }
-
- str = summary_to_string (summary);
- if (str)
- bonobo_stream_client_printf (stream, TRUE, ev, str);
- xmlFree (str);
-
- return;
-}
-
-static Bonobo_Persist_ContentTypeList *
-content_types (BonoboPersistStream *ps,
- void *closure,
- CORBA_Environment *ev)
-{
- return bonobo_persist_generate_content_types (1, "application/x-evolution-calendar-summary");
-}
-
-static void
-property_dialog_changed (GtkWidget *widget,
- CalSummary *summary)
-{
- bonobo_property_control_changed (summary->property_control, NULL);
-}
-
-static BonoboControl *
-property_dialog (BonoboPropertyControl *property_control,
- int page_num,
- void *user_data)
-{
- BonoboControl *control;
- CalSummary *summary = (CalSummary *) user_data;
- GtkWidget *container, *vbox;
-
- container = gtk_frame_new (_("Display"));
- gtk_container_set_border_width (GTK_CONTAINER (container), 2);
- vbox = gtk_vbox_new (FALSE, 2);
- gtk_container_add (GTK_CONTAINER (container), vbox);
-
- summary->show_appointments = gtk_check_button_new_with_label (_("Show appointments"));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (summary->show_appointments),
- summary->appointments);
- gtk_signal_connect (GTK_OBJECT (summary->show_appointments), "toggled",
- GTK_SIGNAL_FUNC (property_dialog_changed), summary);
- gtk_box_pack_start (GTK_BOX (vbox), summary->show_appointments,
- TRUE, TRUE, 0);
-
- summary->show_tasks = gtk_check_button_new_with_label (_("Show tasks"));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (summary->show_tasks),
- summary->tasks);
- gtk_signal_connect (GTK_OBJECT (summary->show_tasks), "toggled",
- GTK_SIGNAL_FUNC (property_dialog_changed), summary);
- gtk_box_pack_start (GTK_BOX (vbox), summary->show_tasks, TRUE, TRUE, 0);
- gtk_widget_show_all (container);
-
- control = bonobo_control_new (container);
- return control;
-}
-
-static void
-property_action (GtkObject *property_control,
- int page_num,
- Bonobo_PropertyControl_Action action,
- CalSummary *summary)
-{
- switch (action) {
- case Bonobo_PropertyControl_APPLY:
- summary->appointments = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (summary->show_appointments));
- summary->tasks = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (summary->show_tasks));
- summary->idle = g_idle_add (generate_html_summary, summary);
- break;
-
- case Bonobo_PropertyControl_HELP:
- g_print ("HELP\n");
- break;
-
- default:
- break;
- }
-}
-
-BonoboObject *
-create_summary_view (ExecutiveSummaryComponentFactory *_factory,
- void *closure)
-{
- BonoboObject *component, *view;
- BonoboPersistStream *stream;
- BonoboPropertyBag *bag;
- BonoboPropertyControl *property_control;
- BonoboEventSource *event_source;
- CalSummary *summary;
- char *file;
- time_t t, day_end;
-
- file = g_concat_dir_and_file (evolution_dir, "local/Calendar/calendar.ics");
-
- /* Create the component object */
- component = executive_summary_component_new ();
-
- summary = g_new (CalSummary, 1);
- summary->component = EXECUTIVE_SUMMARY_COMPONENT (component);
- summary->icon = g_strdup ("evolution-calendar.png");
- summary->title = e_utf8_from_locale_string (_("Things to do"));
- summary->client = cal_client_new ();
- summary->idle = 0;
- summary->appointments = TRUE;
- summary->tasks = TRUE;
-
- t = time (NULL);
- day_end = time_day_end (t);
- summary->alarm = alarm_add (day_end, alarm_fn, summary, NULL);
-
- /* Load calendar */
- cal_client_open_calendar (summary->client, file, FALSE);
- g_free (file);
-
- gtk_signal_connect (GTK_OBJECT (summary->client), "cal-opened",
- GTK_SIGNAL_FUNC (cal_opened_cb), summary);
- gtk_signal_connect (GTK_OBJECT (summary->client), "obj-updated",
- GTK_SIGNAL_FUNC (obj_updated_cb), summary);
- gtk_signal_connect (GTK_OBJECT (summary->client), "obj-removed",
- GTK_SIGNAL_FUNC (obj_removed_cb), summary);
-
- gtk_signal_connect (GTK_OBJECT (component), "destroy",
- GTK_SIGNAL_FUNC (component_destroyed), summary);
-
- event_source = bonobo_event_source_new ();
-
- /* HTML view */
- view = executive_summary_html_view_new_full (event_source);
- summary->view = EXECUTIVE_SUMMARY_HTML_VIEW (view);
-
- executive_summary_html_view_set_html (EXECUTIVE_SUMMARY_HTML_VIEW (view),
- _("Loading Calendar"));
- bonobo_object_add_interface (component, view);
-
- /* BonoboPropertyBag */
- bag = bonobo_property_bag_new_full (get_property, set_property,
- event_source, summary);
- bonobo_property_bag_add (bag, "window_title", PROPERTY_TITLE,
- BONOBO_ARG_STRING, NULL,
- "The title of this component's window", 0);
- bonobo_property_bag_add (bag, "window_icon", PROPERTY_ICON,
- BONOBO_ARG_STRING, NULL,
- "The icon for this component's window", 0);
- bonobo_object_add_interface (component, BONOBO_OBJECT (bag));
-
- property_control = bonobo_property_control_new_full (property_dialog,
- 1, event_source,
- summary);
- summary->property_control = property_control;
- gtk_signal_connect (GTK_OBJECT (property_control), "action",
- GTK_SIGNAL_FUNC (property_action), summary);
- bonobo_object_add_interface (component, BONOBO_OBJECT (property_control));
-
- stream = bonobo_persist_stream_new (load_from_stream, save_to_stream,
- NULL, content_types, summary);
- bonobo_object_add_interface (component, BONOBO_OBJECT (stream));
-
- running_views++;
-
- return component;
-}
-
-static BonoboObject *
-factory_fn (BonoboGenericFactory *generic_factory,
- void *closure)
-{
- BonoboObject *_factory;
-
- _factory = executive_summary_component_factory_new (create_summary_view,
- NULL);
- return _factory;
-}
-
-BonoboGenericFactory *
-calendar_summary_factory_init (void)
-{
- if (factory != NULL)
- return factory;
-
- factory = bonobo_generic_factory_new (CALENDAR_SUMMARY_ID, factory_fn,
- NULL);
-
- if (factory == NULL) {
- g_warning ("Cannot initialize calendar summary factory");
- return NULL;
- }
-
- return factory;
-}
diff --git a/calendar/gui/calendar-summary.h b/calendar/gui/calendar-summary.h
deleted file mode 100644
index e1823cda8a..0000000000
--- a/calendar/gui/calendar-summary.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-/* calendar-summary.c
- *
- * Authors: Iain Holmes <iain@ximian.com>
- *
- * Copyright (C) 2000 Ximian, Inc.
- * Copyright (C) 2000 Ximian, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef CALENDAR_SUMMARY_H
-#define CALENDAR_SUMMARY_H
-
-#include <bonobo/bonobo-generic-factory.h>
-#include <evolution-services/executive-summary-component.h>
-
-BonoboGenericFactory *calendar_summary_factory_init (void);
-
-BonoboObject *create_summary_view (ExecutiveSummaryComponentFactory *_factory,
- void *closure);
-
-#endif
diff --git a/calendar/gui/e-itip-control.c b/calendar/gui/e-itip-control.c
index 229a90ae5d..bb935ea396 100644
--- a/calendar/gui/e-itip-control.c
+++ b/calendar/gui/e-itip-control.c
@@ -187,7 +187,6 @@ static CalClient *
start_calendar_server (gboolean tasks)
{
CalClient *client;
- char *cal_uri;
gboolean success;
client = cal_client_new ();
diff --git a/calendar/gui/e-tasks.c b/calendar/gui/e-tasks.c
index 3d354be7bb..026f8e5708 100644
--- a/calendar/gui/e-tasks.c
+++ b/calendar/gui/e-tasks.c
@@ -46,7 +46,8 @@ static GList *all_tasks = NULL;
struct _ETasksPrivate {
/* The calendar client object we monitor */
CalClient *client;
-
+ CalQuery *query;
+
/* The ECalendarTable showing the tasks. */
GtkWidget *tasks_view;
@@ -119,6 +120,8 @@ e_tasks_init (ETasks *tasks)
priv = g_new0 (ETasksPrivate, 1);
tasks->priv = priv;
+ priv->client = NULL;
+ priv->query = NULL;
priv->view_collection = NULL;
priv->view_menus = NULL;
@@ -310,6 +313,17 @@ e_tasks_destroy (GtkObject *object)
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}
+static void
+set_status_message (ETasks *tasks, const char *message)
+{
+ ETasksPrivate *priv;
+ CalendarModel *model;
+
+ priv = tasks->priv;
+
+ model = e_calendar_table_get_model (E_CALENDAR_TABLE (priv->tasks_view));
+ calendar_model_set_status_message (model, message);
+}
gboolean
e_tasks_open (ETasks *tasks,
@@ -326,9 +340,7 @@ e_tasks_open (ETasks *tasks,
priv = tasks->priv;
message = g_strdup_printf (_("Opening tasks at %s"), file);
- calendar_model_set_status_message (
- e_calendar_table_get_model (E_CALENDAR_TABLE (priv->tasks_view)),
- message);
+ set_status_message (tasks, message);
g_free (message);
if (!cal_client_open_calendar (priv->client, file, FALSE)) {
@@ -383,8 +395,7 @@ cal_opened_cb (CalClient *client,
tasks = E_TASKS (data);
priv = tasks->priv;
- calendar_model_set_status_message (
- e_calendar_table_get_model (E_CALENDAR_TABLE (priv->tasks_view)), NULL);
+ set_status_message (tasks, NULL);
switch (status) {
case CAL_CLIENT_OPEN_SUCCESS:
@@ -506,6 +517,120 @@ e_tasks_delete_selected (ETasks *tasks)
e_calendar_table_delete_selected (cal_table);
}
+static char *
+create_sexp (void)
+{
+ char *completed_sexp;
+ char *new_sexp;
+
+ /* Create a sub-expression for filtering out completed tasks, based on
+ the config settings. */
+ completed_sexp = calendar_config_get_hide_completed_tasks_sexp ();
+
+ new_sexp = g_strdup_printf ("(and (= (get-vtype) \"VTODO\") (not %s))",
+ completed_sexp ? completed_sexp : "");
+ g_free (completed_sexp);
+
+#if 0
+ g_print ("Calendar model sexp:\n%s\n", new_sexp);
+#endif
+
+ return new_sexp;
+}
+
+/* Callback used when a component is updated in the live query */
+static void
+query_obj_updated_cb (CalQuery *query, const char *uid,
+ gboolean query_in_progress, int n_scanned, int total,
+ gpointer data)
+{
+ ETasks *tasks;
+ ETasksPrivate *priv;
+
+ tasks = E_TASKS (data);
+ priv = tasks->priv;
+
+ cal_client_remove_object (priv->client, uid);
+}
+
+/* Callback used when an evaluation error occurs when running a query */
+static void
+query_eval_error_cb (CalQuery *query, const char *error_str, gpointer data)
+{
+ ETasks *tasks;
+ ETasksPrivate *priv;
+
+ tasks = E_TASKS (data);
+ priv = tasks->priv;
+
+ g_warning ("eval error: %s\n", error_str);
+
+ set_status_message (tasks, NULL);
+
+ gtk_signal_disconnect_by_data (GTK_OBJECT (priv->query), tasks);
+ gtk_object_unref (GTK_OBJECT (priv->query));
+ priv->query = NULL;
+}
+
+static void
+query_query_done_cb (CalQuery *query, CalQueryDoneStatus status, const char *error_str, gpointer data)
+{
+ ETasks *tasks;
+ ETasksPrivate *priv;
+
+ tasks = E_TASKS (data);
+ priv = tasks->priv;
+
+ if (status != CAL_QUERY_DONE_SUCCESS)
+ g_warning ("query done: %s\n", error_str);
+
+ set_status_message (tasks, NULL);
+
+ gtk_signal_disconnect_by_data (GTK_OBJECT (priv->query), tasks);
+ gtk_object_unref (GTK_OBJECT (priv->query));
+ priv->query = NULL;
+}
+/**
+ * e_tasks_expunge:
+ * @tasks: A tasks control widget
+ *
+ * Removes all tasks marked as completed
+ **/
+void
+e_tasks_delete_completed (ETasks *tasks)
+{
+ ETasksPrivate *priv;
+ char *sexp;
+
+ g_return_if_fail (tasks != NULL);
+ g_return_if_fail (E_IS_TASKS (tasks));
+
+ priv = tasks->priv;
+
+ /* If we have a query, we are already expunging */
+ if (priv->query)
+ return;
+
+ sexp = create_sexp ();
+
+ set_status_message (tasks, _("Expunging"));
+ priv->query = cal_client_get_query (priv->client, sexp);
+ g_free (sexp);
+
+ if (!priv->query) {
+ set_status_message (tasks, NULL);
+ g_message ("update_query(): Could not create the query");
+ return;
+ }
+
+ gtk_signal_connect (GTK_OBJECT (priv->query), "obj_updated",
+ GTK_SIGNAL_FUNC (query_obj_updated_cb), tasks);
+ gtk_signal_connect (GTK_OBJECT (priv->query), "query_done",
+ GTK_SIGNAL_FUNC (query_query_done_cb), tasks);
+ gtk_signal_connect (GTK_OBJECT (priv->query), "eval_error",
+ GTK_SIGNAL_FUNC (query_eval_error_cb), tasks);
+}
+
/* Callback used from the view collection when we need to display a new view */
static void
display_view_cb (GalViewCollection *collection, GalView *view, gpointer data)
diff --git a/calendar/gui/e-tasks.h b/calendar/gui/e-tasks.h
index e7952752ed..f199a6f251 100644
--- a/calendar/gui/e-tasks.h
+++ b/calendar/gui/e-tasks.h
@@ -67,6 +67,7 @@ CalClient *e_tasks_get_cal_client (ETasks *tasks);
void e_tasks_new_task (ETasks *tasks);
void e_tasks_delete_selected (ETasks *tasks);
+void e_tasks_delete_completed(ETasks *tasks);
void e_tasks_setup_view_menus (ETasks *tasks, BonoboUIComponent *uic);
diff --git a/calendar/gui/tag-calendar.c b/calendar/gui/tag-calendar.c
index 35dca781dc..cda93a1d64 100644
--- a/calendar/gui/tag-calendar.c
+++ b/calendar/gui/tag-calendar.c
@@ -154,7 +154,7 @@ tag_calendar_by_client (ECalendar *ecal, CalClient *client)
/* Resolves TZIDs for the recurrence generator, for when the comp is not on
the server. We need to try to use builtin timezones first, as they may not
be added to the server yet. */
-icaltimezone*
+static icaltimezone*
resolve_tzid_cb (const char *tzid, gpointer data)
{
CalClient *client;
diff --git a/calendar/gui/tasks-control.c b/calendar/gui/tasks-control.c
index 57d3623090..504342fa88 100644
--- a/calendar/gui/tasks-control.c
+++ b/calendar/gui/tasks-control.c
@@ -26,8 +26,13 @@
#include <libgnome/gnome-defs.h>
#include <libgnome/gnome-i18n.h>
#include <libgnome/gnome-util.h>
+#include <libgnomeui/gnome-dialog.h>
+#include <libgnomeui/gnome-dialog-util.h>
+#include <libgnomeui/gnome-stock.h>
#include <bonobo/bonobo-control.h>
#include <bonobo/bonobo-ui-util.h>
+#include <gal/widgets/e-gui-utils.h>
+#include <e-util/e-dialog-utils.h>
#include "dialogs/cal-prefs-dialog.h"
#include "calendar-config.h"
#include "calendar-commands.h"
@@ -74,6 +79,9 @@ static void tasks_control_paste_cmd (BonoboUIComponent *uic,
static void tasks_control_delete_cmd (BonoboUIComponent *uic,
gpointer data,
const char *path);
+static void tasks_control_expunge_cmd (BonoboUIComponent *uic,
+ gpointer data,
+ const char *path);
static void tasks_control_settings_cmd (BonoboUIComponent *uic,
gpointer data,
const char *path);
@@ -238,6 +246,7 @@ static BonoboUIVerb verbs [] = {
BONOBO_UI_VERB ("TasksCopy", tasks_control_copy_cmd),
BONOBO_UI_VERB ("TasksPaste", tasks_control_paste_cmd),
BONOBO_UI_VERB ("TasksDelete", tasks_control_delete_cmd),
+ BONOBO_UI_VERB ("TasksExpunge", tasks_control_expunge_cmd),
BONOBO_UI_VERB ("TasksSettings", tasks_control_settings_cmd),
BONOBO_UI_VERB_END
@@ -387,6 +396,91 @@ tasks_control_delete_cmd (BonoboUIComponent *uic,
e_tasks_delete_selected (tasks);
}
+static gboolean
+confirm_expunge (ETasks *tasks)
+{
+ GtkWidget *dialog, *label, *checkbox;
+ int button, val;
+ char *text = NULL;
+
+ if (!calendar_config_get_confirm_expunge ())
+ return TRUE;
+
+ dialog = gnome_dialog_new (_("Warning"),
+ GNOME_STOCK_BUTTON_YES,
+ GNOME_STOCK_BUTTON_NO,
+ NULL);
+ e_gnome_dialog_set_parent (GNOME_DIALOG (dialog),
+ GTK_WINDOW (gtk_widget_get_ancestor (GTK_WIDGET (tasks),
+ GTK_TYPE_WINDOW)));
+
+ val = calendar_config_get_hide_completed_tasks_value ();
+ if (val == 0) {
+ text = g_strdup (_("This operation will permanently erase all tasks marked as completed. If you continue, you will not be able to recover these tasks.\n\nReally erase these tasks?"));
+ } else {
+ int units;
+
+ units = calendar_config_get_hide_completed_tasks_units ();
+ switch (units) {
+ case CAL_DAYS:
+ if (val == 1)
+ text = g_strdup (_("This operation will permanently erase all tasks marked as completed on or before 1 day ago. If you continue, you will not be able to recover these tasks.\n\nReally erase these tasks?"));
+ else
+ text = g_strdup_printf (_("This operation will permanently erase all tasks marked as completed on or before %d days ago. If you continue, you will not be able to recover these tasks.\n\nReally erase these tasks?"), val);
+ break;
+ case CAL_HOURS:
+ if (val == 1)
+ text = g_strdup (_("This operation will permanently erase all tasks marked as completed on or before 1 hour ago. If you continue, you will not be able to recover these tasks.\n\nReally erase these tasks?"));
+ else
+ text = g_strdup_printf (_("This operation will permanently erase all tasks marked as completed on or before %d hours ago. If you continue, you will not be able to recover these tasks.\n\nReally erase these tasks?"), val);
+ break;
+ case CAL_MINUTES:
+ if (val == 1)
+ text = g_strdup (_("This operation will permanently erase all tasks marked as completed on or before 1 minute ago. If you continue, you will not be able to recover these tasks.\n\nReally erase these tasks?"));
+ else
+ text = g_strdup_printf (_("This operation will permanently erase all tasks marked as completed on or before %d minutes ago. If you continue, you will not be able to recover these tasks.\n\nReally erase these tasks?"), val);
+ break;
+ }
+ }
+ label = gtk_label_new (text);
+ g_free (text);
+
+ gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+ gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
+ gtk_widget_show (label);
+ gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), label, TRUE, TRUE, 4);
+
+ checkbox = gtk_check_button_new_with_label (_("Do not ask me again."));
+ gtk_widget_show (checkbox);
+ gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), checkbox, TRUE, TRUE, 4);
+
+ button = gnome_dialog_run (GNOME_DIALOG (dialog));
+
+ if (button == 0 && gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbox)))
+ calendar_config_set_confirm_expunge (FALSE);
+
+ gnome_dialog_close (GNOME_DIALOG (dialog));
+
+ if (button == 0)
+ return TRUE;
+ else
+ return FALSE;
+}
+
+static void
+tasks_control_expunge_cmd (BonoboUIComponent *uic,
+ gpointer data,
+ const char *path)
+{
+ ETasks *tasks;
+
+ tasks = E_TASKS (data);
+
+ if (confirm_expunge (tasks))
+ e_tasks_delete_completed (tasks);
+}
+
+
/* Callback used for the tasks settings command */
static void
tasks_control_settings_cmd (BonoboUIComponent *uic, gpointer data, const char *path)