Fixed indentation and trailing spaces
This commit is contained in:
parent
048d0c386c
commit
877ce3640b
@ -2,7 +2,7 @@
|
||||
|
||||
import gi
|
||||
gi.require_version("Gtk", "2.0")
|
||||
|
||||
|
||||
from gi.repository import Gtk, GdkPixbuf, Gdk, GObject
|
||||
from gi.repository import MatePanelApplet
|
||||
from gi.repository import Gio
|
||||
@ -61,7 +61,7 @@ class MainWindow( object ):
|
||||
"""This is the main class for the application"""
|
||||
|
||||
def __init__( self, toggleButton, settings, keybinder ):
|
||||
|
||||
|
||||
self.settings = settings
|
||||
self.keybinder = keybinder
|
||||
self.path = PATH
|
||||
@ -72,7 +72,7 @@ class MainWindow( object ):
|
||||
self.icon = "/usr/lib/linuxmint/mintMenu/visualisation-logo.png"
|
||||
|
||||
self.toggle = toggleButton
|
||||
# Load UI file and extract widgets
|
||||
# Load UI file and extract widgets
|
||||
builder = Gtk.Builder()
|
||||
builder.add_from_file(os.path.join( self.path, "mintMenu.glade" ))
|
||||
self.window = builder.get_object( "mainWindow" )
|
||||
@ -81,7 +81,7 @@ class MainWindow( object ):
|
||||
self.window.set_title("")
|
||||
self.paneholder = builder.get_object( "paneholder" )
|
||||
self.border = builder.get_object( "border" )
|
||||
|
||||
|
||||
builder.connect_signals(self)
|
||||
|
||||
self.panesToColor = [ ]
|
||||
@ -109,7 +109,7 @@ class MainWindow( object ):
|
||||
self.settings.connect( "changed::custom-color", self.toggleCustomBackgroundColor )
|
||||
self.settings.connect( "changed::border-width", self.toggleBorderWidth )
|
||||
self.settings.connect( "changed::opacity", self.toggleOpacity )
|
||||
|
||||
|
||||
self.getSetGSettingEntries()
|
||||
|
||||
self.tooltips = Gtk.Tooltips()
|
||||
@ -117,7 +117,7 @@ class MainWindow( object ):
|
||||
self.tooltips.enable()
|
||||
else:
|
||||
self.tooltips.disable()
|
||||
|
||||
|
||||
self.PopulatePlugins();
|
||||
self.firstTime = True;
|
||||
|
||||
@ -169,7 +169,7 @@ class MainWindow( object ):
|
||||
self.customheadingcolor = settings.get_string(key)
|
||||
self.SetHeadingStyle( self.headingsToColor )
|
||||
|
||||
def getSetGSettingEntries( self ):
|
||||
def getSetGSettingEntries( self ):
|
||||
self.dottedfile = os.path.join( self.path, "dotted.png")
|
||||
|
||||
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.borderwidth = self.settings.get_int( "border-width" )
|
||||
self.opacity = self.settings.get_int( "opacity" )
|
||||
self.offset = self.settings.get_int( "offset" )
|
||||
self.enableTooltips = self.settings.get_boolean( "tooltips-enabled" )
|
||||
self.offset = self.settings.get_int( "offset" )
|
||||
self.enableTooltips = self.settings.get_boolean( "tooltips-enabled" )
|
||||
self.startWithFavorites = self.settings.get_boolean( "start-with-favorites" )
|
||||
|
||||
|
||||
self.globalEnableTooltips = self.panelSettings.get_boolean( "tooltips-enabled" )
|
||||
|
||||
def SetupMintMenuBorder( self, defaultStyle = None ):
|
||||
@ -190,14 +190,14 @@ class MainWindow( object ):
|
||||
self.window.modify_bg( Gtk.StateType.NORMAL, Gdk.color_parse( self.custombordercolor ) )
|
||||
elif defaultStyle is not None:
|
||||
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 ):
|
||||
print "Opacity is: " + str(self.opacity)
|
||||
opacity = float(self.opacity) / float(100)
|
||||
print "Setting opacity to: " + str(opacity)
|
||||
self.window.set_opacity(opacity)
|
||||
|
||||
|
||||
def detect_desktop_environment (self):
|
||||
self.de = "mate"
|
||||
try:
|
||||
@ -228,7 +228,7 @@ class MainWindow( object ):
|
||||
|
||||
self.plugins = {}
|
||||
|
||||
for plugin in self.pluginlist:
|
||||
for plugin in self.pluginlist:
|
||||
if plugin in self.plugins:
|
||||
print u"Duplicate plugin in list: ", plugin
|
||||
continue
|
||||
@ -280,7 +280,7 @@ class MainWindow( object ):
|
||||
MyPlugin.content_holder.show()
|
||||
|
||||
VBox1 = Gtk.VBox( False, 0 )
|
||||
if MyPlugin.heading != "":
|
||||
if MyPlugin.heading != "":
|
||||
Label1 = Gtk.Label(label= MyPlugin.heading )
|
||||
Align1 = Gtk.Alignment.new( 0, 0, 0, 0 )
|
||||
Align1.set_padding( 10, 5, 10, 0 )
|
||||
@ -303,7 +303,7 @@ class MainWindow( object ):
|
||||
|
||||
heading.add( Align1 )
|
||||
heading.show()
|
||||
VBox1.pack_start( heading, False, False, 0 )
|
||||
VBox1.pack_start( heading, False, False, 0 )
|
||||
VBox1.show()
|
||||
#Add plugin to Plugin Box under heading button
|
||||
MyPlugin.content_holder.reparent( VBox1 )
|
||||
@ -351,7 +351,7 @@ class MainWindow( object ):
|
||||
Image1.set_from_pixbuf( seperatorImage )
|
||||
Image1.show()
|
||||
#ImageBox.add( Image1 )
|
||||
|
||||
|
||||
Align1 = Gtk.Alignment.new(0, 0, 0, 0)
|
||||
Align1.set_padding( 0, 0, 6, 6 )
|
||||
Align1.add(Image1)
|
||||
@ -369,13 +369,13 @@ class MainWindow( object ):
|
||||
widget = Gtk.EventBox()
|
||||
widget.show()
|
||||
return Gtk.rc_get_style(widget)
|
||||
|
||||
|
||||
def loadTheme( self ):
|
||||
defaultStyle = self.getDefaultStyle()
|
||||
self.SetPaneColors( self.panesToColor, defaultStyle )
|
||||
self.SetupMintMenuBorder( defaultStyle )
|
||||
self.SetHeadingStyle( self.headingsToColor )
|
||||
|
||||
|
||||
def SetPaneColors( self, items, defaultStyle = None ):
|
||||
if self.usecustomcolor:
|
||||
for item in items:
|
||||
@ -419,7 +419,7 @@ class MainWindow( object ):
|
||||
del plugin
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
try:
|
||||
del self.plugins
|
||||
except:
|
||||
@ -441,14 +441,14 @@ class MainWindow( object ):
|
||||
|
||||
def show( self ):
|
||||
self.window.present()
|
||||
|
||||
|
||||
# Hack for opacity not showing on first composited draw
|
||||
if self.firstTime:
|
||||
self.firstTime = False
|
||||
self.SetupMintMenuOpacity()
|
||||
|
||||
self.window.window.focus( Gdk.CURRENT_TIME )
|
||||
|
||||
|
||||
for plugin in self.plugins.values():
|
||||
if hasattr( plugin, "onShowMenu" ):
|
||||
plugin.onShowMenu()
|
||||
@ -462,21 +462,21 @@ class MainWindow( object ):
|
||||
for plugin in self.plugins.values():
|
||||
if hasattr( plugin, "onHideMenu" ):
|
||||
plugin.onHideMenu()
|
||||
|
||||
|
||||
self.window.hide()
|
||||
|
||||
|
||||
def onFocusIn( self, *args ):
|
||||
if self.loseFocusBlocked:
|
||||
self.window.handler_unblock( self.loseFocusId )
|
||||
self.loseFocusBlocked = False
|
||||
|
||||
return False
|
||||
|
||||
def onFocusOut( self, *args):
|
||||
return False
|
||||
|
||||
def onFocusOut( self, *args):
|
||||
if self.window.get_visible():
|
||||
self.hide()
|
||||
return False
|
||||
|
||||
|
||||
def stopHiding( self ):
|
||||
if not self.loseFocusBlocked:
|
||||
self.window.handler_block( self.loseFocusId )
|
||||
@ -484,7 +484,7 @@ class MainWindow( object ):
|
||||
|
||||
class MenuWin( object ):
|
||||
def __init__( self, applet, iid ):
|
||||
self.applet = applet
|
||||
self.applet = applet
|
||||
self.settings = Gio.Settings.new("com.linuxmint.mintmenu")
|
||||
self.keybinder = keybinding.GlobalKeyBinding()
|
||||
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.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("leave-notify-event", self.leave_notify)
|
||||
self.mainwin = MainWindow( self.button_box, self.settings, self.keybinder )
|
||||
@ -524,25 +524,25 @@ class MenuWin( object ):
|
||||
|
||||
self.pointerMonitor = pointerMonitor.PointerMonitor()
|
||||
self.pointerMonitor.connect("activate", self.onPointerOutside)
|
||||
|
||||
|
||||
def onWindowMap( self, *args ):
|
||||
self.applet.set_state( Gtk.StateType.SELECTED )
|
||||
self.keybinder.set_focus_window( self.mainwin.window.window )
|
||||
#self.pointerMonitor.grabPointer()
|
||||
return False
|
||||
|
||||
|
||||
def onWindowUnmap( self, *args ):
|
||||
self.applet.set_state( Gtk.StateType.NORMAL )
|
||||
self.keybinder.set_focus_window()
|
||||
#self.pointerMonitor.ungrabPointer()
|
||||
return False
|
||||
|
||||
|
||||
def onRealize( self, *args):
|
||||
self.pointerMonitor.addWindowToMonitor( self.mainwin.window.window )
|
||||
self.pointerMonitor.addWindowToMonitor( self.applet.window )
|
||||
self.pointerMonitor.start()
|
||||
return False
|
||||
|
||||
|
||||
def onPointerOutside(self, *args):
|
||||
self.mainwin.hide()
|
||||
return True
|
||||
@ -555,11 +555,11 @@ class MenuWin( object ):
|
||||
self.do_image(self.buttonIcon, True)
|
||||
|
||||
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.x >= 0 and event.y >= 0 and event.x < applet.window.get_width() and event.y < applet.window.get_height():
|
||||
self.mainwin.stopHiding()
|
||||
|
||||
|
||||
self.do_image(self.buttonIcon, False)
|
||||
|
||||
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_icon.set_padding( 0, 5 )
|
||||
|
||||
|
||||
|
||||
self.button_box.set_homogeneous( False )
|
||||
self.button_box.show_all()
|
||||
self.sizeButton()
|
||||
@ -613,23 +613,23 @@ class MenuWin( object ):
|
||||
self.theme_name = self.settings.get_string( "theme-name" )
|
||||
self.hotkeyText = self.settings.get_string( "hot-key" )
|
||||
self.buttonIcon = self.settings.get_string( "applet-icon" )
|
||||
self.iconSize = self.settings.get_int( "applet-icon-size" )
|
||||
|
||||
def changeTheme(self, *args):
|
||||
self.iconSize = self.settings.get_int( "applet-icon-size" )
|
||||
|
||||
def changeTheme(self, *args):
|
||||
self.reloadSettings()
|
||||
self.applyTheme()
|
||||
self.mainwin.loadTheme()
|
||||
|
||||
|
||||
def applyTheme(self):
|
||||
style_settings = Gtk.Settings.get_default()
|
||||
desktop_theme = self.mate_settings.get_string('gtk-theme')
|
||||
if self.theme_name == "default":
|
||||
style_settings.set_property("gtk-theme-name", desktop_theme)
|
||||
style_settings.set_property("gtk-theme-name", desktop_theme)
|
||||
else:
|
||||
try:
|
||||
style_settings.set_property("gtk-theme-name", self.theme_name)
|
||||
except:
|
||||
style_settings.set_property("gtk-theme-name", desktop_theme)
|
||||
style_settings.set_property("gtk-theme-name", desktop_theme)
|
||||
|
||||
def changeOrientation( self, *args, **kargs ):
|
||||
|
||||
@ -679,7 +679,7 @@ class MenuWin( object ):
|
||||
self.keybinder.start()
|
||||
# Binding menu to hotkey
|
||||
print "Binding to Hot Key: " + self.hotkeyText
|
||||
|
||||
|
||||
except Exception, cause:
|
||||
print "** WARNING ** - Menu Hotkey Binding Error"
|
||||
print "Error Report :\n", str(cause)
|
||||
@ -713,7 +713,7 @@ class MenuWin( object ):
|
||||
|
||||
def reloadSettings( self, *args ):
|
||||
self.loadSettings()
|
||||
self.updateButton()
|
||||
self.updateButton()
|
||||
|
||||
def showAboutDialog( self, action, userdata = None ):
|
||||
|
||||
@ -849,4 +849,4 @@ def quit_all(widget):
|
||||
MatePanelApplet.Applet.factory_main("MintMenuAppletFactory", True,
|
||||
MatePanelApplet.Applet.__gtype__,
|
||||
applet_factory, None)
|
||||
|
||||
|
||||
|
@ -166,8 +166,8 @@ class Menu:
|
||||
|
||||
class SuggestionButton ( Gtk.Button ):
|
||||
|
||||
def __init__( self, iconName, iconSize, label ):
|
||||
Gtk.Button.__init__( self )
|
||||
def __init__( self, iconName, iconSize, label ):
|
||||
Gtk.Button.__init__( self )
|
||||
self.iconName = iconName
|
||||
self.set_relief( Gtk.ReliefStyle.NONE )
|
||||
self.set_size_request( -1, -1 )
|
||||
@ -191,14 +191,14 @@ class SuggestionButton ( Gtk.Button ):
|
||||
Align1.show()
|
||||
self.add( Align1 )
|
||||
self.show()
|
||||
|
||||
|
||||
def set_image(self, path):
|
||||
self.image.set_from_file(path)
|
||||
|
||||
|
||||
def set_text( self, 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 )
|
||||
|
||||
class TargetEntry(Structure):
|
||||
@ -224,7 +224,7 @@ class pluginclass( object ):
|
||||
|
||||
self.toggleButton = toggleButton
|
||||
self.de = de
|
||||
|
||||
|
||||
self.builder = Gtk.Builder()
|
||||
# The Glade file for the plugin
|
||||
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("label3").set_text(_("Favorites"))
|
||||
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.numApps = 0
|
||||
@ -329,8 +329,8 @@ class pluginclass( object ):
|
||||
# self.menuFileMonitors.append( filemonitor.addMonitor(f, self.onMenuChanged, mymenu.directory.Filename ) )
|
||||
#for f in mymenu.directory.AppDirs:
|
||||
# self.menuFileMonitors.append( filemonitor.addMonitor(f, self.onMenuChanged, mymenu.directory.Filename ) )
|
||||
|
||||
self.refresh_apt_cache()
|
||||
|
||||
self.refresh_apt_cache()
|
||||
self.suggestions = []
|
||||
self.current_suggestion = None
|
||||
self.panel = "top"
|
||||
@ -341,7 +341,7 @@ class pluginclass( object ):
|
||||
def refresh_apt_cache(self):
|
||||
if self.useAPT:
|
||||
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):
|
||||
panelsettings = Gio.Settings.new("org.mate.panel")
|
||||
@ -356,12 +356,12 @@ class pluginclass( object ):
|
||||
self.panel_position = object_schema.get_int("position") + 1
|
||||
|
||||
def apturl_install(self, widget, pkg_name):
|
||||
if os.path.exists("/usr/bin/apturl"):
|
||||
os.system("/usr/bin/apturl apt://%s &" % pkg_name)
|
||||
else:
|
||||
os.system("xdg-open apt://" + pkg_name + " &")
|
||||
self.mintMenuWin.hide()
|
||||
|
||||
if os.path.exists("/usr/bin/apturl"):
|
||||
os.system("/usr/bin/apturl apt://%s &" % pkg_name)
|
||||
else:
|
||||
os.system("xdg-open apt://" + pkg_name + " &")
|
||||
self.mintMenuWin.hide()
|
||||
|
||||
def __del__( self ):
|
||||
print u"Applications plugin deleted"
|
||||
|
||||
@ -426,7 +426,7 @@ class pluginclass( object ):
|
||||
try:
|
||||
child.setIconSize( self.iconSize )
|
||||
except:
|
||||
pass
|
||||
pass
|
||||
|
||||
def changeFavIconSize( self, settings, key, args ):
|
||||
self.faviconsize = settings.get_int(key)
|
||||
@ -434,7 +434,7 @@ class pluginclass( object ):
|
||||
for child in self.favoritesBox:
|
||||
if isinstance( child, FavApplicationLauncher):
|
||||
child.setIconSize( self.faviconsize )
|
||||
|
||||
|
||||
def switchAPTUsage( self, settings, key, args ):
|
||||
self.useAPT = settings.get_boolean(key)
|
||||
self.refresh_apt_cache()
|
||||
@ -465,9 +465,9 @@ class pluginclass( object ):
|
||||
self.favoritesBox.remove( fav )
|
||||
self.favoritesPositionOnGrid( fav )
|
||||
|
||||
def RegenPlugin( self, *args, **kargs ):
|
||||
def RegenPlugin( self, *args, **kargs ):
|
||||
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
|
||||
oldcategories_mouse_over = self.categories_mouse_over
|
||||
oldiconsize = self.iconSize
|
||||
@ -582,11 +582,11 @@ class pluginclass( object ):
|
||||
self.showAllAppsButton.connect( "clicked", lambda widget: self.changeTab( 1 ) )
|
||||
self.showFavoritesButton.connect( "clicked", lambda widget: self.changeTab( 0 ) )
|
||||
self.buildButtonList()
|
||||
|
||||
|
||||
def blockOnPopup( self, *args ):
|
||||
self.mintMenuWin.stopHiding()
|
||||
return False
|
||||
|
||||
|
||||
def blockOnRightPress( self, widget, event ):
|
||||
if event.button == 3:
|
||||
self.mintMenuWin.stopHiding()
|
||||
@ -603,7 +603,7 @@ class pluginclass( object ):
|
||||
else:
|
||||
self.searchEntry.set_text("")
|
||||
|
||||
def buildButtonList( self ):
|
||||
def buildButtonList( self ):
|
||||
if self.buildingButtonList:
|
||||
self.stopBuildingButtonList = True
|
||||
GLib.timeout_add( 100, self.buildButtonList )
|
||||
@ -629,68 +629,68 @@ class pluginclass( object ):
|
||||
self.filterTimer = None
|
||||
|
||||
def add_search_suggestions(self, text):
|
||||
|
||||
|
||||
text = "<b>%s</b>" % text
|
||||
|
||||
|
||||
suggestionButton = SuggestionButton(Gtk.STOCK_ADD, self.iconSize, "")
|
||||
suggestionButton.connect("clicked", self.search_google)
|
||||
suggestionButton.set_text(_("Search Google for %s") % text)
|
||||
suggestionButton.set_image("/usr/lib/linuxmint/mintMenu/search_engines/google.ico")
|
||||
self.applicationsBox.add(suggestionButton)
|
||||
self.suggestions.append(suggestionButton)
|
||||
|
||||
|
||||
suggestionButton = SuggestionButton(Gtk.STOCK_ADD, self.iconSize, "")
|
||||
suggestionButton.connect("clicked", self.search_wikipedia)
|
||||
suggestionButton.set_text(_("Search Wikipedia for %s") % text)
|
||||
suggestionButton.set_image("/usr/lib/linuxmint/mintMenu/search_engines/wikipedia.ico")
|
||||
self.applicationsBox.add(suggestionButton)
|
||||
self.suggestions.append(suggestionButton)
|
||||
|
||||
|
||||
separator = Gtk.EventBox()
|
||||
separator.add(Gtk.HSeparator())
|
||||
separator.set_visible_window(False)
|
||||
separator.set_size_request(-1, 20)
|
||||
separator.type = "separator"
|
||||
separator.set_size_request(-1, 20)
|
||||
separator.type = "separator"
|
||||
separator.show_all()
|
||||
self.applicationsBox.add(separator)
|
||||
self.suggestions.append(separator)
|
||||
|
||||
self.suggestions.append(separator)
|
||||
|
||||
suggestionButton = SuggestionButton(Gtk.STOCK_ADD, self.iconSize, "")
|
||||
suggestionButton.connect("clicked", self.search_dictionary)
|
||||
suggestionButton.set_text(_("Lookup %s in Dictionary") % text)
|
||||
suggestionButton.set_image("/usr/lib/linuxmint/mintMenu/search_engines/dictionary.png")
|
||||
self.applicationsBox.add(suggestionButton)
|
||||
self.suggestions.append(suggestionButton)
|
||||
|
||||
self.suggestions.append(suggestionButton)
|
||||
|
||||
suggestionButton = SuggestionButton(Gtk.STOCK_FIND, self.iconSize, "")
|
||||
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.suggestions.append(suggestionButton)
|
||||
|
||||
self.suggestions.append(suggestionButton)
|
||||
|
||||
#self.last_separator = gtk.EventBox()
|
||||
#self.last_separator.add(gtk.HSeparator())
|
||||
#self.last_separator.set_size_request(-1, 20)
|
||||
#self.last_separator.type = "separator"
|
||||
#self.mintMenuWin.SetPaneColors( [ self.last_separator ] )
|
||||
#self.last_separator.set_size_request(-1, 20)
|
||||
#self.last_separator.type = "separator"
|
||||
#self.mintMenuWin.SetPaneColors( [ self.last_separator ] )
|
||||
#self.last_separator.show_all()
|
||||
#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):
|
||||
try:
|
||||
try:
|
||||
# Wait to see if the keyword has changed.. before doing anything
|
||||
current_keyword = keyword
|
||||
current_keyword = self.searchEntry.get_text()
|
||||
if keyword != current_keyword:
|
||||
return
|
||||
return
|
||||
found_packages = []
|
||||
found_in_name = []
|
||||
found_elsewhere = []
|
||||
keywords = keyword.split(" ")
|
||||
command = "cat %(home)s/.linuxmint/mintMenu/apt.cache" % {'home':home}
|
||||
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 = pkgs.split("\n")
|
||||
num_pkg_found = 0
|
||||
@ -715,30 +715,30 @@ class pluginclass( object ):
|
||||
some_not_found = True
|
||||
if some_found and not some_not_found:
|
||||
found_in_name.append(package)
|
||||
else:
|
||||
found_elsewhere.append(package)
|
||||
else:
|
||||
found_elsewhere.append(package)
|
||||
num_pkg_found+=1
|
||||
else:
|
||||
print "Invalid status code: " + status
|
||||
|
||||
|
||||
found_packages.extend(found_in_name)
|
||||
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.add(Gtk.HSeparator())
|
||||
last_separator.set_visible_window(False)
|
||||
last_separator.set_size_request(-1, 20)
|
||||
last_separator.type = "separator"
|
||||
last_separator.set_size_request(-1, 20)
|
||||
last_separator.type = "separator"
|
||||
last_separator.show_all()
|
||||
self.applicationsBox.add(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..
|
||||
if len(found_packages) > 10:
|
||||
found_packages = found_packages[:10]
|
||||
for pkg in found_packages:
|
||||
for pkg in found_packages:
|
||||
name = pkg.name
|
||||
for word in keywords:
|
||||
if word != "":
|
||||
for word in keywords:
|
||||
if word != "":
|
||||
name = name.replace(word, "<b>%s</b>" % word);
|
||||
suggestionButton = SuggestionButton(Gtk.STOCK_ADD, self.iconSize, "")
|
||||
suggestionButton.connect("clicked", self.apturl_install, pkg.name)
|
||||
@ -756,18 +756,18 @@ class pluginclass( object ):
|
||||
# self.applicationsBox.remove(self.last_separator)
|
||||
# self.suggestions.remove(self.last_separator)
|
||||
# finally:
|
||||
# gtk.gdk.threads_leave()
|
||||
|
||||
except Exception, detail:
|
||||
print detail
|
||||
# gtk.gdk.threads_leave()
|
||||
|
||||
except Exception, detail:
|
||||
print detail
|
||||
|
||||
|
||||
|
||||
def add_apt_filter_results_sync(self, cache, keyword):
|
||||
try:
|
||||
found_packages = []
|
||||
try:
|
||||
found_packages = []
|
||||
keywords = keyword.split(" ")
|
||||
if cache is not None:
|
||||
for pkg in cache:
|
||||
for pkg in cache:
|
||||
some_found = False
|
||||
some_not_found = False
|
||||
for word in keywords:
|
||||
@ -776,9 +776,9 @@ class pluginclass( object ):
|
||||
else:
|
||||
some_not_found = True
|
||||
if some_found and not some_not_found:
|
||||
found_packages.append(pkg)
|
||||
|
||||
if len(found_packages) > 0:
|
||||
found_packages.append(pkg)
|
||||
|
||||
if len(found_packages) > 0:
|
||||
last_separator = Gtk.EventBox()
|
||||
last_separator.add(Gtk.HSeparator())
|
||||
last_separator.set_visible_window(False)
|
||||
@ -787,11 +787,11 @@ class pluginclass( object ):
|
||||
last_separator.show_all()
|
||||
self.applicationsBox.add(last_separator)
|
||||
self.suggestions.append(last_separator)
|
||||
|
||||
|
||||
for pkg in found_packages:
|
||||
name = pkg.name
|
||||
for word in keywords:
|
||||
if word != "":
|
||||
if word != "":
|
||||
name = name.replace(word, "<b>%s</b>" % word);
|
||||
suggestionButton = SuggestionButton(Gtk.STOCK_ADD, self.iconSize, "")
|
||||
suggestionButton.connect("clicked", self.apturl_install, pkg.name)
|
||||
@ -800,24 +800,24 @@ class pluginclass( object ):
|
||||
suggestionButton.set_icon_size(self.iconSize)
|
||||
self.applicationsBox.add(suggestionButton)
|
||||
self.suggestions.append(suggestionButton)
|
||||
|
||||
|
||||
#if len(found_packages) == 0:
|
||||
# self.applicationsBox.remove(self.last_separator)
|
||||
# self.suggestions.remove(self.last_separator)
|
||||
|
||||
|
||||
except Exception, detail:
|
||||
print detail
|
||||
|
||||
|
||||
def Filter( self, widget, category = None ):
|
||||
self.filterTimer = None
|
||||
|
||||
|
||||
for suggestion in self.suggestions:
|
||||
self.applicationsBox.remove(suggestion)
|
||||
self.suggestions = []
|
||||
|
||||
if widget == self.searchEntry:
|
||||
if self.donotfilterapps:
|
||||
widget.set_text( "" )
|
||||
widget.set_text( "" )
|
||||
else:
|
||||
text = widget.get_text()
|
||||
if self.lastActiveTab != 1:
|
||||
@ -844,14 +844,14 @@ class pluginclass( object ):
|
||||
if (not showns and os.path.exists("/usr/bin/mintinstall")):
|
||||
if len(text) >= 3:
|
||||
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)
|
||||
#if (len(self.current_results) > 0):
|
||||
#self.add_apt_filter_results_sync(self.current_results, text)
|
||||
#else:
|
||||
GLib.timeout_add (300, self.add_apt_filter_results, text)
|
||||
else:
|
||||
self.current_results = []
|
||||
self.current_results = []
|
||||
self.add_search_suggestions(text)
|
||||
GLib.timeout_add (300, self.add_apt_filter_results, text)
|
||||
|
||||
@ -889,13 +889,13 @@ class pluginclass( object ):
|
||||
i.released()
|
||||
i.set_relief( Gtk.ReliefStyle.NONE )
|
||||
widget.set_relief( Gtk.ReliefStyle.HALF )
|
||||
|
||||
|
||||
self.applicationsScrolledWindow.get_vadjustment().set_value( 0 )
|
||||
|
||||
def FilterAndClear( self, widget, category = None ):
|
||||
self.searchEntry.set_text( "" )
|
||||
self.Filter( widget, category )
|
||||
|
||||
|
||||
# Forward all text to the search box
|
||||
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(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()
|
||||
|
||||
menuItem = Gtk.ImageMenuItem(_("Search Google"))
|
||||
@ -1068,69 +1068,69 @@ class pluginclass( object ):
|
||||
menuItem.set_image(img)
|
||||
menuItem.connect("activate", self.search_google)
|
||||
menu.append(menuItem)
|
||||
|
||||
|
||||
menuItem = Gtk.ImageMenuItem(_("Search Wikipedia"))
|
||||
img = Gtk.Image()
|
||||
img.set_from_file('/usr/lib/linuxmint/mintMenu/search_engines/wikipedia.ico')
|
||||
menuItem.set_image(img)
|
||||
menuItem.connect("activate", self.search_wikipedia)
|
||||
menu.append(menuItem)
|
||||
|
||||
|
||||
menuItem = Gtk.SeparatorMenuItem()
|
||||
menu.append(menuItem)
|
||||
|
||||
|
||||
menuItem = Gtk.ImageMenuItem(_("Lookup Dictionary"))
|
||||
img = Gtk.Image()
|
||||
img.set_from_file('/usr/lib/linuxmint/mintMenu/search_engines/dictionary.png')
|
||||
menuItem.set_image(img)
|
||||
menuItem.connect("activate", self.search_dictionary)
|
||||
menu.append(menuItem)
|
||||
|
||||
|
||||
menuItem = Gtk.ImageMenuItem(_("Search Computer"))
|
||||
img = Gtk.Image()
|
||||
img.set_from_stock(Gtk.STOCK_FIND, self.iconSize)
|
||||
menuItem.set_image(img)
|
||||
menuItem.connect("activate", self.Search)
|
||||
menu.append(menuItem)
|
||||
|
||||
|
||||
menuItem = Gtk.SeparatorMenuItem()
|
||||
menu.append(menuItem)
|
||||
|
||||
|
||||
menuItem = Gtk.ImageMenuItem(_("Find Software"))
|
||||
img = Gtk.Image()
|
||||
img.set_from_file('/usr/lib/linuxmint/mintMenu/search_engines/software.png')
|
||||
menuItem.set_image(img)
|
||||
menuItem.connect("activate", self.search_mint_software)
|
||||
menu.append(menuItem)
|
||||
|
||||
|
||||
menuItem = Gtk.ImageMenuItem(_("Find Tutorials"))
|
||||
img = Gtk.Image()
|
||||
img.set_from_file('/usr/lib/linuxmint/mintMenu/search_engines/tutorials.png')
|
||||
menuItem.set_image(img)
|
||||
menuItem.connect("activate", self.search_mint_tutorials)
|
||||
menu.append(menuItem)
|
||||
|
||||
|
||||
menuItem = Gtk.ImageMenuItem(_("Find Hardware"))
|
||||
img = Gtk.Image()
|
||||
img.set_from_file('/usr/lib/linuxmint/mintMenu/search_engines/hardware.png')
|
||||
menuItem.set_image(img)
|
||||
menuItem.connect("activate", self.search_mint_hardware)
|
||||
menu.append(menuItem)
|
||||
|
||||
|
||||
menuItem =Gtk.ImageMenuItem(_("Find Ideas"))
|
||||
img = Gtk.Image()
|
||||
img.set_from_file('/usr/lib/linuxmint/mintMenu/search_engines/ideas.png')
|
||||
menuItem.set_image(img)
|
||||
menuItem.connect("activate", self.search_mint_ideas)
|
||||
menu.append(menuItem)
|
||||
|
||||
|
||||
menuItem = Gtk.ImageMenuItem(_("Find Users"))
|
||||
img = Gtk.Image()
|
||||
img.set_from_file('/usr/lib/linuxmint/mintMenu/search_engines/users.png')
|
||||
menuItem.set_image(img)
|
||||
menuItem.connect("activate", self.search_mint_users)
|
||||
menu.append(menuItem)
|
||||
|
||||
|
||||
menu.show_all()
|
||||
|
||||
self.mintMenuWin.stopHiding()
|
||||
@ -1143,60 +1143,60 @@ class pluginclass( object ):
|
||||
#self.mintMenuWin.grab()
|
||||
self.focusSearchEntry(clear = False)
|
||||
return True
|
||||
|
||||
|
||||
def pos_func(self, menu=None):
|
||||
rect = self.searchButton.get_allocation()
|
||||
x = rect.x + rect.width
|
||||
y = rect.y + rect.height
|
||||
return (x, y, False)
|
||||
|
||||
|
||||
def search_google(self, widget):
|
||||
text = self.searchEntry.get_text()
|
||||
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()
|
||||
|
||||
|
||||
def search_wikipedia(self, widget):
|
||||
text = self.searchEntry.get_text()
|
||||
text = text.replace(" ", "+")
|
||||
os.system("xdg-open \"http://en.wikipedia.org/wiki/Special:Search?search=" + text + "\" &")
|
||||
self.mintMenuWin.hide()
|
||||
|
||||
os.system("xdg-open \"http://en.wikipedia.org/wiki/Special:Search?search=" + text + "\" &")
|
||||
self.mintMenuWin.hide()
|
||||
|
||||
def search_dictionary(self, widget):
|
||||
text = self.searchEntry.get_text()
|
||||
os.system("mate-dictionary \"" + text + "\" &")
|
||||
self.mintMenuWin.hide()
|
||||
|
||||
|
||||
def search_mint_tutorials(self, widget):
|
||||
text = self.searchEntry.get_text()
|
||||
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()
|
||||
|
||||
|
||||
def search_mint_ideas(self, widget):
|
||||
text = self.searchEntry.get_text()
|
||||
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()
|
||||
|
||||
|
||||
def search_mint_users(self, widget):
|
||||
text = self.searchEntry.get_text()
|
||||
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()
|
||||
|
||||
|
||||
def search_mint_hardware(self, widget):
|
||||
text = self.searchEntry.get_text()
|
||||
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()
|
||||
|
||||
|
||||
def search_mint_software(self, widget):
|
||||
text = self.searchEntry.get_text()
|
||||
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()
|
||||
|
||||
|
||||
def add_to_desktop(self, widget, desktopEntry):
|
||||
os.system("xdg-desktop-icon install --novendor %s" % desktopEntry.desktopFile)
|
||||
|
||||
@ -1228,7 +1228,7 @@ class pluginclass( object ):
|
||||
except Exception, detail:
|
||||
print detail
|
||||
|
||||
def onLaunchApp( self, menu, widget ):
|
||||
def onLaunchApp( self, menu, widget ):
|
||||
widget.execute()
|
||||
self.mintMenuWin.hide()
|
||||
|
||||
@ -1325,7 +1325,7 @@ class pluginclass( object ):
|
||||
def Search( self, widget ):
|
||||
|
||||
text = self.searchEntry.get_text().strip()
|
||||
if text != "":
|
||||
if text != "":
|
||||
for app_button in self.applicationsBox.get_children():
|
||||
if( isinstance(app_button, ApplicationLauncher) and app_button.filterText( text ) ):
|
||||
app_button.execute()
|
||||
@ -1334,14 +1334,14 @@ class pluginclass( object ):
|
||||
|
||||
self.mintMenuWin.hide()
|
||||
fullstring = self.searchtool.replace( "%s", text )
|
||||
os.system(fullstring + " &")
|
||||
os.system(fullstring + " &")
|
||||
|
||||
def SearchWithButton( self, widget, event ):
|
||||
self.Search( widget )
|
||||
|
||||
def do_plugin( self ):
|
||||
self.Todos()
|
||||
self.buildFavorites()
|
||||
self.buildFavorites()
|
||||
|
||||
# Scroll button into view
|
||||
def scrollItemIntoView( self, widget, event = None ):
|
||||
@ -1612,15 +1612,15 @@ class pluginclass( object ):
|
||||
|
||||
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!
|
||||
if self.rebuildLock:
|
||||
if self.rebuildLock:
|
||||
return
|
||||
|
||||
self.rebuildLock = True
|
||||
|
||||
self.menuChangedTimer = None
|
||||
|
||||
|
||||
self.loadMenuFiles()
|
||||
|
||||
# Find added and removed categories than update the category list
|
||||
@ -1641,7 +1641,7 @@ class pluginclass( object ):
|
||||
break
|
||||
if not found:
|
||||
addedCategories.append(item)
|
||||
|
||||
|
||||
for item in self.categoryList:
|
||||
found = False
|
||||
for item2 in newCategoryList:
|
||||
@ -1655,10 +1655,10 @@ class pluginclass( object ):
|
||||
categoryIconSize = self.iconSize
|
||||
else:
|
||||
categoryIconSize = 0
|
||||
|
||||
|
||||
for item in removedCategories:
|
||||
try:
|
||||
button = item["button"]
|
||||
button = item["button"]
|
||||
self.categoryList.remove(item)
|
||||
button.destroy()
|
||||
del item
|
||||
@ -1709,7 +1709,7 @@ class pluginclass( object ):
|
||||
newApplicationList = self.buildApplicationList()
|
||||
addedApplications = []
|
||||
removedApplications = []
|
||||
|
||||
|
||||
# TODO: optimize this!!!
|
||||
if not self.applicationList:
|
||||
addedApplications = newApplicationList
|
||||
@ -1737,22 +1737,22 @@ class pluginclass( object ):
|
||||
# because when it is removed the index of all later items is
|
||||
# going to be decreased
|
||||
key += 1
|
||||
|
||||
|
||||
for key in removedApplications:
|
||||
self.applicationList[key]["button"].destroy()
|
||||
del self.applicationList[key]
|
||||
del self.applicationList[key]
|
||||
if addedApplications:
|
||||
sortedApplicationList = []
|
||||
for item in self.applicationList:
|
||||
self.applicationsBox.remove( item["button"] )
|
||||
sortedApplicationList.append( ( item["button"].appName, item["button"] ) )
|
||||
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:
|
||||
self.mintMenuWin.setTooltip( item["button"], item["button"].getTooltip() )
|
||||
item["button"].connect( "button-press-event", self.menuPopup )
|
||||
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:
|
||||
item["button"].filterText( self.activeFilter[1] )
|
||||
else:
|
||||
@ -1764,8 +1764,8 @@ class pluginclass( object ):
|
||||
item["button"].destroy()
|
||||
|
||||
|
||||
sortedApplicationList.sort()
|
||||
launcherNames = [] # Keep track of launcher names so we don't add them twice in the list..
|
||||
sortedApplicationList.sort()
|
||||
launcherNames = [] # Keep track of launcher names so we don't add them twice in the list..
|
||||
for item in sortedApplicationList:
|
||||
launcherName = item[0]
|
||||
button = item[1]
|
||||
@ -1774,8 +1774,8 @@ class pluginclass( object ):
|
||||
button.hide()
|
||||
else:
|
||||
launcherNames.append(launcherName)
|
||||
|
||||
self.rebuildLock = False
|
||||
|
||||
self.rebuildLock = False
|
||||
|
||||
# Reload the menufiles from the filesystem
|
||||
def loadMenuFiles( self ):
|
||||
|
@ -60,7 +60,7 @@ class IconManager(GObject.GObject):
|
||||
|
||||
|
||||
def getIcon( self, iconName, iconSize ):
|
||||
|
||||
|
||||
if not iconName:
|
||||
return None
|
||||
|
||||
@ -143,7 +143,7 @@ class easyButton( Gtk.Button ):
|
||||
if labels:
|
||||
for label in labels:
|
||||
if isinstance( label, basestring ):
|
||||
self.addLabel( label )
|
||||
self.addLabel( label )
|
||||
elif isinstance( label, list ):
|
||||
self.addLabel( label[0], label[1] )
|
||||
|
||||
@ -197,7 +197,7 @@ class easyButton( Gtk.Button ):
|
||||
return None
|
||||
|
||||
icon = iconManager.getIcon( self.iconName, iconSize )
|
||||
if icon is None:
|
||||
if icon is None:
|
||||
icon = iconManager.getIcon( "application-default-icon", iconSize )
|
||||
|
||||
return icon
|
||||
@ -335,7 +335,7 @@ class ApplicationLauncher( easyButton ):
|
||||
|
||||
def setupLabels( self ):
|
||||
self.addLabel( self.appName )
|
||||
|
||||
|
||||
def filterText( self, text ):
|
||||
keywords = text.lower().split()
|
||||
appName = self.appName.lower()
|
||||
@ -351,14 +351,14 @@ class ApplicationLauncher( easyButton ):
|
||||
self.show()
|
||||
return True
|
||||
|
||||
def strip_accents(self, string):
|
||||
def strip_accents(self, string):
|
||||
value = string
|
||||
if isinstance(string, unicode):
|
||||
try:
|
||||
value = string.encode('UTF8', 'ignore')
|
||||
value = string.encode('UTF8', 'ignore')
|
||||
except:
|
||||
pass
|
||||
return value
|
||||
return value
|
||||
|
||||
def getTooltip( self ):
|
||||
tooltip = self.appName
|
||||
@ -488,12 +488,12 @@ class MenuApplicationLauncher( ApplicationLauncher ):
|
||||
else:
|
||||
self.hide()
|
||||
|
||||
def setupLabels( self ):
|
||||
def setupLabels( self ):
|
||||
appName = self.appName
|
||||
appComment = self.appComment
|
||||
if self.highlight:
|
||||
if self.highlight:
|
||||
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] == "#":
|
||||
#appName = "<span foreground=\"%s\"><b>%s</b></span>" % (color, appName);
|
||||
#appComment = "<span foreground=\"%s\"><b>%s</b></span>" % (color, appComment);
|
||||
@ -507,7 +507,7 @@ class MenuApplicationLauncher( ApplicationLauncher ):
|
||||
except Exception, detail:
|
||||
print detail
|
||||
pass
|
||||
|
||||
|
||||
if self.showComment and self.appComment != "":
|
||||
if self.iconSize <= 2:
|
||||
self.addLabel( '<span size="small">%s</span>' % appName)
|
||||
@ -517,8 +517,8 @@ class MenuApplicationLauncher( ApplicationLauncher ):
|
||||
self.addLabel( '<span size="small">%s</span>' % appComment)
|
||||
else:
|
||||
self.addLabel( appName )
|
||||
|
||||
def execute( self, *args ):
|
||||
|
||||
def execute( self, *args ):
|
||||
self.highlight = False
|
||||
for child in self.labelBox:
|
||||
child.destroy()
|
||||
@ -553,7 +553,7 @@ class FavApplicationLauncher( ApplicationLauncher ):
|
||||
self.addLabel( self.appComment )
|
||||
else:
|
||||
self.addLabel ( "" )
|
||||
|
||||
|
||||
def setSwapGeneric( self, swapGeneric ):
|
||||
self.swapGeneric = swapGeneric
|
||||
for child in self.labelBox:
|
||||
|
@ -3,122 +3,12 @@
|
||||
import os
|
||||
import os.path
|
||||
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):
|
||||
path = urllib.url2pathname(uri) # escape special chars
|
||||
path = path.strip('\r\n\x00') # remove \r\n and NULL
|
||||
path = urllib.url2pathname(uri) # escape special chars
|
||||
path = path.strip('\r\n\x00') # remove \r\n and NULL
|
||||
|
||||
# get the path to file
|
||||
if path.startswith('file://'): # nautilus, rox
|
||||
path = path[7:] # 7 is len('file://')
|
||||
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"
|
||||
"""
|
||||
# get the path to file
|
||||
if path.startswith('file://'): # nautilus, rox
|
||||
path = path[7:] # 7 is len('file://')
|
||||
return path
|
||||
|
@ -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']:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def bindGSettingsEntryToVar( self, type, key, obj, varName ):
|
||||
return self.notifyAdd( key, self.setVar, ( type, obj, varName ) )
|
||||
|
||||
|
||||
def setVar( self, settings, key, args ):
|
||||
type, obj, varName = args
|
||||
|
||||
|
@ -3,45 +3,45 @@
|
||||
import os
|
||||
|
||||
def RemoveArgs(Execline):
|
||||
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"]
|
||||
for elem in Execline:
|
||||
elem = elem.replace("'","")
|
||||
elem = elem.replace("\"", "")
|
||||
if elem not in Specials:
|
||||
print elem
|
||||
NewExecline.append(elem)
|
||||
return 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"]
|
||||
for elem in Execline:
|
||||
elem = elem.replace("'","")
|
||||
elem = elem.replace("\"", "")
|
||||
if elem not in Specials:
|
||||
print elem
|
||||
NewExecline.append(elem)
|
||||
return NewExecline
|
||||
|
||||
# Actually execute the command
|
||||
def Execute( cmd , commandCwd=None):
|
||||
if not commandCwd:
|
||||
cwd = os.path.expanduser( "~" );
|
||||
else:
|
||||
tmpCwd = os.path.expanduser( commandCwd );
|
||||
if (os.path.exists(tmpCwd)):
|
||||
cwd = tmpCwd
|
||||
|
||||
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):
|
||||
print "running manually..."
|
||||
try:
|
||||
os.chdir(cwd)
|
||||
os.system(cmd + " &")
|
||||
return True
|
||||
except Exception, detail:
|
||||
print detail
|
||||
return False
|
||||
cmd = cmd.split()
|
||||
cmd = RemoveArgs(cmd)
|
||||
|
||||
try:
|
||||
os.chdir( cwd )
|
||||
string = ' '.join(cmd)
|
||||
string = string + " &"
|
||||
os.system(string)
|
||||
return True
|
||||
except Exception, detail:
|
||||
print detail
|
||||
return False
|
||||
|
||||
if not commandCwd:
|
||||
cwd = os.path.expanduser( "~" );
|
||||
else:
|
||||
tmpCwd = os.path.expanduser( commandCwd );
|
||||
if (os.path.exists(tmpCwd)):
|
||||
cwd = tmpCwd
|
||||
|
||||
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):
|
||||
print "running manually..."
|
||||
try:
|
||||
os.chdir(cwd)
|
||||
os.system(cmd + " &")
|
||||
return True
|
||||
except Exception, detail:
|
||||
print detail
|
||||
return False
|
||||
cmd = cmd.split()
|
||||
cmd = RemoveArgs(cmd)
|
||||
|
||||
try:
|
||||
os.chdir( cwd )
|
||||
string = ' '.join(cmd)
|
||||
string = string + " &"
|
||||
os.system(string)
|
||||
return True
|
||||
except Exception, detail:
|
||||
print detail
|
||||
return False
|
||||
|
||||
|
@ -31,7 +31,7 @@ if hasInotify:
|
||||
if mId >= 0:
|
||||
self.callbacks[mId] = ( callback, args )
|
||||
except Exception, detail:
|
||||
mId = 0
|
||||
mId = 0
|
||||
return mId
|
||||
|
||||
def removeMonitor( self, monitorId ):
|
||||
|
@ -3,7 +3,7 @@
|
||||
import apt, sys
|
||||
|
||||
try:
|
||||
cache = apt.Cache()
|
||||
cache = apt.Cache()
|
||||
for pkg in cache:
|
||||
if not pkg.is_installed:
|
||||
name = pkg.name
|
||||
|
@ -28,10 +28,10 @@ class pluginclass( object ):
|
||||
self.toggleButton = toggleButton
|
||||
self.de = de
|
||||
|
||||
# Read UI file
|
||||
# Read UI file
|
||||
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.editableBtnHolder = builder.get_object( "editable_button_holder" )
|
||||
self.scrolledWindow=builder.get_object("scrolledwindow2")
|
||||
@ -49,7 +49,7 @@ class pluginclass( object ):
|
||||
# Items to get custom colors
|
||||
self.itemstocolor = [ builder.get_object( "viewport2" ) ]
|
||||
|
||||
# Settings
|
||||
# Settings
|
||||
self.settings = EasyGSettings("com.linuxmint.mintmenu.plugins.places")
|
||||
|
||||
self.settings.notifyAdd( "icon-size", self.RegenPlugin )
|
||||
@ -62,11 +62,11 @@ class pluginclass( object ):
|
||||
self.settings.notifyAdd( "allow-scrollbar", self.RegenPlugin )
|
||||
self.settings.notifyAdd( "show-gtk-bookmarks", self.RegenPlugin )
|
||||
self.settings.notifyAdd( "height", self.changePluginSize )
|
||||
self.settings.notifyAdd( "width", self.changePluginSize )
|
||||
self.settings.notifyAdd( "width", self.changePluginSize )
|
||||
|
||||
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) :
|
||||
if ( self.showtrash == True ):
|
||||
@ -77,7 +77,7 @@ class pluginclass( object ):
|
||||
|
||||
def changePluginSize( self, settings, key, args = None):
|
||||
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):
|
||||
self.height = -1
|
||||
self.scrolledWindow.set_policy( Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.NEVER )
|
||||
@ -103,7 +103,7 @@ class pluginclass( object ):
|
||||
if (self.allowScrollbar == False):
|
||||
self.height = -1
|
||||
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" )
|
||||
|
||||
# Check default items
|
||||
@ -127,7 +127,7 @@ class pluginclass( object ):
|
||||
# Allow plugin to be minimized to the left plugin pane
|
||||
self.sticky = self.settings.get( "bool", "sticky")
|
||||
self.minimized = self.settings.get( "bool", "minimized")
|
||||
|
||||
|
||||
def ClearAll(self):
|
||||
for child in self.placesBtnHolder.get_children():
|
||||
child.destroy()
|
||||
@ -221,7 +221,7 @@ class pluginclass( object ):
|
||||
currentbutton.show()
|
||||
self.placesBtnHolder.pack_start( currentbutton, False, False, 0)
|
||||
|
||||
def do_gtk_bookmarks( self ):
|
||||
def do_gtk_bookmarks( self ):
|
||||
if self.showGTKBookmarks:
|
||||
if not os.path.exists(os.path.expanduser('~/.gtk-bookmarks')):
|
||||
return
|
||||
@ -247,7 +247,7 @@ class pluginclass( object ):
|
||||
currentbutton.connect( "clicked", self.launch_gtk_bookmark, path )
|
||||
currentbutton.show()
|
||||
self.placesBtnHolder.pack_start( currentbutton, False, False, 0)
|
||||
|
||||
|
||||
def launch_gtk_bookmark (self, widget, path):
|
||||
self.mintMenuWin.hide()
|
||||
if self.de == "mate":
|
||||
|
@ -17,7 +17,7 @@ class PointerMonitor(GObject.GObject, threading.Thread):
|
||||
__gsignals__ = {
|
||||
'activate': (GObject.SignalFlags.RUN_LAST, None, ()),
|
||||
}
|
||||
|
||||
|
||||
def __init__(self):
|
||||
GObject.GObject.__init__ (self)
|
||||
threading.Thread.__init__ (self)
|
||||
@ -25,17 +25,17 @@ class PointerMonitor(GObject.GObject, threading.Thread):
|
||||
self.display = Display()
|
||||
self.root = self.display.screen().root
|
||||
self.windows = []
|
||||
|
||||
|
||||
# Receives GDK windows
|
||||
def addWindowToMonitor(self, window):
|
||||
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)))
|
||||
self.windows.append(xWindow)
|
||||
|
||||
|
||||
def grabPointer(self):
|
||||
self.root.grab_button(X.AnyButton, X.AnyModifier, True, X.ButtonPressMask, X.GrabModeSync, X.GrabModeAsync, 0, 0)
|
||||
self.display.flush()
|
||||
|
||||
|
||||
def ungrabPointer(self):
|
||||
self.root.ungrab_button(X.AnyButton, X.AnyModifier)
|
||||
self.display.flush()
|
||||
@ -46,7 +46,7 @@ class PointerMonitor(GObject.GObject, threading.Thread):
|
||||
|
||||
def activate(self):
|
||||
GLib.idle_add(self.run)
|
||||
|
||||
|
||||
def run(self):
|
||||
self.running = True
|
||||
while self.running:
|
||||
@ -63,7 +63,7 @@ class PointerMonitor(GObject.GObject, threading.Thread):
|
||||
# Is outside, so activate
|
||||
GLib.idle_add(self.idle)
|
||||
self.display.allow_events(X.ReplayPointer, event.time)
|
||||
else:
|
||||
else:
|
||||
self.display.allow_events(X.ReplayPointer, X.CurrentTime)
|
||||
except Exception as e:
|
||||
print "Unexpected error: " + str(e)
|
||||
@ -72,4 +72,4 @@ class PointerMonitor(GObject.GObject, threading.Thread):
|
||||
self.running = False
|
||||
self.root.ungrab_button(X.AnyButton, X.AnyModifier)
|
||||
self.display.close()
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user