Gio.Menu.prototype.insert_item
function insert_item(position: Number(gint), item: Gio.MenuItem): void {
// Gjs wrapper 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.
There are many convenience functions to take care of common cases. See Gio.Menu.prototype.insert, Gio.Menu.prototype.insert_section and Gio.Menu.prototype.insert_submenu as well as "prepend" and "append" variants of each of these functions.
Since 2.32
- position
the position at which to insert the item
- item
the Gio.MenuItem to insert