Gio.Menu¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
None
Signals¶
- Inherited:
Fields¶
- Inherited:
Class Details¶
- class Gio.Menu(**kwargs)¶
- Bases:
- Abstract:
No
GMenu
is a simple implementation of [class`Gio`.MenuModel]. You populate aGMenu
by adding [class`Gio`.MenuItem] instances to it.There are some convenience functions to allow you to directly add items (avoiding [class`Gio`.MenuItem]) for the common cases. To add a regular item, use [method`Gio`.Menu.insert]. To add a section, use [method`Gio`.Menu.insert_section]. To add a submenu, use [method`Gio`.Menu.insert_submenu].
New in version 2.32.
- append(label, detailed_action)[source]¶
- Parameters:
Convenience function for appending a normal menu item to the end of self. Combine
Gio.MenuItem.new
() andGio.Menu.insert_item
() for a more flexible alternative.New in version 2.32.
- append_item(item)[source]¶
- Parameters:
item (
Gio.MenuItem
) – aGio.MenuItem
to append
Appends item to the end of self.
See
Gio.Menu.insert_item
() for more information.New in version 2.32.
- append_section(label, section)[source]¶
- Parameters:
section (
Gio.MenuModel
) – aGio.MenuModel
with the items of the section
Convenience function for appending a section menu item to the end of self. Combine
Gio.MenuItem.new_section
() andGio.Menu.insert_item
() for a more flexible alternative.New in version 2.32.
- append_submenu(label, submenu)[source]¶
- Parameters:
submenu (
Gio.MenuModel
) – aGio.MenuModel
with the items of the submenu
Convenience function for appending a submenu menu item to the end of self. Combine
Gio.MenuItem.new_submenu
() andGio.Menu.insert_item
() for a more flexible alternative.New in version 2.32.
- freeze()[source]¶
Marks self 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
Gio.Menu
API must no longer be used.This function causes
Gio.MenuModel.is_mutable
() to begin returningFalse
, which has some positive performance implications.New in version 2.32.
- insert(position, label, detailed_action)[source]¶
- Parameters:
Convenience function for inserting a normal menu item into self. Combine
Gio.MenuItem.new
() andGio.Menu.insert_item
() for a more flexible alternative.New in version 2.32.
- insert_item(position, item)[source]¶
- Parameters:
position (
int
) – the position at which to insert the itemitem (
Gio.MenuItem
) – theGio.MenuItem
to insert
Inserts item into self.
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 self. 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.insert
(),Gio.Menu.insert_section
() andGio.Menu.insert_submenu
() as well as “prepend” and “append” variants of each of these functions.New in version 2.32.
- insert_section(position, label, section)[source]¶
- Parameters:
position (
int
) – the position at which to insert the itemsection (
Gio.MenuModel
) – aGio.MenuModel
with the items of the section
Convenience function for inserting a section menu item into self. Combine
Gio.MenuItem.new_section
() andGio.Menu.insert_item
() for a more flexible alternative.New in version 2.32.
- insert_submenu(position, label, submenu)[source]¶
- Parameters:
position (
int
) – the position at which to insert the itemsubmenu (
Gio.MenuModel
) – aGio.MenuModel
with the items of the submenu
Convenience function for inserting a submenu menu item into self. Combine
Gio.MenuItem.new_submenu
() andGio.Menu.insert_item
() for a more flexible alternative.New in version 2.32.
- prepend(label, detailed_action)[source]¶
- Parameters:
Convenience function for prepending a normal menu item to the start of self. Combine
Gio.MenuItem.new
() andGio.Menu.insert_item
() for a more flexible alternative.New in version 2.32.
- prepend_item(item)[source]¶
- Parameters:
item (
Gio.MenuItem
) – aGio.MenuItem
to prepend
Prepends item to the start of self.
See
Gio.Menu.insert_item
() for more information.New in version 2.32.
- prepend_section(label, section)[source]¶
- Parameters:
section (
Gio.MenuModel
) – aGio.MenuModel
with the items of the section
Convenience function for prepending a section menu item to the start of self. Combine
Gio.MenuItem.new_section
() andGio.Menu.insert_item
() for a more flexible alternative.New in version 2.32.
- prepend_submenu(label, submenu)[source]¶
- Parameters:
submenu (
Gio.MenuModel
) – aGio.MenuModel
with the items of the submenu
Convenience function for prepending a submenu menu item to the start of self. Combine
Gio.MenuItem.new_submenu
() andGio.Menu.insert_item
() for a more flexible alternative.New in version 2.32.
- remove(position)[source]¶
- Parameters:
position (
int
) – the position of the item to remove
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).
New in version 2.32.