From fe7f3dcf1257a4cba7375439ae50c250abb39a56 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 14 Jan 2010 15:14:12 -0600 Subject: We should have kept ref's to these. --- src/indicator-application.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/indicator-application.c b/src/indicator-application.c index c330645..8e88f8e 100644 --- a/src/indicator-application.c +++ b/src/indicator-application.c @@ -303,6 +303,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); -- cgit v1.2.3 From abd499aaeb280ef2ab24f4e392484ecd4d8bb7a2 Mon Sep 17 00:00:00 2001 From: Cody Russell Date: Thu, 14 Jan 2010 20:27:28 -0600 Subject: Only add the Application if it doesn't already exist in the appstore. --- src/application-service-appstore.c | 12 ++++++++++-- src/libappindicator/app-indicator.c | 4 ++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index fa1b9d2..c896beb 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -333,8 +333,6 @@ apply_status (Application * app, ApplicationStatus status) g_signal_emit(G_OBJECT(appstore), signals[APPLICATION_REMOVED], 0, position, TRUE); - - priv->applications = g_list_remove(priv->applications, app); } else { /* Figure out which icon we should be using */ gchar * newicon = app->icon; @@ -511,6 +509,16 @@ application_service_appstore_application_add (ApplicationServiceAppstore * appst g_return_if_fail(dbus_object != NULL && dbus_object[0] != '\0'); ApplicationServiceAppstorePrivate * priv = APPLICATION_SERVICE_APPSTORE_GET_PRIVATE(appstore); + GList *l = NULL; + for (l = priv->applications; l != NULL; l = g_list_next (l)) { + Application *tmp_app = (Application *)l->data; + + if (g_strcmp0 (tmp_app->dbus_name, dbus_name) == 0 && + g_strcmp0 (tmp_app->dbus_object, dbus_object) == 0) { + return; + } + } + /* Build the application entry. This will be carried along until we're sure we've got everything. */ Application * app = g_new0(Application, 1); diff --git a/src/libappindicator/app-indicator.c b/src/libappindicator/app-indicator.c index 6c969c2..7fabef9 100644 --- a/src/libappindicator/app-indicator.c +++ b/src/libappindicator/app-indicator.c @@ -370,6 +370,10 @@ app_indicator_dispose (GObject *object) priv->menu = NULL; } + if (priv->menuservice != NULL) { + g_object_unref (priv->menuservice); + } + if (priv->dbus_proxy != NULL) { g_object_unref(G_OBJECT(priv->dbus_proxy)); priv->dbus_proxy = NULL; -- cgit v1.2.3 From 7a001c72db8fcbd518c132862ddc215bc215aac4 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 14 Jan 2010 23:22:46 -0600 Subject: Fleshing out returning the list of apps already there. --- src/application-service-appstore.c | 47 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index fa1b9d2..282eb51 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -31,7 +31,7 @@ with this program. If not, see . #include "dbus-shared.h" /* DBus Prototypes */ -static gboolean _application_service_server_get_applications (ApplicationServiceAppstore * appstore, GArray ** apps); +static gboolean _application_service_server_get_applications (ApplicationServiceAppstore * appstore, GPtrArray ** apps); #include "application-service-server.h" @@ -624,8 +624,51 @@ application_service_appstore_application_remove (ApplicationServiceAppstore * ap /* DBus Interface */ static gboolean -_application_service_server_get_applications (ApplicationServiceAppstore * appstore, GArray ** apps) +_application_service_server_get_applications (ApplicationServiceAppstore * appstore, GPtrArray ** apps) { + ApplicationServiceAppstorePrivate * priv = APPLICATION_SERVICE_APPSTORE_GET_PRIVATE(appstore); + + *apps = g_ptr_array_new(); + GList * listpntr; + gint position = 0; + + for (listpntr = priv->applications; listpntr != NULL; listpntr = g_list_next(listpntr)) { + GValueArray * values = g_value_array_new(0); + + GValue value = {0}; + + /* Icon name */ + g_value_init(&value, G_TYPE_STRING); + g_value_set_string(&value, ((Application *)listpntr->data)->icon); + g_value_array_append(values, &value); + g_value_unset(&value); + + /* Position */ + g_value_init(&value, G_TYPE_INT); + g_value_set_int(&value, position++); + g_value_array_append(values, &value); + g_value_unset(&value); + + /* DBus Address */ + g_value_init(&value, G_TYPE_STRING); + g_value_set_string(&value, ((Application *)listpntr->data)->dbus_name); + g_value_array_append(values, &value); + g_value_unset(&value); + + /* DBus Object */ + g_value_init(&value, G_TYPE_STRING); + g_value_set_string(&value, ((Application *)listpntr->data)->dbus_object); + g_value_array_append(values, &value); + g_value_unset(&value); + + /* Icon path */ + g_value_init(&value, G_TYPE_STRING); + g_value_set_string(&value, ((Application *)listpntr->data)->icon_path); + g_value_array_append(values, &value); + g_value_unset(&value); + + g_ptr_array_add(*apps, values); + } return FALSE; } -- cgit v1.2.3 From 321ae86c9366714e74ec70923e52facce29ca0b1 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 14 Jan 2010 23:25:34 -0600 Subject: Need icon path in the list as well. --- src/application-service.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/application-service.xml b/src/application-service.xml index d74aaa9..0b2e959 100644 --- a/src/application-service.xml +++ b/src/application-service.xml @@ -26,7 +26,7 @@ with this program. If not, see . - + -- cgit v1.2.3 From eddc0d0e435a16acacafe086475ef79cc3f599ae Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 14 Jan 2010 23:30:11 -0600 Subject: Returning truth. --- src/application-service-appstore.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 282eb51..d70e2f8 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -670,6 +670,6 @@ _application_service_server_get_applications (ApplicationServiceAppstore * appst g_ptr_array_add(*apps, values); } - return FALSE; + return TRUE; } -- cgit v1.2.3 From 00cad2ec8d5a143b3970dd63825cbd4b6265092a Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 15 Jan 2010 00:48:09 -0600 Subject: Better init value and adding error to prototype. --- src/application-service-appstore.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index d70e2f8..95f8dde 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -31,7 +31,7 @@ with this program. If not, see . #include "dbus-shared.h" /* DBus Prototypes */ -static gboolean _application_service_server_get_applications (ApplicationServiceAppstore * appstore, GPtrArray ** apps); +static gboolean _application_service_server_get_applications (ApplicationServiceAppstore * appstore, GPtrArray ** apps, GError ** error); #include "application-service-server.h" @@ -624,7 +624,7 @@ application_service_appstore_application_remove (ApplicationServiceAppstore * ap /* DBus Interface */ static gboolean -_application_service_server_get_applications (ApplicationServiceAppstore * appstore, GPtrArray ** apps) +_application_service_server_get_applications (ApplicationServiceAppstore * appstore, GPtrArray ** apps, GError ** error) { ApplicationServiceAppstorePrivate * priv = APPLICATION_SERVICE_APPSTORE_GET_PRIVATE(appstore); @@ -633,7 +633,7 @@ _application_service_server_get_applications (ApplicationServiceAppstore * appst gint position = 0; for (listpntr = priv->applications; listpntr != NULL; listpntr = g_list_next(listpntr)) { - GValueArray * values = g_value_array_new(0); + GValueArray * values = g_value_array_new(5); GValue value = {0}; -- cgit v1.2.3 From 8045abdf6b0390572dbeb1a224431ec4c3e3355e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 15 Jan 2010 01:01:11 -0600 Subject: Setting the proper type for the GValue of an 'o' --- src/application-service-appstore.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 95f8dde..df4213a 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -656,8 +656,8 @@ _application_service_server_get_applications (ApplicationServiceAppstore * appst g_value_unset(&value); /* DBus Object */ - g_value_init(&value, G_TYPE_STRING); - g_value_set_string(&value, ((Application *)listpntr->data)->dbus_object); + g_value_init(&value, DBUS_TYPE_G_OBJECT_PATH); + g_value_set_static_boxed(&value, ((Application *)listpntr->data)->dbus_object); g_value_array_append(values, &value); g_value_unset(&value); -- cgit v1.2.3 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(+) 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 36e7fd1e45ad3f3eb89c6a7ea0b9b92b754b3971 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 15 Jan 2010 08:56:49 -0600 Subject: releasing version 0.0.9-0ubuntu1~ppa2~applist1 --- debian/changelog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index 8c58286..8b0e033 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,9 +1,9 @@ -indicator-application (0.0.9-0ubuntu1~ppa2~applist1) UNRELEASED; urgency=low +indicator-application (0.0.9-0ubuntu1~ppa2~applist1) karmic; urgency=low * Upstream update * Support getting the app list from a running service. - -- Ted Gould Fri, 15 Jan 2010 08:53:46 -0600 + -- Ted Gould Fri, 15 Jan 2010 08:56:47 -0600 indicator-application (0.0.9-0ubuntu1~ppa1) karmic; urgency=low -- 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(-) 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 93f32fd90d78997bf9661ddeaa8bfbb2f3020ced Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 15 Jan 2010 10:05:21 -0600 Subject: Using the menu path instead of the item path. --- src/application-service-appstore.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index df4213a..bc99855 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -657,7 +657,7 @@ _application_service_server_get_applications (ApplicationServiceAppstore * appst /* DBus Object */ g_value_init(&value, DBUS_TYPE_G_OBJECT_PATH); - g_value_set_static_boxed(&value, ((Application *)listpntr->data)->dbus_object); + g_value_set_static_boxed(&value, ((Application *)listpntr->data)->menu); g_value_array_append(values, &value); g_value_unset(&value); -- cgit v1.2.3 From fd7d6e6bebe1233ecf2cfba9e8bd69bee6b1a133 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 15 Jan 2010 10:09:00 -0600 Subject: releasing version 0.0.9-0ubuntu1~ppa2~applist2 --- debian/changelog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index 7c3526a..4441648 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,10 +1,10 @@ -indicator-application (0.0.9-0ubuntu1~ppa2~applist2) UNRELEASED; urgency=low +indicator-application (0.0.9-0ubuntu1~ppa2~applist2) karmic; urgency=low * Upstream update * Simplify and correct the structure handling. * Pass the correct object path over the bus. We want the menu. - -- Ted Gould Fri, 15 Jan 2010 10:06:28 -0600 + -- Ted Gould Fri, 15 Jan 2010 10:08:58 -0600 indicator-application (0.0.9-0ubuntu1~ppa2~applist1) karmic; urgency=low -- 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(-) 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 From e9fafdfa046eda4da67357ebfc02f48159403f8d Mon Sep 17 00:00:00 2001 From: Cody Russell Date: Tue, 19 Jan 2010 11:28:33 -0600 Subject: Move the check for duplicates. --- src/application-service-appstore.c | 65 +++++++++++++++++++++++--------------- 1 file changed, 40 insertions(+), 25 deletions(-) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index c896beb..d0b5570 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -311,6 +311,28 @@ application_removed_cb (DBusGProxy * proxy, gpointer userdata) return; } +static gboolean +can_add_application (GList *applications, Application *app) +{ + if (applications) + { + GList *l = NULL; + + for (l = applications; l != NULL; l = g_list_next (l)) + { + Application *tmp_app = (Application *)l->data; + + if (g_strcmp0 (tmp_app->dbus_name, app->dbus_name) == 0 && + g_strcmp0 (tmp_app->dbus_object, app->dbus_object) == 0) + { + return FALSE; + } + } + } + + return TRUE; +} + /* Change the status of the application. If we're going passive it removes it from the panel. If we're coming online, then it add it to the panel. Otherwise it changes the icon. */ @@ -333,6 +355,7 @@ apply_status (Application * app, ApplicationStatus status) g_signal_emit(G_OBJECT(appstore), signals[APPLICATION_REMOVED], 0, position, TRUE); + priv->applications = g_list_remove(priv->applications, app); } else { /* Figure out which icon we should be using */ gchar * newicon = app->icon; @@ -342,21 +365,23 @@ apply_status (Application * app, ApplicationStatus status) /* Determine whether we're already shown or not */ if (app->status == APP_STATUS_PASSIVE) { - /* Put on panel */ - priv->applications = g_list_prepend(priv->applications, app); - - /* TODO: We need to have the position determined better. This - would involve looking at the name and category and sorting - it with the other entries. */ - - g_signal_emit(G_OBJECT(app->appstore), - signals[APPLICATION_ADDED], 0, - newicon, - 0, /* Position */ - app->dbus_name, - app->menu, - app->icon_path, - TRUE); + if (can_add_application (priv->applications, app)) { + /* Put on panel */ + priv->applications = g_list_prepend (priv->applications, app); + + /* TODO: We need to have the position determined better. This + would involve looking at the name and category and sorting + it with the other entries. */ + + g_signal_emit(G_OBJECT(app->appstore), + signals[APPLICATION_ADDED], 0, + newicon, + 0, /* Position */ + app->dbus_name, + app->menu, + app->icon_path, + TRUE); + } } else { /* Icon update */ gint position = get_position(app); @@ -509,16 +534,6 @@ application_service_appstore_application_add (ApplicationServiceAppstore * appst g_return_if_fail(dbus_object != NULL && dbus_object[0] != '\0'); ApplicationServiceAppstorePrivate * priv = APPLICATION_SERVICE_APPSTORE_GET_PRIVATE(appstore); - GList *l = NULL; - for (l = priv->applications; l != NULL; l = g_list_next (l)) { - Application *tmp_app = (Application *)l->data; - - if (g_strcmp0 (tmp_app->dbus_name, dbus_name) == 0 && - g_strcmp0 (tmp_app->dbus_object, dbus_object) == 0) { - return; - } - } - /* Build the application entry. This will be carried along until we're sure we've got everything. */ Application * app = g_new0(Application, 1); -- cgit v1.2.3