Fixed indentation and trailing spaces

This commit is contained in:
Clement Lefebvre 2016-05-21 17:11:36 +01:00
parent 048d0c386c
commit 877ce3640b
10 changed files with 251 additions and 361 deletions

View File

@ -2,7 +2,7 @@
import gi import gi
gi.require_version("Gtk", "2.0") gi.require_version("Gtk", "2.0")
from gi.repository import Gtk, GdkPixbuf, Gdk, GObject from gi.repository import Gtk, GdkPixbuf, Gdk, GObject
from gi.repository import MatePanelApplet from gi.repository import MatePanelApplet
from gi.repository import Gio from gi.repository import Gio
@ -61,7 +61,7 @@ class MainWindow( object ):
"""This is the main class for the application""" """This is the main class for the application"""
def __init__( self, toggleButton, settings, keybinder ): def __init__( self, toggleButton, settings, keybinder ):
self.settings = settings self.settings = settings
self.keybinder = keybinder self.keybinder = keybinder
self.path = PATH self.path = PATH
@ -72,7 +72,7 @@ class MainWindow( object ):
self.icon = "/usr/lib/linuxmint/mintMenu/visualisation-logo.png" self.icon = "/usr/lib/linuxmint/mintMenu/visualisation-logo.png"
self.toggle = toggleButton self.toggle = toggleButton
# Load UI file and extract widgets # Load UI file and extract widgets
builder = Gtk.Builder() builder = Gtk.Builder()
builder.add_from_file(os.path.join( self.path, "mintMenu.glade" )) builder.add_from_file(os.path.join( self.path, "mintMenu.glade" ))
self.window = builder.get_object( "mainWindow" ) self.window = builder.get_object( "mainWindow" )
@ -81,7 +81,7 @@ class MainWindow( object ):
self.window.set_title("") self.window.set_title("")
self.paneholder = builder.get_object( "paneholder" ) self.paneholder = builder.get_object( "paneholder" )
self.border = builder.get_object( "border" ) self.border = builder.get_object( "border" )
builder.connect_signals(self) builder.connect_signals(self)
self.panesToColor = [ ] self.panesToColor = [ ]
@ -109,7 +109,7 @@ class MainWindow( object ):
self.settings.connect( "changed::custom-color", self.toggleCustomBackgroundColor ) self.settings.connect( "changed::custom-color", self.toggleCustomBackgroundColor )
self.settings.connect( "changed::border-width", self.toggleBorderWidth ) self.settings.connect( "changed::border-width", self.toggleBorderWidth )
self.settings.connect( "changed::opacity", self.toggleOpacity ) self.settings.connect( "changed::opacity", self.toggleOpacity )
self.getSetGSettingEntries() self.getSetGSettingEntries()
self.tooltips = Gtk.Tooltips() self.tooltips = Gtk.Tooltips()
@ -117,7 +117,7 @@ class MainWindow( object ):
self.tooltips.enable() self.tooltips.enable()
else: else:
self.tooltips.disable() self.tooltips.disable()
self.PopulatePlugins(); self.PopulatePlugins();
self.firstTime = True; self.firstTime = True;
@ -169,7 +169,7 @@ class MainWindow( object ):
self.customheadingcolor = settings.get_string(key) self.customheadingcolor = settings.get_string(key)
self.SetHeadingStyle( self.headingsToColor ) self.SetHeadingStyle( self.headingsToColor )
def getSetGSettingEntries( self ): def getSetGSettingEntries( self ):
self.dottedfile = os.path.join( self.path, "dotted.png") self.dottedfile = os.path.join( self.path, "dotted.png")
self.pluginlist = self.settings.get_strv( "plugins-list" ) self.pluginlist = self.settings.get_strv( "plugins-list" )
@ -179,10 +179,10 @@ class MainWindow( object ):
self.custombordercolor = self.settings.get_string( "custom-border-color" ) self.custombordercolor = self.settings.get_string( "custom-border-color" )
self.borderwidth = self.settings.get_int( "border-width" ) self.borderwidth = self.settings.get_int( "border-width" )
self.opacity = self.settings.get_int( "opacity" ) self.opacity = self.settings.get_int( "opacity" )
self.offset = self.settings.get_int( "offset" ) self.offset = self.settings.get_int( "offset" )
self.enableTooltips = self.settings.get_boolean( "tooltips-enabled" ) self.enableTooltips = self.settings.get_boolean( "tooltips-enabled" )
self.startWithFavorites = self.settings.get_boolean( "start-with-favorites" ) self.startWithFavorites = self.settings.get_boolean( "start-with-favorites" )
self.globalEnableTooltips = self.panelSettings.get_boolean( "tooltips-enabled" ) self.globalEnableTooltips = self.panelSettings.get_boolean( "tooltips-enabled" )
def SetupMintMenuBorder( self, defaultStyle = None ): def SetupMintMenuBorder( self, defaultStyle = None ):
@ -190,14 +190,14 @@ class MainWindow( object ):
self.window.modify_bg( Gtk.StateType.NORMAL, Gdk.color_parse( self.custombordercolor ) ) self.window.modify_bg( Gtk.StateType.NORMAL, Gdk.color_parse( self.custombordercolor ) )
elif defaultStyle is not None: elif defaultStyle is not None:
self.window.modify_bg( Gtk.StateType.NORMAL, defaultStyle.lookup_color('bg_color')[1] ) self.window.modify_bg( Gtk.StateType.NORMAL, defaultStyle.lookup_color('bg_color')[1] )
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 ):
print "Opacity is: " + str(self.opacity) print "Opacity is: " + str(self.opacity)
opacity = float(self.opacity) / float(100) opacity = float(self.opacity) / float(100)
print "Setting opacity to: " + str(opacity) print "Setting opacity to: " + str(opacity)
self.window.set_opacity(opacity) self.window.set_opacity(opacity)
def detect_desktop_environment (self): def detect_desktop_environment (self):
self.de = "mate" self.de = "mate"
try: try:
@ -228,7 +228,7 @@ class MainWindow( object ):
self.plugins = {} self.plugins = {}
for plugin in self.pluginlist: for plugin in self.pluginlist:
if plugin in self.plugins: if plugin in self.plugins:
print u"Duplicate plugin in list: ", plugin print u"Duplicate plugin in list: ", plugin
continue continue
@ -280,7 +280,7 @@ class MainWindow( object ):
MyPlugin.content_holder.show() MyPlugin.content_holder.show()
VBox1 = Gtk.VBox( False, 0 ) VBox1 = Gtk.VBox( False, 0 )
if MyPlugin.heading != "": if MyPlugin.heading != "":
Label1 = Gtk.Label(label= MyPlugin.heading ) Label1 = Gtk.Label(label= MyPlugin.heading )
Align1 = Gtk.Alignment.new( 0, 0, 0, 0 ) Align1 = Gtk.Alignment.new( 0, 0, 0, 0 )
Align1.set_padding( 10, 5, 10, 0 ) Align1.set_padding( 10, 5, 10, 0 )
@ -303,7 +303,7 @@ class MainWindow( object ):
heading.add( Align1 ) heading.add( Align1 )
heading.show() heading.show()
VBox1.pack_start( heading, False, False, 0 ) VBox1.pack_start( heading, False, False, 0 )
VBox1.show() VBox1.show()
#Add plugin to Plugin Box under heading button #Add plugin to Plugin Box under heading button
MyPlugin.content_holder.reparent( VBox1 ) MyPlugin.content_holder.reparent( VBox1 )
@ -351,7 +351,7 @@ class MainWindow( object ):
Image1.set_from_pixbuf( seperatorImage ) Image1.set_from_pixbuf( seperatorImage )
Image1.show() Image1.show()
#ImageBox.add( Image1 ) #ImageBox.add( Image1 )
Align1 = Gtk.Alignment.new(0, 0, 0, 0) Align1 = Gtk.Alignment.new(0, 0, 0, 0)
Align1.set_padding( 0, 0, 6, 6 ) Align1.set_padding( 0, 0, 6, 6 )
Align1.add(Image1) Align1.add(Image1)
@ -369,13 +369,13 @@ class MainWindow( object ):
widget = Gtk.EventBox() widget = Gtk.EventBox()
widget.show() widget.show()
return Gtk.rc_get_style(widget) return Gtk.rc_get_style(widget)
def loadTheme( self ): def loadTheme( self ):
defaultStyle = self.getDefaultStyle() defaultStyle = self.getDefaultStyle()
self.SetPaneColors( self.panesToColor, defaultStyle ) self.SetPaneColors( self.panesToColor, defaultStyle )
self.SetupMintMenuBorder( defaultStyle ) self.SetupMintMenuBorder( defaultStyle )
self.SetHeadingStyle( self.headingsToColor ) self.SetHeadingStyle( self.headingsToColor )
def SetPaneColors( self, items, defaultStyle = None ): def SetPaneColors( self, items, defaultStyle = None ):
if self.usecustomcolor: if self.usecustomcolor:
for item in items: for item in items:
@ -419,7 +419,7 @@ class MainWindow( object ):
del plugin del plugin
except: except:
pass pass
try: try:
del self.plugins del self.plugins
except: except:
@ -441,14 +441,14 @@ class MainWindow( object ):
def show( self ): def show( self ):
self.window.present() self.window.present()
# Hack for opacity not showing on first composited draw # Hack for opacity not showing on first composited draw
if self.firstTime: if self.firstTime:
self.firstTime = False self.firstTime = False
self.SetupMintMenuOpacity() self.SetupMintMenuOpacity()
self.window.window.focus( Gdk.CURRENT_TIME ) self.window.window.focus( Gdk.CURRENT_TIME )
for plugin in self.plugins.values(): for plugin in self.plugins.values():
if hasattr( plugin, "onShowMenu" ): if hasattr( plugin, "onShowMenu" ):
plugin.onShowMenu() plugin.onShowMenu()
@ -462,21 +462,21 @@ class MainWindow( object ):
for plugin in self.plugins.values(): for plugin in self.plugins.values():
if hasattr( plugin, "onHideMenu" ): if hasattr( plugin, "onHideMenu" ):
plugin.onHideMenu() plugin.onHideMenu()
self.window.hide() self.window.hide()
def onFocusIn( self, *args ): def onFocusIn( self, *args ):
if self.loseFocusBlocked: if self.loseFocusBlocked:
self.window.handler_unblock( self.loseFocusId ) self.window.handler_unblock( self.loseFocusId )
self.loseFocusBlocked = False self.loseFocusBlocked = False
return False return False
def onFocusOut( self, *args): def onFocusOut( self, *args):
if self.window.get_visible(): if self.window.get_visible():
self.hide() self.hide()
return False return False
def stopHiding( self ): def stopHiding( self ):
if not self.loseFocusBlocked: if not self.loseFocusBlocked:
self.window.handler_block( self.loseFocusId ) self.window.handler_block( self.loseFocusId )
@ -484,7 +484,7 @@ class MainWindow( object ):
class MenuWin( object ): class MenuWin( object ):
def __init__( self, applet, iid ): def __init__( self, applet, iid ):
self.applet = applet self.applet = applet
self.settings = Gio.Settings.new("com.linuxmint.mintmenu") self.settings = Gio.Settings.new("com.linuxmint.mintmenu")
self.keybinder = keybinding.GlobalKeyBinding() self.keybinder = keybinding.GlobalKeyBinding()
self.settings.connect( "changed::applet-text", self.reloadSettings ) self.settings.connect( "changed::applet-text", self.reloadSettings )
@ -503,7 +503,7 @@ class MenuWin( object ):
self.applet.set_flags( MatePanelApplet.AppletFlags.EXPAND_MINOR ) self.applet.set_flags( MatePanelApplet.AppletFlags.EXPAND_MINOR )
self.applet.connect( "button-press-event", self.showMenu ) self.applet.connect( "button-press-event", self.showMenu )
self.applet.connect( "change-orient", self.changeOrientation ) self.applet.connect( "change-orient", self.changeOrientation )
self.applet.connect("enter-notify-event", self.enter_notify) self.applet.connect("enter-notify-event", self.enter_notify)
self.applet.connect("leave-notify-event", self.leave_notify) self.applet.connect("leave-notify-event", self.leave_notify)
self.mainwin = MainWindow( self.button_box, self.settings, self.keybinder ) self.mainwin = MainWindow( self.button_box, self.settings, self.keybinder )
@ -524,25 +524,25 @@ class MenuWin( object ):
self.pointerMonitor = pointerMonitor.PointerMonitor() self.pointerMonitor = pointerMonitor.PointerMonitor()
self.pointerMonitor.connect("activate", self.onPointerOutside) self.pointerMonitor.connect("activate", self.onPointerOutside)
def onWindowMap( self, *args ): def onWindowMap( self, *args ):
self.applet.set_state( Gtk.StateType.SELECTED ) self.applet.set_state( Gtk.StateType.SELECTED )
self.keybinder.set_focus_window( self.mainwin.window.window ) self.keybinder.set_focus_window( self.mainwin.window.window )
#self.pointerMonitor.grabPointer() #self.pointerMonitor.grabPointer()
return False return False
def onWindowUnmap( self, *args ): def onWindowUnmap( self, *args ):
self.applet.set_state( Gtk.StateType.NORMAL ) self.applet.set_state( Gtk.StateType.NORMAL )
self.keybinder.set_focus_window() self.keybinder.set_focus_window()
#self.pointerMonitor.ungrabPointer() #self.pointerMonitor.ungrabPointer()
return False return False
def onRealize( self, *args): def onRealize( self, *args):
self.pointerMonitor.addWindowToMonitor( self.mainwin.window.window ) self.pointerMonitor.addWindowToMonitor( self.mainwin.window.window )
self.pointerMonitor.addWindowToMonitor( self.applet.window ) self.pointerMonitor.addWindowToMonitor( self.applet.window )
self.pointerMonitor.start() self.pointerMonitor.start()
return False return False
def onPointerOutside(self, *args): def onPointerOutside(self, *args):
self.mainwin.hide() self.mainwin.hide()
return True return True
@ -555,11 +555,11 @@ class MenuWin( object ):
self.do_image(self.buttonIcon, True) self.do_image(self.buttonIcon, True)
def leave_notify(self, applet, event): def leave_notify(self, applet, event):
# Hack for mate-panel-test-applets focus issue (this can be commented) # Hack for mate-panel-test-applets focus issue (this can be commented)
if event.state & Gdk.ModifierType.BUTTON1_MASK and applet.state & Gtk.StateType.SELECTED: if event.state & Gdk.ModifierType.BUTTON1_MASK and applet.state & Gtk.StateType.SELECTED:
if event.x >= 0 and event.y >= 0 and event.x < applet.window.get_width() and event.y < applet.window.get_height(): if event.x >= 0 and event.y >= 0 and event.x < applet.window.get_width() and event.y < applet.window.get_height():
self.mainwin.stopHiding() self.mainwin.stopHiding()
self.do_image(self.buttonIcon, False) self.do_image(self.buttonIcon, False)
def do_image(self, image_file, saturate): def do_image(self, image_file, saturate):
@ -598,7 +598,7 @@ class MenuWin( object ):
self.button_box.pack_start( self.button_icon , False, False, 0) self.button_box.pack_start( self.button_icon , False, False, 0)
self.button_icon.set_padding( 0, 5 ) self.button_icon.set_padding( 0, 5 )
self.button_box.set_homogeneous( False ) self.button_box.set_homogeneous( False )
self.button_box.show_all() self.button_box.show_all()
self.sizeButton() self.sizeButton()
@ -613,23 +613,23 @@ class MenuWin( object ):
self.theme_name = self.settings.get_string( "theme-name" ) self.theme_name = self.settings.get_string( "theme-name" )
self.hotkeyText = self.settings.get_string( "hot-key" ) self.hotkeyText = self.settings.get_string( "hot-key" )
self.buttonIcon = self.settings.get_string( "applet-icon" ) self.buttonIcon = self.settings.get_string( "applet-icon" )
self.iconSize = self.settings.get_int( "applet-icon-size" ) self.iconSize = self.settings.get_int( "applet-icon-size" )
def changeTheme(self, *args): def changeTheme(self, *args):
self.reloadSettings() self.reloadSettings()
self.applyTheme() self.applyTheme()
self.mainwin.loadTheme() self.mainwin.loadTheme()
def applyTheme(self): def applyTheme(self):
style_settings = Gtk.Settings.get_default() style_settings = Gtk.Settings.get_default()
desktop_theme = self.mate_settings.get_string('gtk-theme') desktop_theme = self.mate_settings.get_string('gtk-theme')
if self.theme_name == "default": if self.theme_name == "default":
style_settings.set_property("gtk-theme-name", desktop_theme) style_settings.set_property("gtk-theme-name", desktop_theme)
else: else:
try: try:
style_settings.set_property("gtk-theme-name", self.theme_name) style_settings.set_property("gtk-theme-name", self.theme_name)
except: except:
style_settings.set_property("gtk-theme-name", desktop_theme) style_settings.set_property("gtk-theme-name", desktop_theme)
def changeOrientation( self, *args, **kargs ): def changeOrientation( self, *args, **kargs ):
@ -679,7 +679,7 @@ class MenuWin( object ):
self.keybinder.start() self.keybinder.start()
# Binding menu to hotkey # Binding menu to hotkey
print "Binding to Hot Key: " + self.hotkeyText print "Binding to Hot Key: " + self.hotkeyText
except Exception, cause: except Exception, cause:
print "** WARNING ** - Menu Hotkey Binding Error" print "** WARNING ** - Menu Hotkey Binding Error"
print "Error Report :\n", str(cause) print "Error Report :\n", str(cause)
@ -713,7 +713,7 @@ class MenuWin( object ):
def reloadSettings( self, *args ): def reloadSettings( self, *args ):
self.loadSettings() self.loadSettings()
self.updateButton() self.updateButton()
def showAboutDialog( self, action, userdata = None ): def showAboutDialog( self, action, userdata = None ):
@ -849,4 +849,4 @@ def quit_all(widget):
MatePanelApplet.Applet.factory_main("MintMenuAppletFactory", True, MatePanelApplet.Applet.factory_main("MintMenuAppletFactory", True,
MatePanelApplet.Applet.__gtype__, MatePanelApplet.Applet.__gtype__,
applet_factory, None) applet_factory, None)

