## Nautilus.MenuProvider

Nautilus.MenuProvider — Nautilus.MenuProvider Reference

## Synopsis

     Nautilus.MenuProvider {
      get_file_items(files);
      get_file_items_full(provider,
                          files);
      get_background_items(folder);
      get_background_items_full(provider,
                                folder);
      Nautilus.menu_provider_emit_items_updated_signal(provider);
    }

## Description

If subclassed, Nautilus will request a list of `Nautilus.MenuItem` objects, which are then attached to various menus. Nautilus 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 nautilus-python 1.0 because they were removed from Nautilus 3. Technically, you should still be able to call those methods with nautilus-python 1.0 if you are running Nautilus 2.x with annotations.

Example 4. Nautilus.MenuProvider Example

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48

    from gi.repository import Nautilus, GObject
    from typing import List

    class ExampleMenuProvider(GObject.GObject, Nautilus.MenuProvider):
        def get_file_items(
            self,
            files: List[Nautilus.FileInfo],
        ) -> List[Nautilus.MenuItem]:
            top_menuitem = Nautilus.MenuItem(
                name="ExampleMenuProvider::Foo",
                label="Foo",
            )

            submenu = Nautilus.Menu()
            top_menuitem.set_submenu(submenu)

            sub_menuitem = Nautilus.MenuItem(
                name="ExampleMenuProvider::Bar",
                label="Bar",
            )
            submenu.append_item(sub_menuitem)

            return [
                top_menuitem,
            ]

        def get_background_items(
            self,
            current_folder: Nautilus.FileInfo,
        ) -> List[Nautilus.MenuItem]:
            submenu = Nautilus.Menu()
            submenu.append_item(
                Nautilus.MenuItem(
                    name="ExampleMenuProvider::Bar2",
                    label="Bar2",
                )
            )

            menuitem = Nautilus.MenuItem(
                name="ExampleMenuProvider::Foo2",
                label="Foo2",
            )
            menuitem.set_submenu(submenu)

            return [
                menuitem,
            ]

## Signals

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

## Passive Methods

### Nautilus.MenuProvider.get_file_items

    get_file_items(files);

`menu` : | a list of `Nautilus.FileInfo` objects.
Returns : | a list of `Nautilus.MenuItem` objects

The `get_file_items`() method returns a list of `Nautilus.MenuItem` objects.

### Nautilus.MenuProvider.get_file_items_full

    get_file_items_full(provider,
                        files);

`provider` : | the current `Nautilus.MenuProvider` instance
`files` : | a list of `Nautilus.FileInfo` objects.
Returns : | a list of `Nautilus.MenuItem` objects

The `get_file_items_full`() method returns a list of `Nautilus.MenuItem` objects.

This method was created in order to allow extension writers to call the Nautilus.menu_provider_emit_items_updated_signal, which must be passed the current provider instance.

This method was introduced in nautilus-python 0.7.0.

### Nautilus.MenuProvider.get_background_items

    get_background_items(folder);

`folder` : | the current folder, as a `Nautilus.FileInfo` object.
Returns : | a list of `Nautilus.MenuItem` objects

The `get_background_items`() method returns a list of `Nautilus.MenuItem` objects.

### Nautilus.MenuProvider.get_background_items_full

    get_background_items_full(provider,
                              folder);

`provider` : | the current `Nautilus.MenuProvider` instance
`folder` : | the current folder, as a `Nautilus.FileInfo` object.
Returns : | a list of `Nautilus.MenuItem` objects

The `get_background_items_full`() method returns a list of `Nautilus.MenuItem` objects.

This method was created in order to allow extension writers to call the Nautilus.menu_provider_emit_items_updated_signal, which must be passed the current provider instance.

This method was introduced in nautilus-python 0.7.0.

## Active Methods

### Nautilus.menu_provider_emit_items_updated_signal

    menu_provider_emit_items_updated_signal(provider);

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

Emits the "items-updated" signal.

This method was introduced in nautilus-python 0.7.0.

## Signal Details

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

Emits the "items-updated" signal.