← Back to team overview

ayatana-commits team mailing list archive

Re: [Merge] lp:~mterry/dbusmenu/submenus into lp:dbusmenu

 

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
> 



-- 
https://code.launchpad.net/~mterry/dbusmenu/submenus/+merge/47855
Your team ayatana-commits is subscribed to branch lp:dbusmenu.



References