diff options
author | Ted Gould <ted@gould.cx> | 2010-01-12 21:12:46 -0600 |
---|---|---|
committer | Ted Gould <ted@gould.cx> | 2010-01-12 21:12:46 -0600 |
commit | 7e0feb2329d04007a4b98104f1d76a5e6d4384b4 (patch) | |
tree | 7b127e5fb4ea63b657d68ac0a6c3dfcac982f6a5 /src/libappindicator | |
parent | f55bf250c331a4384f00ada67df4ff525b8c4ffe (diff) | |
download | ayatana-indicator-application-7e0feb2329d04007a4b98104f1d76a5e6d4384b4.tar.gz ayatana-indicator-application-7e0feb2329d04007a4b98104f1d76a5e6d4384b4.tar.bz2 ayatana-indicator-application-7e0feb2329d04007a4b98104f1d76a5e6d4384b4.zip |
Setting up a dbus proxy and starting to look at owner change events on it when we don't have a NotificationWatcher to look at.
Diffstat (limited to 'src/libappindicator')
-rw-r--r-- | src/libappindicator/app-indicator.c | 53 |
1 files changed, 52 insertions, 1 deletions
diff --git a/src/libappindicator/app-indicator.c b/src/libappindicator/app-indicator.c index c1b9bf8..4018083 100644 --- a/src/libappindicator/app-indicator.c +++ b/src/libappindicator/app-indicator.c @@ -73,6 +73,7 @@ struct _AppIndicatorPrivate { /* Fun stuff */ DBusGProxy *watcher_proxy; DBusGConnection *connection; + DBusGProxy * dbus_proxy; }; /* Signals Stuff */ @@ -312,6 +313,7 @@ app_indicator_init (AppIndicator *self) priv->watcher_proxy = NULL; priv->connection = NULL; + priv->dbus_proxy = NULL; priv->status_icon = NULL; priv->fallback_timer = 0; @@ -364,6 +366,11 @@ app_indicator_dispose (GObject *object) priv->menu = NULL; } + if (priv->dbus_proxy != NULL) { + g_object_unref(G_OBJECT(priv->dbus_proxy)); + priv->dbus_proxy = NULL; + } + if (priv->watcher_proxy != NULL) { dbus_g_connection_flush(priv->connection); g_object_unref(G_OBJECT(priv->watcher_proxy)); @@ -612,6 +619,40 @@ category_from_enum (AppIndicatorCategory category) return value->value_nick; } +/* Watching the dbus owner change events to see if someone + we care about pops up! */ +static void +dbus_owner_change (DBusGProxy * proxy, const gchar * name, const gchar * prev, const gchar * new, gpointer data) +{ + if (new == NULL || new[0] == '\0') { + /* We only care about folks coming on the bus. Exit quickly otherwise. */ + return; + } + + if (g_strcmp0(name, NOTIFICATION_WATCHER_DBUS_ADDR)) { + /* We only care about this address, reject all others. */ + return; + } + + /* Woot, there's a new notification watcher in town. */ + + AppIndicatorPrivate * priv = APP_INDICATOR_GET_PRIVATE(data); + + if (priv->fallback_timer != 0) { + /* Stop a timer */ + g_source_remove(priv->fallback_timer); + + /* Stop listening to bus events */ + g_object_unref(G_OBJECT(priv->dbus_proxy)); + priv->dbus_proxy = NULL; + } + + /* Let's start from the very beginning */ + check_connect(APP_INDICATOR(data)); + + return; +} + /* A function that will start the fallback timer if it's not already started. It sets up the DBus watcher to see if there is a change. Also, provides an override mode for cases @@ -627,7 +668,17 @@ start_fallback_timer (AppIndicator * self, gboolean do_it_now) return; } - /* TODO: Setup what we need to check things out */ + if (priv->dbus_proxy == NULL) { + priv->dbus_proxy = dbus_g_proxy_new_for_name(priv->connection, + DBUS_SERVICE_DBUS, + DBUS_PATH_DBUS, + DBUS_INTERFACE_DBUS); + dbus_g_proxy_add_signal(priv->dbus_proxy, "NameOwnerChanged", + G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, + G_TYPE_INVALID); + dbus_g_proxy_connect_signal(priv->dbus_proxy, "NameOwnerChanged", + G_CALLBACK(dbus_owner_change), self, NULL); + } if (do_it_now) { fallback_timer_expire(self); |