View File

@ -166,8 +166,8 @@ class Menu:
class SuggestionButton ( Gtk.Button ): class SuggestionButton ( Gtk.Button ):
def __init__( self, iconName, iconSize, label ): def __init__( self, iconName, iconSize, label ):
Gtk.Button.__init__( self ) Gtk.Button.__init__( self )
self.iconName = iconName self.iconName = iconName
self.set_relief( Gtk.ReliefStyle.NONE ) self.set_relief( Gtk.ReliefStyle.NONE )
self.set_size_request( -1, -1 ) self.set_size_request( -1, -1 )
@ -191,14 +191,14 @@ class SuggestionButton ( Gtk.Button ):
Align1.show() Align1.show()
self.add( Align1 ) self.add( Align1 )
self.show() self.show()
def set_image(self, path): def set_image(self, path):
self.image.set_from_file(path) self.image.set_from_file(path)
def set_text( self, text): def set_text( self, text):
self.label.set_markup(text) self.label.set_markup(text)
def set_icon_size (self, size): def set_icon_size (self, size):
self.image.set_from_stock( self.iconName, size ) self.image.set_from_stock( self.iconName, size )
class TargetEntry(Structure): class TargetEntry(Structure):
@ -224,7 +224,7 @@ class pluginclass( object ):
self.toggleButton = toggleButton self.toggleButton = toggleButton
self.de = de self.de = de
self.builder = Gtk.Builder() self.builder = Gtk.Builder()
# The Glade file for the plugin # The Glade file for the plugin
self.builder.add_from_file (os.path.join( os.path.dirname( __file__ ), "applications.glade" )) self.builder.add_from_file (os.path.join( os.path.dirname( __file__ ), "applications.glade" ))
@ -245,8 +245,8 @@ class pluginclass( object ):
self.builder.get_object("label6").set_text(_("Favorites")) self.builder.get_object("label6").set_text(_("Favorites"))
self.builder.get_object("label3").set_text(_("Favorites")) self.builder.get_object("label3").set_text(_("Favorites"))
self.builder.get_object("label7").set_text(_("All applications")) self.builder.get_object("label7").set_text(_("All applications"))
self.builder.get_object("label2").set_text(_("Applications")) self.builder.get_object("label2").set_text(_("Applications"))
self.headingstocolor = [self.builder.get_object("label6"),self.builder.get_object("label2")] self.headingstocolor = [self.builder.get_object("label6"),self.builder.get_object("label2")]
self.numApps = 0 self.numApps = 0
@ -329,8 +329,8 @@ class pluginclass( object ):
# self.menuFileMonitors.append( filemonitor.addMonitor(f, self.onMenuChanged, mymenu.directory.Filename ) ) # self.menuFileMonitors.append( filemonitor.addMonitor(f, self.onMenuChanged, mymenu.directory.Filename ) )
#for f in mymenu.directory.AppDirs: #for f in mymenu.directory.AppDirs:
# self.menuFileMonitors.append( filemonitor.addMonitor(f, self.onMenuChanged, mymenu.directory.Filename ) ) # self.menuFileMonitors.append( filemonitor.addMonitor(f, self.onMenuChanged, mymenu.directory.Filename ) )
self.refresh_apt_cache() self.refresh_apt_cache()
self.suggestions = [] self.suggestions = []
self.current_suggestion = None self.current_suggestion = None
self.panel = "top" self.panel = "top"
@ -341,7 +341,7 @@ class pluginclass( object ):
def refresh_apt_cache(self): def refresh_apt_cache(self):
if self.useAPT: if self.useAPT:
os.system("mkdir -p %s/.linuxmint/mintMenu/" % home) os.system("mkdir -p %s/.linuxmint/mintMenu/" % home)
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):
panelsettings = Gio.Settings.new("org.mate.panel") panelsettings = Gio.Settings.new("org.mate.panel")
@ -356,12 +356,12 @@ class pluginclass( object ):
self.panel_position = object_schema.get_int("position") + 1 self.panel_position = object_schema.get_int("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"):
os.system("/usr/bin/apturl apt://%s &" % pkg_name) os.system("/usr/bin/apturl apt://%s &" % pkg_name)
else: else:
os.system("xdg-open apt://" + pkg_name + " &") os.system("xdg-open apt://" + pkg_name + " &")
self.mintMenuWin.hide() self.mintMenuWin.hide()
def __del__( self ): def __del__( self ):
print u"Applications plugin deleted" print u"Applications plugin deleted"
@ -426,7 +426,7 @@ class pluginclass( object ):
try: try:
child.setIconSize( self.iconSize ) child.setIconSize( self.iconSize )
except: except:
pass pass
def changeFavIconSize( self, settings, key, args ): def changeFavIconSize( self, settings, key, args ):
self.faviconsize = settings.get_int(key) self.faviconsize = settings.get_int(key)
@ -434,7 +434,7 @@ class pluginclass( object ):
for child in self.favoritesBox: for child in self.favoritesBox:
if isinstance( child, FavApplicationLauncher): if isinstance( child, FavApplicationLauncher):
child.setIconSize( self.faviconsize ) child.setIconSize( self.faviconsize )
def switchAPTUsage( self, settings, key, args ): def switchAPTUsage( self, settings, key, args ):
self.useAPT = settings.get_boolean(key) self.useAPT = settings.get_boolean(key)
self.refresh_apt_cache() self.refresh_apt_cache()
@ -465,9 +465,9 @@ class pluginclass( object ):
self.favoritesBox.remove( fav ) self.favoritesBox.remove( fav )
self.favoritesPositionOnGrid( fav ) self.favoritesPositionOnGrid( fav )
def RegenPlugin( self, *args, **kargs ): def RegenPlugin( self, *args, **kargs ):
self.refresh_apt_cache() self.refresh_apt_cache()
# save old config - this is necessary because the app will notified when it sets the default values and you don't want the to reload itself several times # save old config - this is necessary because the app will notified when it sets the default values and you don't want the to reload itself several times
oldcategories_mouse_over = self.categories_mouse_over oldcategories_mouse_over = self.categories_mouse_over
oldiconsize = self.iconSize oldiconsize = self.iconSize
@ -582,11 +582,11 @@ class pluginclass( object ):
self.showAllAppsButton.connect( "clicked", lambda widget: self.changeTab( 1 ) ) self.showAllAppsButton.connect( "clicked", lambda widget: self.changeTab( 1 ) )
self.showFavoritesButton.connect( "clicked", lambda widget: self.changeTab( 0 ) ) self.showFavoritesButton.connect( "clicked", lambda widget: self.changeTab( 0 ) )
self.buildButtonList() self.buildButtonList()
def blockOnPopup( self, *args ): def blockOnPopup( self, *args ):
self.mintMenuWin.stopHiding() self.mintMenuWin.stopHiding()
return False return False
def blockOnRightPress( self, widget, event ): def blockOnRightPress( self, widget, event ):
if event.button == 3: if event.button == 3:
self.mintMenuWin.stopHiding() self.mintMenuWin.stopHiding()
@ -603,7 +603,7 @@ class pluginclass( object ):
else: else:
self.searchEntry.set_text("") self.searchEntry.set_text("")
def buildButtonList( self ): def buildButtonList( self ):
if self.buildingButtonList: if self.buildingButtonList:
self.stopBuildingButtonList = True self.stopBuildingButtonList = True
GLib.timeout_add( 100, self.buildButtonList ) GLib.timeout_add( 100, self.buildButtonList )
@ -629,68 +629,68 @@ class pluginclass( object ):
self.filterTimer = None self.filterTimer = None
def add_search_suggestions(self, text): def add_search_suggestions(self, text):
text = "<b>%s</b>" % text text = "<b>%s</b>" % text
suggestionButton = SuggestionButton(Gtk.STOCK_ADD, self.iconSize, "") suggestionButton = SuggestionButton(Gtk.STOCK_ADD, self.iconSize, "")
suggestionButton.connect("clicked", self.search_google) suggestionButton.connect("clicked", self.search_google)
suggestionButton.set_text(_("Search Google for %s") % text) suggestionButton.set_text(_("Search Google for %s") % text)
suggestionButton.set_image("/usr/lib/linuxmint/mintMenu/search_engines/google.ico") suggestionButton.set_image("/usr/lib/linuxmint/mintMenu/search_engines/google.ico")
self.applicationsBox.add(suggestionButton) self.applicationsBox.add(suggestionButton)
self.suggestions.append(suggestionButton) self.suggestions.append(suggestionButton)
suggestionButton = SuggestionButton(Gtk.STOCK_ADD, self.iconSize, "") suggestionButton = SuggestionButton(Gtk.STOCK_ADD, self.iconSize, "")
suggestionButton.connect("clicked", self.search_wikipedia) suggestionButton.connect("clicked", self.search_wikipedia)
suggestionButton.set_text(_("Search Wikipedia for %s") % text) suggestionButton.set_text(_("Search Wikipedia for %s") % text)
suggestionButton.set_image("/usr/lib/linuxmint/mintMenu/search_engines/wikipedia.ico") suggestionButton.set_image("/usr/lib/linuxmint/mintMenu/search_engines/wikipedia.ico")
self.applicationsBox.add(suggestionButton) self.applicationsBox.add(suggestionButton)
self.suggestions.append(suggestionButton) self.suggestions.append(suggestionButton)
separator = Gtk.EventBox() separator = Gtk.EventBox()
separator.add(Gtk.HSeparator()) separator.add(Gtk.HSeparator())
separator.set_visible_window(False) separator.set_visible_window(False)
separator.set_size_request(-1, 20) separator.set_size_request(-1, 20)
separator.type = "separator" separator.type = "separator"
separator.show_all() separator.show_all()
self.applicationsBox.add(separator) self.applicationsBox.add(separator)
self.suggestions.append(separator) self.suggestions.append(separator)
suggestionButton = SuggestionButton(Gtk.STOCK_ADD, self.iconSize, "") suggestionButton = SuggestionButton(Gtk.STOCK_ADD, self.iconSize, "")
suggestionButton.connect("clicked", self.search_dictionary) suggestionButton.connect("clicked", self.search_dictionary)
suggestionButton.set_text(_("Lookup %s in Dictionary") % text) suggestionButton.set_text(_("Lookup %s in Dictionary") % text)
suggestionButton.set_image("/usr/lib/linuxmint/mintMenu/search_engines/dictionary.png") suggestionButton.set_image("/usr/lib/linuxmint/mintMenu/search_engines/dictionary.png")
self.applicationsBox.add(suggestionButton) self.applicationsBox.add(suggestionButton)
self.suggestions.append(suggestionButton) self.suggestions.append(suggestionButton)
suggestionButton = SuggestionButton(Gtk.STOCK_FIND, self.iconSize, "") suggestionButton = SuggestionButton(Gtk.STOCK_FIND, self.iconSize, "")
suggestionButton.connect("clicked", self.Search) suggestionButton.connect("clicked", self.Search)
suggestionButton.set_text(_("Search Computer for %s") % text) suggestionButton.set_text(_("Search Computer for %s") % text)
self.applicationsBox.add(suggestionButton) self.applicationsBox.add(suggestionButton)
self.suggestions.append(suggestionButton) self.suggestions.append(suggestionButton)
#self.last_separator = gtk.EventBox() #self.last_separator = gtk.EventBox()
#self.last_separator.add(gtk.HSeparator()) #self.last_separator.add(gtk.HSeparator())
#self.last_separator.set_size_request(-1, 20) #self.last_separator.set_size_request(-1, 20)
#self.last_separator.type = "separator" #self.last_separator.type = "separator"
#self.mintMenuWin.SetPaneColors( [ self.last_separator ] ) #self.mintMenuWin.SetPaneColors( [ self.last_separator ] )
#self.last_separator.show_all() #self.last_separator.show_all()
#self.applicationsBox.add(self.last_separator) #self.applicationsBox.add(self.last_separator)
#self.suggestions.append(self.last_separator) #self.suggestions.append(self.last_separator)
def add_apt_filter_results(self, keyword): def add_apt_filter_results(self, keyword):
try: try:
# Wait to see if the keyword has changed.. before doing anything # Wait to see if the keyword has changed.. before doing anything
current_keyword = keyword current_keyword = keyword
current_keyword = self.searchEntry.get_text() current_keyword = self.searchEntry.get_text()
if keyword != current_keyword: if keyword != current_keyword:
return return
found_packages = [] found_packages = []
found_in_name = [] found_in_name = []
found_elsewhere = [] found_elsewhere = []
keywords = keyword.split(" ") keywords = keyword.split(" ")
command = "cat %(home)s/.linuxmint/mintMenu/apt.cache" % {'home':home} command = "cat %(home)s/.linuxmint/mintMenu/apt.cache" % {'home':home}
for word in keywords: for word in keywords:
command = "%(command)s | grep %(word)s" % {'command':command, 'word':word} command = "%(command)s | grep %(word)s" % {'command':command, 'word':word}
pkgs = commands.getoutput(command) pkgs = commands.getoutput(command)
pkgs = pkgs.split("\n") pkgs = pkgs.split("\n")
num_pkg_found = 0 num_pkg_found = 0
@ -715,30 +715,30 @@ class pluginclass( object ):
some_not_found = True some_not_found = True
if some_found and not some_not_found: if some_found and not some_not_found:
found_in_name.append(package) found_in_name.append(package)
else: else:
found_elsewhere.append(package) found_elsewhere.append(package)
num_pkg_found+=1 num_pkg_found+=1
else: else:
print "Invalid status code: " + status print "Invalid status code: " + status
found_packages.extend(found_in_name) found_packages.extend(found_in_name)
found_packages.extend(found_elsewhere) found_packages.extend(found_elsewhere)
if keyword == self.searchEntry.get_text() and len(found_packages) > 0: if keyword == self.searchEntry.get_text() and len(found_packages) > 0:
last_separator = Gtk.EventBox() last_separator = Gtk.EventBox()
last_separator.add(Gtk.HSeparator()) last_separator.add(Gtk.HSeparator())
last_separator.set_visible_window(False) last_separator.set_visible_window(False)
last_separator.set_size_request(-1, 20) last_separator.set_size_request(-1, 20)
last_separator.type = "separator" last_separator.type = "separator"
last_separator.show_all() last_separator.show_all()
self.applicationsBox.add(last_separator) self.applicationsBox.add(last_separator)
self.suggestions.append(last_separator) self.suggestions.append(last_separator)
#Reduce the number of results to 10 max... it takes a HUGE amount of time to add the GTK box in the menu otherwise.. #Reduce the number of results to 10 max... it takes a HUGE amount of time to add the GTK box in the menu otherwise..
if len(found_packages) > 10: if len(found_packages) > 10:
found_packages = found_packages[:10] found_packages = found_packages[:10]
for pkg in found_packages: for pkg in found_packages:
name = pkg.name name = pkg.name
for word in keywords: for word in keywords:
if word != "": if word != "":
name = name.replace(word, "<b>%s</b>" % word); name = name.replace(word, "<b>%s</b>" % word);
suggestionButton = SuggestionButton(Gtk.STOCK_ADD, self.iconSize, "") suggestionButton = SuggestionButton(Gtk.STOCK_ADD, self.iconSize, "")
suggestionButton.connect("clicked", self.apturl_install, pkg.name) suggestionButton.connect("clicked", self.apturl_install, pkg.name)
@ -756,18 +756,18 @@ class pluginclass( object ):
# self.applicationsBox.remove(self.last_separator) # self.applicationsBox.remove(self.last_separator)
# self.suggestions.remove(self.last_separator) # self.suggestions.remove(self.last_separator)
# finally: # finally:
# gtk.gdk.threads_leave() # gtk.gdk.threads_leave()
except Exception, detail: except Exception, detail:
print detail print detail
def add_apt_filter_results_sync(self, cache, keyword): def add_apt_filter_results_sync(self, cache, keyword):
try: try:
found_packages = [] found_packages = []
keywords = keyword.split(" ") keywords = keyword.split(" ")
if cache is not None: if cache is not None:
for pkg in cache: for pkg in cache:
some_found = False some_found = False
some_not_found = False some_not_found = False
for word in keywords: for word in keywords:
@ -776,9 +776,9 @@ class pluginclass( object ):
else: else:
some_not_found = True some_not_found = True
if some_found and not some_not_found: if some_found and not some_not_found:
found_packages.append(pkg) found_packages.append(pkg)
if len(found_packages) > 0: if len(found_packages) > 0:
last_separator = Gtk.EventBox() last_separator = Gtk.EventBox()
last_separator.add(Gtk.HSeparator()) last_separator.add(Gtk.HSeparator())
last_separator.set_visible_window(False) last_separator.set_visible_window(False)
@ -787,11 +787,11 @@ class pluginclass( object ):
last_separator.show_all() last_separator.show_all()
self.applicationsBox.add(last_separator) self.applicationsBox.add(last_separator)
self.suggestions.append(last_separator) self.suggestions.append(last_separator)
for pkg in found_packages: for pkg in found_packages:
name = pkg.name name = pkg.name
for word in keywords: for word in keywords:
if word != "": if word != "":
name = name.replace(word, "<b>%s</b>" % word); name = name.replace(word, "<b>%s</b>" % word);
suggestionButton = SuggestionButton(Gtk.STOCK_ADD, self.iconSize, "") suggestionButton = SuggestionButton(Gtk.STOCK_ADD, self.iconSize, "")
suggestionButton.connect("clicked", self.apturl_install, pkg.name) suggestionButton.connect("clicked", self.apturl_install, pkg.name)
@ -800,24 +800,24 @@ class pluginclass( object ):
suggestionButton.set_icon_size(self.iconSize) suggestionButton.set_icon_size(self.iconSize)
self.applicationsBox.add(suggestionButton) self.applicationsBox.add(suggestionButton)
self.suggestions.append(suggestionButton) self.suggestions.append(suggestionButton)
#if len(found_packages) == 0: #if len(found_packages) == 0:
# self.applicationsBox.remove(self.last_separator) # self.applicationsBox.remove(self.last_separator)
# self.suggestions.remove(self.last_separator) # self.suggestions.remove(self.last_separator)
except Exception, detail: except Exception, detail:
print detail print detail
def Filter( self, widget, category = None ): def Filter( self, widget, category = None ):
self.filterTimer = None self.filterTimer = None
for suggestion in self.suggestions: for suggestion in self.suggestions:
self.applicationsBox.remove(suggestion) self.applicationsBox.remove(suggestion)
self.suggestions = [] self.suggestions = []
if widget == self.searchEntry: if widget == self.searchEntry:
if self.donotfilterapps: if self.donotfilterapps:
widget.set_text( "" ) widget.set_text( "" )
else: else:
text = widget.get_text() text = widget.get_text()
if self.lastActiveTab != 1: if self.lastActiveTab != 1:
@ -844,14 +844,14 @@ class pluginclass( object ):
if (not showns and os.path.exists("/usr/bin/mintinstall")): if (not showns and os.path.exists("/usr/bin/mintinstall")):
if len(text) >= 3: if len(text) >= 3:
if self.current_suggestion is not None and self.current_suggestion in text: if self.current_suggestion is not None and self.current_suggestion in text:
# We're restricting our search... # We're restricting our search...
self.add_search_suggestions(text) self.add_search_suggestions(text)
#if (len(self.current_results) > 0): #if (len(self.current_results) > 0):
#self.add_apt_filter_results_sync(self.current_results, text) #self.add_apt_filter_results_sync(self.current_results, text)
#else: #else:
GLib.timeout_add (300, self.add_apt_filter_results, text) GLib.timeout_add (300, self.add_apt_filter_results, text)
else: else:
self.current_results = [] self.current_results = []
self.add_search_suggestions(text) self.add_search_suggestions(text)
GLib.timeout_add (300, self.add_apt_filter_results, text) GLib.timeout_add (300, self.add_apt_filter_results, text)
@ -889,13 +889,13 @@ class pluginclass( object ):
i.released() i.released()
i.set_relief( Gtk.ReliefStyle.NONE ) i.set_relief( Gtk.ReliefStyle.NONE )
widget.set_relief( Gtk.ReliefStyle.HALF ) widget.set_relief( Gtk.ReliefStyle.HALF )
self.applicationsScrolledWindow.get_vadjustment().set_value( 0 ) self.applicationsScrolledWindow.get_vadjustment().set_value( 0 )
def FilterAndClear( self, widget, category = None ): def FilterAndClear( self, widget, category = None ):
self.searchEntry.set_text( "" ) self.searchEntry.set_text( "" )
self.Filter( widget, category ) self.Filter( widget, category )
# Forward all text to the search box # Forward all text to the search box
def keyPress( self, widget, event ): def keyPress( self, widget, event ):
@ -1058,8 +1058,8 @@ class pluginclass( object ):
gtk.gtk_menu_popup.argtypes = [c_void_p, c_void_p, c_void_p, c_void_p, c_void_p, c_uint, c_uint] gtk.gtk_menu_popup.argtypes = [c_void_p, c_void_p, c_void_p, c_void_p, c_void_p, c_uint, c_uint]
gtk.gtk_menu_popup(hash(mTree), None, None, None, None, event.button, event.time) gtk.gtk_menu_popup(hash(mTree), None, None, None, None, event.button, event.time)
def searchPopup( self, widget=None, event=None ): def searchPopup( self, widget=None, event=None ):
menu = Gtk.Menu() menu = Gtk.Menu()
menuItem = Gtk.ImageMenuItem(_("Search Google")) menuItem = Gtk.ImageMenuItem(_("Search Google"))
@ -1068,69 +1068,69 @@ class pluginclass( object ):
menuItem.set_image(img) menuItem.set_image(img)
menuItem.connect("activate", self.search_google) menuItem.connect("activate", self.search_google)
menu.append(menuItem) menu.append(menuItem)
menuItem = Gtk.ImageMenuItem(_("Search Wikipedia")) menuItem = Gtk.ImageMenuItem(_("Search Wikipedia"))
img = Gtk.Image() img = Gtk.Image()
img.set_from_file('/usr/lib/linuxmint/mintMenu/search_engines/wikipedia.ico') img.set_from_file('/usr/lib/linuxmint/mintMenu/search_engines/wikipedia.ico')
menuItem.set_image(img) menuItem.set_image(img)
menuItem.connect("activate", self.search_wikipedia) menuItem.connect("activate", self.search_wikipedia)
menu.append(menuItem) menu.append(menuItem)
menuItem = Gtk.SeparatorMenuItem() menuItem = Gtk.SeparatorMenuItem()
menu.append(menuItem) menu.append(menuItem)
menuItem = Gtk.ImageMenuItem(_("Lookup Dictionary")) menuItem = Gtk.ImageMenuItem(_("Lookup Dictionary"))
img = Gtk.Image() img = Gtk.Image()
img.set_from_file('/usr/lib/linuxmint/mintMenu/search_engines/dictionary.png') img.set_from_file('/usr/lib/linuxmint/mintMenu/search_engines/dictionary.png')
menuItem.set_image(img) menuItem.set_image(img)
menuItem.connect("activate", self.search_dictionary) menuItem.connect("activate", self.search_dictionary)
menu.append(menuItem) menu.append(menuItem)
menuItem = Gtk.ImageMenuItem(_("Search Computer")) menuItem = Gtk.ImageMenuItem(_("Search Computer"))
img = Gtk.Image() img = Gtk.Image()
img.set_from_stock(Gtk.STOCK_FIND, self.iconSize) img.set_from_stock(Gtk.STOCK_FIND, self.iconSize)
menuItem.set_image(img) menuItem.set_image(img)
menuItem.connect("activate", self.Search) menuItem.connect("activate", self.Search)
menu.append(menuItem) menu.append(menuItem)
menuItem = Gtk.SeparatorMenuItem() menuItem = Gtk.SeparatorMenuItem()
menu.append(menuItem) menu.append(menuItem)
menuItem = Gtk.ImageMenuItem(_("Find Software")) menuItem = Gtk.ImageMenuItem(_("Find Software"))
img = Gtk.Image() img = Gtk.Image()
img.set_from_file('/usr/lib/linuxmint/mintMenu/search_engines/software.png') img.set_from_file('/usr/lib/linuxmint/mintMenu/search_engines/software.png')
menuItem.set_image(img) menuItem.set_image(img)
menuItem.connect("activate", self.search_mint_software) menuItem.connect("activate", self.search_mint_software)
menu.append(menuItem) menu.append(menuItem)
menuItem = Gtk.ImageMenuItem(_("Find Tutorials")) menuItem = Gtk.ImageMenuItem(_("Find Tutorials"))
img = Gtk.Image() img = Gtk.Image()
img.set_from_file('/usr/lib/linuxmint/mintMenu/search_engines/tutorials.png') img.set_from_file('/usr/lib/linuxmint/mintMenu/search_engines/tutorials.png')
menuItem.set_image(img) menuItem.set_image(img)
menuItem.connect("activate", self.search_mint_tutorials) menuItem.connect("activate", self.search_mint_tutorials)
menu.append(menuItem) menu.append(menuItem)
menuItem = Gtk.ImageMenuItem(_("Find Hardware")) menuItem = Gtk.ImageMenuItem(_("Find Hardware"))
img = Gtk.Image() img = Gtk.Image()
img.set_from_file('/usr/lib/linuxmint/mintMenu/search_engines/hardware.png') img.set_from_file('/usr/lib/linuxmint/mintMenu/search_engines/hardware.png')
menuItem.set_image(img) menuItem.set_image(img)
menuItem.connect("activate", self.search_mint_hardware) menuItem.connect("activate", self.search_mint_hardware)
menu.append(menuItem) menu.append(menuItem)
menuItem =Gtk.ImageMenuItem(_("Find Ideas")) menuItem =Gtk.ImageMenuItem(_("Find Ideas"))
img = Gtk.Image() img = Gtk.Image()
img.set_from_file('/usr/lib/linuxmint/mintMenu/search_engines/ideas.png') img.set_from_file('/usr/lib/linuxmint/mintMenu/search_engines/ideas.png')
menuItem.set_image(img) menuItem.set_image(img)
menuItem.connect("activate", self.search_mint_ideas) menuItem.connect("activate", self.search_mint_ideas)
menu.append(menuItem) menu.append(menuItem)
menuItem = Gtk.ImageMenuItem(_("Find Users")) menuItem = Gtk.ImageMenuItem(_("Find Users"))
img = Gtk.Image() img = Gtk.Image()
img.set_from_file('/usr/lib/linuxmint/mintMenu/search_engines/users.png') img.set_from_file('/usr/lib/linuxmint/mintMenu/search_engines/users.png')
menuItem.set_image(img) menuItem.set_image(img)
menuItem.connect("activate", self.search_mint_users) menuItem.connect("activate", self.search_mint_users)
menu.append(menuItem) menu.append(menuItem)
menu.show_all() menu.show_all()
self.mintMenuWin.stopHiding() self.mintMenuWin.stopHiding()
@ -1143,60 +1143,60 @@ class pluginclass( object ):
#self.mintMenuWin.grab() #self.mintMenuWin.grab()
self.focusSearchEntry(clear = False) self.focusSearchEntry(clear = False)
return True return True
def pos_func(self, menu=None): def pos_func(self, menu=None):
rect = self.searchButton.get_allocation() rect = self.searchButton.get_allocation()
x = rect.x + rect.width x = rect.x + rect.width
y = rect.y + rect.height y = rect.y + rect.height
return (x, y, False) return (x, y, False)
def search_google(self, widget): def search_google(self, widget):
text = self.searchEntry.get_text() text = self.searchEntry.get_text()
text = text.replace(" ", "+") text = text.replace(" ", "+")
os.system("xdg-open \"http://www.google.com/cse?cx=002683415331144861350%3Atsq8didf9x0&ie=utf-8&sa=Search&q=" + text + "\" &") os.system("xdg-open \"http://www.google.com/cse?cx=002683415331144861350%3Atsq8didf9x0&ie=utf-8&sa=Search&q=" + text + "\" &")
self.mintMenuWin.hide() self.mintMenuWin.hide()
def search_wikipedia(self, widget): def search_wikipedia(self, widget):
text = self.searchEntry.get_text() text = self.searchEntry.get_text()
text = text.replace(" ", "+") text = text.replace(" ", "+")
os.system("xdg-open \"http://en.wikipedia.org/wiki/Special:Search?search=" + text + "\" &") os.system("xdg-open \"http://en.wikipedia.org/wiki/Special:Search?search=" + text + "\" &")
self.mintMenuWin.hide() self.mintMenuWin.hide()
def search_dictionary(self, widget): def search_dictionary(self, widget):
text = self.searchEntry.get_text() text = self.searchEntry.get_text()
os.system("mate-dictionary \"" + text + "\" &") os.system("mate-dictionary \"" + text + "\" &")
self.mintMenuWin.hide() self.mintMenuWin.hide()
def search_mint_tutorials(self, widget): def search_mint_tutorials(self, widget):
text = self.searchEntry.get_text() text = self.searchEntry.get_text()
text = text.replace(" ", "%20") text = text.replace(" ", "%20")
os.system("xdg-open \"http://community.linuxmint.com/index.php/tutorial/search/0/" + text + "\" &") os.system("xdg-open \"http://community.linuxmint.com/index.php/tutorial/search/0/" + text + "\" &")
self.mintMenuWin.hide() self.mintMenuWin.hide()
def search_mint_ideas(self, widget): def search_mint_ideas(self, widget):
text = self.searchEntry.get_text() text = self.searchEntry.get_text()
text = text.replace(" ", "%20") text = text.replace(" ", "%20")
os.system("xdg-open \"http://community.linuxmint.com/index.php/idea/search/0/" + text + "\" &") os.system("xdg-open \"http://community.linuxmint.com/index.php/idea/search/0/" + text + "\" &")
self.mintMenuWin.hide() self.mintMenuWin.hide()
def search_mint_users(self, widget): def search_mint_users(self, widget):
text = self.searchEntry.get_text() text = self.searchEntry.get_text()
text = text.replace(" ", "%20") text = text.replace(" ", "%20")
os.system("xdg-open \"http://community.linuxmint.com/index.php/user/search/0/" + text + "\" &") os.system("xdg-open \"http://community.linuxmint.com/index.php/user/search/0/" + text + "\" &")
self.mintMenuWin.hide() self.mintMenuWin.hide()
def search_mint_hardware(self, widget): def search_mint_hardware(self, widget):
text = self.searchEntry.get_text() text = self.searchEntry.get_text()
text = text.replace(" ", "%20") text = text.replace(" ", "%20")
os.system("xdg-open \"http://community.linuxmint.com/index.php/hardware/search/0/" + text + "\" &") os.system("xdg-open \"http://community.linuxmint.com/index.php/hardware/search/0/" + text + "\" &")
self.mintMenuWin.hide() self.mintMenuWin.hide()
def search_mint_software(self, widget): def search_mint_software(self, widget):
text = self.searchEntry.get_text() text = self.searchEntry.get_text()
text = text.replace(" ", "%20") text = text.replace(" ", "%20")
os.system("xdg-open \"http://community.linuxmint.com/index.php/software/search/0/" + text + "\" &") os.system("xdg-open \"http://community.linuxmint.com/index.php/software/search/0/" + text + "\" &")
self.mintMenuWin.hide() self.mintMenuWin.hide()
def add_to_desktop(self, widget, desktopEntry): def add_to_desktop(self, widget, desktopEntry):
os.system("xdg-desktop-icon install --novendor %s" % desktopEntry.desktopFile) os.system("xdg-desktop-icon install --novendor %s" % desktopEntry.desktopFile)
@ -1228,7 +1228,7 @@ class pluginclass( object ):
except Exception, detail: except Exception, detail:
print detail print detail
def onLaunchApp( self, menu, widget ): def onLaunchApp( self, menu, widget ):
widget.execute() widget.execute()
self.mintMenuWin.hide() self.mintMenuWin.hide()
@ -1325,7 +1325,7 @@ class pluginclass( object ):
def Search( self, widget ): def Search( self, widget ):
text = self.searchEntry.get_text().strip() text = self.searchEntry.get_text().strip()
if text != "": if text != "":
for app_button in self.applicationsBox.get_children(): for app_button in self.applicationsBox.get_children():
if( isinstance(app_button, ApplicationLauncher) and app_button.filterText( text ) ): if( isinstance(app_button, ApplicationLauncher) and app_button.filterText( text ) ):
app_button.execute() app_button.execute()
@ -1334,14 +1334,14 @@ class pluginclass( object ):
self.mintMenuWin.hide() self.mintMenuWin.hide()
fullstring = self.searchtool.replace( "%s", text ) fullstring = self.searchtool.replace( "%s", text )
os.system(fullstring + " &") os.system(fullstring + " &")
def SearchWithButton( self, widget, event ): def SearchWithButton( self, widget, event ):
self.Search( widget ) self.Search( widget )
def do_plugin( self ): def do_plugin( self ):
self.Todos() self.Todos()
self.buildFavorites() self.buildFavorites()
# Scroll button into view # Scroll button into view
def scrollItemIntoView( self, widget, event = None ): def scrollItemIntoView( self, widget, event = None ):
@ -1612,15 +1612,15 @@ class pluginclass( object ):
self.menuChangedTimer = GLib.timeout_add( 100, self.updateBoxes, True ) self.menuChangedTimer = GLib.timeout_add( 100, self.updateBoxes, True )
def updateBoxes( self, menu_has_changed ): def updateBoxes( self, menu_has_changed ):
# FIXME: This is really bad! # FIXME: This is really bad!
if self.rebuildLock: if self.rebuildLock:
return return
self.rebuildLock = True self.rebuildLock = True
self.menuChangedTimer = None self.menuChangedTimer = None
self.loadMenuFiles() self.loadMenuFiles()
# Find added and removed categories than update the category list # Find added and removed categories than update the category list
@ -1641,7 +1641,7 @@ class pluginclass( object ):
break break
if not found: if not found:
addedCategories.append(item) addedCategories.append(item)
for item in self.categoryList: for item in self.categoryList:
found = False found = False
for item2 in newCategoryList: for item2 in newCategoryList:
@ -1655,10 +1655,10 @@ class pluginclass( object ):
categoryIconSize = self.iconSize categoryIconSize = self.iconSize
else: else:
categoryIconSize = 0 categoryIconSize = 0
for item in removedCategories: for item in removedCategories:
try: try:
button = item["button"] button = item["button"]
self.categoryList.remove(item) self.categoryList.remove(item)
button.destroy() button.destroy()
del item del item
@ -1709,7 +1709,7 @@ class pluginclass( object ):
newApplicationList = self.buildApplicationList() newApplicationList = self.buildApplicationList()
addedApplications = [] addedApplications = []
removedApplications = [] removedApplications = []
# TODO: optimize this!!! # TODO: optimize this!!!
if not self.applicationList: if not self.applicationList:
addedApplications = newApplicationList addedApplications = newApplicationList
@ -1737,22 +1737,22 @@ class pluginclass( object ):
# because when it is removed the index of all later items is # because when it is removed the index of all later items is
# going to be decreased # going to be decreased
key += 1 key += 1
for key in removedApplications: for key in removedApplications:
self.applicationList[key]["button"].destroy() self.applicationList[key]["button"].destroy()
del self.applicationList[key] del self.applicationList[key]
if addedApplications: if addedApplications:
sortedApplicationList = [] sortedApplicationList = []
for item in self.applicationList: for item in self.applicationList:
self.applicationsBox.remove( item["button"] ) self.applicationsBox.remove( item["button"] )
sortedApplicationList.append( ( item["button"].appName, item["button"] ) ) sortedApplicationList.append( ( item["button"].appName, item["button"] ) )
for item in addedApplications: for item in addedApplications:
item["button"] = MenuApplicationLauncher( item["entry"].get_desktop_file_path(), self.iconSize, item["category"], self.showapplicationcomments, highlight=(True and menu_has_changed) ) item["button"] = MenuApplicationLauncher( item["entry"].get_desktop_file_path(), self.iconSize, item["category"], self.showapplicationcomments, highlight=(True and menu_has_changed) )
if item["button"].appExec: if item["button"].appExec:
self.mintMenuWin.setTooltip( item["button"], item["button"].getTooltip() ) self.mintMenuWin.setTooltip( item["button"], item["button"].getTooltip() )
item["button"].connect( "button-press-event", self.menuPopup ) item["button"].connect( "button-press-event", self.menuPopup )
item["button"].connect( "focus-in-event", self.scrollItemIntoView ) item["button"].connect( "focus-in-event", self.scrollItemIntoView )
item["button"].connect( "clicked", lambda w: self.mintMenuWin.hide() ) item["button"].connect( "clicked", lambda w: self.mintMenuWin.hide() )
if self.activeFilter[0] == 0: if self.activeFilter[0] == 0:
item["button"].filterText( self.activeFilter[1] ) item["button"].filterText( self.activeFilter[1] )
else: else:
@ -1764,8 +1764,8 @@ class pluginclass( object ):
item["button"].destroy() item["button"].destroy()
sortedApplicationList.sort() sortedApplicationList.sort()
launcherNames = [] # Keep track of launcher names so we don't add them twice in the list.. launcherNames = [] # Keep track of launcher names so we don't add them twice in the list..
for item in sortedApplicationList: for item in sortedApplicationList:
launcherName = item[0] launcherName = item[0]
button = item[1] button = item[1]
@ -1774,8 +1774,8 @@ class pluginclass( object ):
button.hide() button.hide()
else: else:
launcherNames.append(launcherName) launcherNames.append(launcherName)
self.rebuildLock = False self.rebuildLock = False
# Reload the menufiles from the filesystem # Reload the menufiles from the filesystem
def loadMenuFiles( self ): def loadMenuFiles( self ):

