title: Submenu items in Nautilus right-click menu
body: <p>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)</p>
  
  <p><img src="https://img.photobucket.com/albums/v425/play/help/Screenshot-1.png" alt="alt text"></p>
  
  <p>However, I would like to add a submenu to my custom menu item.</p>
  
  <p>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:</p>
  
  <pre><code>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,
  </code></pre>
  
  <p>ps: i didn't add "# FIX ME: Why isnt this working?". that is actually included in the example </p>
  
  <p>The code doesn't work. Even if i take out the second function and leave just the first one, it doesn't work.</p>
  
  <p>Any help would be appreciated, thanks.</p>