Panel.MenuManager¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
None
Signals¶
- Inherited:
Fields¶
- Inherited:
Class Details¶
- class Panel.MenuManager(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
The goal of
Panel.MenuManager
is to simplify the process of merging multipleGtk.Builder
.ui files containing menus into a single representation of the application menus. Additionally, it provides the ability to “unmerge” previously merged menus.This allows for an application to have plugins which seemlessly extends the core application menus.
Implementation notes:
To make this work, we don’t use the
Gio.Menu
instances created by aGtk.Builder
instance. Instead, we create the menus ourself and recreate section and submenu links. This allows thePanel.MenuManager
to be in full control of the generated menus.Panel.MenuManager.get_menu_by_id
() will always return aGio.Menu
, however that menu may contain no children until something has extended it later on during the application process.- classmethod new()¶
- Return type:
- add_resource(resource)¶
- Parameters:
resource (
str
) –- Raises:
- Returns:
the merge id
- Return type:
New in version 1.4.
- find_item_by_id(id)¶
- Parameters:
id (
str
) – the identifier of the menu item- Returns:
a
Gio.Menu
if successful; otherwiseNone
and position is unset.- position:
the position within the resulting menu
- Return type:
Locates a menu item that matches id and sets the position within the resulting
Gio.Menu
to position.If no match is found,
None
is returned.New in version 1.4.
- get_menu_by_id(menu_id)¶
-
New in version 1.4.
- merge(menu_id, menu_model)¶
- Parameters:
menu_id (
str
) – the identifier of the menumenu_model (
Gio.MenuModel
) – the menu model to merge
- Returns:
the merge-id which can be used with
Panel.MenuManager.remove
()- Return type:
Note that menu_model is not retained, a copy of it is made.
New in version 1.4.
- remove(merge_id)¶
- Parameters:
merge_id (
int
) – A previously registered merge id
This removes items from menus that were added as part of a previous menu merge. Use the value returned from
Panel.MenuManager.merge
() as the merge_id.New in version 1.4.
- set_attribute_string(menu, position, attribute, value)¶
- Parameters:
menu (
Gio.Menu
) – the menu that was retreived withPanel.MenuManager.get_menu_by_id
()position (
int
) – the index of the item in the menuattribute (
str
) – the attribute to changevalue (
str
) – the new value for the attribute
Overwrites an attribute for a menu that was created by
Panel.MenuManager
.This can be useful when you want to update an attribute such as “accel” when an accelerator has changed due to user mappings.
New in version 1.4.