View File

@ -60,7 +60,7 @@ class IconManager(GObject.GObject):
def getIcon( self, iconName, iconSize ): def getIcon( self, iconName, iconSize ):
if not iconName: if not iconName:
return None return None
@ -143,7 +143,7 @@ class easyButton( Gtk.Button ):
if labels: if labels:
for label in labels: for label in labels:
if isinstance( label, basestring ): if isinstance( label, basestring ):
self.addLabel( label ) self.addLabel( label )
elif isinstance( label, list ): elif isinstance( label, list ):
self.addLabel( label[0], label[1] ) self.addLabel( label[0], label[1] )
@ -197,7 +197,7 @@ class easyButton( Gtk.Button ):
return None return None
icon = iconManager.getIcon( self.iconName, iconSize ) icon = iconManager.getIcon( self.iconName, iconSize )
if icon is None: if icon is None:
icon = iconManager.getIcon( "application-default-icon", iconSize ) icon = iconManager.getIcon( "application-default-icon", iconSize )
return icon return icon
@ -335,7 +335,7 @@ class ApplicationLauncher( easyButton ):
def setupLabels( self ): def setupLabels( self ):
self.addLabel( self.appName ) self.addLabel( self.appName )
def filterText( self, text ): def filterText( self, text ):
keywords = text.lower().split() keywords = text.lower().split()
appName = self.appName.lower() appName = self.appName.lower()
@ -351,14 +351,14 @@ class ApplicationLauncher( easyButton ):
self.show() self.show()
return True return True
def strip_accents(self, string): def strip_accents(self, string):
value = string value = string
if isinstance(string, unicode): if isinstance(string, unicode):
try: try:
value = string.encode('UTF8', 'ignore') value = string.encode('UTF8', 'ignore')
except: except:
pass pass
return value return value
def getTooltip( self ): def getTooltip( self ):
tooltip = self.appName tooltip = self.appName
@ -488,12 +488,12 @@ class MenuApplicationLauncher( ApplicationLauncher ):
else: else:
self.hide() self.hide()
def setupLabels( self ): def setupLabels( self ):
appName = self.appName appName = self.appName
appComment = self.appComment appComment = self.appComment
if self.highlight: if self.highlight:
try: try:
#color = self.labelBox.rc_get_style().fg[ Gtk.StateType.SELECTED ].to_string() #color = self.labelBox.rc_get_style().fg[ Gtk.StateType.SELECTED ].to_string()
#if len(color) > 0 and color[0] == "#": #if len(color) > 0 and color[0] == "#":
#appName = "<span foreground=\"%s\"><b>%s</b></span>" % (color, appName); #appName = "<span foreground=\"%s\"><b>%s</b></span>" % (color, appName);
#appComment = "<span foreground=\"%s\"><b>%s</b></span>" % (color, appComment); #appComment = "<span foreground=\"%s\"><b>%s</b></span>" % (color, appComment);
@ -507,7 +507,7 @@ class MenuApplicationLauncher( ApplicationLauncher ):
except Exception, detail: except Exception, detail:
print detail print detail
pass pass
if self.showComment and self.appComment != "": if self.showComment and self.appComment != "":
if self.iconSize <= 2: if self.iconSize <= 2:
self.addLabel( '<span size="small">%s</span>' % appName) self.addLabel( '<span size="small">%s</span>' % appName)
@ -517,8 +517,8 @@ class MenuApplicationLauncher( ApplicationLauncher ):
self.addLabel( '<span size="small">%s</span>' % appComment) self.addLabel( '<span size="small">%s</span>' % appComment)
else: else:
self.addLabel( appName ) self.addLabel( appName )
def execute( self, *args ): def execute( self, *args ):
self.highlight = False self.highlight = False
for child in self.labelBox: for child in self.labelBox:
child.destroy() child.destroy()
@ -553,7 +553,7 @@ class FavApplicationLauncher( ApplicationLauncher ):
self.addLabel( self.appComment ) self.addLabel( self.appComment )
else: else:
self.addLabel ( "" ) self.addLabel ( "" )
def setSwapGeneric( self, swapGeneric ): def setSwapGeneric( self, swapGeneric ):
self.swapGeneric = swapGeneric self.swapGeneric = swapGeneric
for child in self.labelBox: for child in self.labelBox:

View File

@ -3,122 +3,12 @@
import os import os
import os.path import os.path
import urllib import urllib
"""
def TestForDir(dirname):
if not os.path.exists( os.path.join(os.path.expanduser("~"), dirname ) ):
os.makedirs( os.path.join( os.path.expanduser("~"), dirname) )
def TestForFiles(filename):
if not os.path.exists( os.path.join( os.path.expanduser("~"), filename ) ):
file = open( os.path.join( os.path.expanduser("~"), filename ),"w")
file.close()
def FileExists(f):
return os.path.exists(f)
"""
def GetFilePath(uri): def GetFilePath(uri):
path = urllib.url2pathname(uri) # escape special chars path = urllib.url2pathname(uri) # escape special chars
path = path.strip('\r\n\x00') # remove \r\n and NULL path = path.strip('\r\n\x00') # remove \r\n and NULL
# get the path to file # get the path to file
if path.startswith('file://'): # nautilus, rox if path.startswith('file://'): # nautilus, rox
path = path[7:] # 7 is len('file://') path = path[7:] # 7 is len('file://')
return path return path
"""
def ParseDesktopFile(DFile):
# Get the locale
lang = os.getenv("LANG")
if lang:
langArray = lang.split("_")
else:
langArray = [ None ]
locale = langArray[0] or ""
localeName = "Name[" + locale + "]="
localeComment = "Comment[" + locale + "]="
localeGenericName = "GenericName[" + locale + "]="
PlaceName=PlaceComment=PlaceExec=PlaceIconName=GenericName=TerminalName=""
FileData = []
if FileExists(GetFilePath(DFile))==True:
parseData = False
openfile = open(GetFilePath(DFile), 'r')
datalist = openfile.readlines()
openfile.close()
for i in datalist:
i = i.strip('\r\n\x00')
if len(i) != 0:
if i[0] == "[" and i[-1] == "]":
parseData = "[Desktop Entry]" == i
elif parseData:
if i[0:5] == "Name=":
PlaceName = i[5:]
elif i[0:9] == localeName:
PlaceName = i[9:]
elif i[0:8] == "Comment=":
PlaceComment = i[8:]
elif i[0:12] == localeComment:
PlaceComment = i[12:]
elif i[0:5] == "Exec=":
PlaceExec = i[5:]
elif i[0:5] == "Icon=":
PlaceIconName = i[5:]
elif i[0:12] == "GenericName=":
GenericName = i[12:]
elif i[0:16] == localeGenericName:
GenericName = i[16:]
elif i[0:9] == "Terminal=":
TerminalName = i[9:]
FileData.append(PlaceName)
FileData.append(PlaceComment)
FileData.append(PlaceExec)
FileData.append(PlaceIconName)
FileData.append(GenericName)
FileData.append(TerminalName)
return FileData
return None
def WriteListFile(ListToAdd,ItemToAdd,mode):
RecentapplicationsFile = open (os.path.join(os.path.expanduser("~"), ListToAdd),"r")
RecentapplicationsList = RecentapplicationsFile.readlines()
RecentapplicationsList.reverse()
RecentapplicationsFile.close()
if RecentapplicationsList != []:
outfile = open (os.path.join(os.path.expanduser("~"), ListToAdd),mode)
outfile.write(ItemToAdd+"\n")
outfile.close()
else:
outfile = open (os.path.join(os.path.expanduser("~"), ListToAdd),mode)
outfile.write(ItemToAdd+"\n")
outfile.close()
def EditDesktopFile(DroppedFile,FileData,ListToAdd):
fileHandle = open ( DroppedFile , 'w' )
fileHandle.write ( '[Desktop Entry]\nEncoding=UTF-8\n' )
fileHandle.write ( 'Name='+FileData[0]+'\n')
fileHandle.write ( 'Comment='+FileData[1]+'\n')
fileHandle.write ( 'Exec='+FileData[2]+'\n')
fileHandle.write ( 'Icon='+FileData[3]+'\n')
fileHandle.write ( 'GenericName='+FileData[4]+'\n')
fileHandle.write ( 'Terminal='+FileData[5]+'\n')
fileHandle.close()
def WriteDesktopFile(DroppedFile,FileData,ListToAdd):
fileHandle = open ( DroppedFile , 'w' )
fileHandle.write ( '[Desktop Entry]\nEncoding=UTF-8\n' )
fileHandle.write ( 'Name='+FileData[0]+'\n')
fileHandle.write ( 'Comment='+FileData[1]+'\n')
fileHandle.write ( 'Exec='+FileData[2]+'\n')
fileHandle.write ( 'Icon='+FileData[3]+'\n')
fileHandle.write ( 'GenericName='+FileData[4]+'\n')
fileHandle.write ( 'Terminal='+FileData[5]+'\n')
fileHandle.close()
WriteListFile(ListToAdd,DroppedFile,"a")
print "Added to places.list"
"""

