[evolution] Bug 602704 - Actions->Purge in task view doesn't work



commit 02b15ae6b88dad131f56c74fd1205b8b9aacbf80
Author: Matthew Barnes <mbarnes redhat com>
Date:   Wed Nov 25 15:07:15 2009 -0500

    Bug 602704 - Actions->Purge in task view doesn't work

 modules/calendar/e-task-shell-view-actions.c |    4 +-
 modules/calendar/e-task-shell-view-private.c |   58 +++++++++++++++++++++++++-
 modules/calendar/e-task-shell-view-private.h |    2 +
 3 files changed, 60 insertions(+), 4 deletions(-)
---
diff --git a/modules/calendar/e-task-shell-view-actions.c b/modules/calendar/e-task-shell-view-actions.c
index 0e77efb..6f70c9a 100644
--- a/modules/calendar/e-task-shell-view-actions.c
+++ b/modules/calendar/e-task-shell-view-actions.c
@@ -589,9 +589,7 @@ action_task_purge_cb (GtkAction *action,
 		e_task_shell_view_set_confirm_purge (task_shell_view, FALSE);
 
 purge:
-
-	/* FIXME KILL-BONOBO */
-        ;
+	e_task_shell_view_delete_completed (task_shell_view);
 }
 
 static void
diff --git a/modules/calendar/e-task-shell-view-private.c b/modules/calendar/e-task-shell-view-private.c
index 532b357..bbe0a10 100644
--- a/modules/calendar/e-task-shell-view-private.c
+++ b/modules/calendar/e-task-shell-view-private.c
@@ -374,7 +374,7 @@ e_task_shell_view_private_dispose (ETaskShellView *task_shell_view)
 	DISPOSE (priv->task_shell_sidebar);
 
 	if (task_shell_view->priv->activity != NULL) {
-		/* XXX Activity is no cancellable. */
+		/* XXX Activity is not cancellable. */
 		e_activity_complete (task_shell_view->priv->activity);
 		g_object_unref (task_shell_view->priv->activity);
 		task_shell_view->priv->activity = NULL;
@@ -447,6 +447,62 @@ exit:
 }
 
 void
+e_task_shell_view_delete_completed (ETaskShellView *task_shell_view)
+{
+	ETaskShellSidebar *task_shell_sidebar;
+	GList *list, *iter;
+	const gchar *sexp;
+
+	g_return_if_fail (E_IS_TASK_SHELL_VIEW (task_shell_view));
+
+	sexp = "(is-completed?)";
+
+	task_shell_sidebar = task_shell_view->priv->task_shell_sidebar;
+	list = e_task_shell_sidebar_get_clients (task_shell_sidebar);
+
+	e_task_shell_view_set_status_message (
+		task_shell_view, _("Expunging"), -1.0);
+
+	for (iter = list; iter != NULL; iter = iter->next) {
+		ECal *client = E_CAL (iter->data);
+		GList *objects;
+		gboolean read_only = TRUE;
+		GError *error = NULL;
+
+		if (!e_cal_is_read_only (client, &read_only, &error)) {
+			g_warning ("%s", error->message);
+			g_error_free (error);
+			continue;
+		}
+
+		if (read_only)
+			continue;
+
+		if (!e_cal_get_object_list (client, sexp, &objects, &error)) {
+			g_warning ("%s", error->message);
+			g_error_free (error);
+			continue;
+		}
+
+		while (objects != NULL) {
+			icalcomponent *component = objects->data;
+			const gchar *uid;
+
+			uid = icalcomponent_get_uid (component);
+			if (!e_cal_remove_object (client, uid, &error)) {
+				g_warning ("%s", error->message);
+				g_clear_error (&error);
+			}
+
+			icalcomponent_free (component);
+			objects = g_list_delete_link (objects, objects);
+		}
+	}
+
+	e_task_shell_view_set_status_message (task_shell_view, NULL, -1.0);
+}
+
+void
 e_task_shell_view_set_status_message (ETaskShellView *task_shell_view,
                                       const gchar *status_message,
                                       gdouble percent)
diff --git a/modules/calendar/e-task-shell-view-private.h b/modules/calendar/e-task-shell-view-private.h
index fcbe852..4418fd7 100644
--- a/modules/calendar/e-task-shell-view-private.h
+++ b/modules/calendar/e-task-shell-view-private.h
@@ -126,6 +126,8 @@ void		e_task_shell_view_actions_init
 void		e_task_shell_view_open_task
 					(ETaskShellView *task_shell_view,
 					 ECalModelComponent *comp_data);
+void		e_task_shell_view_delete_completed
+					(ETaskShellView *task_shell_view);
 void		e_task_shell_view_set_status_message
 					(ETaskShellView *task_shell_view,
 					 const gchar *status_message,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]