aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2011-03-16 14:47:30 -0500
committerTed Gould <ted@gould.cx>2011-03-16 14:47:30 -0500
commit57bf196fb01cd7f9bd4185c5d8d35cfc441795b7 (patch)
treea1834d0c41f6e68595a7951de314a431133b7c18 /src
parent87fb9978433b41004b66772284e4f4f64b53313b (diff)
parent449299038368f8814050aa2fa2256657ff050f17 (diff)
downloadayatana-indicator-application-57bf196fb01cd7f9bd4185c5d8d35cfc441795b7.tar.gz
ayatana-indicator-application-57bf196fb01cd7f9bd4185c5d8d35cfc441795b7.tar.bz2
ayatana-indicator-application-57bf196fb01cd7f9bd4185c5d8d35cfc441795b7.zip
Import upstream version 0.2.95
Diffstat (limited to 'src')
-rw-r--r--src/application-service-appstore.c12
-rw-r--r--src/indicator-application.c59
2 files changed, 65 insertions, 6 deletions
diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c
index 10feef5..25eba69 100644
--- a/src/application-service-appstore.c
+++ b/src/application-service-appstore.c
@@ -374,6 +374,7 @@ load_override_file (GHashTable * hash, const gchar * filename)
g_return_if_fail(filename != NULL);
if (!g_file_test(filename, G_FILE_TEST_EXISTS)) {
+ g_debug("Override file '%s' doesn't exist", filename);
return;
}
@@ -438,7 +439,7 @@ got_all_properties (GObject * source_object, GAsyncResult * res,
* icon_theme_path = NULL, * index = NULL, * label = NULL,
* guide = NULL;
- GVariant * properties = g_dbus_proxy_call_finish(app->props, res, &error);
+ GVariant * properties = g_dbus_proxy_call_finish(G_DBUS_PROXY(source_object), res, &error);
if (app->props_cancel != NULL) {
g_object_unref(app->props_cancel);
@@ -486,6 +487,7 @@ got_all_properties (GObject * source_object, GAsyncResult * res,
} /* else ignore */
}
g_variant_iter_free (iter);
+ g_variant_unref(properties);
if (menu == NULL || id == NULL || category == NULL || status == NULL ||
icon_name == NULL) {
@@ -524,6 +526,7 @@ got_all_properties (GObject * source_object, GAsyncResult * res,
app->ordering_index = GPOINTER_TO_UINT(ordering_index_over);
}
g_debug("'%s' ordering index is '%X'", app->id, app->ordering_index);
+ app->appstore->priv->applications = g_list_sort_with_data(app->appstore->priv->applications, app_sort_func, NULL);
if (label != NULL) {
app->label = g_variant_dup_string(label, NULL);
@@ -1238,9 +1241,10 @@ get_applications (ApplicationServiceAppstore * appstore)
}
g_variant_builder_add (&builder, "(sisossss)", app->icon,
- position++, app->dbus_name, app->menu,
- app->icon_theme_path, app->label,
- app->guide, app->icon_desc);
+ position++, app->dbus_name, app->menu,
+ app->icon_theme_path, app->label,
+ app->guide,
+ (app->icon_desc != NULL) ? app->icon_desc : "");
}
out = g_variant_builder_end(&builder);
diff --git a/src/indicator-application.c b/src/indicator-application.c
index f7ce391..2b26c92 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);
+ g_object_unref(priv->get_apps_cancel);
+ 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;
@@ -730,6 +749,22 @@ receive_signal (GDBusProxy * proxy, gchar * sender_name, gchar * signal_name,
GVariant * parameters, gpointer user_data)
{
IndicatorApplication * self = INDICATOR_APPLICATION(user_data);
+ IndicatorApplicationPrivate * priv = INDICATOR_APPLICATION_GET_PRIVATE(self);
+
+ /* If we're in the middle of a GetApplications call and we get
+ any of these our state is probably going to just be confused. Let's
+ cancel the call we had and try again to try and get a clear answer */
+ if (priv->get_apps_cancel != NULL) {
+ g_cancellable_cancel(priv->get_apps_cancel);
+ g_object_unref(priv->get_apps_cancel);
+
+ priv->get_apps_cancel = g_cancellable_new();
+
+ g_dbus_proxy_call(priv->service_proxy, "GetApplications", NULL,
+ G_DBUS_CALL_FLAGS_NONE, -1, priv->get_apps_cancel,
+ get_applications, self);
+ return;
+ }
if (g_strcmp0(signal_name, "ApplicationAdded") == 0) {
const gchar * iconname;
@@ -791,15 +826,35 @@ get_applications (GObject * obj, GAsyncResult * res, gpointer user_data)
result = g_dbus_proxy_call_finish(priv->service_proxy, res, &error);
+ /* No one can cancel us anymore, we've completed! */
+ if (priv->get_apps_cancel != NULL) {
+ if (error == NULL || error->domain != G_IO_ERROR || error->code != G_IO_ERROR_CANCELLED) {
+ g_object_unref(priv->get_apps_cancel);
+ priv->get_apps_cancel = NULL;
+ }
+ }
+
+ /* If we got an error, print it and exit out */
if (error != NULL) {
g_warning("Unable to get application list: %s", error->message);
+ g_error_free(error);
return;
}
+ /* Remove all applications that we previously had
+ as we're going to repopulate the list. */
+ while (priv->applications != NULL) {
+ application_removed(self, 0);
+ }
+
+ /* Get our new applications that we got in the request */
g_variant_get(result, "(a(sisossss))", &iter);
- while ((child = g_variant_iter_next_value (iter)))
+ while ((child = g_variant_iter_next_value (iter))) {
get_applications_helper(self, child);
+ g_variant_unref(child);
+ }
g_variant_iter_free (iter);
+ g_variant_unref(result);
return;
}