Gio.Menu¶
| Subclasses: | None |
|---|
Methods¶
| Inherited: | Gio.MenuModel (7), GObject.Object (37) |
|---|---|
| Structs: | GObject.ObjectClass (5) |
| class | new () |
append (label, detailed_action) |
|
append_item (item) |
|
append_section (label, section) |
|
append_submenu (label, submenu) |
|
freeze () |
|
insert (position, label, detailed_action) |
|
insert_item (position, item) |
|
insert_section (position, label, section) |
|
insert_submenu (position, label, submenu) |
|
prepend (label, detailed_action) |
|
prepend_item (item) |
|
prepend_section (label, section) |
|
prepend_submenu (label, submenu) |
|
remove (position) |
|
remove_all () |
Virtual Methods¶
| Inherited: | Gio.MenuModel (8), GObject.Object (7) |
|---|
Properties¶
None
Signals¶
| Inherited: | Gio.MenuModel (1), GObject.Object (1) |
|---|
Fields¶
| Inherited: | Gio.MenuModel (1), GObject.Object (1) |
|---|
Class Details¶
-
class
Gio.Menu(**kwargs)¶ Bases: Gio.MenuModelAbstract: No Gio.Menuis a simple implementation ofGio.MenuModel. You populate aGio.Menuby addingGio.MenuIteminstances to it.There are some convenience functions to allow you to directly add items (avoiding
Gio.MenuItem) for the common cases. To add a regular item, useGio.Menu.insert(). To add a section, useGio.Menu.insert_section(). To add a submenu, useGio.Menu.insert_submenu().New in version 2.32.
-
classmethod
new()[source]¶ Returns: a new Gio.MenuReturn type: Gio.MenuCreates a new
Gio.Menu.The new menu has no items.
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.MenuItemto appendAppends 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: - label (
strorNone) – the section label, orNone - section (
Gio.MenuModel) – aGio.MenuModelwith 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.
- label (
-
append_submenu(label, submenu)[source]¶ Parameters: - label (
strorNone) – the section label, orNone - submenu (
Gio.MenuModel) – aGio.MenuModelwith 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.
- label (
-
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.MenuAPI 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 item - item (
Gio.MenuItem) – theGio.MenuItemto 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.
- position (
-
insert_section(position, label, section)[source]¶ Parameters: - position (
int) – the position at which to insert the item - label (
strorNone) – the section label, orNone - section (
Gio.MenuModel) – aGio.MenuModelwith 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.
- position (
-
insert_submenu(position, label, submenu)[source]¶ Parameters: - position (
int) – the position at which to insert the item - label (
strorNone) – the section label, orNone - submenu (
Gio.MenuModel) – aGio.MenuModelwith 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.
- position (
-
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.MenuItemto prependPrepends 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: - label (
strorNone) – the section label, orNone - section (
Gio.MenuModel) – aGio.MenuModelwith 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.
- label (
-
prepend_submenu(label, submenu)[source]¶ Parameters: - label (
strorNone) – the section label, orNone - submenu (
Gio.MenuModel) – aGio.MenuModelwith 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.
- label (
-
remove(position)[source]¶ Parameters: position ( int) – the position of the item to removeRemoves 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.
-
classmethod