[evolution/gnome-3-8] Add e_activity_cancel().
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/gnome-3-8] Add e_activity_cancel().
- Date: Thu, 25 Apr 2013 16:12:58 +0000 (UTC)
commit 0aa6d685c397a8fb93c27e4237de6f55cd36d747
Author: Matthew Barnes <mbarnes redhat com>
Date: Wed Apr 24 18:26:43 2013 -0400
Add e_activity_cancel().
Convenience function cancels the activity's GCancellable.
(cherry picked from commit 8b245838de22f470e867b28631240a018a0bc36b)
doc/reference/libeutil/libeutil-sections.txt | 1 +
e-util/e-activity-bar.c | 4 +--
e-util/e-activity-proxy.c | 4 +--
e-util/e-activity.c | 27 ++++++++++++++++++++++++++
e-util/e-activity.h | 1 +
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 60aeed7..2bf11ad 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 b90996b..51435d3 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 43c77a5..aeef5d2 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 e4c1213..87b8449 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 0ba5753..9309fe1 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 0749aac..0261d8a 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));
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]