Baul.MenuProvider — Baul.MenuProvider Reference
class Baul.MenuProvider: |
If subclassed, Baul will request a list of Baul.MenuItem objects,
which are then attached to various menus. Baul expects at least one of
the following methods to be defined (or their *_full variants): get_file_items or
get_background_items.
The get_toolbar_items methods were removed in baul-python 1.0 because they were removed from Baul 3. Technically, you should still be able to call those methods with baul-python 1.0 if you are running Baul 2.x with annotations.
Example 5. Baul.MenuProvider Example
from gi.repository import Baul, GObject
class ColumnExtension(GObject.GObject, Baul.MenuProvider):
def __init__(self):
pass
def get_file_items(self, window, files):
top_menuitem = Baul.MenuItem(name='ExampleMenuProvider::Foo',
label='Foo',
tip='',
icon='')
submenu = Baul.Menu()
top_menuitem.set_submenu(submenu)
sub_menuitem = Baul.MenuItem(name='ExampleMenuProvider::Bar',
label='Bar',
tip='',
icon='')
submenu.append_item(sub_menuitem)
return top_menuitem,
def get_background_items(self, window, file):
submenu = Baul.Menu()
submenu.append_item(Baul.MenuItem(name='ExampleMenuProvider::Bar2',
label='Bar2',
tip='',
icon=''))
menuitem = Baul.MenuItem(name='ExampleMenuProvider::Foo2',
label='Foo2',
tip='',
icon='')
menuitem.set_submenu(submenu)
return menuitem,
def get_file_items(window, files)
| the current ctk.Window instance |
| a list of Baul.FileInfo objects. |
Returns : | a list of Baul.MenuItem objects |
The get_file_items() method returns a list of
Baul.MenuItem objects.
def get_file_items_full(provider, window, files)
| the current Baul.MenuProvider instance |
| the current ctk.Window instance |
| a list of Baul.FileInfo objects. |
Returns : | a list of Baul.MenuItem objects |
The get_file_items_full() method returns a list of
Baul.MenuItem objects.
This method was created in order to allow extension writers to call the Baul.menu_provider_emit_items_updated_signal, which must be passed the current provider instance.
def get_background_items(window, folder)
| the current ctk.Window instance |
| the current folder, as a Baul.FileInfo object. |
Returns : | a list of Baul.MenuItem objects |
The get_background_items() method returns a list of
Baul.MenuItem objects.
def get_background_items_full(provider, window, folder)
| the current Baul.MenuProvider instance |
| the current ctk.Window instance |
| the current folder, as a Baul.FileInfo object. |
Returns : | a list of Baul.MenuItem objects |
The get_background_items_full() method returns a list of
Baul.MenuItem objects.
This method was created in order to allow extension writers to call the Baul.menu_provider_emit_items_updated_signal, which must be passed the current provider instance.
def menu_provider_emit_items_updated_signal(provider)
| the current Baul.MenuProvider instance |
Emits the "items-updated" signal.