From ca56fa8e1922572cbfc22f5a18e61a275b64b534 Mon Sep 17 00:00:00 2001 From: Michael Webster Date: Wed, 6 Mar 2013 20:16:45 -0500 Subject: [PATCH] Fix panel context menu generation --- usr/lib/linuxmint/mintMenu/mintMenu.py | 33 ++++++++++++------- .../mintMenu/plugins/applications.py | 10 +++--- usr/lib/linuxmint/mintMenu/plugins/places.py | 2 +- 3 files changed, 28 insertions(+), 17 deletions(-) diff --git a/usr/lib/linuxmint/mintMenu/mintMenu.py b/usr/lib/linuxmint/mintMenu/mintMenu.py index 801af73..a1dd833 100755 --- a/usr/lib/linuxmint/mintMenu/mintMenu.py +++ b/usr/lib/linuxmint/mintMenu/mintMenu.py @@ -9,6 +9,7 @@ from gi.repository import Gio try: import sys + sys.path.append('/usr/lib/linuxmint/mintMenu/plugins') from gi.repository import Pango import os import commands @@ -19,6 +20,7 @@ try: import ctypes from ctypes import * import capi + from execute import * import xdg.Config except Exception, e: print e @@ -554,15 +556,6 @@ class MenuWin( object ): if icon: Gtk.Window.set_default_icon( icon ) - self.propxml = """ - - - - - - - """ % ( _("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() def onBindingPress(self): @@ -774,11 +767,11 @@ class MenuWin( object ): about.show() - def showPreferences( self, uicomponent, verb ): + def showPreferences( self, action, userdata = None ): # Execute( "mateconf-editor /apps/mintMenu" ) Execute( os.path.join( PATH, "mintMenuConfig.py" ) ) - def showMenuEditor( self, uicomponent, verb ): + def showMenuEditor( self, action, userdata = None ): Execute( "mozo" ) def showMenu( self, widget=None, event=None ): @@ -851,7 +844,23 @@ class MenuWin( object ): # this callback is to create a context menu 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 ): MenuWin( applet, iid ) diff --git a/usr/lib/linuxmint/mintMenu/plugins/applications.py b/usr/lib/linuxmint/mintMenu/plugins/applications.py index 43e2067..839b4c7 100755 --- a/usr/lib/linuxmint/mintMenu/plugins/applications.py +++ b/usr/lib/linuxmint/mintMenu/plugins/applications.py @@ -16,6 +16,7 @@ import commands import subprocess import filecmp import ctypes +import capi from ctypes import * from easybuttons import * from execute import Execute @@ -1000,8 +1001,8 @@ class pluginclass( object ): startupMenuItem.connect( "toggled", self.onAddToStartup, widget ) mTree.connect( 'deactivate', self.onMenuPopupDeactivate) - gtk.gtk_menu_popup(hash(mTree), None, None, None, 0, 0) - #mTree.popup_for_device( None, None, None, event.button, event.time ) + gtk.gtk_menu_popup(hash(mTree), None, None, None, 3, 0) + #mTree.popup( None, None, None, event.button, event.time ) return True def onMenuPopupDeactivate( self, widget): @@ -1009,8 +1010,8 @@ class pluginclass( object ): self.mintMenuWin.grab() def searchPopup( self, widget=None, event=None ): - menu = Gtk.Menu() - + menu = Gtk.Menu() + menuItem = Gtk.ImageMenuItem(_("Search Google")) img = Gtk.Image() img.set_from_file('/usr/lib/linuxmint/mintMenu/search_engines/google.ico') @@ -1081,6 +1082,7 @@ class pluginclass( object ): menu.append(menuItem) menu.show_all() + print "show" #menu.popup( None, None, self.pos_func, 3, 0) gtk.gtk_menu_popup(hash(menu), None, None, None, 3, 0) #menu.popup( None, None, None, 3, 0) diff --git a/usr/lib/linuxmint/mintMenu/plugins/places.py b/usr/lib/linuxmint/mintMenu/plugins/places.py index c10164a..1a5d37b 100755 --- a/usr/lib/linuxmint/mintMenu/plugins/places.py +++ b/usr/lib/linuxmint/mintMenu/plugins/places.py @@ -258,7 +258,7 @@ class pluginclass( object ): trashMenu.append(emptyTrashMenuItem) trashMenu.show_all() 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 ) # self.mintMenuWin.grab()