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
=== modified file 'libindicator/indicator-ng.c'
--- libindicator/indicator-ng.c 2013-12-20 11:30:44 +0000
+++ libindicator/indicator-ng.c 2014-01-29 13:30:47 +0000
@@ -35,6 +35,7 @@
35 gchar *header_action;35 gchar *header_action;
36 gchar *scroll_action;36 gchar *scroll_action;
37 gchar *secondary_action;37 gchar *secondary_action;
38 gchar *submenu_action;
38 gint position;39 gint position;
3940
40 guint name_watch_id;41 guint name_watch_id;
@@ -162,6 +163,7 @@
162 g_free (self->header_action);163 g_free (self->header_action);
163 g_free (self->scroll_action);164 g_free (self->scroll_action);
164 g_free (self->secondary_action);165 g_free (self->secondary_action);
166 g_free (self->submenu_action);
165167
166 G_OBJECT_CLASS (indicator_ng_parent_class)->finalize (object);168 G_OBJECT_CLASS (indicator_ng_parent_class)->finalize (object);
167}169}
@@ -214,6 +216,28 @@
214}216}
215217
216static void218static void
219indicator_ng_menu_shown (GtkWidget *widget,
220 gpointer user_data)
221{
222 IndicatorNg *self = user_data;
223
224 if (self->submenu_action)
225 g_action_group_change_action_state (self->actions, self->submenu_action,
226 g_variant_new_boolean (TRUE));
227}
228
229static void
230indicator_ng_menu_hidden (GtkWidget *widget,
231 gpointer user_data)
232{
233 IndicatorNg *self = user_data;
234
235 if (self->submenu_action)
236 g_action_group_change_action_state (self->actions, self->submenu_action,
237 g_variant_new_boolean (FALSE));
238}
239
240static void
217indicator_ng_set_accessible_desc (IndicatorNg *self,241indicator_ng_set_accessible_desc (IndicatorNg *self,
218 const gchar *accessible_desc)242 const gchar *accessible_desc)
219{243{
@@ -390,6 +414,13 @@
390 g_free (action);414 g_free (action);
391 }415 }
392416
417 if (g_menu_model_get_item_attribute (self->menu, 0, "submenu-action", "s", &action))
418 {
419 if (g_str_has_prefix (action, "indicator."))
420 self->submenu_action = g_strdup (action + strlen ("indicator."));
421 g_free (action);
422 }
423
393 popup = g_menu_model_get_item_link (self->menu, 0, G_MENU_LINK_SUBMENU);424 popup = g_menu_model_get_item_link (self->menu, 0, G_MENU_LINK_SUBMENU);
394 if (popup)425 if (popup)
395 {426 {
@@ -657,6 +688,9 @@
657688
658 self->entry.menu = g_object_ref_sink (gtk_menu_new ());689 self->entry.menu = g_object_ref_sink (gtk_menu_new ());
659690
691 g_signal_connect (self->entry.menu, "show", G_CALLBACK (indicator_ng_menu_shown), self);
692 g_signal_connect (self->entry.menu, "hide", G_CALLBACK (indicator_ng_menu_hidden), self);
693
660 /* work around IndicatorObject's warning that the accessible694 /* work around IndicatorObject's warning that the accessible
661 * description is missing. We never set it on construction, but when695 * description is missing. We never set it on construction, but when
662 * the menu model has arrived on the bus.696 * the menu model has arrived on the bus.

Subscribers

People subscribed via source and target branches