GNOME Bugzilla – Bug 708906
Make g_menu_append() and friends return the GMenuItem
Last modified: 2013-10-01 09:30:34 UTC
Created attachment 255912 [details] [review] 0001-GMenu-Return-the-GMenuItem-from-append-prepend-inser.patch This patch gives g_menu_append(), g_menu_prepend() and g_menu_insert() a return value, for convenience. I don't think it breaks any API or ABI.
GMenu doesn't work this way. See the docs for g_menu_insert_item(): Inserts item into menu. The "insertion" is actually done by copying all of the attribute and link values of item and using them to form a new item within menu. As such, item itself is not really inserted, but rather, a menu item that is exactly the same as the one presently described by item. This means that item is essentially useless after the insertion occurs. Any changes you make to it are ignored unless it is inserted again (at which point its updated values will be copied). You should probably just free item once you're done.
Ah, OK. And it doesn't look like there's any way to get a GMenuItem from a GMenu. Oh well. Thanks.
g_menu_item_new_from_model() exists and works on any GMenuModel (not just GMenu), but it just does the same thing (ie: makes a copy), so it's not useful for what you were trying to do. Sorry :(