After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 708906 - Make g_menu_append() and friends return the GMenuItem
Make g_menu_append() and friends return the GMenuItem
Status: RESOLVED WONTFIX
Product: glib
Classification: Platform
Component: gio
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2013-09-27 10:23 UTC by Murray Cumming
Modified: 2013-10-01 09:30 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
0001-GMenu-Return-the-GMenuItem-from-append-prepend-inser.patch (3.30 KB, patch)
2013-09-27 10:23 UTC, Murray Cumming
none Details | Review

Description Murray Cumming 2013-09-27 10:23:43 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.
Comment 1 Allison Karlitskaya (desrt) 2013-10-01 08:32:23 UTC
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.
Comment 2 Murray Cumming 2013-10-01 08:40:33 UTC
Ah, OK. And it doesn't look like there's any way to get a GMenuItem from a GMenu. Oh well. Thanks.
Comment 3 Allison Karlitskaya (desrt) 2013-10-01 09:30:34 UTC
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 :(