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 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