From c881b5bc5e61d04b18d4ab46ad70533e7340d15b Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Thu, 21 Oct 2010 16:21:19 -0400 Subject: Simplify EActivity. With unintrusive error dialogs gone, we can cut some unnecessary bits out of EActivity. I'm also adding a new enum property called "state", which is one of: E_ACTIVITY_RUNNING E_ACTIVITY_WAITING E_ACTIVITY_CANCELLED E_ACTIVITY_COMPLETED The state of an activity must be explicitly changed. In particular, when the user cancels an activity the state should be set only after confirming the operation has been cancelled and not when cancellation is requested (e.g. after receiving a G_IO_ERROR_CANCELLED, not when the GCancellable emits "cancelled"). EActivityBar and EActivityProxy widgets have been updated to make this distinction clearer in the UI. E_ACTIVITY_WAITING will be used when activities have to be queued and dispatched in sequence, which I haven't written yet. --- plugins/pst-import/pst-importer.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'plugins/pst-import') diff --git a/plugins/pst-import/pst-importer.c b/plugins/pst-import/pst-importer.c index 2e994f78e4..d0a69ddece 100644 --- a/plugins/pst-import/pst-importer.c +++ b/plugins/pst-import/pst-importer.c @@ -121,7 +121,6 @@ struct _PstImporter { pst_file pst; - GCancellable *cancellable; CamelFolder *folder; gchar *parent_uri; gchar *folder_name; @@ -394,7 +393,9 @@ open_ecal (ECalSourceType type, const gchar *name) } static void -pst_import_import (PstImporter *m) +pst_import_import (PstImporter *m, + GCancellable *cancellable, + GError **error) { if (GPOINTER_TO_INT (g_datalist_get_data (&m->target->data, "pst-do-addr"))) { /* Hack - grab the first address book we can find @@ -456,11 +457,14 @@ pst_import_file (PstImporter *m) EShell *shell; EShellBackend *shell_backend; EMailSession *session; + GCancellable *cancellable; gint ret; gchar *filename; pst_item *item = NULL; pst_desc_tree *d_ptr; + cancellable = e_activity_get_cancellable (m->base.activity); + /* XXX Dig up the EMailSession from the default EShell. * Since the EImport framework doesn't allow for user * data, I don't see how else to get to it. */ @@ -476,7 +480,7 @@ pst_import_file (PstImporter *m) if (GPOINTER_TO_INT (g_datalist_get_data (&m->target->data, "pst-do-mail"))) { e_mail_session_uri_to_folder_sync ( session, m->parent_uri, CAMEL_STORE_FOLDER_CREATE, - m->base.cancellable, &m->base.error); + cancellable, &m->base.error); } ret = pst_init (&m->pst, filename); @@ -710,10 +714,13 @@ pst_create_folder (PstImporter *m) EShell *shell; EShellBackend *shell_backend; EMailSession *session; + GCancellable *cancellable; const gchar *parent; gchar *dest, *dest_end, *pos; gint dest_len; + cancellable = e_activity_get_cancellable (m->base.activity); + /* XXX Dig up the EMailSession from the default EShell. * Since the EImport framework doesn't allow for user * data, I don't see how else to get to it. */ @@ -740,7 +747,7 @@ pst_create_folder (PstImporter *m) folder = e_mail_session_uri_to_folder_sync ( session, dest, CAMEL_STORE_FOLDER_CREATE, - m->base.cancellable, &m->base.error); + cancellable, &m->base.error); g_object_unref (folder); *pos = '/'; } @@ -754,7 +761,7 @@ pst_create_folder (PstImporter *m) m->folder = e_mail_session_uri_to_folder_sync ( session, m->folder_uri, CAMEL_STORE_FOLDER_CREATE, - m->base.cancellable, &m->base.error); + cancellable, &m->base.error); } /** @@ -1659,7 +1666,6 @@ pst_import (EImport *ei, EImportTarget *target) m->status_timeout_id = g_timeout_add (100, pst_status_timeout, m); /*m->status_timeout_id = NULL;*/ m->status_lock = g_mutex_new (); - m->cancellable = camel_operation_new (); g_signal_connect ( m->status, "status", -- cgit