aboutsummaryrefslogtreecommitdiff
path: root/libmessaging-menu
diff options
context:
space:
mode:
authorLars Uebernickel <lars.uebernickel@canonical.com>2012-08-23 16:31:30 +0200
committerLars Uebernickel <lars.uebernickel@canonical.com>2012-08-23 16:31:30 +0200
commit423d61b377588e67cb570480828f752925371f85 (patch)
treec3c124a4a09d91232d121c1df5592daa8bc3c0ce /libmessaging-menu
parent802b10555a5d2fe6bdbbe34cba873cf9dd60050e (diff)
downloadayatana-indicator-messages-423d61b377588e67cb570480828f752925371f85.tar.gz
ayatana-indicator-messages-423d61b377588e67cb570480828f752925371f85.tar.bz2
ayatana-indicator-messages-423d61b377588e67cb570480828f752925371f85.zip
libmessaging-menu: re-register with the service if it restarted
Diffstat (limited to 'libmessaging-menu')
-rw-r--r--libmessaging-menu/messaging-menu.c42
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);
}
/**