aboutsummaryrefslogtreecommitdiff
path: root/src/indicator-application.c
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2010-01-20 14:45:24 -0600
committerTed Gould <ted@gould.cx>2010-01-20 14:45:24 -0600
commitf279a2d4d4438be0cd172d776613c586cfc9370c (patch)
tree93c6d9f5c6c11f29f9a16129e854e9c12b1f1bff /src/indicator-application.c
parentbd7118f59345fbf9c7a22fdfb7a65e7f97dfa6c8 (diff)
parent3d7c9e254538d4e965b1ab6a7461f9df3a53ea30 (diff)
downloadayatana-indicator-application-f279a2d4d4438be0cd172d776613c586cfc9370c.tar.gz
ayatana-indicator-application-f279a2d4d4438be0cd172d776613c586cfc9370c.tar.bz2
ayatana-indicator-application-f279a2d4d4438be0cd172d776613c586cfc9370c.zip
* Upstream update
* Support getting the app list from a running service.
Diffstat (limited to 'src/indicator-application.c')
-rw-r--r--src/indicator-application.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/indicator-application.c b/src/indicator-application.c
index c330645..ef11179 100644
--- a/src/indicator-application.c
+++ b/src/indicator-application.c
@@ -96,6 +96,7 @@ static void application_added (DBusGProxy * proxy, const gchar * iconname, gint
static void application_removed (DBusGProxy * proxy, gint position , IndicatorApplication * application);
static void application_icon_changed (DBusGProxy * proxy, gint position, const gchar * iconname, IndicatorApplication * application);
static void get_applications (DBusGProxy *proxy, GPtrArray *OUT_applications, GError *error, gpointer userdata);
+static void get_applications_helper (gpointer data, gpointer user_data);
G_DEFINE_TYPE (IndicatorApplication, indicator_application, INDICATOR_OBJECT_TYPE);
@@ -303,6 +304,10 @@ application_added (DBusGProxy * proxy, const gchar * iconname, gint position, co
app->entry.label = NULL;
app->entry.menu = GTK_MENU(dbusmenu_gtkmenu_new((gchar *)dbusaddress, (gchar *)dbusobject));
+ /* Keep copies of these for ourself, just in case. */
+ g_object_ref(app->entry.image);
+ g_object_ref(app->entry.menu);
+
gtk_widget_show(GTK_WIDGET(app->entry.image));
priv->applications = g_list_insert(priv->applications, app, position);
@@ -368,6 +373,29 @@ application_icon_changed (DBusGProxy * proxy, gint position, const gchar * iconn
static void
get_applications (DBusGProxy *proxy, GPtrArray *OUT_applications, GError *error, gpointer userdata)
{
+ if (error != NULL) {
+ g_warning("Unable to get application list: %s", error->message);
+ return;
+ }
+ g_ptr_array_foreach(OUT_applications, get_applications_helper, userdata);
return;
}
+
+/* A little helper that takes apart the DBus structure and calls
+ application_added on every entry in the list. */
+static void
+get_applications_helper (gpointer data, gpointer user_data)
+{
+ GValueArray * array = (GValueArray *)data;
+
+ g_return_if_fail(array->n_values == 5);
+
+ const gchar * icon_name = g_value_get_string(g_value_array_get_nth(array, 0));
+ gint position = g_value_get_int(g_value_array_get_nth(array, 1));
+ const gchar * dbus_address = g_value_get_string(g_value_array_get_nth(array, 2));
+ const gchar * dbus_object = g_value_get_boxed(g_value_array_get_nth(array, 3));
+ const gchar * icon_path = g_value_get_string(g_value_array_get_nth(array, 4));
+
+ return application_added(NULL, icon_name, position, dbus_address, dbus_object, icon_path, user_data);
+}