Fix panel context menu generation
This commit is contained in:
parent
5b102017b6
commit
ca56fa8e19
@ -9,6 +9,7 @@ from gi.repository import Gio
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
import sys
|
import sys
|
||||||
|
sys.path.append('/usr/lib/linuxmint/mintMenu/plugins')
|
||||||
from gi.repository import Pango
|
from gi.repository import Pango
|
||||||
import os
|
import os
|
||||||
import commands
|
import commands
|
||||||
@ -19,6 +20,7 @@ try:
|
|||||||
import ctypes
|
import ctypes
|
||||||
from ctypes import *
|
from ctypes import *
|
||||||
import capi
|
import capi
|
||||||
|
from execute import *
|
||||||
import xdg.Config
|
import xdg.Config
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
print e
|
print e
|
||||||
@ -554,15 +556,6 @@ class MenuWin( object ):
|
|||||||
if icon:
|
if icon:
|
||||||
Gtk.Window.set_default_icon( icon )
|
Gtk.Window.set_default_icon( icon )
|
||||||
|
|
||||||
self.propxml = """
|
|
||||||
<popup name="button3">
|
|
||||||
<menuitem name="Item 1" verb="Preferences" label="%s" pixtype="stock" pixname="gtk-preferences" />
|
|
||||||
<menuitem name="Item 1" verb="Edit" label="%s" pixtype="stock" pixname="gtk-edit" />
|
|
||||||
<menuitem name="Item 2" verb="Reload" label="%s" pixtype="stock" pixname="gtk-refresh" />
|
|
||||||
<menuitem name="Item 3" verb="About" label="%s" pixtype="stock" pixname="gtk-about" />
|
|
||||||
</popup>
|
|
||||||
""" % ( _("Preferences"), _("Edit menu"), _("Reload plugins"), _("About") )
|
|
||||||
self.verbs = [ ("Preferences", self.showPreferences), ("Edit", self.showMenuEditor), ("About", self.showAboutDialog), ("Reload",self.mainwin.RegenPlugins) ]
|
|
||||||
self.bind_hot_key()
|
self.bind_hot_key()
|
||||||
|
|
||||||
def onBindingPress(self):
|
def onBindingPress(self):
|
||||||
@ -774,11 +767,11 @@ class MenuWin( object ):
|
|||||||
about.show()
|
about.show()
|
||||||
|
|
||||||
|
|
||||||
def showPreferences( self, uicomponent, verb ):
|
def showPreferences( self, action, userdata = None ):
|
||||||
# Execute( "mateconf-editor /apps/mintMenu" )
|
# Execute( "mateconf-editor /apps/mintMenu" )
|
||||||
Execute( os.path.join( PATH, "mintMenuConfig.py" ) )
|
Execute( os.path.join( PATH, "mintMenuConfig.py" ) )
|
||||||
|
|
||||||
def showMenuEditor( self, uicomponent, verb ):
|
def showMenuEditor( self, action, userdata = None ):
|
||||||
Execute( "mozo" )
|
Execute( "mozo" )
|
||||||
|
|
||||||
def showMenu( self, widget=None, event=None ):
|
def showMenu( self, widget=None, event=None ):
|
||||||
@ -851,7 +844,23 @@ class MenuWin( object ):
|
|||||||
|
|
||||||
# this callback is to create a context menu
|
# this callback is to create a context menu
|
||||||
def create_menu(self):
|
def create_menu(self):
|
||||||
self.applet.setup_menu(self.propxml, self.verbs, None)
|
action_group = Gtk.ActionGroup("context-menu")
|
||||||
|
action = Gtk.Action("MintMenuPrefs", _("Preferences"), None, "gtk-preferences")
|
||||||
|
action.connect("activate", self.showPreferences)
|
||||||
|
action_group.add_action(action)
|
||||||
|
action = Gtk.Action("MintMenuEdit", _("Edit menu"), None, "gtk-edit")
|
||||||
|
action.connect("activate", self.showMenuEditor)
|
||||||
|
action_group.add_action(action)
|
||||||
|
action = Gtk.Action("MintMenuReload", _("Reload plugins"), None, "gtk-refresh")
|
||||||
|
action.connect("activate", self.mainwin.RegenPlugins)
|
||||||
|
action_group.add_action(action)
|
||||||
|
action = Gtk.Action("MintMenuAbout", _("About"), None, "gtk-about")
|
||||||
|
action.connect("activate", self.showAboutDialog)
|
||||||
|
action_group.add_action(action)
|
||||||
|
action_group.set_translation_domain ("mintmenu")
|
||||||
|
|
||||||
|
xml = os.path.join( os.path.join( os.path.dirname( __file__ )), "menu.xml" )
|
||||||
|
self.applet.setup_menu_from_file(xml, action_group)
|
||||||
|
|
||||||
def applet_factory( applet, iid, data ):
|
def applet_factory( applet, iid, data ):
|
||||||
MenuWin( applet, iid )
|
MenuWin( applet, iid )
|
||||||
|
@ -16,6 +16,7 @@ import commands
|
|||||||
import subprocess
|
import subprocess
|
||||||
import filecmp
|
import filecmp
|
||||||
import ctypes
|
import ctypes
|
||||||
|
import capi
|
||||||
from ctypes import *
|
from ctypes import *
|
||||||
from easybuttons import *
|
from easybuttons import *
|
||||||
from execute import Execute
|
from execute import Execute
|
||||||
@ -1000,8 +1001,8 @@ class pluginclass( object ):
|
|||||||
startupMenuItem.connect( "toggled", self.onAddToStartup, widget )
|
startupMenuItem.connect( "toggled", self.onAddToStartup, widget )
|
||||||
|
|
||||||
mTree.connect( 'deactivate', self.onMenuPopupDeactivate)
|
mTree.connect( 'deactivate', self.onMenuPopupDeactivate)
|
||||||
gtk.gtk_menu_popup(hash(mTree), None, None, None, 0, 0)
|
gtk.gtk_menu_popup(hash(mTree), None, None, None, 3, 0)
|
||||||
#mTree.popup_for_device( None, None, None, event.button, event.time )
|
#mTree.popup( None, None, None, event.button, event.time )
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def onMenuPopupDeactivate( self, widget):
|
def onMenuPopupDeactivate( self, widget):
|
||||||
@ -1081,6 +1082,7 @@ class pluginclass( object ):
|
|||||||
menu.append(menuItem)
|
menu.append(menuItem)
|
||||||
|
|
||||||
menu.show_all()
|
menu.show_all()
|
||||||
|
print "show"
|
||||||
#menu.popup( None, None, self.pos_func, 3, 0)
|
#menu.popup( None, None, self.pos_func, 3, 0)
|
||||||
gtk.gtk_menu_popup(hash(menu), None, None, None, 3, 0)
|
gtk.gtk_menu_popup(hash(menu), None, None, None, 3, 0)
|
||||||
#menu.popup( None, None, None, 3, 0)
|
#menu.popup( None, None, None, 3, 0)
|
||||||
|
@ -258,7 +258,7 @@ class pluginclass( object ):
|
|||||||
trashMenu.append(emptyTrashMenuItem)
|
trashMenu.append(emptyTrashMenuItem)
|
||||||
trashMenu.show_all()
|
trashMenu.show_all()
|
||||||
emptyTrashMenuItem.connect ( "activate", self.emptyTrash, widget )
|
emptyTrashMenuItem.connect ( "activate", self.emptyTrash, widget )
|
||||||
gtk.gtk_menu_popup(hash(trashMenu), None, None, None, event.button, event.time)
|
gtk.gtk_menu_popup(hash(trashMenu), None, None, None, 3, 0)
|
||||||
#trashMenu.popup( None, None, None, event.button, event.time )
|
#trashMenu.popup( None, None, None, event.button, event.time )
|
||||||
# self.mintMenuWin.grab()
|
# self.mintMenuWin.grab()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user