View File

@ -73,10 +73,10 @@ class EasyGSettings:
if i not in ['a', 'A', 'b', 'B', 'c', 'C', 'd', 'D', 'e', 'E', 'f', 'F', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9']: if i not in ['a', 'A', 'b', 'B', 'c', 'C', 'd', 'D', 'e', 'E', 'f', 'F', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9']:
return False return False
return True return True
def bindGSettingsEntryToVar( self, type, key, obj, varName ): def bindGSettingsEntryToVar( self, type, key, obj, varName ):
return self.notifyAdd( key, self.setVar, ( type, obj, varName ) ) return self.notifyAdd( key, self.setVar, ( type, obj, varName ) )
def setVar( self, settings, key, args ): def setVar( self, settings, key, args ):
type, obj, varName = args type, obj, varName = args

View File

@ -3,45 +3,45 @@
import os import os
def RemoveArgs(Execline): def RemoveArgs(Execline):
NewExecline = [] NewExecline = []
Specials=["\"%c\"", "%f","%F","%u","%U","%d","%D","%n","%N","%i","%c","%k","%v","%m","%M", "-caption", "/bin/sh", "sh", "-c", "STARTED_FROM_MENU=yes"] Specials=["\"%c\"", "%f","%F","%u","%U","%d","%D","%n","%N","%i","%c","%k","%v","%m","%M", "-caption", "/bin/sh", "sh", "-c", "STARTED_FROM_MENU=yes"]
for elem in Execline: for elem in Execline:
elem = elem.replace("'","") elem = elem.replace("'","")
elem = elem.replace("\"", "") elem = elem.replace("\"", "")
if elem not in Specials: if elem not in Specials:
print elem print elem
NewExecline.append(elem) NewExecline.append(elem)
return NewExecline return NewExecline
# Actually execute the command # Actually execute the command
def Execute( cmd , commandCwd=None): def Execute( cmd , commandCwd=None):
if not commandCwd: if not commandCwd:
cwd = os.path.expanduser( "~" ); cwd = os.path.expanduser( "~" );
else: else:
tmpCwd = os.path.expanduser( commandCwd ); tmpCwd = os.path.expanduser( commandCwd );
if (os.path.exists(tmpCwd)): if (os.path.exists(tmpCwd)):
cwd = tmpCwd cwd = tmpCwd
if isinstance( cmd, str ) or isinstance( cmd, unicode): if isinstance( cmd, str ) or isinstance( cmd, unicode):
if (cmd.find("ubiquity") >= 0) or (cmd.find("/home/") >= 0) or (cmd.find("su-to-root") >= 0) or (cmd.find("\"") >= 0): if (cmd.find("ubiquity") >= 0) or (cmd.find("/home/") >= 0) or (cmd.find("su-to-root") >= 0) or (cmd.find("\"") >= 0):
print "running manually..." print "running manually..."
try: try:
os.chdir(cwd) os.chdir(cwd)
os.system(cmd + " &") os.system(cmd + " &")
return True return True
except Exception, detail: except Exception, detail:
print detail print detail
return False return False
cmd = cmd.split() cmd = cmd.split()
cmd = RemoveArgs(cmd) cmd = RemoveArgs(cmd)
try: try:
os.chdir( cwd ) os.chdir( cwd )
string = ' '.join(cmd) string = ' '.join(cmd)
string = string + " &" string = string + " &"
os.system(string) os.system(string)
return True return True
except Exception, detail: except Exception, detail:
print detail print detail
return False return False

