From c881b5bc5e61d04b18d4ab46ad70533e7340d15b Mon Sep 17 00:00:00 2001
From: Matthew Barnes <mbarnes@redhat.com>
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.
---
 mail/em-composer-utils.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

(limited to 'mail/em-composer-utils.c')

diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c
index 704bd2bd37..f084155362 100644
--- a/mail/em-composer-utils.c
+++ b/mail/em-composer-utils.c
@@ -482,6 +482,7 @@ composer_send_completed (EMailSession *session,
 
 	/* Ignore cancellations. */
 	if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
+		e_activity_set_state (context->activity, E_ACTIVITY_CANCELLED);
 		g_error_free (error);
 		goto exit;
 	}
@@ -495,7 +496,7 @@ composer_send_completed (EMailSession *session,
 		goto exit;
 	}
 
-	e_activity_complete (context->activity);
+	e_activity_set_state (context->activity, E_ACTIVITY_COMPLETED);
 
 	/* Wait for the EActivity's completion message to
 	 * time out and then destroy the composer window. */
@@ -625,13 +626,16 @@ composer_save_draft_complete (EMailSession *session,
 
 	e_mail_session_handle_draft_headers_finish (session, result, &error);
 
-	if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+	if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
+		e_activity_set_state (context->activity, E_ACTIVITY_CANCELLED);
 		g_error_free (error);
 
-	else if (error != NULL) {
+	} else if (error != NULL) {
 		g_warning ("%s", error->message);
 		g_error_free (error);
-	}
+
+	} else
+		e_activity_set_state (context->activity, E_ACTIVITY_COMPLETED);
 
 	/* Encode the draft message we just saved into the EMsgComposer
 	 * as X-Evolution-Draft headers.  The message will be marked for
@@ -641,8 +645,6 @@ composer_save_draft_complete (EMailSession *session,
 		context->composer, context->folder_uri,
 		context->message_uid);
 
-	e_activity_complete (context->activity);
-
 	async_context_free (context);
 }
 
-- 
cgit