aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLars Uebernickel <lars.uebernickel@canonical.com>2012-05-31 19:29:27 +0200
committerLars Uebernickel <lars.uebernickel@canonical.com>2012-05-31 19:29:27 +0200
commiteea45a449eb4de159aab08bad864b27f584af519 (patch)
tree043341fc431d7e38d16cb3daacc5d400f44d6336 /src
parent4f2dd60a130dcaeb4378219baca1f3d4e9637824 (diff)
downloadayatana-indicator-messages-eea45a449eb4de159aab08bad864b27f584af519.tar.gz
ayatana-indicator-messages-eea45a449eb4de159aab08bad864b27f584af519.tar.bz2
ayatana-indicator-messages-eea45a449eb4de159aab08bad864b27f584af519.zip
Put the 'launch' action onto app's menu sections
This requires clients to make those menu sections clickable.
Diffstat (limited to 'src')
-rw-r--r--src/app-section.c33
-rw-r--r--src/app-section.h1
-rw-r--r--src/messages-service.c9
3 files changed, 27 insertions, 16 deletions
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;
+}
+
diff --git a/src/app-section.h b/src/app-section.h
index 7989824..e5c3892 100644
--- a/src/app-section.h
+++ b/src/app-section.h
@@ -51,6 +51,7 @@ const gchar * app_section_get_name (AppSection * appitem);
const gchar * app_section_get_desktop (AppSection * appitem);
GMenuModel * app_section_get_menu (AppSection *appitem);
GAppInfo * app_section_get_app_info (AppSection *appitem);
+GMenuItem * app_section_create_menu_item (AppSection *self);
G_END_DECLS
diff --git a/src/messages-service.c b/src/messages-service.c
index dcce1c5..ddedee9 100644
--- a/src/messages-service.c
+++ b/src/messages-service.c
@@ -64,13 +64,14 @@ add_application (const gchar *desktop_id,
if (!g_hash_table_lookup (applications, desktop_file)) {
AppSection *section = app_section_new(appinfo);
+ GMenuItem *item = app_section_create_menu_item (section);
+
+ g_hash_table_insert (applications, g_strdup (desktop_file), section);
/* TODO insert it at the right position (alphabetically by application name) */
- g_menu_insert_section (menu, 2,
- app_section_get_name (section),
- app_section_get_menu (section));
+ g_menu_insert_item (menu, 2, item);
- g_hash_table_insert (applications, g_strdup (desktop_file), section);
+ g_object_unref (item);
}
g_object_unref (appinfo);