aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2010-08-18 14:26:10 -0500
committerTed Gould <ted@gould.cx>2010-08-18 14:26:10 -0500
commit1865cf3b4e415dcb8b9cf85208ab88596d00b043 (patch)
treecf60c70056537cca2e1de9a06b674d87e49d0b0c
parentca213633c7a98b7d9dd37a5a373f7ef825098eeb (diff)
downloadlibayatana-appindicator-1865cf3b4e415dcb8b9cf85208ab88596d00b043.tar.gz
libayatana-appindicator-1865cf3b4e415dcb8b9cf85208ab88596d00b043.tar.bz2
libayatana-appindicator-1865cf3b4e415dcb8b9cf85208ab88596d00b043.zip
Refactor so that there is a function to look for applications.
-rw-r--r--src/application-service-appstore.c33
1 files changed, 23 insertions, 10 deletions
diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c
index 789ca48..7040b2a 100644
--- a/src/application-service-appstore.c
+++ b/src/application-service-appstore.c
@@ -959,6 +959,24 @@ application_service_appstore_application_add (ApplicationServiceAppstore * appst
return;
}
+/* Looks for an application in the list of applications */
+static Application *
+find_application (ApplicationServiceAppstore * appstore, const gchar * address, const gchar * object)
+{
+ ApplicationServiceAppstorePrivate * priv = appstore->priv;
+ GList * listpntr;
+
+ for (listpntr = priv->applications; listpntr != NULL; listpntr = g_list_next(listpntr)) {
+ Application * app = (Application *)listpntr->data;
+
+ if (!g_strcmp0(app->dbus_name, address) && !g_strcmp0(app->dbus_object, object)) {
+ return app;
+ }
+ }
+
+ return NULL;
+}
+
/* Removes an application. Currently only works for the apps
that are shown. */
void
@@ -968,16 +986,11 @@ 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 = appstore->priv;
- 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 */
- }
+ Application * app = find_application(appstore, dbus_name, dbus_object);
+ if (app != NULL) {
+ application_removed_cb(NULL, app);
+ } else {
+ g_warning("Unable to find application %s:%s", dbus_name, dbus_object);
}
return;