From eea45a449eb4de159aab08bad864b27f584af519 Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Thu, 31 May 2012 19:29:27 +0200 Subject: Put the 'launch' action onto app's menu sections This requires clients to make those menu sections clickable. --- src/app-section.c | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) (limited to 'src/app-section.c') diff --git a/src/app-section.c b/src/app-section.c index 5a5e838..5cb2c25 100644 --- a/src/app-section.c +++ b/src/app-section.c @@ -192,9 +192,6 @@ app_section_set_app_info (AppSection *self, { AppSectionPrivate *priv = APP_SECTION_GET_PRIVATE (self); GSimpleAction *launch; - GMenuItem *menuitem; - GIcon *icon; - gchar *iconstr = NULL; gchar *label; g_return_if_fail (priv->appinfo == NULL); @@ -206,9 +203,6 @@ app_section_set_app_info (AppSection *self, priv->appinfo = g_object_ref (appinfo); - icon = g_app_info_get_icon (G_APP_INFO(priv->appinfo)); - iconstr = g_icon_to_string (icon); - launch = g_simple_action_new ("launch", NULL); g_signal_connect (launch, "activate", G_CALLBACK (activate_cb), self); g_simple_action_group_insert (priv->static_shortcuts, G_ACTION (launch)); @@ -218,10 +212,6 @@ app_section_set_app_info (AppSection *self, else label = g_strdup(app_section_get_name (self)); - menuitem = g_menu_item_new (label, "launch"); - g_menu_item_set_attribute (menuitem, INDICATOR_MENU_ATTRIBUTE_ICON_NAME, "s", iconstr); - g_menu_append_item (priv->menu, menuitem); - /* Start to build static shortcuts */ priv->ids = indicator_desktop_shortcuts_new(g_desktop_app_info_get_filename (priv->appinfo), "Messaging Menu"); const gchar ** nicks = indicator_desktop_shortcuts_get_nicks(priv->ids); @@ -245,9 +235,7 @@ app_section_set_app_info (AppSection *self, } g_free(label); - g_free(iconstr); g_object_unref (launch); - g_object_unref (menuitem); } AppSection * @@ -319,3 +307,24 @@ app_section_get_app_info (AppSection *self) return G_APP_INFO (priv->appinfo); } +GMenuItem * +app_section_create_menu_item (AppSection *self) +{ + AppSectionPrivate *priv = APP_SECTION_GET_PRIVATE (self); + GMenuItem *item; + const gchar *name; + gchar *iconstr; + + g_return_val_if_fail (priv->appinfo != NULL, NULL); + + name = g_app_info_get_name (G_APP_INFO (priv->appinfo)); + iconstr = g_icon_to_string (g_app_info_get_icon (G_APP_INFO (priv->appinfo))); + + item = g_menu_item_new (name, "launch"); + g_menu_item_set_attribute (item, INDICATOR_MENU_ATTRIBUTE_ICON_NAME, "s", iconstr); + g_menu_item_set_section (item, G_MENU_MODEL (priv->menu)); + + g_free(iconstr); + return item; +} + -- cgit v1.2.3