Progress on popup menus, something to do with focus grabbing, as well as

we may need to manually destroy popup menus after we're done with them.
This commit is contained in:
Michael Webster 2013-03-07 13:55:12 -05:00
parent e81b078789
commit 1a22a9b03e
4 changed files with 54 additions and 53 deletions

View File

@ -201,10 +201,10 @@ class MainWindow( object ):
self.globalEnableTooltips = mate_settings.get_boolean( "tooltips-enabled" ) self.globalEnableTooltips = mate_settings.get_boolean( "tooltips-enabled" )
def SetupMintMenuBorder( self ): def SetupMintMenuBorder( self ):
if self.usecustomcolor: # if self.usecustomcolor:
self.window.modify_bg( Gtk.StateType.NORMAL, Gdk.color_parse( self.custombordercolor ) ) # self.window.modify_bg( Gtk.StateType.NORMAL, Gdk.color_parse( self.custombordercolor ) )
else: # else:
self.window.modify_bg( Gtk.StateType.NORMAL, self.window.rc_get_style().bg[ Gtk.StateType.SELECTED ] ) # self.window.modify_bg( Gtk.StateType.NORMAL, self.window.rc_get_style().bg[ Gtk.StateType.SELECTED ] )
self.border.set_padding( self.borderwidth, self.borderwidth, self.borderwidth, self.borderwidth ) self.border.set_padding( self.borderwidth, self.borderwidth, self.borderwidth, self.borderwidth )
def SetupMintMenuOpacity( self ): def SetupMintMenuOpacity( self ):
@ -384,16 +384,16 @@ class MainWindow( object ):
#print u"Loading", (time.time() - start), "s" #print u"Loading", (time.time() - start), "s"
def SetPaneColors( self, items ): def SetPaneColors( self, items ):
for item in items: # for item in items:
if item not in self.panesToColor: # if item not in self.panesToColor:
self.panesToColor.append( item ) # self.panesToColor.append( item )
if self.usecustomcolor: # if self.usecustomcolor:
for item in items: # for item in items:
item.modify_bg( Gtk.StateType.NORMAL, Gdk.color_parse( self.customcolor ) ) # item.modify_bg( Gtk.StateType.NORMAL, Gdk.color_parse( self.customcolor ) )
else: # else:
for item in items: # for item in items:
item.modify_bg( Gtk.StateType.NORMAL, self.paneholder.rc_get_style().bg[ Gtk.StateType.NORMAL ] ) # item.modify_bg( Gtk.StateType.NORMAL, self.paneholder.rc_get_style().bg[ Gtk.StateType.NORMAL ] )
pass
def SetHeadingStyle( self, items ): def SetHeadingStyle( self, items ):
return return
@ -460,15 +460,16 @@ class MainWindow( object ):
def grab( self ): def grab( self ):
gdk.gdk_pointer_grab (hash(self.window.window), True, Gdk.EventMask.BUTTON_PRESS_MASK, None, None, 0) gdk.gdk_pointer_grab (hash(self.window.window), True, Gdk.EventMask.BUTTON_PRESS_MASK, None, None, 0)
Gdk.keyboard_grab( self.window.window, False, Gdk.CURRENT_TIME ) Gdk.keyboard_grab( self.window.window, False, Gdk.CURRENT_TIME )
Gtk.grab_add(self.window) # Gtk.grab_add(self.window)
def ungrab( self ): def ungrab( self ):
Gtk.grab_remove(self.window) # Gtk.grab_remove(self.window)
self.window.hide() self.window.hide()
Gdk.pointer_ungrab(Gdk.CURRENT_TIME) Gdk.pointer_ungrab(Gdk.CURRENT_TIME)
Gdk.keyboard_ungrab(Gdk.CURRENT_TIME) Gdk.keyboard_ungrab(Gdk.CURRENT_TIME)
def onMap( self, widget, event ): def onMap( self, widget, event ):
return
self.grab() self.grab()
def onShow( self, widget ): def onShow( self, widget ):