View File

@ -31,7 +31,7 @@ if hasInotify:
if mId >= 0: if mId >= 0:
self.callbacks[mId] = ( callback, args ) self.callbacks[mId] = ( callback, args )
except Exception, detail: except Exception, detail:
mId = 0 mId = 0
return mId return mId
def removeMonitor( self, monitorId ): def removeMonitor( self, monitorId ):

View File

@ -3,7 +3,7 @@
import apt, sys import apt, sys
try: try:
cache = apt.Cache() cache = apt.Cache()
for pkg in cache: for pkg in cache:
if not pkg.is_installed: if not pkg.is_installed:
name = pkg.name name = pkg.name

View File

@ -28,10 +28,10 @@ class pluginclass( object ):
self.toggleButton = toggleButton self.toggleButton = toggleButton
self.de = de self.de = de
# Read UI file # Read UI file
builder = Gtk.Builder() builder = Gtk.Builder()
builder.add_from_file(os.path.join( os.path.dirname( __file__ ), "places.glade" )) builder.add_from_file(os.path.join( os.path.dirname( __file__ ), "places.glade" ))
self.placesBtnHolder = builder.get_object( "places_button_holder" ) self.placesBtnHolder = builder.get_object( "places_button_holder" )
self.editableBtnHolder = builder.get_object( "editable_button_holder" ) self.editableBtnHolder = builder.get_object( "editable_button_holder" )
self.scrolledWindow=builder.get_object("scrolledwindow2") self.scrolledWindow=builder.get_object("scrolledwindow2")
@ -49,7 +49,7 @@ class pluginclass( object ):
# Items to get custom colors # Items to get custom colors
self.itemstocolor = [ builder.get_object( "viewport2" ) ] self.itemstocolor = [ builder.get_object( "viewport2" ) ]
# Settings # Settings
self.settings = EasyGSettings("com.linuxmint.mintmenu.plugins.places") self.settings = EasyGSettings("com.linuxmint.mintmenu.plugins.places")
self.settings.notifyAdd( "icon-size", self.RegenPlugin ) self.settings.notifyAdd( "icon-size", self.RegenPlugin )
@ -62,11 +62,11 @@ class pluginclass( object ):
self.settings.notifyAdd( "allow-scrollbar", self.RegenPlugin ) self.settings.notifyAdd( "allow-scrollbar", self.RegenPlugin )
self.settings.notifyAdd( "show-gtk-bookmarks", self.RegenPlugin ) self.settings.notifyAdd( "show-gtk-bookmarks", self.RegenPlugin )
self.settings.notifyAdd( "height", self.changePluginSize ) self.settings.notifyAdd( "height", self.changePluginSize )
self.settings.notifyAdd( "width", self.changePluginSize ) self.settings.notifyAdd( "width", self.changePluginSize )
self.loadSettings() self.loadSettings()
self.content_holder.set_size_request( self.width, self.height ) self.content_holder.set_size_request( self.width, self.height )
def wake (self) : def wake (self) :
if ( self.showtrash == True ): if ( self.showtrash == True ):
@ -77,7 +77,7 @@ class pluginclass( object ):
def changePluginSize( self, settings, key, args = None): def changePluginSize( self, settings, key, args = None):
self.allowScrollbar = self.settings.get( "bool", "allow-scrollbar" ) self.allowScrollbar = self.settings.get( "bool", "allow-scrollbar" )
self.width = self.settings.get( "int", "width" ) self.width = self.settings.get( "int", "width" )
if (self.allowScrollbar == False): if (self.allowScrollbar == False):
self.height = -1 self.height = -1
self.scrolledWindow.set_policy( Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.NEVER ) self.scrolledWindow.set_policy( Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.NEVER )
@ -103,7 +103,7 @@ class pluginclass( object ):
if (self.allowScrollbar == False): if (self.allowScrollbar == False):
self.height = -1 self.height = -1
self.scrolledWindow.set_policy( Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.NEVER ) self.scrolledWindow.set_policy( Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.NEVER )
self.content_holder.set_size_request( self.width, self.height ) self.content_holder.set_size_request( self.width, self.height )
self.iconsize = self.settings.get( "int", "icon-size" ) self.iconsize = self.settings.get( "int", "icon-size" )
# Check default items # Check default items
@ -127,7 +127,7 @@ class pluginclass( object ):
# Allow plugin to be minimized to the left plugin pane # Allow plugin to be minimized to the left plugin pane
self.sticky = self.settings.get( "bool", "sticky") self.sticky = self.settings.get( "bool", "sticky")
self.minimized = self.settings.get( "bool", "minimized") self.minimized = self.settings.get( "bool", "minimized")
def ClearAll(self): def ClearAll(self):
for child in self.placesBtnHolder.get_children(): for child in self.placesBtnHolder.get_children():
child.destroy() child.destroy()
@ -221,7 +221,7 @@ class pluginclass( object ):
currentbutton.show() currentbutton.show()
self.placesBtnHolder.pack_start( currentbutton, False, False, 0) self.placesBtnHolder.pack_start( currentbutton, False, False, 0)
def do_gtk_bookmarks( self ): def do_gtk_bookmarks( self ):
if self.showGTKBookmarks: if self.showGTKBookmarks:
if not os.path.exists(os.path.expanduser('~/.gtk-bookmarks')): if not os.path.exists(os.path.expanduser('~/.gtk-bookmarks')):
return return
@ -247,7 +247,7 @@ class pluginclass( object ):
currentbutton.connect( "clicked", self.launch_gtk_bookmark, path ) currentbutton.connect( "clicked", self.launch_gtk_bookmark, path )
currentbutton.show() currentbutton.show()
self.placesBtnHolder.pack_start( currentbutton, False, False, 0) self.placesBtnHolder.pack_start( currentbutton, False, False, 0)
def launch_gtk_bookmark (self, widget, path): def launch_gtk_bookmark (self, widget, path):
self.mintMenuWin.hide() self.mintMenuWin.hide()
if self.de == "mate": if self.de == "mate":

