Class: Gio::Menu
- Inherits:
-
Object
- Object
- Gio::Menu
- Defined in:
- (unknown)
Overview
#GMenu is a simple implementation of GMenu::Model. You populate a #GMenu by adding GMenu::Item instances to it.
There are some convenience functions to allow you to directly add items (avoiding GMenu::Item) 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().
Instance Method Summary collapse
-
#append(label, detailed_action) ⇒ nil
Convenience function for appending a normal menu item to the end of menu.
-
#append_item(item) ⇒ nil
Appends item to the end of menu.
-
#append_section(label, section) ⇒ nil
Convenience function for appending a section menu item to the end of menu.
-
#append_submenu(label, submenu) ⇒ nil
Convenience function for appending a submenu menu item to the end of menu.
-
#freeze ⇒ nil
Marks menu as frozen.
-
#insert(position, label, detailed_action) ⇒ nil
Convenience function for inserting a normal menu item into menu.
-
#insert_item(position, item) ⇒ nil
Inserts item into menu.
-
#insert_section(position, label, section) ⇒ nil
Convenience function for inserting a section menu item into menu.
-
#insert_submenu(position, label, submenu) ⇒ nil
Convenience function for inserting a submenu menu item into menu.
-
#new ⇒ Gio::Menu
Creates a new #GMenu.
-
#prepend(label, detailed_action) ⇒ nil
Convenience function for prepending a normal menu item to the start of menu.
-
#prepend_item(item) ⇒ nil
Prepends item to the start of menu.
-
#prepend_section(label, section) ⇒ nil
Convenience function for prepending a section menu item to the start of menu.
-
#prepend_submenu(label, submenu) ⇒ nil
Convenience function for prepending a submenu menu item to the start of menu.
-
#remove(position) ⇒ nil
Removes an item from the menu.
-
#remove_all ⇒ nil
Removes all items in the menu.
Instance Method Details
#append(label, detailed_action) ⇒ nil
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.
#append_item(item) ⇒ nil
Appends item to the end of menu.
See g_menu_insert_item() for more information.
#append_section(label, section) ⇒ nil
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.
#append_submenu(label, submenu) ⇒ nil
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.
#freeze ⇒ nil
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.
#insert(position, label, detailed_action) ⇒ nil
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.
#insert_item(position, item) ⇒ nil
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.
#insert_section(position, label, section) ⇒ nil
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.
#insert_submenu(position, label, submenu) ⇒ nil
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.
#new ⇒ Gio::Menu
Creates a new #GMenu.
The new menu has no items.
#prepend(label, detailed_action) ⇒ nil
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.
#prepend_item(item) ⇒ nil
Prepends item to the start of menu.
See g_menu_insert_item() for more information.
#prepend_section(label, section) ⇒ nil
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.
#prepend_submenu(label, submenu) ⇒ nil
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.
#remove(position) ⇒ nil
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 to the menu simply by copying their links and attributes (ie: identity of the item itself is not preserved).
#remove_all ⇒ nil
Removes all items in the menu.