From b447c26d5dab577f46ad32d6191bc623be9aaf25 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 15 Jan 2010 08:51:02 -0600 Subject: Fleshing out the get_applications function so that we do something with the list we now get. --- src/indicator-application.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'src/indicator-application.c') diff --git a/src/indicator-application.c b/src/indicator-application.c index c330645..c6b962a 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); @@ -368,6 +369,42 @@ 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, proxy); 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) +{ + GType structype = dbus_g_type_get_struct("GValueArray", + G_TYPE_STRING, + G_TYPE_INT, + G_TYPE_STRING, + DBUS_TYPE_G_OBJECT_PATH, + G_TYPE_STRING, + G_TYPE_INVALID); + g_return_if_fail(G_VALUE_HOLDS(data, structype)); + + gchar * icon_name; + gint position; + gchar * dbus_address; + gchar * dbus_object; + gchar * icon_path; + + dbus_g_type_struct_get(data, + 0, &icon_name, + 1, &position, + 2, &dbus_address, + 3, &dbus_object, + 4, &icon_path, + G_MAXUINT); + + return application_added(user_data, icon_name, position, dbus_address, dbus_object, icon_path, NULL); +} -- cgit v1.2.3 From 2579e9f10454dc36c6b793fd064936737052d577 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 15 Jan 2010 10:04:24 -0600 Subject: Using a straight value array and making sure to pass the application --- src/indicator-application.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) (limited to 'src/indicator-application.c') diff --git a/src/indicator-application.c b/src/indicator-application.c index c6b962a..fc7f56d 100644 --- a/src/indicator-application.c +++ b/src/indicator-application.c @@ -373,7 +373,7 @@ get_applications (DBusGProxy *proxy, GPtrArray *OUT_applications, GError *error, g_warning("Unable to get application list: %s", error->message); return; } - g_ptr_array_foreach(OUT_applications, get_applications_helper, proxy); + g_ptr_array_foreach(OUT_applications, get_applications_helper, userdata); return; } @@ -383,6 +383,7 @@ get_applications (DBusGProxy *proxy, GPtrArray *OUT_applications, GError *error, static void get_applications_helper (gpointer data, gpointer user_data) { +#if 0 GType structype = dbus_g_type_get_struct("GValueArray", G_TYPE_STRING, G_TYPE_INT, @@ -390,21 +391,16 @@ get_applications_helper (gpointer data, gpointer user_data) DBUS_TYPE_G_OBJECT_PATH, G_TYPE_STRING, G_TYPE_INVALID); - g_return_if_fail(G_VALUE_HOLDS(data, structype)); +#endif + GValueArray * array = (GValueArray *)data; - gchar * icon_name; - gint position; - gchar * dbus_address; - gchar * dbus_object; - gchar * icon_path; + g_debug("Size: %d", array->n_values); - dbus_g_type_struct_get(data, - 0, &icon_name, - 1, &position, - 2, &dbus_address, - 3, &dbus_object, - 4, &icon_path, - G_MAXUINT); + 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(user_data, icon_name, position, dbus_address, dbus_object, icon_path, NULL); + return application_added(NULL, icon_name, position, dbus_address, dbus_object, icon_path, user_data); } -- cgit v1.2.3 From 9c545b7e13a3c0926d569775cfe5ff470874f675 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 15 Jan 2010 10:14:31 -0600 Subject: Cleaning out dead code and turning a printout into an assert. --- src/indicator-application.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'src/indicator-application.c') diff --git a/src/indicator-application.c b/src/indicator-application.c index fc7f56d..c8f3024 100644 --- a/src/indicator-application.c +++ b/src/indicator-application.c @@ -383,18 +383,9 @@ get_applications (DBusGProxy *proxy, GPtrArray *OUT_applications, GError *error, static void get_applications_helper (gpointer data, gpointer user_data) { -#if 0 - GType structype = dbus_g_type_get_struct("GValueArray", - G_TYPE_STRING, - G_TYPE_INT, - G_TYPE_STRING, - DBUS_TYPE_G_OBJECT_PATH, - G_TYPE_STRING, - G_TYPE_INVALID); -#endif GValueArray * array = (GValueArray *)data; - g_debug("Size: %d", array->n_values); + 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)); -- cgit v1.2.3