aboutsummaryrefslogtreecommitdiff
path: root/libindicator/indicator-service.c
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2009-12-01 10:11:50 -0600
committerTed Gould <ted@gould.cx>2009-12-01 10:11:50 -0600
commitc0e2510ba29adc62b7816995031d46f8655d208a (patch)
treef9fec5850173fa6cdb213b68e81cf8c5b37e0b7b /libindicator/indicator-service.c
parent8a1912e7b9f8a7a0351ef252359ae04ff9fc4402 (diff)
downloadlibayatana-indicator-c0e2510ba29adc62b7816995031d46f8655d208a.tar.gz
libayatana-indicator-c0e2510ba29adc62b7816995031d46f8655d208a.tar.bz2
libayatana-indicator-c0e2510ba29adc62b7816995031d46f8655d208a.zip
Finding the watcher and removing him from the list.
Diffstat (limited to 'libindicator/indicator-service.c')
-rw-r--r--libindicator/indicator-service.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/libindicator/indicator-service.c b/libindicator/indicator-service.c
index dda00a9..c6ef077 100644
--- a/libindicator/indicator-service.c
+++ b/libindicator/indicator-service.c
@@ -310,6 +310,12 @@ _indicator_service_server_watch (IndicatorService * service, DBusGMethodInvocati
return TRUE;
}
+static gint
+find_watcher (gconstpointer a, gconstpointer b)
+{
+ return g_strcmp0((const gchar *)a, (const gchar *)b);
+}
+
static gboolean
_indicator_service_server_un_watch (IndicatorService * service, DBusGMethodInvocation * method)
{
@@ -317,7 +323,16 @@ _indicator_service_server_un_watch (IndicatorService * service, DBusGMethodInvoc
IndicatorServicePrivate * priv = INDICATOR_SERVICE_GET_PRIVATE(service);
/* Remove us from the watcher list here */
-
+ GList * watcher_item = g_list_find_custom(priv->watchers, dbus_g_method_get_sender(method), find_watcher);
+ if (watcher_item != NULL) {
+ /* Free the watcher */
+ gchar * name = watcher_item->data;
+ priv->watchers = g_list_remove(priv->watchers, name);
+ g_free(name);
+ } else {
+ /* Odd that we couldn't find the person, but, eh */
+ g_warning("Unable to find watcher who is unwatching: %s", dbus_g_method_get_sender(method));
+ }
/* If we're out of watchers set the timeout for shutdown */
if (priv->watchers == NULL) {
@@ -328,6 +343,7 @@ _indicator_service_server_un_watch (IndicatorService * service, DBusGMethodInvoc
g_source_remove(priv->timeout);
priv->timeout = 0;
}
+ /* If we don't get a new watcher quickly, we'll shutdown. */
priv->timeout = g_timeout_add(500, timeout_no_watchers, service);
}