aboutsummaryrefslogtreecommitdiffstats
path: root/e-util
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2011-05-12 00:19:17 +0800
committerMatthew Barnes <mbarnes@redhat.com>2011-05-12 00:59:29 +0800
commitba8f1f78f4ec76aeaec6e2b55fcb9b2dec17ba65 (patch)
tree8ff0520b904abff75be0ed9a6002fbbcbb0b193b /e-util
parentc780b7d21255a5e6a0f15af12e02accbda088f3b (diff)
downloadgsoc2013-evolution-ba8f1f78f4ec76aeaec6e2b55fcb9b2dec17ba65.tar
gsoc2013-evolution-ba8f1f78f4ec76aeaec6e2b55fcb9b2dec17ba65.tar.gz
gsoc2013-evolution-ba8f1f78f4ec76aeaec6e2b55fcb9b2dec17ba65.tar.bz2
gsoc2013-evolution-ba8f1f78f4ec76aeaec6e2b55fcb9b2dec17ba65.tar.lz
gsoc2013-evolution-ba8f1f78f4ec76aeaec6e2b55fcb9b2dec17ba65.tar.xz
gsoc2013-evolution-ba8f1f78f4ec76aeaec6e2b55fcb9b2dec17ba65.tar.zst
gsoc2013-evolution-ba8f1f78f4ec76aeaec6e2b55fcb9b2dec17ba65.zip
Add e_activity_handle_cancellation().
Convenience function for use in GAsyncReadyCallback functions. This acknowledges the cancellation, so that the activity's description changes from "(cancelling)" to "(cancelled)" and the description appears crossed out in the UI for a moment before disappearing.
Diffstat (limited to 'e-util')
-rw-r--r--e-util/e-activity.c15
-rw-r--r--e-util/e-activity.h2
-rw-r--r--e-util/e-file-utils.c4
3 files changed, 18 insertions, 3 deletions
diff --git a/e-util/e-activity.c b/e-util/e-activity.c
index 231de505b4..2e3a078f82 100644
--- a/e-util/e-activity.c
+++ b/e-util/e-activity.c
@@ -498,3 +498,18 @@ e_activity_set_text (EActivity *activity,
g_object_notify (G_OBJECT (activity), "text");
}
+gboolean
+e_activity_handle_cancellation (EActivity *activity,
+ const GError *error)
+{
+ gboolean handled = FALSE;
+
+ g_return_val_if_fail (E_IS_ACTIVITY (activity), FALSE);
+
+ if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
+ e_activity_set_state (activity, E_ACTIVITY_CANCELLED);
+ handled = TRUE;
+ }
+
+ return handled;
+}
diff --git a/e-util/e-activity.h b/e-util/e-activity.h
index 4602a5696e..3e56f992f8 100644
--- a/e-util/e-activity.h
+++ b/e-util/e-activity.h
@@ -84,6 +84,8 @@ void e_activity_set_state (EActivity *activity,
const gchar * e_activity_get_text (EActivity *activity);
void e_activity_set_text (EActivity *activity,
const gchar *text);
+gboolean e_activity_handle_cancellation (EActivity *activity,
+ const GError *error);
G_END_DECLS
diff --git a/e-util/e-file-utils.c b/e-util/e-file-utils.c
index 2d5ff30ff7..49fd4a07ee 100644
--- a/e-util/e-file-utils.c
+++ b/e-util/e-file-utils.c
@@ -85,9 +85,7 @@ file_replace_contents_cb (GFile *file,
g_file_replace_contents_finish (file, result, &new_etag, &error);
- if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
- e_activity_set_state (context->activity, E_ACTIVITY_CANCELLED);
- else
+ if (!e_activity_handle_cancellation (context->activity, error))
e_activity_set_state (context->activity, E_ACTIVITY_COMPLETED);
if (error == NULL)