diff options
-rw-r--r-- | doc/reference/libeutil/libeutil-sections.txt | 1 | ||||
-rw-r--r-- | e-util/e-activity-bar.c | 4 | ||||
-rw-r--r-- | e-util/e-activity-proxy.c | 4 | ||||
-rw-r--r-- | e-util/e-activity.c | 27 | ||||
-rw-r--r-- | e-util/e-activity.h | 1 | ||||
-rw-r--r-- | shell/e-shell-backend.c | 10 |
6 files changed, 33 insertions, 14 deletions
diff --git a/doc/reference/libeutil/libeutil-sections.txt b/doc/reference/libeutil/libeutil-sections.txt index 71174e3db2..8227c44230 100644 --- a/doc/reference/libeutil/libeutil-sections.txt +++ b/doc/reference/libeutil/libeutil-sections.txt @@ -28,6 +28,7 @@ EActionComboBoxPrivate <TITLE>EActivity</TITLE> EActivity e_activity_new +e_activity_cancel e_activity_describe e_activity_get_alert_sink e_activity_set_alert_sink diff --git a/e-util/e-activity-bar.c b/e-util/e-activity-bar.c index b90996bd9b..51435d3dda 100644 --- a/e-util/e-activity-bar.c +++ b/e-util/e-activity-bar.c @@ -150,13 +150,11 @@ static void activity_bar_cancel (EActivityBar *bar) { EActivity *activity; - GCancellable *cancellable; activity = e_activity_bar_get_activity (bar); g_return_if_fail (E_IS_ACTIVITY (activity)); - cancellable = e_activity_get_cancellable (activity); - g_cancellable_cancel (cancellable); + e_activity_cancel (activity); activity_bar_update (bar); } diff --git a/e-util/e-activity-proxy.c b/e-util/e-activity-proxy.c index 43c77a522f..aeef5d2cd8 100644 --- a/e-util/e-activity-proxy.c +++ b/e-util/e-activity-proxy.c @@ -156,13 +156,11 @@ static void activity_proxy_cancel (EActivityProxy *proxy) { EActivity *activity; - GCancellable *cancellable; activity = e_activity_proxy_get_activity (proxy); g_return_if_fail (E_IS_ACTIVITY (activity)); - cancellable = e_activity_get_cancellable (activity); - g_cancellable_cancel (cancellable); + e_activity_cancel (activity); activity_proxy_update (proxy); } diff --git a/e-util/e-activity.c b/e-util/e-activity.c index e4c121308b..87b84495db 100644 --- a/e-util/e-activity.c +++ b/e-util/e-activity.c @@ -383,6 +383,33 @@ e_activity_new (void) } /** + * e_activity_cancel: + * @activity: an #EActivity + * + * Convenience function cancels @activity's #EActivity:cancellable. + * + * <para> + * <note> + * This function will not set @activity's #EActivity:state to + * @E_ACTIVITY_CANCELLED. It merely requests that the associated + * operation be cancelled. Only after the operation finishes with + * a @G_IO_ERROR_CANCELLED should the @activity's #EActivity:state + * be changed (see e_activity_handle_cancellation()). During this + * interim period e_activity_describe() will indicate the activity + * is "cancelling". + * </note> + * </para> + **/ +void +e_activity_cancel (EActivity *activity) +{ + g_return_if_fail (E_IS_ACTIVITY (activity)); + + /* This function handles NULL gracefully. */ + g_cancellable_cancel (activity->priv->cancellable); +} + +/** * e_activity_describe: * @activity: an #EActivity * diff --git a/e-util/e-activity.h b/e-util/e-activity.h index 0ba5753528..9309fe1fb0 100644 --- a/e-util/e-activity.h +++ b/e-util/e-activity.h @@ -70,6 +70,7 @@ struct _EActivityClass { GType e_activity_get_type (void) G_GNUC_CONST; EActivity * e_activity_new (void); +void e_activity_cancel (EActivity *activity); gchar * e_activity_describe (EActivity *activity); EAlertSink * e_activity_get_alert_sink (EActivity *activity); void e_activity_set_alert_sink (EActivity *activity, diff --git a/shell/e-shell-backend.c b/shell/e-shell-backend.c index 0749aac4e6..0261d8a3e2 100644 --- a/shell/e-shell-backend.c +++ b/shell/e-shell-backend.c @@ -619,14 +619,8 @@ e_shell_backend_cancel_all (EShellBackend *shell_backend) list = g_queue_peek_head_link (shell_backend->priv->activities); - for (iter = list; iter != NULL; iter = g_list_next (iter)) { - EActivity *activity; - GCancellable *cancellable; - - activity = E_ACTIVITY (iter->data); - cancellable = e_activity_get_cancellable (activity); - g_cancellable_cancel (cancellable); - } + for (iter = list; iter != NULL; iter = g_list_next (iter)) + e_activity_cancel (E_ACTIVITY (iter->data)); } /** |