From ad42e1044d1bc653a3df8ce76e6e74d79ea890cc Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 8 Jan 2010 11:53:21 -0600 Subject: Fleshing out some of the remove function. For some reason the appstore is getting disposed, but that's the next thing to look at. --- src/application-service-appstore.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index ae9876e..3215b49 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -585,6 +585,8 @@ application_service_appstore_application_add (ApplicationServiceAppstore * appst return; } +/* Removes an application. Currently only works for the apps + that are shown. /TODO Need to fix that. */ void application_service_appstore_application_remove (ApplicationServiceAppstore * appstore, const gchar * dbus_name, const gchar * dbus_object) { @@ -592,6 +594,17 @@ application_service_appstore_application_remove (ApplicationServiceAppstore * ap g_return_if_fail(dbus_name != NULL && dbus_name[0] != '\0'); g_return_if_fail(dbus_object != NULL && dbus_object[0] != '\0'); + ApplicationServiceAppstorePrivate * priv = APPLICATION_SERVICE_APPSTORE_GET_PRIVATE(appstore); + GList * listpntr; + + for (listpntr = priv->applications; listpntr != NULL; listpntr = g_list_next(listpntr)) { + Application * app = (Application *)listpntr->data; + + if (!g_strcmp0(app->dbus_name, dbus_name) && !g_strcmp0(app->dbus_object, dbus_object)) { + application_removed_cb(NULL, app); + break; /* NOTE: Must break as the list will become inconsistent */ + } + } return; } -- cgit v1.2.3 From 12aab9617cef451183373e16b70a7a168aa82114 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 8 Jan 2010 12:34:43 -0600 Subject: When destroying the application free all the proxies. --- src/application-service-appstore.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 3215b49..de8d914 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -78,6 +78,7 @@ struct _Application { gchar * aicon; gchar * menu; gchar * icon_path; + gboolean currently_free; }; #define APPLICATION_SERVICE_APPSTORE_GET_PRIVATE(o) \ @@ -261,6 +262,18 @@ static void application_free (Application * app) { if (app == NULL) return; + + /* Handle the case where this could be called by unref'ing one of + the proxy objects. */ + if (app->currently_free) return; + app->currently_free = TRUE; + + if (app->dbus_proxy) { + g_object_unref(app->dbus_proxy); + } + if (app->prop_proxy) { + g_object_unref(app->prop_proxy); + } if (app->dbus_name != NULL) { g_free(app->dbus_name); @@ -512,6 +525,7 @@ application_service_appstore_application_add (ApplicationServiceAppstore * appst app->aicon = NULL; app->menu = NULL; app->icon_path = NULL; + app->currently_free = FALSE; /* Get the DBus proxy for the NotificationItem interface */ GError * error = NULL; -- cgit v1.2.3 From 7970210755bb4523c02b122c8a5eaa0d4e83bde7 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 8 Jan 2010 13:19:52 -0600 Subject: Fixing shutdown signal, but disabling for now --- src/application-service.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/application-service.c b/src/application-service.c index 45295a1..d21154f 100644 --- a/src/application-service.c +++ b/src/application-service.c @@ -43,7 +43,7 @@ service_disconnected (IndicatorService * service, gpointer data) { g_debug("Service disconnected"); if (mainloop != NULL) { - g_main_loop_quit(mainloop); + //g_main_loop_quit(mainloop); } return; } @@ -57,7 +57,7 @@ main (int argc, char ** argv) /* Bring us up as a basic indicator service */ service = indicator_service_new(INDICATOR_APPLICATION_DBUS_ADDR); - g_signal_connect(G_OBJECT(service), "disconnected", G_CALLBACK(service_disconnected), NULL); + g_signal_connect(G_OBJECT(service), INDICATOR_SERVICE_SIGNAL_SHUTDOWN, G_CALLBACK(service_disconnected), NULL); /* Building our app store */ appstore = APPLICATION_SERVICE_APPSTORE(g_object_new(APPLICATION_SERVICE_APPSTORE_TYPE, NULL)); -- cgit v1.2.3 From f8e9a51b9aeeadc89c7e60abca531ab076cacca5 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 8 Jan 2010 13:20:06 -0600 Subject: Debug message cleanup. --- src/application-service-appstore.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index de8d914..4772e49 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -136,7 +136,6 @@ application_service_appstore_class_init (ApplicationServiceAppstoreClass *klass) _application_service_marshal_VOID__INT_STRING, G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_STRING, G_TYPE_NONE); - dbus_g_object_type_install_info(APPLICATION_SERVICE_APPSTORE_TYPE, &dbus_glib__application_service_server_object_info); @@ -249,7 +248,6 @@ get_position (Application * app) { GList * applistitem = g_list_find(priv->applications, app); if (applistitem == NULL) { - g_warning("Change the icon of an application that isn't in the application list?"); return -1; } @@ -322,6 +320,7 @@ apply_status (Application * app, ApplicationStatus status) if (app->status == status) { return; } + g_debug("Changing app status to: %d", status); ApplicationServiceAppstore * appstore = app->appstore; ApplicationServiceAppstorePrivate * priv = APPLICATION_SERVICE_APPSTORE_GET_PRIVATE(appstore); -- cgit v1.2.3 From 5f797d71ef38ddb421e9b26757df8d3e87b84bce Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 8 Jan 2010 14:10:45 -0600 Subject: Putting the signal on the Class instead of the Instance. --- src/application-service-appstore.c | 6 +++--- src/application-service-appstore.h | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 4772e49..fa1b9d2 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -117,21 +117,21 @@ application_service_appstore_class_init (ApplicationServiceAppstoreClass *klass) signals[APPLICATION_ADDED] = g_signal_new ("application-added", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (ApplicationServiceAppstore, application_added), + G_STRUCT_OFFSET (ApplicationServiceAppstoreClass, application_added), NULL, NULL, _application_service_marshal_VOID__STRING_INT_STRING_STRING_STRING, G_TYPE_NONE, 5, G_TYPE_STRING, G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_NONE); signals[APPLICATION_REMOVED] = g_signal_new ("application-removed", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (ApplicationServiceAppstore, application_removed), + G_STRUCT_OFFSET (ApplicationServiceAppstoreClass, application_removed), NULL, NULL, g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT, G_TYPE_NONE); signals[APPLICATION_ICON_CHANGED] = g_signal_new ("application-icon-changed", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (ApplicationServiceAppstore, application_icon_changed), + G_STRUCT_OFFSET (ApplicationServiceAppstoreClass, application_icon_changed), NULL, NULL, _application_service_marshal_VOID__INT_STRING, G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_STRING, G_TYPE_NONE); diff --git a/src/application-service-appstore.h b/src/application-service-appstore.h index 7ab20c5..6bd7a01 100644 --- a/src/application-service-appstore.h +++ b/src/application-service-appstore.h @@ -40,16 +40,16 @@ typedef struct _ApplicationServiceAppstoreClass ApplicationServiceAppstoreClass; struct _ApplicationServiceAppstoreClass { GObjectClass parent_class; -}; - -struct _ApplicationServiceAppstore { - GObject parent; void (*application_added) (ApplicationServiceAppstore * appstore, gchar *, gint, gchar *, gchar *, gpointer); void (*application_removed) (ApplicationServiceAppstore * appstore, gint, gpointer); void (*application_icon_changed)(ApplicationServiceAppstore * appstore, gint, const gchar *, gpointer); }; +struct _ApplicationServiceAppstore { + GObject parent; +}; + GType application_service_appstore_get_type (void); void application_service_appstore_application_add (ApplicationServiceAppstore * appstore, const gchar * dbus_name, -- cgit v1.2.3