Baul.MenuProvider
Prev | Provider Interfaces | Next

## Baul.MenuProvider

Baul.MenuProvider — Baul.MenuProvider Reference

## Synopsis

    class Baul.MenuProvider:
        def get_file_items(window, files)
        def get_file_items_full(provider, window, files)
        def get_background_items(window, folder)
        def get_background_items_full(provider, window, folder)
        def Baul.menu_provider_emit_items_updated_signal(provider)

## Description

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,

## Signals

"items-updated" | `def callback()`

## Passive Methods

### Baul.MenuProvider.get_file_items

        def get_file_items(window, files)

`window` : | the current `ctk.Window` instance
`menu` : | 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.

### Baul.MenuProvider.get_file_items_full

        def get_file_items_full(provider, window, files)

`provider` : | the current `Baul.MenuProvider` instance
`window` : | the current `ctk.Window` instance
`files` : | 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.

### Note

This method was introduced in baul-python 0.7.0.

### Baul.MenuProvider.get_background_items

        def get_background_items(window, folder)

`window` : | the current `ctk.Window` instance
`folder` : | 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.

### Baul.MenuProvider.get_background_items_full

        def get_background_items_full(provider, window, folder)

`provider` : | the current `Baul.MenuProvider` instance
`window` : | the current `ctk.Window` instance
`folder` : | 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.

### Note

This method was introduced in baul-python 0.7.0.

## Active Methods

### Baul.menu_provider_emit_items_updated_signal

        def menu_provider_emit_items_updated_signal(provider)

`provider` : | the current `Baul.MenuProvider` instance

Emits the "items-updated" signal.

### Note

This method was introduced in baul-python 0.7.0.

## Signal Details

### The "items-updated" Baul.MenuProvider Signal

Emits the "items-updated" signal.

Prev | Up | Next
Baul.LocationWidgetProvider | Home | Baul.PropertyPageProvider