Fixed focus bugs

This commit is contained in:
Clement Lefebvre 2010-09-12 12:56:38 +01:00
parent dc39d0783e
commit ec4866b1ab
3 changed files with 191 additions and 185 deletions

1
debian/changelog vendored
View File

@ -2,6 +2,7 @@ mintmenu (5.0.5) julia; urgency=low
* Multi-threaded search * Multi-threaded search
* Multiple keywords search * Multiple keywords search
* Fixed grab focus bugs
-- Clement Lefebvre <root@linuxmint.com> Sun, 12 Sep 2010 12:21:00 +0000 -- Clement Lefebvre <root@linuxmint.com> Sun, 12 Sep 2010 12:21:00 +0000

View File

@ -910,6 +910,7 @@ class pluginclass( object ):
mTree.get_widget("favoritesMenu").show_all() mTree.get_widget("favoritesMenu").show_all()
mTree.get_widget( "favoritesMenu" ).popup( None, None, None, ev.button, ev.time ) mTree.get_widget( "favoritesMenu" ).popup( None, None, None, ev.button, ev.time )
self.mintMenuWin.grab()
else: else:
mTree = gtk.glade.XML( self.gladefile, "favoritesMenuExtra" ) mTree = gtk.glade.XML( self.gladefile, "favoritesMenuExtra" )
@ -926,6 +927,7 @@ class pluginclass( object ):
insertSpaceMenuItem.connect( "activate", self.onFavoritesInsertSpace, widget, insertBefore ) insertSpaceMenuItem.connect( "activate", self.onFavoritesInsertSpace, widget, insertBefore )
insertSeparatorMenuItem.connect( "activate", self.onFavoritesInsertSeparator, widget, insertBefore ) insertSeparatorMenuItem.connect( "activate", self.onFavoritesInsertSeparator, widget, insertBefore )
mTree.get_widget( "favoritesMenuExtra" ).popup( None, None, None, ev.button, ev.time ) mTree.get_widget( "favoritesMenuExtra" ).popup( None, None, None, ev.button, ev.time )
self.mintMenuWin.grab()
def menuPopup( self, widget, event ): def menuPopup( self, widget, event ):
if event.button == 3: if event.button == 3:
@ -988,6 +990,7 @@ class pluginclass( object ):
startupMenuItem.connect( "toggled", self.onAddToStartup, widget ) startupMenuItem.connect( "toggled", self.onAddToStartup, widget )
mTree.get_widget( "applicationsMenu" ).popup( None, None, None, event.button, event.time ) mTree.get_widget( "applicationsMenu" ).popup( None, None, None, event.button, event.time )
self.mintMenuWin.grab()
def searchPopup( self, widget=None, event=None ): def searchPopup( self, widget=None, event=None ):
menu = gtk.Menu() menu = gtk.Menu()
@ -1067,6 +1070,7 @@ class pluginclass( object ):
#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.focusSearchEntry() self.focusSearchEntry()
def pos_func(self, menu=None): def pos_func(self, menu=None):

View File

