Hello. I am trying to write an extension for nautilus, which add an item to the menu that appears when you right-click a file (as shown in image)
However, I would like to add a submenu to my custom menu item.
I downloaded a 'nautilus-python' package which includes examples of how to write extensions for Nautilus (and so far it turned out to be the best/only documentation i found). In it, is a file called submenu.py, which contains the following:
import nautilus
class ExampleMenuProvider(nautilus.MenuProvider):
def get_file_items(self, window, files):
menuitem = nautilus.MenuItem('ExampleMenuProvider::Foo', 'Foo', '')
submenu = nautilus.Menu()
menuitem.set_submenu(submenu)
menuitem = nautilus.MenuItem('ExampleMenuProvider::Bar','Bar','')
submenu.append_item(menuitem)
return menuitem,
# FIXME: Why isn't this working?
def get_background_items(self, window, file):
submenu = nautilus.Menu()
submenu.append_item(nautilus.MenuItem('ExampleMenuProvider::Bar', 'Bar', ''))
menuitem = nautilus.MenuItem('ExampleMenuProvider::Foo', 'Foo', '')
menuitem.set_submenu(submenu)
return menuitem,
ps: i didn't add "# FIX ME: Why isnt this working?". that is actually included in the example
The code doesn't work. Even if i take out the second function and leave just the first one, it doesn't work.
Any help would be appreciated, thanks.