diff options
author | Lars Uebernickel <lars.uebernickel@canonical.com> | 2012-11-21 00:02:12 +0100 |
---|---|---|
committer | Lars Uebernickel <lars.uebernickel@canonical.com> | 2012-11-21 00:02:12 +0100 |
commit | d22b49e5fee5ae352ec6050e63181850a857fb3a (patch) | |
tree | f64a82b8233d0fcc18cdfd3c918b361f22ebd14f /src/im-phone-menu.c | |
parent | 15f2eef7082f9a68b1511f0868cdd60558b3a4f6 (diff) | |
download | ayatana-indicator-messages-d22b49e5fee5ae352ec6050e63181850a857fb3a.tar.gz ayatana-indicator-messages-d22b49e5fee5ae352ec6050e63181850a857fb3a.tar.bz2 ayatana-indicator-messages-d22b49e5fee5ae352ec6050e63181850a857fb3a.zip |
Remove applications from the menu when the disappear from the bus
Diffstat (limited to 'src/im-phone-menu.c')
-rw-r--r-- | src/im-phone-menu.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/im-phone-menu.c b/src/im-phone-menu.c index abb3a11..43b7a6c 100644 --- a/src/im-phone-menu.c +++ b/src/im-phone-menu.c @@ -214,3 +214,46 @@ im_phone_menu_remove_source (ImPhoneMenu *menu, g_free (action_name); } + +static void +im_phone_menu_remove_all_for_app (GMenu *menu, + GDesktopAppInfo *app) +{ + gchar *prefix; + gint n_items; + gint i = 0; + + prefix = g_strconcat (g_app_info_get_id (G_APP_INFO (app)), ".", NULL); + + n_items = g_menu_model_get_n_items (G_MENU_MODEL (menu)); + while (i < n_items) + { + gchar *action; + + g_menu_model_get_item_attribute (G_MENU_MODEL (menu), i, G_MENU_ATTRIBUTE_ACTION, "s", &action); + if (g_str_has_prefix (action, prefix)) + { + g_menu_remove (menu, i); + n_items--; + } + else + { + i++; + } + + g_free (action); + } + + g_free (prefix); +} + +void +im_phone_menu_remove_application (ImPhoneMenu *menu, + GDesktopAppInfo *app) +{ + g_return_if_fail (IM_IS_PHONE_MENU (menu)); + g_return_if_fail (G_IS_DESKTOP_APP_INFO (app)); + + im_phone_menu_remove_all_for_app (menu->source_section, app); + im_phone_menu_remove_all_for_app (menu->message_section, app); +} |