Dazzle.MenuManager

g Dazzle.MenuManager Dazzle.MenuManager GObject.Object GObject.Object GObject.Object->Dazzle.MenuManager

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

new ()

add_filename (filename)

add_resource (resource)

get_menu_by_id (menu_id)

merge (menu_id, model)

remove (merge_id)

Virtual Methods

Inherited:

GObject.Object (7)

Properties

None

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Class Details

class Dazzle.MenuManager(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

Dazzle.MenuManagerClass

The goal of Dazzle.MenuManager is to simplify the process of merging multiple Gtk.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 a Gtk.Builder instance. Instead, we create the menus ourself and recreate section and submenu links. This allows the Dazzle.MenuManager to be in full control of the generated menus.

Dazzle.MenuManager.get_menu_by_id() will always return a Gio.Menu, however that menu may contain no children until something has extended it later on during the application process.

New in version 3.26.

classmethod new()
Return type:

Dazzle.MenuManager

add_filename(filename)
Parameters:

filename (str) –

Raises:

GLib.Error

Return type:

int

add_resource(resource)
Parameters:

resource (str) –

Raises:

GLib.Error

Return type:

int

get_menu_by_id(menu_id)
Parameters:

menu_id (str) –

Returns:

A Gio.Menu.

Return type:

Gio.Menu

merge(menu_id, model)
Parameters:
Return type:

int

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 Dazzle.MenuManager.merge() as the merge_id.

New in version 3.26.