FoundryGtk.MenuManager¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
None
Signals¶
- Inherited:
Fields¶
- Inherited:
Class Details¶
- class FoundryGtk.MenuManager(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
The goal of
FoundryGtk.MenuManageris 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.Menuinstances created by aGtk.Builderinstance. Instead, we create the menus ourself and recreate section and submenu links. This allows theFoundryGtk.MenuManagerto be in full control of the generated menus.FoundryGtk.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 get_default()¶
- Return type:
- 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.Menuif successful; otherwiseNoneand 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.Menuto position.If no match is found,
Noneis 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
FoundryGtk.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
FoundryGtk.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 withFoundryGtk.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
FoundryGtk.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.