Results 1 to 5 of 5

Thread: Python Nautilus Context Menu Extension

  1. #1
    Join Date
    Jan 2007
    Beans
    6
    Distro
    Ubuntu 6.10 Edgy

    Python Nautilus Context Menu Extension

    I'm trying to add simple Menu Item into nautilus context menu, with python-nautilus.

    But the script seems to don't run. I've placed it into
    /usr/lib/nautilus/extensions-1.0/python/ with chmod 755.

    Code:
    import gtk
    import nautilus
    import os
    
    def alert(message):
        """A function to debug"""
        dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_INFO, gtk.BUTTONS_CLOSE, message)
        dialog.run()
        dialog.destroy()
    
    class TestExtension(nautilus.MenuProvider):
    	def __init__(self):
    		pass
    
    	def get_file_items(self, window, files):
    		items = []
    		"""Called when the user selects a file in Nautilus."""
    		item = nautilus.MenuItem("NautilusPython::test_item", "Test", "Test")
    		item.connect("activate", self.menu_activate_cb, files)
    		items.append(item)
    		return items
    
    	def menu_activate_cb(self, menu, files):
    		"""Called when the user selects the menu."""
    		for name in files:
    			alert(name)
    Thanks

  2. #2
    Join Date
    Sep 2006
    Location
    Pretoria, South-Africa
    Beans
    471
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: Python Nautilus Context Menu Extension

    I think you are supposed to have the following on your first line

    Code:
    #!/usr/bin/env python
    if you dont have that line, then you will have to run the script directly with python.

  3. #3
    Join Date
    Jan 2007
    Beans
    6
    Distro
    Ubuntu 6.10 Edgy

    Re: Python Nautilus Context Menu Extension

    unfortunatly the solution is not so easier...
    the script doesn't run again

  4. #4
    Join Date
    Mar 2005
    Location
    Little Horse, Argentina
    Beans
    22
    Distro
    Ubuntu Karmic Koala (testing)

    Re: Python Nautilus Context Menu Extension

    I'm having the same issue, any solution here?

  5. #5
    Join Date
    Sep 2005
    Location
    Crevillent (Alicante), Sp
    Beans
    69
    Distro
    Ubuntu 7.10 Gutsy Gibbon

    Re: Python Nautilus Context Menu Extension

    According to /usr/share/doc/python-nautilus/examples/README in order to test your extensions you need to do this:

    To try any of the examples, copy them over to:

    /usr/lib/nautilus/extensions-1.0/python/
    or:
    ~/.nautilus/python-extensions/

    Then restart nautilus.

    Hint: if you're testing an extension that you're developing, it may
    be useful to start a 'private' instance of nautilus, like this:
    $ mkdir /tmp/testing
    $ export TMPDIR=/tmp/testing
    $ nautilus --no-desktop
    There are some examples in /usr/share/doc/python-nautilus/examples/ that you could try to modify to suit your needs.

    Edit: I've realized that there is a bug in the package "python-nautilus" https://bugs.launchpad.net/nautilus-python/+bug/145811 . You can download a fixed package from here https://edge.launchpad.net/%7Ejonner/+archive (I couldn't install ppa5 but ppa4 works fine).
    Last edited by llonesmiz; December 31st, 2007 at 02:16 PM.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •