Merge lp:~mterry/libdbusmenu/submenus into lp:libdbusmenu/0.5

Proposed by Michael Terry
Status: Merged
Merged at revision: 201
Proposed branch: lp:~mterry/libdbusmenu/submenus
Merge into: lp:libdbusmenu/0.5
Diff against target: 31 lines (+21/-0)
1 file modified
libdbusmenu-gtk/parser.c (+21/-0)
To merge this branch: bzr merge lp:~mterry/libdbusmenu/submenus
Reviewer Review Type Date Requested Status
DBus Menu Team Pending
Review via email: mp+47855@code.launchpad.net

Description of the change

Watch GtkMenu items for submenus. When they appear, parse them. Fixes issues with dynamic menus in applications like empathy.

This seems to have been made much easier with the new parser code, thanks! (I had looked into this briefly before, but the parsing would have been much more complicated before.)

To post a comment you must log in.
Revision history for this message
Ted Gould (ted) wrote :

This should use dbusmenu_menuitem_take_children and then run
g_object_unref() on them. Since child_delete() is going to free the
memory for the GList structure currently pointed to by children, next
isn't necessarily there (in all practical cases it is). Other solution
is that you could keep next on the stack, but I think take_children() is
probably cleaner.

On Fri, 2011-01-28 at 19:40 +0000, Michael Terry wrote:
> Michael Terry has proposed merging lp:~mterry/dbusmenu/submenus into lp:dbusmenu.
>
> Requested reviews:
> DBus Menu Team (dbusmenu-team)
> Related bugs:
> #696896 Empathy's Edit->Contact menu item should have a submenu
> https://bugs.launchpad.net/bugs/696896
>
> For more details, see:
> https://code.launchpad.net/~mterry/dbusmenu/submenus/+merge/47855
>
> Watch GtkMenu items for submenus. When they appear, parse them. Fixes issues with dynamic menus in applications like empathy.
>
> This seems to have been made much easier with the new parser code, thanks! (I had looked into this briefly before, but the parsing would have been much more complicated before.)
> differences between files attachment (review-diff.txt)
> === modified file 'libdbusmenu-gtk/parser.c'
> --- libdbusmenu-gtk/parser.c 2011-01-27 19:54:18 +0000
> +++ libdbusmenu-gtk/parser.c 2011-01-28 19:40:14 +0000
> @@ -649,6 +649,27 @@
> }
> }
> }
> + else if (pspec->name == g_intern_static_string ("submenu"))
> + {
> + /* The underlying submenu got swapped out. Let's see what it is now. */
> + /* First, delete any children that may exist currently. */
> + DbusmenuMenuitem * item = DBUSMENU_MENUITEM(g_object_get_data(G_OBJECT(widget), CACHED_MENUITEM));
> + if (item != NULL)
> + {
> + GList * children = dbusmenu_menuitem_get_children (item);
> + while (children != NULL) {
> + dbusmenu_menuitem_child_delete (item, DBUSMENU_MENUITEM(children->data));
> + children = children->next;
> + }
> + }
> +
> + /* Now parse new submenu. */
> + GtkWidget * menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (widget));
> + RecurseContext recurse = {0};
> + recurse.toplevel = gtk_widget_get_toplevel(widget);
> + recurse.parent = item;
> + parse_menu_structure_helper(menu, &recurse);
> + }
> }
>
> static gboolean
>

Revision history for this message
Michael Terry (mterry) wrote :

ACK

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libdbusmenu-gtk/parser.c'
2--- libdbusmenu-gtk/parser.c 2011-01-27 19:54:18 +0000
3+++ libdbusmenu-gtk/parser.c 2011-01-28 19:40:14 +0000
4@@ -649,6 +649,27 @@
5 }
6 }
7 }
8+ else if (pspec->name == g_intern_static_string ("submenu"))
9+ {
10+ /* The underlying submenu got swapped out. Let's see what it is now. */
11+ /* First, delete any children that may exist currently. */
12+ DbusmenuMenuitem * item = DBUSMENU_MENUITEM(g_object_get_data(G_OBJECT(widget), CACHED_MENUITEM));
13+ if (item != NULL)
14+ {
15+ GList * children = dbusmenu_menuitem_get_children (item);
16+ while (children != NULL) {
17+ dbusmenu_menuitem_child_delete (item, DBUSMENU_MENUITEM(children->data));
18+ children = children->next;
19+ }
20+ }
21+
22+ /* Now parse new submenu. */
23+ GtkWidget * menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (widget));
24+ RecurseContext recurse = {0};
25+ recurse.toplevel = gtk_widget_get_toplevel(widget);
26+ recurse.parent = item;
27+ parse_menu_structure_helper(menu, &recurse);
28+ }
29 }
30
31 static gboolean

Subscribers

People subscribed via source and target branches