aboutsummaryrefslogtreecommitdiffstats
path: root/e-util/e-io-activity.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 /e-util/e-io-activity.c
parentb145c0a2522c5c9942c0827bf03baefea68f5d99 (diff)
downloadgsoc2013-evolution-a98c07a569292fa66f91d3fa4bd32f32adff1880.tar
gsoc2013-evolution-a98c07a569292fa66f91d3fa4bd32f32adff1880.tar.gz
gsoc2013-evolution-a98c07a569292fa66f91d3fa4bd32f32adff1880.tar.bz2
gsoc2013-evolution-a98c07a569292fa66f91d3fa4bd32f32adff1880.tar.lz
gsoc2013-evolution-a98c07a569292fa66f91d3fa4bd32f32adff1880.tar.xz
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 'e-util/e-io-activity.c')
-rw-r--r--e-util/e-io-activity.c82
1 files changed, 1 insertions, 81 deletions
diff --git a/e-util/e-io-activity.c b/e-util/e-io-activity.c
index c8eb761708..e519fea18b 100644
--- a/e-util/e-io-activity.c
+++ b/e-util/e-io-activity.c
@@ -27,13 +27,11 @@
struct _EIOActivityPrivate {
GAsyncResult *async_result;
- GCancellable *cancellable;
};
enum {
PROP_0,
- PROP_ASYNC_RESULT,
- PROP_CANCELLABLE
+ PROP_ASYNC_RESULT
};
G_DEFINE_TYPE (
@@ -53,12 +51,6 @@ io_activity_set_property (GObject *object,
E_IO_ACTIVITY (object),
g_value_get_object (value));
return;
-
- case PROP_CANCELLABLE:
- e_io_activity_set_cancellable (
- E_IO_ACTIVITY (object),
- g_value_get_object (value));
- return;
}
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -76,12 +68,6 @@ io_activity_get_property (GObject *object,
value, e_io_activity_get_async_result (
E_IO_ACTIVITY (object)));
return;
-
- case PROP_CANCELLABLE:
- g_value_set_object (
- value, e_io_activity_get_cancellable (
- E_IO_ACTIVITY (object)));
- return;
}
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -99,32 +85,11 @@ io_activity_dispose (GObject *object)
priv->async_result = NULL;
}
- if (priv->cancellable != NULL) {
- g_object_unref (priv->cancellable);
- priv->cancellable = NULL;
- }
-
/* Chain up to parent's dispose() method. */
G_OBJECT_CLASS (e_io_activity_parent_class)->dispose (object);
}
static void
-io_activity_cancelled (EActivity *activity)
-{
- EIOActivity *io_activity;
- GCancellable *cancellable;
-
- /* Chain up to parent's cancelled() method. */
- E_ACTIVITY_CLASS (e_io_activity_parent_class)->cancelled (activity);
-
- io_activity = E_IO_ACTIVITY (activity);
- cancellable = e_io_activity_get_cancellable (io_activity);
-
- if (cancellable != NULL)
- g_cancellable_cancel (cancellable);
-}
-
-static void
io_activity_completed (EActivity *activity)
{
EIOActivity *io_activity;
@@ -158,7 +123,6 @@ e_io_activity_class_init (EIOActivityClass *class)
object_class->dispose = io_activity_dispose;
activity_class = E_ACTIVITY_CLASS (class);
- activity_class->cancelled = io_activity_cancelled;
activity_class->completed = io_activity_completed;
g_object_class_install_property (
@@ -171,17 +135,6 @@ e_io_activity_class_init (EIOActivityClass *class)
G_TYPE_ASYNC_RESULT,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
-
- g_object_class_install_property (
- object_class,
- PROP_CANCELLABLE,
- g_param_spec_object (
- "cancellable",
- "Cancellable",
- NULL,
- G_TYPE_CANCELLABLE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT));
}
static void
@@ -236,36 +189,3 @@ e_io_activity_set_async_result (EIOActivity *io_activity,
g_object_notify (G_OBJECT (io_activity), "async-result");
}
-GCancellable *
-e_io_activity_get_cancellable (EIOActivity *io_activity)
-{
- g_return_val_if_fail (E_IS_IO_ACTIVITY (io_activity), NULL);
-
- return io_activity->priv->cancellable;
-}
-
-void
-e_io_activity_set_cancellable (EIOActivity *io_activity,
- GCancellable *cancellable)
-{
- g_return_if_fail (E_IS_IO_ACTIVITY (io_activity));
-
- if (cancellable != NULL) {
- g_return_if_fail (G_IS_CANCELLABLE (cancellable));
- g_object_ref (cancellable);
- }
-
- if (io_activity->priv->cancellable != NULL)
- g_object_unref (io_activity->priv->cancellable);
-
- io_activity->priv->cancellable = cancellable;
-
- g_object_freeze_notify (G_OBJECT (io_activity));
-
- e_activity_set_allow_cancel (
- E_ACTIVITY (io_activity), (cancellable != NULL));
-
- g_object_notify (G_OBJECT (io_activity), "cancellable");
-
- g_object_thaw_notify (G_OBJECT (io_activity));
-}