diff options
author | Sebastien Bacher <seb128@ubuntu.com> | 2012-08-24 11:56:54 +0200 |
---|---|---|
committer | Sebastien Bacher <seb128@ubuntu.com> | 2012-08-24 11:56:54 +0200 |
commit | 1e2a94c141361b6b2269cb030a72bee068442942 (patch) | |
tree | 4d87ab627fc64d022df4720fe4edd4c7b5c4a521 /libmessaging-menu | |
parent | f070076dd2d20dc90bdd9507acd751ec83070ae2 (diff) | |
parent | 423d61b377588e67cb570480828f752925371f85 (diff) | |
download | ayatana-indicator-messages-1e2a94c141361b6b2269cb030a72bee068442942.tar.gz ayatana-indicator-messages-1e2a94c141361b6b2269cb030a72bee068442942.tar.bz2 ayatana-indicator-messages-1e2a94c141361b6b2269cb030a72bee068442942.zip |
Backported fixes from trunk up to r286, some of those are needed for the
Diffstat (limited to 'libmessaging-menu')
-rw-r--r-- | libmessaging-menu/messaging-menu.c | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/libmessaging-menu/messaging-menu.c b/libmessaging-menu/messaging-menu.c index 69fb3b7..387412e 100644 --- a/libmessaging-menu/messaging-menu.c +++ b/libmessaging-menu/messaging-menu.c @@ -39,6 +39,7 @@ struct _MessagingMenuApp GMenu *menu; IndicatorMessagesService *messages_service; + guint watch_id; GCancellable *cancellable; }; @@ -119,6 +120,12 @@ messaging_menu_app_dispose (GObject *object) { MessagingMenuApp *app = MESSAGING_MENU_APP (object); + if (app->watch_id > 0) + { + g_bus_unwatch_name (app->watch_id); + app->watch_id = 0; + } + if (app->cancellable) { g_cancellable_cancel (app->cancellable); @@ -243,6 +250,17 @@ got_session_bus (GObject *source, g_error_free (error); } + g_object_unref (bus); +} + +static void +indicator_messages_appeared (GDBusConnection *bus, + const gchar *name, + const gchar *name_owner, + gpointer user_data) +{ + MessagingMenuApp *app = user_data; + indicator_messages_service_proxy_new (bus, G_DBUS_PROXY_FLAGS_NONE, "com.canonical.indicator.messages", @@ -250,8 +268,22 @@ got_session_bus (GObject *source, app->cancellable, created_messages_service, app); +} - g_object_unref (bus); +static void +indicator_messages_vanished (GDBusConnection *bus, + const gchar *name, + gpointer user_data) +{ + MessagingMenuApp *app = user_data; + + if (app->messages_service) + { + g_signal_handlers_disconnect_by_func (app->messages_service, + global_status_changed, + app); + g_clear_object (&app->messages_service); + } } static void @@ -272,6 +304,14 @@ messaging_menu_app_init (MessagingMenuApp *app) app->cancellable, got_session_bus, app); + + app->watch_id = g_bus_watch_name (G_BUS_TYPE_SESSION, + "com.canonical.indicator.messages", + G_BUS_NAME_WATCHER_FLAGS_NONE, + indicator_messages_appeared, + indicator_messages_vanished, + app, + NULL); } /** |