View File

@ -17,7 +17,7 @@ class PointerMonitor(GObject.GObject, threading.Thread):
__gsignals__ = { __gsignals__ = {
'activate': (GObject.SignalFlags.RUN_LAST, None, ()), 'activate': (GObject.SignalFlags.RUN_LAST, None, ()),
} }
def __init__(self): def __init__(self):
GObject.GObject.__init__ (self) GObject.GObject.__init__ (self)
threading.Thread.__init__ (self) threading.Thread.__init__ (self)
@ -25,17 +25,17 @@ class PointerMonitor(GObject.GObject, threading.Thread):
self.display = Display() self.display = Display()
self.root = self.display.screen().root self.root = self.display.screen().root
self.windows = [] self.windows = []
# Receives GDK windows # Receives GDK windows
def addWindowToMonitor(self, window): def addWindowToMonitor(self, window):
gdk.gdk_x11_drawable_get_xid.argtypes = [c_void_p] gdk.gdk_x11_drawable_get_xid.argtypes = [c_void_p]
xWindow = self.display.create_resource_object("window", gdk.gdk_x11_drawable_get_xid(hash(window))) xWindow = self.display.create_resource_object("window", gdk.gdk_x11_drawable_get_xid(hash(window)))
self.windows.append(xWindow) self.windows.append(xWindow)
def grabPointer(self): def grabPointer(self):
self.root.grab_button(X.AnyButton, X.AnyModifier, True, X.ButtonPressMask, X.GrabModeSync, X.GrabModeAsync, 0, 0) self.root.grab_button(X.AnyButton, X.AnyModifier, True, X.ButtonPressMask, X.GrabModeSync, X.GrabModeAsync, 0, 0)
self.display.flush() self.display.flush()
def ungrabPointer(self): def ungrabPointer(self):
self.root.ungrab_button(X.AnyButton, X.AnyModifier) self.root.ungrab_button(X.AnyButton, X.AnyModifier)
self.display.flush() self.display.flush()
@ -46,7 +46,7 @@ class PointerMonitor(GObject.GObject, threading.Thread):
def activate(self): def activate(self):
GLib.idle_add(self.run) GLib.idle_add(self.run)
def run(self): def run(self):
self.running = True self.running = True
while self.running: while self.running:
@ -63,7 +63,7 @@ class PointerMonitor(GObject.GObject, threading.Thread):
# Is outside, so activate # Is outside, so activate
GLib.idle_add(self.idle) GLib.idle_add(self.idle)
self.display.allow_events(X.ReplayPointer, event.time) self.display.allow_events(X.ReplayPointer, event.time)
else: else:
self.display.allow_events(X.ReplayPointer, X.CurrentTime) self.display.allow_events(X.ReplayPointer, X.CurrentTime)
except Exception as e: except Exception as e:
print "Unexpected error: " + str(e) print "Unexpected error: " + str(e)
@ -72,4 +72,4 @@ class PointerMonitor(GObject.GObject, threading.Thread):
self.running = False self.running = False
self.root.ungrab_button(X.AnyButton, X.AnyModifier) self.root.ungrab_button(X.AnyButton, X.AnyModifier)
self.display.close() self.display.close()