View File

@ -6,7 +6,7 @@ gi.require_version("Gtk", "2.0")
from gi.repository import Gtk, GObject, Pango, Gdk from gi.repository import Gtk, GObject, Pango, Gdk
import os import os
import mateconf #import mateconf
import fnmatch import fnmatch
import time import time
import string import string
@ -335,14 +335,15 @@ class pluginclass( object ):
os.system("/usr/lib/linuxmint/mintMenu/plugins/get_apt_cache.py > %s/.linuxmint/mintMenu/apt.cache &" % home) os.system("/usr/lib/linuxmint/mintMenu/plugins/get_apt_cache.py > %s/.linuxmint/mintMenu/apt.cache &" % home)
def get_panel(self): def get_panel(self):
self.panel = None pass
self.panel_position = 0 # self.panel = None
appletidlist = mateconf.client_get_default().get_list("/apps/panel/general/applet_id_list", "string") #FIX # self.panel_position = 0
for applet in appletidlist: # appletidlist = mateconf.client_get_default().get_list("/apps/panel/general/applet_id_list", "string")
bonobo_id = mateconf.client_get_default().get_string("/apps/panel/applets/" + applet + "/applet_iid") # for applet in appletidlist:
if bonobo_id == "OAFIID:MATE_mintMenu": # bonobo_id = mateconf.client_get_default().get_string("/apps/panel/applets/" + applet + "/applet_iid")
self.panel = mateconf.client_get_default().get_string("/apps/panel/applets/" + applet + "/toplevel_id") # if bonobo_id == "OAFIID:MATE_mintMenu":
self.panel_position = mateconf.client_get_default().get_int("/apps/panel/applets/" + applet + "/position") + 1 # self.panel = mateconf.client_get_default().get_string("/apps/panel/applets/" + applet + "/toplevel_id")
# self.panel_position = mateconf.client_get_default().get_int("/apps/panel/applets/" + applet + "/position") + 1
def apturl_install(self, widget, pkg_name): def apturl_install(self, widget, pkg_name):
if os.path.exists("/usr/bin/apturl"): if os.path.exists("/usr/bin/apturl"):
@ -920,7 +921,7 @@ class pluginclass( object ):
#mTree.popup( None, None, None, ev.button, ev.time ) #mTree.popup( None, None, None, ev.button, ev.time )
gtk.gtk_menu_popup(hash(mTree), None, None, None, None, None) gtk.gtk_menu_popup(hash(mTree), None, None, None, None, None)
self.mintMenuWin.grab() # self.mintMenuWin.grab()
else: else:
mTree = self.builder.get_object( "favoritesMenuExtra" ) mTree = self.builder.get_object( "favoritesMenuExtra" )
@ -938,7 +939,7 @@ class pluginclass( object ):
insertSeparatorMenuItem.connect( "activate", self.onFavoritesInsertSeparator, widget, insertBefore ) insertSeparatorMenuItem.connect( "activate", self.onFavoritesInsertSeparator, widget, insertBefore )
#mTree.popup( None, None, None, ev.button, ev.time ) #mTree.popup( None, None, None, ev.button, ev.time )
gtk.gtk_menu_popup(hash(mTree), None, None, None, ev.button, ev.time) gtk.gtk_menu_popup(hash(mTree), None, None, None, ev.button, ev.time)
self.mintMenuWin.grab() # self.mintMenuWin.grab()
return True return True
def menuPopup( self, widget, event ): def menuPopup( self, widget, event ):
@ -1083,14 +1084,13 @@ 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, None, 3, 0)
#menu.popup( None, None, None, 3, 0) #menu.popup( None, None, None, 3, 0)
#menu.attach_to_widget(self.searchButton, None) #menu.attach_to_widget(self.searchButton, None)
#menu.reposition() #menu.reposition()
#menu.reposition() #menu.reposition()
self.mintMenuWin.grab() # self.mintMenuWin.grab()
self.focusSearchEntry() self.focusSearchEntry()
return True return True
@ -1177,28 +1177,28 @@ class pluginclass( object ):
os.system("cp \"%s\" \"%s\"" % (desktopEntry.desktopFile, new_file)) os.system("cp \"%s\" \"%s\"" % (desktopEntry.desktopFile, new_file))
os.system("chmod a+rx %s" % (new_file)) os.system("chmod a+rx %s" % (new_file))
# Add to Gnome/GConf #FIX # Add to Gnome/GConf
object_dir = "/apps/panel/objects/" # object_dir = "/apps/panel/objects/"
object_client = mateconf.client_get_default() # object_client = mateconf.client_get_default()
object_client.set_string(object_dir + object_name +"/"+ "menu_path", "applications:/") # object_client.set_string(object_dir + object_name +"/"+ "menu_path", "applications:/")
object_client.set_bool(object_dir + object_name +"/"+ "locked", False) # object_client.set_bool(object_dir + object_name +"/"+ "locked", False)
object_client.set_int(object_dir + object_name +"/"+ "position", self.panel_position) # object_client.set_int(object_dir + object_name +"/"+ "position", self.panel_position)
object_client.set_string(object_dir + object_name +"/"+ "object_type", "launcher-object") # object_client.set_string(object_dir + object_name +"/"+ "object_type", "launcher-object")
object_client.set_bool(object_dir + object_name +"/"+ "panel_right_stick", False) # object_client.set_bool(object_dir + object_name +"/"+ "panel_right_stick", False)
object_client.set_bool(object_dir + object_name +"/"+ "use_menu_path", False) # object_client.set_bool(object_dir + object_name +"/"+ "use_menu_path", False)
object_client.set_string(object_dir + object_name +"/"+ "launcher_location", new_file) # object_client.set_string(object_dir + object_name +"/"+ "launcher_location", new_file)
object_client.set_string(object_dir + object_name +"/"+ "custom_icon", "") # object_client.set_string(object_dir + object_name +"/"+ "custom_icon", "")
object_client.set_string(object_dir + object_name +"/"+ "tooltip", "") # object_client.set_string(object_dir + object_name +"/"+ "tooltip", "")
object_client.set_string(object_dir + object_name +"/"+ "action_type", "lock") # object_client.set_string(object_dir + object_name +"/"+ "action_type", "lock")
object_client.set_bool(object_dir + object_name +"/"+ "use_custom_icon", False) # object_client.set_bool(object_dir + object_name +"/"+ "use_custom_icon", False)
object_client.set_string(object_dir + object_name +"/"+ "attached_toplevel_id", "") # object_client.set_string(object_dir + object_name +"/"+ "attached_toplevel_id", "")
object_client.set_string(object_dir + object_name +"/"+ "bonobo_iid", "") # object_client.set_string(object_dir + object_name +"/"+ "bonobo_iid", "")
object_client.set_string(object_dir + object_name +"/"+ "toplevel_id", self.panel) # object_client.set_string(object_dir + object_name +"/"+ "toplevel_id", self.panel)
launchers_list = object_client.get_list("/apps/panel/general/object_id_list", "string") # launchers_list = object_client.get_list("/apps/panel/general/object_id_list", "string")
launchers_list.append(object_name) # launchers_list.append(object_name)
object_client.set_list("/apps/panel/general/object_id_list", mateconf.VALUE_STRING, launchers_list) # object_client.set_list("/apps/panel/general/object_id_list", mateconf.VALUE_STRING, launchers_list)
def delete_from_menu(self, widget, desktopEntry): def delete_from_menu(self, widget, desktopEntry):
try: try:

View File

@ -1,6 +1,6 @@
#!/usr/bin/env python #!/usr/bin/env python
import mateconf
from gi.repository import Gio from gi.repository import Gio
class EasyGSettings: class EasyGSettings:

View File

@ -258,9 +258,9 @@ 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(trashMenu, None, None, None, None, 3, 0) gtk.gtk_menu_popup(hash(trashMenu), None, 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()
return True return True