aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/misc/e-activity-proxy.c
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2010-09-19 03:57:27 +0800
committerMatthew Barnes <mbarnes@redhat.com>2010-09-19 04:40:19 +0800
commita98c07a569292fa66f91d3fa4bd32f32adff1880 (patch)
tree98caa43594f61662289fd696b409978946e92255 /widgets/misc/e-activity-proxy.c
parentb145c0a2522c5c9942c0827bf03baefea68f5d99 (diff)
downloadgsoc2013-evolution-a98c07a569292fa66f91d3fa4bd32f32adff1880.tar.gz
gsoc2013-evolution-a98c07a569292fa66f91d3fa4bd32f32adff1880.tar.zst
gsoc2013-evolution-a98c07a569292fa66f91d3fa4bd32f32adff1880.zip
Add a GCancellable to EActivity.
EActivity now uses a GCancellable to manage cancellations, instead of having its own redundant cancellation API. API changes are as follows: + e_activity_get_cancellable() + e_activity_set_cancellable() - e_activity_cancel() - e_activity_is_cancelled() - e_activity_get_allow_cancel() - e_activity_set_allow_cancel() EActivity's "cancelled" signal remains, but only as a repeater for GCancellable::cancelled signals. It should not be emitted directly. The presence of a GCancellable implies that cancellation is allowed. EActivity does not create its own default GCancellable, it has to be given one. If a CamelOperation (cast as a GCancellable) is given, EActivity will configure itself to listen for status updates from the CamelOperation and propagate the information to its own "primary-text" and "percent" properties. These changes allowed me to start cleaning up some of the incredibly convoluted logic in mail-mt.c -- in particular, mail_operation_status() is completely gone now. mail-mt.c is still in a transitional state -- much more significant changes coming soon.
Diffstat (limited to 'widgets/misc/e-activity-proxy.c')
-rw-r--r--widgets/misc/e-activity-proxy.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/widgets/misc/e-activity-proxy.c b/widgets/misc/e-activity-proxy.c
index 8e20e67d5d..e96f18ed63 100644
--- a/widgets/misc/e-activity-proxy.c
+++ b/widgets/misc/e-activity-proxy.c
@@ -47,19 +47,33 @@ G_DEFINE_TYPE (
GTK_TYPE_EVENT_BOX)
static void
+activity_proxy_cancel (EActivity *activity)
+{
+ GCancellable *cancellable;
+
+ /* We shouldn't get here unless the EActivity has a GCancellable,
+ * since otherwise the cancel button is invisible and unclickable.
+ * g_cancellable_cancel() will emit a warning if this breaks. */
+
+ cancellable = e_activity_get_cancellable (activity);
+ g_cancellable_cancel (cancellable);
+}
+
+static void
activity_proxy_update (EActivityProxy *proxy)
{
- EActivity *activity = proxy->priv->activity;
+ EActivity *activity;
+ GCancellable *cancellable;
const gchar *icon_name;
- gboolean allow_cancel;
gboolean cancelled;
gboolean clickable;
gboolean completed;
gboolean sensitive;
gchar *description;
- allow_cancel = e_activity_get_allow_cancel (activity);
- cancelled = e_activity_is_cancelled (activity);
+ activity = proxy->priv->activity;
+ cancellable = e_activity_get_cancellable (activity);
+ cancelled = g_cancellable_is_cancelled (cancellable);
clickable = e_activity_get_clickable (activity);
completed = e_activity_is_completed (activity);
icon_name = e_activity_get_icon_name (activity);
@@ -67,6 +81,7 @@ activity_proxy_update (EActivityProxy *proxy)
description = e_activity_describe (activity);
gtk_widget_set_tooltip_text (GTK_WIDGET (proxy), description);
gtk_label_set_text (GTK_LABEL (proxy->priv->label), description);
+ gtk_widget_set_visible (GTK_WIDGET (proxy), (description != NULL));
g_free (description);
/* Note, an activity requires an icon name in order to
@@ -93,7 +108,7 @@ activity_proxy_update (EActivityProxy *proxy)
gtk_widget_hide (proxy->priv->image);
}
- if (allow_cancel)
+ if (cancellable != NULL)
gtk_widget_show (proxy->priv->cancel);
else
gtk_widget_hide (proxy->priv->cancel);
@@ -202,7 +217,7 @@ activity_proxy_constructed (GObject *object)
g_signal_connect_swapped (
proxy->priv->cancel, "clicked",
- G_CALLBACK (e_activity_cancel), proxy->priv->activity);
+ G_CALLBACK (activity_proxy_cancel), proxy->priv->activity);
g_signal_connect_swapped (
proxy->priv->activity, "cancelled",