aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2011-03-11 14:50:18 -0600
committerTed Gould <ted@gould.cx>2011-03-11 14:50:18 -0600
commitc6313acb0861e4861a160f6866e42995cd50f062 (patch)
treeff6ce47108f192a455e70928f22997242eada2bf
parent7b316782e0acd1ef0e91f41feca4ddb9c4ac5c4f (diff)
downloadayatana-indicator-application-c6313acb0861e4861a160f6866e42995cd50f062.tar.gz
ayatana-indicator-application-c6313acb0861e4861a160f6866e42995cd50f062.tar.bz2
ayatana-indicator-application-c6313acb0861e4861a160f6866e42995cd50f062.zip
Add a cancellable object for the GetApplications call
-rw-r--r--src/indicator-application.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/src/indicator-application.c b/src/indicator-application.c
index f7ce391..1d074d6 100644
--- a/src/indicator-application.c
+++ b/src/indicator-application.c
@@ -86,6 +86,7 @@ struct _IndicatorApplicationPrivate {
GList * applications;
GHashTable * theme_dirs;
guint disconnect_kill;
+ GCancellable * get_apps_cancel;
};
typedef struct _ApplicationEntry ApplicationEntry;
@@ -166,6 +167,8 @@ indicator_application_init (IndicatorApplication *self)
priv->theme_dirs = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
+ priv->get_apps_cancel = NULL;
+
return;
}
@@ -178,6 +181,12 @@ indicator_application_dispose (GObject *object)
g_source_remove(priv->disconnect_kill);
}
+ if (priv->get_apps_cancel != NULL) {
+ g_cancellable_cancel(priv->get_apps_cancel);
+ /* The callback should clear the cancelable */
+ g_warn_if_fail(priv->get_apps_cancel == NULL);
+ }
+
while (priv->applications != NULL) {
application_removed(INDICATOR_APPLICATION(object),
0);
@@ -290,10 +299,20 @@ service_proxy_cb (GObject * object, GAsyncResult * res, gpointer user_data)
g_signal_connect(proxy, "g-signal", G_CALLBACK(receive_signal), self);
+ /* We shouldn't be in a situation where we've already
+ called this function. It doesn't *hurt* anything, but
+ man we should look into it more. */
+ if (priv->get_apps_cancel != NULL) {
+ g_warning("Already getting applications? Odd.");
+ return;
+ }
+
+ priv->get_apps_cancel = g_cancellable_new();
+
/* Query it for existing applications */
g_debug("Request current apps");
g_dbus_proxy_call(priv->service_proxy, "GetApplications", NULL,
- G_DBUS_CALL_FLAGS_NONE, -1, NULL,
+ G_DBUS_CALL_FLAGS_NONE, -1, priv->get_apps_cancel,
get_applications, self);
return;
@@ -789,6 +808,12 @@ get_applications (GObject * obj, GAsyncResult * res, gpointer user_data)
GVariant * child;
GVariantIter * iter;
+ /* No one can cancel us anymore, we've completed! */
+ if (priv->get_apps_cancel != NULL) {
+ g_object_unref(priv->get_apps_cancel);
+ priv->get_apps_cancel = NULL;
+ }
+
result = g_dbus_proxy_call_finish(priv->service_proxy, res, &error);
if (error != NULL) {