As far as I know you can't use ".directory" files in this way. You have to create the pop-up menu yourself and use something like "python gmenu" or python-xdg (both work but python-xdg is more DE neutral) to parse *.desktop, *.directory and *.menu information.
About left button click, the following should work fine:
PHP Code:
def showMenu(widget, event, applet):
if event.button == 1:
print "do something on button 1"
widget.emit_stop_by_name("button_press_event")
To help you out a little.. with the code below you can create a menu on the fly:
PHP Code:
def createAndShowMenu(event, menuItems):
menu = gtk.Menu()
for menuItem in menuItems:
item = gtk.MenuItem(menuItem[0], True)
item.show()
item.connect( "activate", *menuItem[1:])
menu.add(item)
menu.popup( None, None, None, event.button, event.time )
And use it like this to create a menu with elements: "first", "second", "third" in the "showMenu" method:
PHP Code:
def doFirst(widget, additionalParameter):
print "do first"
def doSecond(widget):
print "do second"
def doThird(widget):
print "do third"
def showMenu(widget, event, applet):
if event.button == 1:
menu = [
["first", doFirst, "AdditionalParameterIfYouNeedIt"],
["second", doSecond],
["third", doThird]]
createAndShowMenu(event, menu)
widget.emit_stop_by_name("button_press_event")
NOTE! I have not checked any of this.. errors in the code are possible.
Bookmarks