@ -19,216 +19,217 @@ from user import home
gettext.install("mintmenu", "/usr/share/linuxmint/locale") gettext.install("mintmenu", "/usr/share/linuxmint/locale")
class pluginclass( object ): class pluginclass( object ):
def __init__( self, mintMenuWin, toggleButton ):
self.mintMenuWin = mintMenuWin
self.toggleButton = toggleButton
# Read GLADE file
gladefile = os.path.join( os.path.dirname( __file__ ), "places.glade" )
wTree = gtk.glade.XML( gladefile, "mainWindow" )
self.placesBtnHolder = wTree.get_widget( "places_button_holder" )
self.editableBtnHolder = wTree.get_widget( "editable_button_holder" )
self.scrolledWindow=wTree.get_widget("scrolledwindow2")
# These properties are NECESSARY to maintain consistency
# Set 'window' property for the plugin (Must be the root widget) def __init__( self, mintMenuWin, toggleButton ):
self.window = wTree.get_widget( "mainWindow" )
# Set 'heading' property for plugin self.mintMenuWin = mintMenuWin
self.heading = _("Places") self.toggleButton = toggleButton
# This should be the first item added to the window in glade # Read GLADE file
self.content_holder = wTree.get_widget( "Places" ) gladefile = os.path.join( os.path.dirname( __file__ ), "places.glade" )
wTree = gtk.glade.XML( gladefile, "mainWindow" )
self.placesBtnHolder = wTree.get_widget( "places_button_holder" )
self.editableBtnHolder = wTree.get_widget( "editable_button_holder" )
self.scrolledWindow=wTree.get_widget("scrolledwindow2")
# These properties are NECESSARY to maintain consistency
# Items to get custom colors # Set 'window' property for the plugin (Must be the root widget)
self.itemstocolor = [ wTree.get_widget( "viewport2" ) ] self.window = wTree.get_widget( "mainWindow" )
# Gconf stuff # Set 'heading' property for plugin
self.gconf = EasyGConf( "/apps/mintMenu/plugins/places/" ) self.heading = _("Places")
self.gconf.notifyAdd( "icon_size", self.RegenPlugin ) # This should be the first item added to the window in glade
self.gconf.notifyAdd( "show_computer", self.RegenPlugin ) self.content_holder = wTree.get_widget( "Places" )
self.gconf.notifyAdd( "show_desktop", self.RegenPlugin )
self.gconf.notifyAdd( "show_home_folder", self.RegenPlugin )
self.gconf.notifyAdd( "show_network", self.RegenPlugin )
self.gconf.notifyAdd( "show_trash", self.RegenPlugin )
self.gconf.notifyAdd( "custom_names", self.RegenPlugin )
self.gconf.notifyAdd( "custom_paths", self.RegenPlugin )
self.gconf.notifyAdd( "allowScrollbar", self.RegenPlugin )
self.gconf.notifyAdd( "height", self.changePluginSize )
self.gconf.notifyAdd( "width", self.changePluginSize )
self.gconf.bindGconfEntryToVar( "bool", "sticky", self, "sticky" )
self.GetGconfEntries() # Items to get custom colors
self.itemstocolor = [ wTree.get_widget( "viewport2" ) ]
self.content_holder.set_size_request( self.width, self.height )
def wake (self) : # Gconf stuff
if ( self.showtrash == True ): self.gconf = EasyGConf( "/apps/mintMenu/plugins/places/" )
self.refreshTrash()
def destroy( self ): self.gconf.notifyAdd( "icon_size", self.RegenPlugin )
self.gconf.notifyRemoveAll() self.gconf.notifyAdd( "show_computer", self.RegenPlugin )
self.gconf.notifyAdd( "show_desktop", self.RegenPlugin )
self.gconf.notifyAdd( "show_home_folder", self.RegenPlugin )
self.gconf.notifyAdd( "show_network", self.RegenPlugin )
self.gconf.notifyAdd( "show_trash", self.RegenPlugin )
self.gconf.notifyAdd( "custom_names", self.RegenPlugin )
self.gconf.notifyAdd( "custom_paths", self.RegenPlugin )
self.gconf.notifyAdd( "allowScrollbar", self.RegenPlugin )
self.gconf.notifyAdd( "height", self.changePluginSize )
self.gconf.notifyAdd( "width", self.changePluginSize )
self.gconf.bindGconfEntryToVar( "bool", "sticky", self, "sticky" )
def changePluginSize( self, client, connection_id, entry, args ): self.GetGconfEntries()
self.allowScrollbar = self.gconf.get( "bool", "allowScrollbar", False)
if entry.get_key() == self.gconf.gconfDir+"width":
self.width = entry.get_value().get_int()
elif entry.get_key() == self.gconf.gconfDir+"height":
if (self.allowScrollbar == False):
self.height = -1
self.scrolledWindow.set_policy( gtk.POLICY_AUTOMATIC, gtk.POLICY_NEVER )
else:
self.scrolledWindow.set_policy( gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC )
self.height = entry.get_value().get_int()
self.content_holder.set_size_request( self.width, self.height ) self.content_holder.set_size_request( self.width, self.height )
def wake (self) :
if ( self.showtrash == True ):
self.refreshTrash()
def destroy( self ):
self.gconf.notifyRemoveAll()
def changePluginSize( self, client, connection_id, entry, args ):
self.allowScrollbar = self.gconf.get( "bool", "allowScrollbar", False)
if entry.get_key() == self.gconf.gconfDir+"width":
self.width = entry.get_value().get_int()
elif entry.get_key() == self.gconf.gconfDir+"height":
if (self.allowScrollbar == False):
self.height = -1
self.scrolledWindow.set_policy( gtk.POLICY_AUTOMATIC, gtk.POLICY_NEVER )
else:
self.scrolledWindow.set_policy( gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC )
self.height = entry.get_value().get_int()
self.content_holder.set_size_request( self.width, self.height )
def RegenPlugin( self, *args, **kargs ):
self.GetGconfEntries()
self.ClearAll()
self.do_standard_places()
self.do_custom_places()
def GetGconfEntries( self ): def RegenPlugin( self, *args, **kargs ):
self.GetGconfEntries()
self.ClearAll()
self.do_standard_places()
self.do_custom_places()
self.width = self.gconf.get( "int", "width", 200 ) def GetGconfEntries( self ):
self.allowScrollbar = self.gconf.get( "bool", "allowScrollbar", False)
self.scrolledWindow.set_policy( gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC )
self.height = self.gconf.get( "int", "height", 180 )
self.content_holder.set_size_request( self.width, self.height )
if (self.allowScrollbar == False):
self.height = -1
self.scrolledWindow.set_policy( gtk.POLICY_AUTOMATIC, gtk.POLICY_NEVER )
self.content_holder.set_size_request( self.width, self.height )
self.execapp = self.gconf.get( "string", "execute_app", "nautilus" )
self.iconsize = self.gconf.get( "int","icon_size", 2 )
# Check default items
self.showcomputer = self.gconf.get( "bool", "show_computer", True )
self.showhomefolder = self.gconf.get( "bool", "show_home_folder", True )
self.shownetwork = self.gconf.get( "bool", "show_network", True )
self.showdesktop = self.gconf.get( "bool", "show_desktop", True )
self.showtrash = self.gconf.get( "bool", "show_trash", True )
# Get paths for custom items
self.custompaths = self.gconf.get( "list-string", "custom_paths", [ ] )
# Get names for custom items
self.customnames = self.gconf.get( "list-string", "custom_names", [ ] )
# Hide vertical dotted separator self.width = self.gconf.get( "int", "width", 200 )
self.hideseparator = self.gconf.get( "bool", "hide_separator", False ) self.allowScrollbar = self.gconf.get( "bool", "allowScrollbar", False)
# Plugin icon self.scrolledWindow.set_policy( gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC )
self.icon = self.gconf.get( "string", 'icon', "gnome-fs-directory.png" ) self.height = self.gconf.get( "int", "height", 180 )
# Allow plugin to be minimized to the left plugin pane self.content_holder.set_size_request( self.width, self.height )
self.sticky = self.gconf.get( "bool", "sticky", False ) if (self.allowScrollbar == False):
self.minimized = self.gconf.get( "bool", "minimized", False ) self.height = -1
self.scrolledWindow.set_policy( gtk.POLICY_AUTOMATIC, gtk.POLICY_NEVER )
self.content_holder.set_size_request( self.width, self.height )
self.execapp = self.gconf.get( "string", "execute_app", "nautilus" )
self.iconsize = self.gconf.get( "int","icon_size", 2 )
def ClearAll(self): # Check default items
for child in self.placesBtnHolder.get_children():
child.destroy()
for child in self.editableBtnHolder.get_children():
child.destroy()
#Add standard places self.showcomputer = self.gconf.get( "bool", "show_computer", True )
def do_standard_places( self ): self.showhomefolder = self.gconf.get( "bool", "show_home_folder", True )
self.shownetwork = self.gconf.get( "bool", "show_network", True )
self.showdesktop = self.gconf.get( "bool", "show_desktop", True )
self.showtrash = self.gconf.get( "bool", "show_trash", True )
if ( self.showcomputer == True ): # Get paths for custom items
Button1 = easyButton( "computer", self.iconsize, [_("Computer")], -1, -1 )
Button1.connect( "clicked", self.ButtonClicked, "nautilus computer:" )
Button1.show()
self.placesBtnHolder.pack_start( Button1, False, False )
self.mintMenuWin.setTooltip( Button1, _("Browse all local and remote disks and folders accessible from this computer") )
if ( self.showhomefolder == True ): self.custompaths = self.gconf.get( "list-string", "custom_paths", [ ] )
Button2 = easyButton( "user-home", self.iconsize, [_("Home Folder")], -1, -1 )
Button2.connect( "clicked", self.ButtonClicked, "nautilus" )
Button2.show()
self.placesBtnHolder.pack_start( Button2, False, False )
self.mintMenuWin.setTooltip( Button2, _("Open your personal folder") )
if ( self.shownetwork == True ): # Get names for custom items
Button3 = easyButton( "network-workgroup", self.iconsize, [_("Network")], -1, -1 )
Button3.connect( "clicked", self.ButtonClicked, "nautilus network:" )
Button3.show()
self.placesBtnHolder.pack_start( Button3, False, False )
self.mintMenuWin.setTooltip( Button3, _("Browse bookmarked and local network locations") )
if ( self.showdesktop == True ):
# Determine where the Desktop folder is (could be localized)
desktopDir = home + "/Desktop"
try:
import sys
sys.path.append('/usr/lib/linuxmint/common')
from configobj import ConfigObj
config = ConfigObj(home + "/.config/user-dirs.dirs")
tmpdesktopDir = config['XDG_DESKTOP_DIR']
tmpdesktopDir = commands.getoutput("echo " + tmpdesktopDir)
if os.path.exists(tmpdesktopDir):
desktopDir = tmpdesktopDir
except Exception, detail:
print detail
Button4 = easyButton( "gnome-fs-desktop", self.iconsize, [_("Desktop")], -1, -1 )
Button4.connect( "clicked", self.ButtonClicked, "nautilus \"" + desktopDir + "\"")
Button4.show()
self.placesBtnHolder.pack_start( Button4, False, False )
self.mintMenuWin.setTooltip( Button4, _("Browse items placed on the desktop") )
if ( self.showtrash == True ): self.customnames = self.gconf.get( "list-string", "custom_names", [ ] )
self.trashButton = easyButton( "user-trash", self.iconsize, [_("Trash")], -1, -1 )
self.trashButton.connect( "clicked", self.ButtonClicked, "nautilus trash:" )
self.trashButton.show()
self.trashButton.connect( "button-release-event", self.trashPopup )
self.refreshTrash()
self.placesBtnHolder.pack_start( self.trashButton, False, False )
self.mintMenuWin.setTooltip( self.trashButton, _("Browse deleted files") )
def do_custom_places( self ):
for index in range( len(self.custompaths) ):
path = self.custompaths[index]
path = path.replace("~", home)
command = ( "nautilus \"" + path + "\"")
currentbutton = easyButton( "folder", self.iconsize, [self.customnames[index]], -1, -1 )
currentbutton.connect( "clicked", self.ButtonClicked, command )
currentbutton.show()
self.placesBtnHolder.pack_start( currentbutton, False, False )
def trashPopup( self, widget, event ): # Hide vertical dotted separator
if event.button == 3: self.hideseparator = self.gconf.get( "bool", "hide_separator", False )
trashMenu = gtk.Menu() # Plugin icon
emptyTrashMenuItem = gtk.MenuItem(_("Empty trash")) self.icon = self.gconf.get( "string", 'icon', "gnome-fs-directory.png" )
trashMenu.append(emptyTrashMenuItem) # Allow plugin to be minimized to the left plugin pane
trashMenu.show_all() self.sticky = self.gconf.get( "bool", "sticky", False )
emptyTrashMenuItem.connect ( "activate", self.emptyTrash, widget ) self.minimized = self.gconf.get( "bool", "minimized", False )
trashMenu.popup( None, None, None, event.button, event.time )
def emptyTrash( self, menu, widget): def ClearAll(self):
os.system("rm -rf " + home + "/.local/share/Trash/info/*") for child in self.placesBtnHolder.get_children():
os.system("rm -rf " + home + "/.local/share/Trash/files/*") child.destroy()
self.trashButton.setIcon("user-trash") for child in self.editableBtnHolder.get_children():
child.destroy()
def ButtonClicked( self, widget, Exec ): #Add standard places
self.mintMenuWin.hide() def do_standard_places( self ):
if Exec:
Execute( Exec )
def do_plugin( self ): if ( self.showcomputer == True ):
self.do_standard_places() Button1 = easyButton( "computer", self.iconsize, [_("Computer")], -1, -1 )
self.do_custom_places() Button1.connect( "clicked", self.ButtonClicked, "nautilus computer:" )
Button1.show()
self.placesBtnHolder.pack_start( Button1, False, False )
self.mintMenuWin.setTooltip( Button1, _("Browse all local and remote disks and folders accessible from this computer") )
def refreshTrash (self): if ( self.showhomefolder == True ):
iconName = "user-trash" Button2 = easyButton( "user-home", self.iconsize, [_("Home Folder")], -1, -1 )
if (os.path.exists(home + "/.local/share/Trash/info")): Button2.connect( "clicked", self.ButtonClicked, "nautilus" )
infoFiles = commands.getoutput("ls " + home + "/.local/share/Trash/info/ | wc -l") Button2.show()
if (int(infoFiles) > 0): self.placesBtnHolder.pack_start( Button2, False, False )
iconName = "user-trash-full" self.mintMenuWin.setTooltip( Button2, _("Open your personal folder") )
self.trashButton.setIcon(iconName)
if ( self.shownetwork == True ):
Button3 = easyButton( "network-workgroup", self.iconsize, [_("Network")], -1, -1 )
Button3.connect( "clicked", self.ButtonClicked, "nautilus network:" )
Button3.show()
self.placesBtnHolder.pack_start( Button3, False, False )
self.mintMenuWin.setTooltip( Button3, _("Browse bookmarked and local network locations") )
if ( self.showdesktop == True ):
# Determine where the Desktop folder is (could be localized)
desktopDir = home + "/Desktop"
try:
import sys
sys.path.append('/usr/lib/linuxmint/common')
from configobj import ConfigObj
config = ConfigObj(home + "/.config/user-dirs.dirs")
tmpdesktopDir = config['XDG_DESKTOP_DIR']
tmpdesktopDir = commands.getoutput("echo " + tmpdesktopDir)
if os.path.exists(tmpdesktopDir):
desktopDir = tmpdesktopDir
except Exception, detail:
print detail
Button4 = easyButton( "gnome-fs-desktop", self.iconsize, [_("Desktop")], -1, -1 )
Button4.connect( "clicked", self.ButtonClicked, "nautilus \"" + desktopDir + "\"")
Button4.show()
self.placesBtnHolder.pack_start( Button4, False, False )
self.mintMenuWin.setTooltip( Button4, _("Browse items placed on the desktop") )
if ( self.showtrash == True ):
self.trashButton = easyButton( "user-trash", self.iconsize, [_("Trash")], -1, -1 )
self.trashButton.connect( "clicked", self.ButtonClicked, "nautilus trash:" )
self.trashButton.show()
self.trashButton.connect( "button-release-event", self.trashPopup )
self.refreshTrash()
self.placesBtnHolder.pack_start( self.trashButton, False, False )
self.mintMenuWin.setTooltip( self.trashButton, _("Browse deleted files") )
def do_custom_places( self ):
for index in range( len(self.custompaths) ):
path = self.custompaths[index]
path = path.replace("~", home)
command = ( "nautilus \"" + path + "\"")
currentbutton = easyButton( "folder", self.iconsize, [self.customnames[index]], -1, -1 )
currentbutton.connect( "clicked", self.ButtonClicked, command )
currentbutton.show()
self.placesBtnHolder.pack_start( currentbutton, False, False )
def trashPopup( self, widget, event ):
if event.button == 3:
trashMenu = gtk.Menu()
emptyTrashMenuItem = gtk.MenuItem(_("Empty trash"))
trashMenu.append(emptyTrashMenuItem)
trashMenu.show_all()
emptyTrashMenuItem.connect ( "activate", self.emptyTrash, widget )
trashMenu.popup( None, None, None, event.button, event.time )
self.mintMenuWin.grab()
def emptyTrash( self, menu, widget):
os.system("rm -rf " + home + "/.local/share/Trash/info/*")
os.system("rm -rf " + home + "/.local/share/Trash/files/*")
self.trashButton.setIcon("user-trash")
def ButtonClicked( self, widget, Exec ):
self.mintMenuWin.hide()
if Exec:
Execute( Exec )
def do_plugin( self ):
self.do_standard_places()
self.do_custom_places()
def refreshTrash (self):
iconName = "user-trash"
if (os.path.exists(home + "/.local/share/Trash/info")):
infoFiles = commands.getoutput("ls " + home + "/.local/share/Trash/info/ | wc -l")
if (int(infoFiles) > 0):
iconName = "user-trash-full"
self.trashButton.setIcon(iconName)