aboutsummaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2011-05-13 03:32:33 +0800
committerMatthew Barnes <mbarnes@redhat.com>2011-05-13 06:24:41 +0800
commit366dacefa0a59c66320f65f19796eb30ad23f255 (patch)
treeb5e559fc920513222c45002a836ece4fa9c87632 /modules
parentc082e5843416aae0002251640e2f72327fd014d0 (diff)
downloadgsoc2013-evolution-366dacefa0a59c66320f65f19796eb30ad23f255.tar
gsoc2013-evolution-366dacefa0a59c66320f65f19796eb30ad23f255.tar.gz
gsoc2013-evolution-366dacefa0a59c66320f65f19796eb30ad23f255.tar.bz2
gsoc2013-evolution-366dacefa0a59c66320f65f19796eb30ad23f255.tar.lz
gsoc2013-evolution-366dacefa0a59c66320f65f19796eb30ad23f255.tar.xz
gsoc2013-evolution-366dacefa0a59c66320f65f19796eb30ad23f255.tar.zst
gsoc2013-evolution-366dacefa0a59c66320f65f19796eb30ad23f255.zip
Add e_mail_reader_new_activity().
Configuring and submitting an EActivity for every mail operation is getting tedious. This function helps reduce boilerplate code by: * Creating a new EActivity instance. * Installing an EAlertSink using e_mail_reader_get_alert_sink(). * Installing a GCancellable (which is really a CamelOperation). * Submitting the activity via e_shell_backend_add_activity(). I'm considering adding a similar function (or class method) for EShellView. Not sure yet...
Diffstat (limited to 'modules')
-rw-r--r--modules/mail/e-mail-shell-view-actions.c7
-rw-r--r--modules/mail/e-mail-shell-view-private.c19
2 files changed, 12 insertions, 14 deletions
diff --git a/modules/mail/e-mail-shell-view-actions.c b/modules/mail/e-mail-shell-view-actions.c
index d44ac6f5ad..a0a6ec2dfe 100644
--- a/modules/mail/e-mail-shell-view-actions.c
+++ b/modules/mail/e-mail-shell-view-actions.c
@@ -522,10 +522,13 @@ action_mail_folder_unsubscribe_cb (GtkAction *action,
session = e_mail_backend_get_session (backend);
activity = e_activity_new ();
- cancellable = camel_operation_new ();
+
alert_sink = E_ALERT_SINK (shell_content);
e_activity_set_alert_sink (activity, alert_sink);
+
+ cancellable = camel_operation_new ();
e_activity_set_cancellable (activity, cancellable);
+
e_shell_backend_add_activity (shell_backend, activity);
folder_uri = em_folder_tree_get_selected_uri (folder_tree);
@@ -536,6 +539,8 @@ action_mail_folder_unsubscribe_cb (GtkAction *action,
activity);
g_free (folder_uri);
+
+ g_object_unref (cancellable);
}
static void
diff --git a/modules/mail/e-mail-shell-view-private.c b/modules/mail/e-mail-shell-view-private.c
index d99b643d38..b3cfb7e796 100644
--- a/modules/mail/e-mail-shell-view-private.c
+++ b/modules/mail/e-mail-shell-view-private.c
@@ -94,16 +94,14 @@ mail_shell_view_folder_tree_selected_cb (EMailShellView *mail_shell_view,
EMFolderTree *folder_tree)
{
EMailShellContent *mail_shell_content;
- EShellBackend *shell_backend;
EShellView *shell_view;
EMailReader *reader;
EMailView *mail_view;
GCancellable *cancellable;
- EAlertSink *alert_sink;
AsyncContext *context;
+ EActivity *activity;
shell_view = E_SHELL_VIEW (mail_shell_view);
- shell_backend = e_shell_view_get_shell_backend (shell_view);
mail_shell_content = mail_shell_view->priv->mail_shell_content;
mail_view = e_mail_shell_content_get_mail_view (mail_shell_content);
@@ -127,20 +125,15 @@ mail_shell_view_folder_tree_selected_cb (EMailShellView *mail_shell_view,
/* Open the selected folder asynchronously. */
+ activity = e_mail_reader_new_activity (reader);
+ cancellable = e_activity_get_cancellable (activity);
+ mail_shell_view->priv->opening_folder = g_object_ref (cancellable);
+
context = g_slice_new0 (AsyncContext);
- context->activity = e_activity_new ();
+ context->activity = activity;
context->reader = g_object_ref (reader);
context->shell_view = g_object_ref (shell_view);
- alert_sink = E_ALERT_SINK (mail_shell_content);
- e_activity_set_alert_sink (context->activity, alert_sink);
-
- cancellable = camel_operation_new ();
- e_activity_set_cancellable (context->activity, cancellable);
- mail_shell_view->priv->opening_folder = cancellable;
-
- e_shell_backend_add_activity (shell_backend, context->activity);
-
camel_store_get_folder (
store, folder_name, 0, G_PRIORITY_DEFAULT, cancellable,
(GAsyncReadyCallback) mail_shell_view_got_folder_cb, context);