Menu

GMenu is a simple implementation of GMenuModel. You populate a GMenu by adding GMenuItem instances to it.

There are some convenience functions to allow you to directly add items (avoiding GMenuItem) for the common cases. To add a regular item, use g_menu_insert(). To add a section, use g_menu_insert_section(). To add a submenu, use g_menu_insert_submenu().

Constructors

this
this(GMenu* gMenu)

Sets our main struct and passes it to the parent class

this
this()

Creates a new GMenu. The new menu has no items. Since 2.32

Members

Functions

append
void append(string label, string detailedAction)

Convenience function for appending a normal menu item to the end of menu. Combine g_menu_item_new() and g_menu_insert_item() for a more flexible alternative. Since 2.32

appendItem
void appendItem(MenuItem item)

Appends item to the end of menu. See g_menu_insert_item() for more information. Since 2.32

appendSection
void appendSection(string label, MenuModel section)

Convenience function for appending a section menu item to the end of menu. Combine g_menu_item_new_section() and g_menu_insert_item() for a more flexible alternative. Since 2.32

appendSubmenu
void appendSubmenu(string label, MenuModel submenu)

Convenience function for appending a submenu menu item to the end of menu. Combine g_menu_item_new_submenu() and g_menu_insert_item() for a more flexible alternative. Since 2.32

freeze
void freeze()

Marks menu as frozen. After the menu is frozen, it is an error to attempt to make any changes to it. In effect this means that the GMenu API must no longer be used. This function causes g_menu_model_is_mutable() to begin returning FALSE, which has some positive performance implications. Since 2.32

getMenuStruct
GMenu* getMenuStruct()

Get the main Gtk struct

getStruct
void* getStruct()

the main Gtk struct as a void*

insert
void insert(int position, string label, string detailedAction)

Convenience function for inserting a normal menu item into menu. Combine g_menu_item_new() and g_menu_insert_item() for a more flexible alternative. Since 2.32

insertItem
void insertItem(int position, MenuItem 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 g_menu_insert(), g_menu_insert_section() and g_menu_insert_submenu() as well as "prepend" and "append" variants of each of these functions. Since 2.32

insertSection
void insertSection(int position, string label, MenuModel section)

Convenience function for inserting a section menu item into menu. Combine g_menu_item_new_section() and g_menu_insert_item() for a more flexible alternative. Since 2.32

insertSubmenu
void insertSubmenu(int position, string label, MenuModel submenu)

Convenience function for inserting a submenu menu item into menu. Combine g_menu_item_new_submenu() and g_menu_insert_item() for a more flexible alternative. Since 2.32

prepend
void prepend(string label, string detailedAction)

Convenience function for prepending a normal menu item to the start of menu. Combine g_menu_item_new() and g_menu_insert_item() for a more flexible alternative. Since 2.32

prependItem
void prependItem(MenuItem item)

Prepends item to the start of menu. See g_menu_insert_item() for more information. Since 2.32

prependSection
void prependSection(string label, MenuModel section)

Convenience function for prepending a section menu item to the start of menu. Combine g_menu_item_new_section() and g_menu_insert_item() for a more flexible alternative. Since 2.32

prependSubmenu
void prependSubmenu(string label, MenuModel submenu)

Convenience function for prepending a submenu menu item to the start of menu. Combine g_menu_item_new_submenu() and g_menu_insert_item() for a more flexible alternative. Since 2.32

remove
void remove(int position)

Removes an item from the menu. position gives the index of the item to remove. It is an error if position is not in range the range from 0 to one less than the number of items in the menu. It is not possible to remove items by identity since items are added Since 2.32

removeAll
void removeAll()

Removes all items in the menu. Since 2.38

setStruct
void setStruct(GObject* obj)
Undocumented in source. Be warned that the author may not have intended to support it.

Variables

gMenu
GMenu* gMenu;

the main Gtk struct

Inherited Members

From MenuModel

gMenuModel
GMenuModel* gMenuModel;

the main Gtk struct

getMenuModelStruct
GMenuModel* getMenuModelStruct()

Get the main Gtk struct

getStruct
void* getStruct()

the main Gtk struct as a void*

setStruct
void setStruct(GObject* obj)
Undocumented in source. Be warned that the author may not have intended to support it.
connectedSignals
int[string] connectedSignals;
onItemsChangedListeners
void delegate(gint, gint, gint, MenuModel)[] onItemsChangedListeners;
Undocumented in source.
addOnItemsChanged
void addOnItemsChanged(void delegate(gint, gint, gint, MenuModel) dlg, ConnectFlags connectFlags)

Emitted when a change has occured to the menu. The only changes that can occur to a menu is that items are removed or added. Items may not change (except by being removed and added back in the same location). This signal is capable of describing both of those changes (at the same time). The signal means that starting at the index position, removed items were removed and added items were added in their place. If removed is zero then only items were added. If added is zero then only items were removed. As an example, if the menu contains items a, b, c, d (in that order) and the signal (2, 1, 3) occurs then the new composition of the menu will be a, b, _, _, _, d (with each _ representing some new item). Signal handlers may query the model (particularly the added items) and expect to see the results of the modification that is being reported. The signal is emitted after the modification. See Also GActionGroup

callBackItemsChanged
void callBackItemsChanged(GMenuModel* modelStruct, gint position, gint removed, gint added, MenuModel _menuModel)
Undocumented in source. Be warned that the author may not have intended to support it.
isMutable
int isMutable()

Queries if model is mutable. An immutable GMenuModel will never emit the "items-changed" signal. Consumers of the model may make optimisations accordingly. Since 2.32

getNItems
int getNItems()

Query the number of items in model. Since 2.32

getItemAttributeValue
Variant getItemAttributeValue(int itemIndex, string attribute, VariantType expectedType)

Queries the item at position item_index in model for the attribute specified by attribute. If expected_type is non-NULL then it specifies the expected type of the attribute. If it is NULL then any type will be accepted. If the attribute exists and matches expected_type (or if the expected type is unspecified) then the value is returned. If the attribute does not exist, or does not match the expected type then NULL is returned. Since 2.32

getItemLink
MenuModel getItemLink(int itemIndex, string link)

Queries the item at position item_index in model for the link specified by link. If the link exists, the linked GMenuModel is returned. If the link does not exist, NULL is returned. Since 2.32

iterateItemAttributes
MenuAttributeIter iterateItemAttributes(int itemIndex)

Creates a GMenuAttributeIter to iterate over the attributes of the item at position item_index in model. You must free the iterator with g_object_unref() when you are done. Since 2.32

iterateItemLinks
MenuLinkIter iterateItemLinks(int itemIndex)

Creates a GMenuLinkIter to iterate over the links of the item at position item_index in model. You must free the iterator with g_object_unref() when you are done. Since 2.32

itemsChanged
void itemsChanged(int position, int removed, int added)

Requests emission of the "items-changed" signal on model. This function should never be called except by GMenuModel subclasses. Any other calls to this function will very likely lead to a violation of the interface of the model. The implementation should update its internal representation of the menu before emitting the signal. The implementation should further expect to receive queries about the new state of the menu (and particularly added menu items) while signal handlers are running. The implementation must dispatch this call directly from a mainloop entry and not in response to calls -- particularly those from the GMenuModel API. Said another way: the menu must not change while user code is running without returning to the mainloop. Since 2.32

Meta