Created
November 23, 2010 07:34
-
-
Save dongyuwei/711405 to your computer and use it in GitHub Desktop.
test-nautilus-pyextension
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gtk | |
import nautilus | |
import os | |
#http://seemanta.net/myblog/?p=509 | |
#sudo apt-get install python-nautilus | |
#killall nautilus | |
#see https://bugs.launchpad.net/ubuntu/+source/nautilus-python/+bug/125990 | |
#http://code.google.com/p/giuspen-nautilus-pyextensions | |
def alert(message): | |
"""A function to debug""" | |
f = open('/home/dyw/debug.log','w') | |
f.write('test-dyw-ok!') | |
f.close() | |
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-dyw", "Test-mjj") | |
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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment