aboutsummaryrefslogtreecommitdiff
path: root/src/messages-service.c
diff options
context:
space:
mode:
authorLars Uebernickel <lars.uebernickel@canonical.com>2012-09-06 10:53:54 +0200
committerLars Uebernickel <lars.uebernickel@canonical.com>2012-09-06 10:53:54 +0200
commit10d194fc1b4630a43317d9ecc919c62c4f95d48c (patch)
treed34e6466a99cb7c0365ff39be1661aab25d662e3 /src/messages-service.c
parent2e17120b6eefea4710e5a1abf859825f507014bb (diff)
parentbdf943c3c2d9aef1511d24e928e9d8652a17e703 (diff)
downloadayatana-indicator-messages-10d194fc1b4630a43317d9ecc919c62c4f95d48c.tar.gz
ayatana-indicator-messages-10d194fc1b4630a43317d9ecc919c62c4f95d48c.tar.bz2
ayatana-indicator-messages-10d194fc1b4630a43317d9ecc919c62c4f95d48c.zip
Merge lp:~larsu/indicator-messages/watch-desktop-files
Diffstat (limited to 'src/messages-service.c')
-rw-r--r--src/messages-service.c32
1 files changed, 23 insertions, 9 deletions
diff --git a/src/messages-service.c b/src/messages-service.c
index d016ff1..437f046 100644
--- a/src/messages-service.c
+++ b/src/messages-service.c
@@ -45,7 +45,6 @@ static GMenu *menu;
static GMenuModel *chat_section;
static GSettings *settings;
-
static gchar *
g_app_info_get_simple_id (GAppInfo *appinfo)
{
@@ -138,6 +137,23 @@ uses_chat_status_changed (GObject *object,
g_object_unref (first_section);
}
+static void
+remove_section (AppSection *section,
+ const gchar *id)
+{
+ int pos = g_menu_find_section (menu, app_section_get_menu (section));
+ if (pos >= 0)
+ g_menu_remove (menu, pos);
+ g_action_muxer_remove (action_muxer, id);
+
+ g_signal_handlers_disconnect_by_func (section, actions_changed, NULL);
+ g_signal_handlers_disconnect_by_func (section, draws_attention_changed, NULL);
+ g_signal_handlers_disconnect_by_func (section, uses_chat_status_changed, NULL);
+ g_signal_handlers_disconnect_by_func (section, remove_section, NULL);
+
+ g_hash_table_remove (applications, id);
+}
+
static AppSection *
add_application (const gchar *desktop_id)
{
@@ -167,6 +183,11 @@ add_application (const gchar *desktop_id)
G_CALLBACK (draws_attention_changed), NULL);
g_signal_connect (section, "notify::uses-chat-status",
G_CALLBACK (uses_chat_status_changed), NULL);
+ g_signal_connect_data (section, "destroy",
+ G_CALLBACK (remove_section),
+ g_strdup (id),
+ (GClosureNotify) g_free,
+ 0);
/* TODO insert it at the right position (alphabetically by application name) */
menuitem = g_menu_item_new_section (NULL, app_section_get_menu (section));
@@ -216,14 +237,7 @@ remove_application (const char *desktop_id)
section = g_hash_table_lookup (applications, id);
if (section) {
- int pos = g_menu_find_section (menu, app_section_get_menu (section));
- if (pos >= 0)
- g_menu_remove (menu, pos);
- g_action_muxer_remove (action_muxer, id);
-
- g_signal_handlers_disconnect_by_func (section, actions_changed, NULL);
- g_signal_handlers_disconnect_by_func (section, draws_attention_changed, NULL);
- g_signal_handlers_disconnect_by_func (section, uses_chat_status_changed, NULL);
+ remove_section (section, id);
}
else {
g_warning ("could not remove '%s', it's not registered", desktop_id);