Garcon.Menu

g GObject.GInterface GObject.GInterface Garcon.MenuElement Garcon.MenuElement GObject.GInterface->Garcon.MenuElement GObject.Object GObject.Object Garcon.Menu Garcon.Menu GObject.Object->Garcon.Menu Garcon.MenuElement->Garcon.Menu

Subclasses:

None

Methods

Inherited:

GObject.Object (37), Garcon.MenuElement (7)

Structs:

GObject.ObjectClass (5)

class

new (file)

class

new_applications ()

class

new_for_path (filename)

add_menu (submenu)

get_directory ()

get_elements ()

get_file ()

get_item_pool ()

get_items ()

get_menu_with_name (name)

get_menus ()

get_parent ()

load (cancellable)

Virtual Methods

Inherited:

GObject.Object (7), Garcon.MenuElement (7)

Properties

Name

Type

Flags

Short Description

directory

Garcon.MenuDirectory

r/w

Directory entry associated with this menu

file

Gio.File

r/w/co

file

Signals

Inherited:

GObject.Object (1)

Name

Short Description

directory-changed

reload-required

Fields

Inherited:

GObject.Object (1)

Class Details

class Garcon.Menu(**kwargs)
Bases:

GObject.Object, Garcon.MenuElement

Abstract:

No

Structure:

Garcon.MenuClass

classmethod new(file)
Parameters:

file (Gio.File) – Gio.File for the .menu file you want to load.

Returns:

a new Garcon.Menu.

Return type:

Garcon.Menu

Creates a new Garcon.Menu for the .menu file referred to by file. This operation only fails if file is invalid. To load the menu tree from the file, you need to call Garcon.Menu.load() with the returned Garcon.Menu.

<informalexample><programlisting> Garcon.Menu *menu = Garcon.Menu.new (filename);

if (Garcon.Menu.load (menu, &error)) … else …

GObject.Object.unref (menu); </programlisting></informalexample>

The caller is responsible to destroy the returned Garcon.Menu using GObject.Object.unref().

For more information about the usage see Garcon.Menu.new().

classmethod new_applications()
Returns:

a new Garcon.Menu for applications.menu.

Return type:

Garcon.Menu

Creates a new Garcon.Menu for the applications.menu file which is being used to display installed applications.

For more information about the usage see Garcon.Menu.new().

classmethod new_for_path(filename)
Parameters:

filename (str) – Path/URI of the .menu file you want to load.

Returns:

a new Garcon.Menu for filename.

Return type:

Garcon.Menu

Creates a new Garcon.Menu for the .menu file referred to by filename. This operation only fails if the filename is None. To load the menu tree from the file, you need to call Garcon.Menu.load() with the returned Garcon.Menu.

The caller is responsible to destroy the returned Garcon.Menu using GObject.Object.unref().

add_menu(submenu)
Parameters:

submenu (Garcon.Menu) – a Garcon.Menu

Adds submenu as a sub menu to self.

get_directory()
Returns:

a Garcon.MenuDirectory

Return type:

Garcon.MenuDirectory or None

Returns the Garcon.MenuDirectory of self or None if self has no valid directory element.

The menu directory may contain a lot of useful information about the menu like the display and icon name, desktop environments it should show up in etc.

get_elements()
Return type:

[Garcon.MenuItem] or None

Get all the menu element in self. This contains sub menus, menu items and separators.

Returns a list of Garcon.MenuItem or None. Free the list with g_list_free().

get_file()
Returns:

a Gio.File.

Return type:

Gio.File

Get the file for self. It refers to the .menu file from which self was or will be loaded.

The returned object should be unreffed with GObject.Object.unref() when no longer needed.

get_item_pool()
Returns:

a Garcon.MenuItemPool.

Return type:

Garcon.MenuItemPool

Get the item pool of the menu. This pool contains all items in this menu (for that of its submenus).

get_items()
Returns:

list of Garcon.MenuItem included in self.

Return type:

[Garcon.MenuItem]

Returns all Garcon.MenuItem included in self. The items are sorted by their display names in ascending order.

The caller is responsible to free the returned list using g_list_free() when no longer needed.

get_menu_with_name(name)
Parameters:

name (str) – a sub menu name

Returns:

a Garcon.Menu or None.

Return type:

Garcon.Menu or None

Looks in self for a submenu with name as name.

get_menus()
Returns:

a sorted list of Garcon.Menu.

Return type:

[Garcon.Menu]

Returns a sorted list of Garcon.Menu submenus of self. The list should be freed with g_list_free().

get_parent()
Returns:

a Garcon.Menu or None if self is the root menu.

Return type:

Garcon.Menu or None

Returns the parent Garcon.Menu or self.

load(cancellable)
Parameters:

cancellable (Gio.Cancellable or None) – a Gio.Cancellable

Raises:

GLib.Error

Returns:

True if the menu was loaded successfully or False if there was an error or the process was cancelled.

Return type:

bool

This function loads the entire menu tree from the file referred to by self. It resolves merges, moves and everything else defined in the menu specification. The resulting tree information is stored within self and can be accessed using the public Garcon.Menu API afterwards.

cancellable can be used to handle blocking I/O when reading data from files during the loading process.

error should either be None or point to a GLib.Error return location where errors should be stored in.

Signal Details

Garcon.Menu.signals.directory_changed(menu, object, p0)
Signal Name:

directory-changed

Flags:

RUN_LAST, NO_HOOKS

Parameters:
Garcon.Menu.signals.reload_required(menu)
Signal Name:

reload-required

Flags:

RUN_LAST, NO_HOOKS

Parameters:

menu (Garcon.Menu) – The object which received the signal

Property Details

Garcon.Menu.props.directory
Name:

directory

Type:

Garcon.MenuDirectory

Default Value:

None

Flags:

READABLE, WRITABLE

The directory entry associated with this menu.

Garcon.Menu.props.file
Name:

file

Type:

Gio.File

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

The Gio.File from which the Garcon.Menu was loaded.