Merge lp:~larsu/libindicator/support-submenu-action into lp:libindicator/14.04

Proposed by Lars Karlitski
Status: Merged
Approved by: Charles Kerr
Approved revision: 522
Merged at revision: 522
Proposed branch: lp:~larsu/libindicator/support-submenu-action
Merge into: lp:libindicator/14.04
Diff against target: 72 lines (+34/-0)
1 file modified
libindicator/indicator-ng.c (+34/-0)
To merge this branch: bzr merge lp:~larsu/libindicator/support-submenu-action
Reviewer Review Type Date Requested Status
Charles Kerr (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+203735@code.launchpad.net

Commit message

indicator-ng: support "submenu-action" on root menu items

Description of the change

indicator-ng: support "submenu-action" on root menu items

Treat "submenu-action" attributes on the root menu item in the same way that gtk+ does. If that attribute exists, it must reference an action with boolean state that is set to 'true' whenever a corresponding indicator menu is open.

We need this for root items because they are not handled by gtk's menu tracker. Nested submenus already get this.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Charles Kerr (charlesk) wrote :

Nice work!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libindicator/indicator-ng.c'
2--- libindicator/indicator-ng.c 2013-12-20 11:30:44 +0000
3+++ libindicator/indicator-ng.c 2014-01-29 13:30:47 +0000
4@@ -35,6 +35,7 @@
5 gchar *header_action;
6 gchar *scroll_action;
7 gchar *secondary_action;
8+ gchar *submenu_action;
9 gint position;
10
11 guint name_watch_id;
12@@ -162,6 +163,7 @@
13 g_free (self->header_action);
14 g_free (self->scroll_action);
15 g_free (self->secondary_action);
16+ g_free (self->submenu_action);
17
18 G_OBJECT_CLASS (indicator_ng_parent_class)->finalize (object);
19 }
20@@ -214,6 +216,28 @@
21 }
22
23 static void
24+indicator_ng_menu_shown (GtkWidget *widget,
25+ gpointer user_data)
26+{
27+ IndicatorNg *self = user_data;
28+
29+ if (self->submenu_action)
30+ g_action_group_change_action_state (self->actions, self->submenu_action,
31+ g_variant_new_boolean (TRUE));
32+}
33+
34+static void
35+indicator_ng_menu_hidden (GtkWidget *widget,
36+ gpointer user_data)
37+{
38+ IndicatorNg *self = user_data;
39+
40+ if (self->submenu_action)
41+ g_action_group_change_action_state (self->actions, self->submenu_action,
42+ g_variant_new_boolean (FALSE));
43+}
44+
45+static void
46 indicator_ng_set_accessible_desc (IndicatorNg *self,
47 const gchar *accessible_desc)
48 {
49@@ -390,6 +414,13 @@
50 g_free (action);
51 }
52
53+ if (g_menu_model_get_item_attribute (self->menu, 0, "submenu-action", "s", &action))
54+ {
55+ if (g_str_has_prefix (action, "indicator."))
56+ self->submenu_action = g_strdup (action + strlen ("indicator."));
57+ g_free (action);
58+ }
59+
60 popup = g_menu_model_get_item_link (self->menu, 0, G_MENU_LINK_SUBMENU);
61 if (popup)
62 {
63@@ -657,6 +688,9 @@
64
65 self->entry.menu = g_object_ref_sink (gtk_menu_new ());
66
67+ g_signal_connect (self->entry.menu, "show", G_CALLBACK (indicator_ng_menu_shown), self);
68+ g_signal_connect (self->entry.menu, "hide", G_CALLBACK (indicator_ng_menu_hidden), self);
69+
70 /* work around IndicatorObject's warning that the accessible
71 * description is missing. We never set it on construction, but when
72 * the menu model has arrived on the bus.

Subscribers

People subscribed via source and target branches