further cleanup, mostly coding style
This commit is contained in:
parent
cc75da5868
commit
8b42c0f32f
@ -1,6 +1,5 @@
|
|||||||
#!/usr/bin/python2
|
#!/usr/bin/python2
|
||||||
|
|
||||||
|
|
||||||
import gc
|
import gc
|
||||||
import gettext
|
import gettext
|
||||||
import os
|
import os
|
||||||
@ -21,6 +20,7 @@ import pointerMonitor
|
|||||||
import setproctitle
|
import setproctitle
|
||||||
from plugins.execute import Execute
|
from plugins.execute import Execute
|
||||||
|
|
||||||
|
|
||||||
GObject.threads_init()
|
GObject.threads_init()
|
||||||
|
|
||||||
# Rename the process
|
# Rename the process
|
||||||
@ -50,7 +50,6 @@ class MainWindow( object ):
|
|||||||
sys.path.append(os.path.join(self.path, "plugins"))
|
sys.path.append(os.path.join(self.path, "plugins"))
|
||||||
|
|
||||||
self.de = de
|
self.de = de
|
||||||
|
|
||||||
self.icon = "/usr/lib/linuxmint/mintMenu/visualisation-logo.png"
|
self.icon = "/usr/lib/linuxmint/mintMenu/visualisation-logo.png"
|
||||||
|
|
||||||
self.toggle = toggleButton
|
self.toggle = toggleButton
|
||||||
@ -222,7 +221,7 @@ class MainWindow( object ):
|
|||||||
Align1.show()
|
Align1.show()
|
||||||
Label1.show()
|
Label1.show()
|
||||||
|
|
||||||
if not hasattr( MyPlugin, 'sticky' ) or MyPlugin.sticky == True:
|
if not hasattr(MyPlugin, 'sticky') or MyPlugin.sticky:
|
||||||
heading = Gtk.EventBox()
|
heading = Gtk.EventBox()
|
||||||
Align1.set_padding(0, 0, 10, 0)
|
Align1.set_padding(0, 0, 10, 0)
|
||||||
heading.set_visible_window(False)
|
heading.set_visible_window(False)
|
||||||
@ -400,8 +399,8 @@ class MainWindow( object ):
|
|||||||
if hasattr(plugin, "onShowMenu"):
|
if hasattr(plugin, "onShowMenu"):
|
||||||
plugin.onShowMenu()
|
plugin.onShowMenu()
|
||||||
|
|
||||||
if ( "applications" in self.plugins ) and ( hasattr( self.plugins["applications"], "focusSearchEntry" ) ):
|
if "applications" in self.plugins and hasattr(self.plugins["applications"], "focusSearchEntry"):
|
||||||
if (self.startWithFavorites):
|
if self.startWithFavorites:
|
||||||
self.plugins["applications"].changeTab(0)
|
self.plugins["applications"].changeTab(0)
|
||||||
self.plugins["applications"].focusSearchEntry()
|
self.plugins["applications"].focusSearchEntry()
|
||||||
|
|
||||||
@ -430,6 +429,7 @@ class MainWindow( object ):
|
|||||||
self.loseFocusBlocked = True
|
self.loseFocusBlocked = True
|
||||||
|
|
||||||
class MenuWin(object):
|
class MenuWin(object):
|
||||||
|
|
||||||
def __init__(self, applet, iid):
|
def __init__(self, applet, iid):
|
||||||
self.applet = applet
|
self.applet = applet
|
||||||
self.detect_desktop_environment()
|
self.detect_desktop_environment()
|
||||||
|
@ -22,6 +22,7 @@ from plugins.easybuttons import (CategoryButton, FavApplicationLauncher,
|
|||||||
from plugins.easygsettings import EasyGSettings
|
from plugins.easygsettings import EasyGSettings
|
||||||
from plugins.execute import Execute
|
from plugins.execute import Execute
|
||||||
|
|
||||||
|
|
||||||
# i18n
|
# i18n
|
||||||
gettext.install("mintmenu", "/usr/share/linuxmint/locale")
|
gettext.install("mintmenu", "/usr/share/linuxmint/locale")
|
||||||
|
|
||||||
@ -477,8 +478,8 @@ class pluginclass( object ):
|
|||||||
# Hide vertical dotted separator
|
# Hide vertical dotted separator
|
||||||
self.hideseparator = self.settings.get("bool", "hide-separator")
|
self.hideseparator = self.settings.get("bool", "hide-separator")
|
||||||
|
|
||||||
def SetHidden( self, state ):
|
def SetHidden(self, minimized):
|
||||||
if state == True:
|
if minimized:
|
||||||
self.settings.set("bool", "minimized", True)
|
self.settings.set("bool", "minimized", True)
|
||||||
else:
|
else:
|
||||||
self.settings.set("bool", "minimized", False)
|
self.settings.set("bool", "minimized", False)
|
||||||
@ -647,9 +648,9 @@ class pluginclass( object ):
|
|||||||
values = string.split(pkg, "###")
|
values = string.split(pkg, "###")
|
||||||
if len(values) == 4:
|
if len(values) == 4:
|
||||||
status = values[0]
|
status = values[0]
|
||||||
if (status == "ERROR"):
|
if status == "ERROR":
|
||||||
print "Could not refresh APT cache"
|
print "Could not refresh APT cache"
|
||||||
elif (status == "CACHE"):
|
elif status == "CACHE":
|
||||||
name = values[1]
|
name = values[1]
|
||||||
summary = values[2]
|
summary = values[2]
|
||||||
description = values[3].replace("~~~", "\n")
|
description = values[3].replace("~~~", "\n")
|
||||||
@ -776,7 +777,7 @@ class pluginclass( object ):
|
|||||||
shownList = []
|
shownList = []
|
||||||
for i in self.applicationsBox.get_children():
|
for i in self.applicationsBox.get_children():
|
||||||
shown = i.filterText(text)
|
shown = i.filterText(text)
|
||||||
if (shown):
|
if shown:
|
||||||
dupe = False
|
dupe = False
|
||||||
for item in shownList:
|
for item in shownList:
|
||||||
if i.desktopFile == item.desktopFile:
|
if i.desktopFile == item.desktopFile:
|
||||||
@ -790,7 +791,7 @@ class pluginclass( object ):
|
|||||||
if(not showns):
|
if(not showns):
|
||||||
i.grab_focus()
|
i.grab_focus()
|
||||||
showns = True
|
showns = True
|
||||||
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...
|
||||||
@ -1146,13 +1147,13 @@ class pluginclass( object ):
|
|||||||
applet_list = panel_schema.get_strv("object-id-list")
|
applet_list = panel_schema.get_strv("object-id-list")
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
test_obj = "object_%d" % (i)
|
test_obj = "object_%d" % i
|
||||||
if test_obj in applet_list:
|
if test_obj in applet_list:
|
||||||
i += 1
|
i += 1
|
||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
|
|
||||||
path = "/org/mate/panel/objects/%s/" % (test_obj)
|
path = "/org/mate/panel/objects/%s/" % test_obj
|
||||||
new_schema = Gio.Settings.new_with_path("org.mate.panel.object", path)
|
new_schema = Gio.Settings.new_with_path("org.mate.panel.object", path)
|
||||||
new_schema.set_string("launcher-location", desktopEntry.desktopFile)
|
new_schema.set_string("launcher-location", desktopEntry.desktopFile)
|
||||||
new_schema.set_string("object-type", "launcher")
|
new_schema.set_string("object-type", "launcher")
|
||||||
@ -1224,7 +1225,6 @@ class pluginclass( object ):
|
|||||||
else:
|
else:
|
||||||
self.buildFavorites()
|
self.buildFavorites()
|
||||||
|
|
||||||
|
|
||||||
def onUninstallApp(self, menu, widget):
|
def onUninstallApp(self, menu, widget):
|
||||||
widget.uninstall()
|
widget.uninstall()
|
||||||
self.mintMenuWin.hide()
|
self.mintMenuWin.hide()
|
||||||
@ -1300,9 +1300,7 @@ class pluginclass( object ):
|
|||||||
space.set_visible_window(False)
|
space.set_visible_window(False)
|
||||||
space.connect("button-press-event", self.favPopup)
|
space.connect("button-press-event", self.favPopup)
|
||||||
space.type = "space"
|
space.type = "space"
|
||||||
|
|
||||||
space.show()
|
space.show()
|
||||||
|
|
||||||
return space
|
return space
|
||||||
|
|
||||||
def favoritesBuildSeparator(self):
|
def favoritesBuildSeparator(self):
|
||||||
@ -1368,12 +1366,12 @@ class pluginclass( object ):
|
|||||||
|
|
||||||
def buildFavorites(self):
|
def buildFavorites(self):
|
||||||
try:
|
try:
|
||||||
if (not os.path.exists(home + "/.linuxmint/mintMenu/applications.list")):
|
path = os.path.join(home, ".linuxmint/mintMenu/applications.list")
|
||||||
os.system("mkdir -p " + home + "/.linuxmint/mintMenu/applications")
|
if not os.path.exists(path):
|
||||||
os.system("cp /usr/lib/linuxmint/mintMenu/applications.list " + home + "/.linuxmint/mintMenu/applications.list")
|
os.system("mkdir -p " + path)
|
||||||
|
os.system("cp /usr/lib/linuxmint/mintMenu/applications.list " + path)
|
||||||
|
|
||||||
applicationsFile = open ( os.path.join( os.path.expanduser( "~" ), ".linuxmint", "mintMenu", "applications.list" ), "r" )
|
applicationsList = open(path).readlines() # TODO py3 encoding="UTF-8"
|
||||||
applicationsList = applicationsFile.readlines()
|
|
||||||
|
|
||||||
self.favorites = []
|
self.favorites = []
|
||||||
|
|
||||||
@ -1392,7 +1390,7 @@ class pluginclass( object ):
|
|||||||
elif app == "separator":
|
elif app == "separator":
|
||||||
favButton = self.favoritesBuildSeparator()
|
favButton = self.favoritesBuildSeparator()
|
||||||
else:
|
else:
|
||||||
if ( app.endswith( ".desktop" ) ):
|
if app.endswith(".desktop"):
|
||||||
favButton = self.favoritesBuildLauncher(app)
|
favButton = self.favoritesBuildLauncher(app)
|
||||||
else:
|
else:
|
||||||
favButton = None
|
favButton = None
|
||||||
@ -1493,17 +1491,15 @@ class pluginclass( object ):
|
|||||||
def favoritesSave(self):
|
def favoritesSave(self):
|
||||||
try:
|
try:
|
||||||
self.checkMintMenuFolder()
|
self.checkMintMenuFolder()
|
||||||
appListFile = open( os.path.join( os.path.expanduser( "~"), ".linuxmint", "mintMenu", "applications.list" ) , "w" )
|
with open(os.path.join(home, ".linuxmint/mintMenu/applications.list") , "w") as appListFile:
|
||||||
|
|
||||||
for favorite in self.favorites:
|
for favorite in self.favorites:
|
||||||
if favorite.type == "location":
|
if favorite.type == "location":
|
||||||
appListFile.write("location:" + favorite.desktopFile + "\n")
|
appListFile.write("location:" + favorite.desktopFile + "\n")
|
||||||
else:
|
else:
|
||||||
appListFile.write(favorite.type + "\n")
|
appListFile.write(favorite.type + "\n")
|
||||||
|
|
||||||
appListFile.close( )
|
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
msgDlg = Gtk.MessageDialog( None, Gtk.DialogFlags.MODAL, Gtk.MessageType.ERROR, Gtk.ButtonsType.OK, _("Couldn't save favorites. Check if you have write access to ~/.linuxmint/mintMenu")+"\n(" + e.__str__() + ")" )
|
msgDlg = Gtk.MessageDialog(None, Gtk.DialogFlags.MODAL, Gtk.MessageType.ERROR, Gtk.ButtonsType.OK,
|
||||||
|
_("Couldn't save favorites. Check if you have write access to ~/.linuxmint/mintMenu")+"\n(" + e.__str__() + ")")
|
||||||
msgDlg.run()
|
msgDlg.run()
|
||||||
msgDlg.destroy()
|
msgDlg.destroy()
|
||||||
|
|
||||||
@ -1543,11 +1539,9 @@ class pluginclass( object ):
|
|||||||
return
|
return
|
||||||
|
|
||||||
self.rebuildLock = True
|
self.rebuildLock = True
|
||||||
|
|
||||||
self.menuChangedTimer = None
|
self.menuChangedTimer = None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
self.loadMenuFiles()
|
self.loadMenuFiles()
|
||||||
|
|
||||||
# Find added and removed categories than update the category list
|
# Find added and removed categories than update the category list
|
||||||
@ -1578,7 +1572,7 @@ class pluginclass( object ):
|
|||||||
if not found:
|
if not found:
|
||||||
removedCategories.append(item)
|
removedCategories.append(item)
|
||||||
|
|
||||||
if self.showcategoryicons == True:
|
if self.showcategoryicons:
|
||||||
categoryIconSize = self.iconSize
|
categoryIconSize = self.iconSize
|
||||||
else:
|
else:
|
||||||
categoryIconSize = 0
|
categoryIconSize = 0
|
||||||
@ -1631,7 +1625,6 @@ class pluginclass( object ):
|
|||||||
except Exception, e:
|
except Exception, e:
|
||||||
print e
|
print e
|
||||||
|
|
||||||
|
|
||||||
# Find added and removed applications add update the application list
|
# Find added and removed applications add update the application list
|
||||||
newApplicationList = self.buildApplicationList()
|
newApplicationList = self.buildApplicationList()
|
||||||
addedApplications = []
|
addedApplications = []
|
||||||
@ -1690,7 +1683,6 @@ class pluginclass( object ):
|
|||||||
else:
|
else:
|
||||||
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:
|
||||||
@ -1715,9 +1707,7 @@ class pluginclass( object ):
|
|||||||
# Build a list of all categories in the menu ([{"name", "icon", tooltip"}]
|
# Build a list of all categories in the menu ([{"name", "icon", tooltip"}]
|
||||||
def buildCategoryList(self):
|
def buildCategoryList(self):
|
||||||
newCategoryList = [{"name": _("All"), "icon": "edit-select-all", "tooltip": _("Show all applications"), "filter":"", "index": 0}]
|
newCategoryList = [{"name": _("All"), "icon": "edit-select-all", "tooltip": _("Show all applications"), "filter":"", "index": 0}]
|
||||||
|
|
||||||
num = 1
|
num = 1
|
||||||
|
|
||||||
for menu in self.menuFiles:
|
for menu in self.menuFiles:
|
||||||
for child in menu.directory.get_contents():
|
for child in menu.directory.get_contents():
|
||||||
if child.get_type() == matemenu.TYPE_DIRECTORY:
|
if child.get_type() == matemenu.TYPE_DIRECTORY:
|
||||||
@ -1727,7 +1717,6 @@ class pluginclass( object ):
|
|||||||
#if (icon != "applications-system" and icon != "applications-other"):
|
#if (icon != "applications-system" and icon != "applications-other"):
|
||||||
newCategoryList.append({"name": child.name, "icon": child.icon, "tooltip": child.name, "filter": child.name, "index": num})
|
newCategoryList.append({"name": child.name, "icon": child.icon, "tooltip": child.name, "filter": child.name, "index": num})
|
||||||
num += 1
|
num += 1
|
||||||
|
|
||||||
return newCategoryList
|
return newCategoryList
|
||||||
|
|
||||||
# Build a list containing the DesktopEntry object and the category of each application in the menu
|
# Build a list containing the DesktopEntry object and the category of each application in the menu
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#!/usr/bin/python2
|
#!/usr/bin/python2
|
||||||
|
|
||||||
import os.path
|
import os.path
|
||||||
import re
|
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
import xdg.DesktopEntry
|
import xdg.DesktopEntry
|
||||||
@ -12,7 +11,6 @@ gi.require_version('MateDesktop', '2.0')
|
|||||||
from gi.repository import Gtk, Gdk, GLib
|
from gi.repository import Gtk, Gdk, GLib
|
||||||
from gi.repository import Pango
|
from gi.repository import Pango
|
||||||
from gi.repository import GObject
|
from gi.repository import GObject
|
||||||
from gi.repository import MateDesktop
|
|
||||||
|
|
||||||
from plugins.execute import Execute
|
from plugins.execute import Execute
|
||||||
from plugins.filemonitor import monitor as filemonitor
|
from plugins.filemonitor import monitor as filemonitor
|
||||||
@ -491,8 +489,8 @@ class MenuApplicationLauncher( ApplicationLauncher ):
|
|||||||
#else:
|
#else:
|
||||||
#appName = "<b>%s</b>" % (appName);
|
#appName = "<b>%s</b>" % (appName);
|
||||||
#appComment = "<b>%s</b>" % (appComment);
|
#appComment = "<b>%s</b>" % (appComment);
|
||||||
appName = "<b>%s</b>" % (appName);
|
appName = "<b>%s</b>" % appName
|
||||||
appComment = "<b>%s</b>" % (appComment);
|
appComment = "<b>%s</b>" % appComment
|
||||||
except Exception, detail:
|
except Exception, detail:
|
||||||
print detail
|
print detail
|
||||||
pass
|
pass
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import urllib
|
import urllib
|
||||||
|
|
||||||
|
|
||||||
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
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#!/usr/bin/python2
|
#!/usr/bin/python2
|
||||||
|
|
||||||
|
|
||||||
from gi.repository import Gio
|
from gi.repository import Gio
|
||||||
|
|
||||||
|
|
||||||
class EasyGSettings:
|
class EasyGSettings:
|
||||||
|
|
||||||
def __init__(self, schema = None):
|
def __init__(self, schema = None):
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
import os
|
import os
|
||||||
from gi.repository import Gio
|
from gi.repository import Gio
|
||||||
|
|
||||||
|
|
||||||
def RemoveArgs(Execline):
|
def RemoveArgs(Execline):
|
||||||
if isinstance(Execline, list):
|
if isinstance(Execline, list):
|
||||||
Execline = ' '.join(Execline)
|
Execline = ' '.join(Execline)
|
||||||
|
@ -12,7 +12,9 @@ try:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
hasInotify = False
|
hasInotify = False
|
||||||
|
|
||||||
|
|
||||||
if hasInotify:
|
if hasInotify:
|
||||||
|
|
||||||
class FileMonitor(object):
|
class FileMonitor(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.monitorId = 0
|
self.monitorId = 0
|
||||||
@ -48,7 +50,6 @@ if hasInotify:
|
|||||||
else:
|
else:
|
||||||
GLib.idle_add(callback[0])
|
GLib.idle_add(callback[0])
|
||||||
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
||||||
class _MonitoredFile(object):
|
class _MonitoredFile(object):
|
||||||
@ -91,8 +92,6 @@ else:
|
|||||||
self.monitor.checkFiles()
|
self.monitor.checkFiles()
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class FileMonitor(object):
|
class FileMonitor(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.monitorId = 0
|
self.monitorId = 0
|
||||||
@ -120,5 +119,4 @@ else:
|
|||||||
else:
|
else:
|
||||||
GLib.idle_add(monitored.callback)
|
GLib.idle_add(monitored.callback)
|
||||||
|
|
||||||
|
|
||||||
monitor = FileMonitor()
|
monitor = FileMonitor()
|
||||||
|
@ -15,6 +15,7 @@ from plugins.easybuttons import easyButton
|
|||||||
from plugins.easygsettings import EasyGSettings
|
from plugins.easygsettings import EasyGSettings
|
||||||
from plugins.execute import Execute
|
from plugins.execute import Execute
|
||||||
|
|
||||||
|
|
||||||
# i18n
|
# i18n
|
||||||
gettext.install("mintmenu", "/usr/share/linuxmint/locale")
|
gettext.install("mintmenu", "/usr/share/linuxmint/locale")
|
||||||
|
|
||||||
@ -67,7 +68,7 @@ class pluginclass( object ):
|
|||||||
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:
|
||||||
self.refreshTrash()
|
self.refreshTrash()
|
||||||
|
|
||||||
def destroy(self):
|
def destroy(self):
|
||||||
@ -76,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 not self.allowScrollbar:
|
||||||
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)
|
||||||
else:
|
else:
|
||||||
@ -98,7 +99,7 @@ class pluginclass( object ):
|
|||||||
self.scrolledWindow.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
|
self.scrolledWindow.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
|
||||||
self.height = self.settings.get("int", "height")
|
self.height = self.settings.get("int", "height")
|
||||||
self.content_holder.set_size_request(self.width, self.height)
|
self.content_holder.set_size_request(self.width, self.height)
|
||||||
if (self.allowScrollbar == False):
|
if not self.allowScrollbar:
|
||||||
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)
|
||||||
@ -135,21 +136,21 @@ class pluginclass( object ):
|
|||||||
#Add standard places
|
#Add standard places
|
||||||
def do_standard_places(self):
|
def do_standard_places(self):
|
||||||
|
|
||||||
if ( self.showcomputer == True ):
|
if self.showcomputer:
|
||||||
Button1 = easyButton("computer", self.iconsize, [_("Computer")], -1, -1)
|
Button1 = easyButton("computer", self.iconsize, [_("Computer")], -1, -1)
|
||||||
Button1.connect("clicked", self.ButtonClicked, "xdg-open computer:")
|
Button1.connect("clicked", self.ButtonClicked, "xdg-open computer:")
|
||||||
Button1.show()
|
Button1.show()
|
||||||
self.placesBtnHolder.pack_start(Button1, False, False, 0)
|
self.placesBtnHolder.pack_start(Button1, False, False, 0)
|
||||||
self.mintMenuWin.setTooltip(Button1, _("Browse all local and remote disks and folders accessible from this computer"))
|
self.mintMenuWin.setTooltip(Button1, _("Browse all local and remote disks and folders accessible from this computer"))
|
||||||
|
|
||||||
if ( self.showhomefolder == True ):
|
if self.showhomefolder:
|
||||||
Button2 = easyButton("user-home", self.iconsize, [_("Home Folder")], -1, -1)
|
Button2 = easyButton("user-home", self.iconsize, [_("Home Folder")], -1, -1)
|
||||||
Button2.connect("clicked", self.ButtonClicked, "xdg-open %s " % home)
|
Button2.connect("clicked", self.ButtonClicked, "xdg-open %s " % home)
|
||||||
Button2.show()
|
Button2.show()
|
||||||
self.placesBtnHolder.pack_start(Button2, False, False, 0)
|
self.placesBtnHolder.pack_start(Button2, False, False, 0)
|
||||||
self.mintMenuWin.setTooltip(Button2, _("Open your personal folder"))
|
self.mintMenuWin.setTooltip(Button2, _("Open your personal folder"))
|
||||||
|
|
||||||
if ( self.shownetwork == True and self.de == "mate"):
|
if self.shownetwork and self.de == "mate":
|
||||||
mate_settings = Gio.Settings.new("org.mate.interface")
|
mate_settings = Gio.Settings.new("org.mate.interface")
|
||||||
icon_theme = mate_settings.get_string("icon-theme")
|
icon_theme = mate_settings.get_string("icon-theme")
|
||||||
if "Mint-X" in icon_theme:
|
if "Mint-X" in icon_theme:
|
||||||
@ -161,7 +162,7 @@ class pluginclass( object ):
|
|||||||
self.placesBtnHolder.pack_start(Button3, False, False, 0)
|
self.placesBtnHolder.pack_start(Button3, False, False, 0)
|
||||||
self.mintMenuWin.setTooltip(Button3, _("Browse bookmarked and local network locations"))
|
self.mintMenuWin.setTooltip(Button3, _("Browse bookmarked and local network locations"))
|
||||||
|
|
||||||
if ( self.showdesktop == True ):
|
if self.showdesktop:
|
||||||
# Determine where the Desktop folder is (could be localized)
|
# Determine where the Desktop folder is (could be localized)
|
||||||
desktopDir = home + "/Desktop"
|
desktopDir = home + "/Desktop"
|
||||||
try:
|
try:
|
||||||
@ -180,7 +181,7 @@ class pluginclass( object ):
|
|||||||
self.placesBtnHolder.pack_start(Button4, False, False, 0)
|
self.placesBtnHolder.pack_start(Button4, False, False, 0)
|
||||||
self.mintMenuWin.setTooltip(Button4, _("Browse items placed on the desktop"))
|
self.mintMenuWin.setTooltip(Button4, _("Browse items placed on the desktop"))
|
||||||
|
|
||||||
if ( self.showtrash == True ):
|
if self.showtrash:
|
||||||
self.trashButton = easyButton("user-trash", self.iconsize, [_("Trash")], -1, -1)
|
self.trashButton = easyButton("user-trash", self.iconsize, [_("Trash")], -1, -1)
|
||||||
self.trashButton.connect("clicked", self.ButtonClicked, "xdg-open trash:")
|
self.trashButton.connect("clicked", self.ButtonClicked, "xdg-open trash:")
|
||||||
self.trashButton.show()
|
self.trashButton.show()
|
||||||
@ -194,7 +195,7 @@ class pluginclass( object ):
|
|||||||
for index in range(len(self.custompaths)):
|
for index in range(len(self.custompaths)):
|
||||||
path = self.custompaths[index]
|
path = self.custompaths[index]
|
||||||
path = path.replace("~", home)
|
path = path.replace("~", home)
|
||||||
command = ( "xdg-open \"" + path + "\"")
|
command = 'xdg-open "%s"' % path
|
||||||
currentbutton = easyButton("folder", self.iconsize, [self.customnames[index]], -1, -1)
|
currentbutton = easyButton("folder", self.iconsize, [self.customnames[index]], -1, -1)
|
||||||
currentbutton.connect("clicked", self.ButtonClicked, command)
|
currentbutton.connect("clicked", self.ButtonClicked, command)
|
||||||
currentbutton.show()
|
currentbutton.show()
|
||||||
|
@ -103,8 +103,8 @@ class pluginclass:
|
|||||||
RecentHelper.iconSize = self.appSettings.get("int", "icon-size")
|
RecentHelper.iconSize = self.appSettings.get("int", "icon-size")
|
||||||
self.RebuildPlugin()
|
self.RebuildPlugin()
|
||||||
|
|
||||||
def SetHidden( self, state ):
|
def SetHidden(self, minimized):
|
||||||
if state == True:
|
if minimized:
|
||||||
self.settings.set("bool", "minimized", True)
|
self.settings.set("bool", "minimized", True)
|
||||||
else:
|
else:
|
||||||
self.settings.set("bool", "minimized", False)
|
self.settings.set("bool", "minimized", False)
|
||||||
|
@ -9,6 +9,7 @@ from gi.repository import Gtk
|
|||||||
|
|
||||||
from plugins.easybuttons import ApplicationLauncher
|
from plugins.easybuttons import ApplicationLauncher
|
||||||
|
|
||||||
|
|
||||||
recentApps = []
|
recentApps = []
|
||||||
mintMenuWin = None
|
mintMenuWin = None
|
||||||
recentAppBox = None
|
recentAppBox = None
|
||||||
@ -17,9 +18,7 @@ iconSize = 16
|
|||||||
|
|
||||||
def recentAppsAdd(recentAppsButton):
|
def recentAppsAdd(recentAppsButton):
|
||||||
if recentAppsButton:
|
if recentAppsButton:
|
||||||
|
|
||||||
recentApps.insert(0, recentAppsButton)
|
recentApps.insert(0, recentAppsButton)
|
||||||
|
|
||||||
counter = 0
|
counter = 0
|
||||||
for recentApp in recentApps:
|
for recentApp in recentApps:
|
||||||
if counter != 0 and (recentApp.desktopFile == recentAppsButton.desktopFile or counter >= numentries):
|
if counter != 0 and (recentApp.desktopFile == recentAppsButton.desktopFile or counter >= numentries):
|
||||||
@ -28,20 +27,18 @@ def recentAppsAdd( recentAppsButton ):
|
|||||||
|
|
||||||
def recentAppsSave():
|
def recentAppsSave():
|
||||||
try:
|
try:
|
||||||
if (not os.path.exists(home + "/.linuxmint/mintMenu/recentApplications.list")):
|
path = os.path.join(home, ".linuxmint/mintMenu/recentApplications.list")
|
||||||
os.system("touch " + home + "/.linuxmint/mintMenu/recentApplications.list")
|
with open(path, "w") as recentAppListFile:
|
||||||
recentAppListFile = open( os.path.join( os.path.expanduser( "~"), ".linuxmint", "mintMenu", "recentApplications.list" ) , "w" )
|
|
||||||
|
|
||||||
for recentApp in recentApps:
|
for recentApp in recentApps:
|
||||||
if not hasattr(recentApp, "type") or recentApp.type == "location":
|
if not hasattr(recentApp, "type") or recentApp.type == "location":
|
||||||
recentAppListFile.write("location:" + recentApp.desktopFile + "\n")
|
recentAppListFile.write("location:" + recentApp.desktopFile + "\n")
|
||||||
else:
|
else:
|
||||||
recentAppListFile.write(recentApp.type + "\n")
|
recentAppListFile.write(recentApp.type + "\n")
|
||||||
|
|
||||||
recentAppListFile.close( )
|
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
print e
|
print e
|
||||||
msgDlg = Gtk.MessageDialog( None, Gtk.DialogFlags.MODAL, Gtk.MessageType.ERROR, Gtk.ButtonsType.OK, _("Couldn't save recent apps. Check if you have write access to ~/.linuxmint/mintMenu")+"\n(" + e.__str__() + ")" )
|
msgDlg = Gtk.MessageDialog(None, Gtk.DialogFlags.MODAL, Gtk.MessageType.ERROR, Gtk.ButtonsType.OK,
|
||||||
|
_("Couldn't save recent apps. Check if you have write access to ~/.linuxmint/mintMenu")+"\n(" + e.__str__() + ")")
|
||||||
msgDlg.run()
|
msgDlg.run()
|
||||||
msgDlg.destroy()
|
msgDlg.destroy()
|
||||||
|
|
||||||
@ -82,7 +79,6 @@ def recentAppBuildLauncher( location ):
|
|||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def buildRecentApps():
|
def buildRecentApps():
|
||||||
print "-- recentHelper.buildRecentApps"
|
print "-- recentHelper.buildRecentApps"
|
||||||
del recentApps[:]
|
del recentApps[:]
|
||||||
@ -90,7 +86,6 @@ def buildRecentApps():
|
|||||||
path = os.path.join(home, ".linuxmint/mintMenu/recentApplications.list")
|
path = os.path.join(home, ".linuxmint/mintMenu/recentApplications.list")
|
||||||
if not os.path.exists(path):
|
if not os.path.exists(path):
|
||||||
print "does not exist"
|
print "does not exist"
|
||||||
#os.system("touch " + path)
|
|
||||||
recentApplicationsList = []
|
recentApplicationsList = []
|
||||||
else:
|
else:
|
||||||
recentApplicationsList = open(path).readlines()
|
recentApplicationsList = open(path).readlines()
|
||||||
@ -124,10 +119,8 @@ def doRecentApps():
|
|||||||
# recent apps
|
# recent apps
|
||||||
buildRecentApps()
|
buildRecentApps()
|
||||||
for AButton in recentApps:
|
for AButton in recentApps:
|
||||||
|
|
||||||
AButton.set_size_request(200, -1)
|
AButton.set_size_request(200, -1)
|
||||||
AButton.set_relief(Gtk.ReliefStyle.NONE)
|
AButton.set_relief(Gtk.ReliefStyle.NONE)
|
||||||
|
|
||||||
recentAppBox.pack_start(AButton, False, True, 0)
|
recentAppBox.pack_start(AButton, False, True, 0)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
@ -22,7 +22,6 @@ class pluginclass( object ):
|
|||||||
self.toggleButton = toggleButton
|
self.toggleButton = toggleButton
|
||||||
self.de = de
|
self.de = de
|
||||||
|
|
||||||
|
|
||||||
self.builder = Gtk.Builder()
|
self.builder = Gtk.Builder()
|
||||||
self.builder.add_from_file(os.path.join(os.path.dirname(__file__), "system_management.glade"))
|
self.builder.add_from_file(os.path.join(os.path.dirname(__file__), "system_management.glade"))
|
||||||
|
|
||||||
@ -75,7 +74,7 @@ class pluginclass( object ):
|
|||||||
if key == "width":
|
if key == "width":
|
||||||
self.width = settings.get_int(key)
|
self.width = settings.get_int(key)
|
||||||
elif key == "height":
|
elif key == "height":
|
||||||
if (self.allowScrollbar == False):
|
if not self.allowScrollbar:
|
||||||
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)
|
||||||
else:
|
else:
|
||||||
@ -97,7 +96,7 @@ class pluginclass( object ):
|
|||||||
self.scrolledWindow.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
|
self.scrolledWindow.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
|
||||||
self.height = self.settings.get("int", "height")
|
self.height = self.settings.get("int", "height")
|
||||||
self.content_holder.set_size_request(self.width, self.height)
|
self.content_holder.set_size_request(self.width, self.height)
|
||||||
if (self.allowScrollbar == False):
|
if not self.allowScrollbar:
|
||||||
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)
|
||||||
@ -150,7 +149,7 @@ class pluginclass( object ):
|
|||||||
#Add standard items
|
#Add standard items
|
||||||
def do_standard_items(self):
|
def do_standard_items(self):
|
||||||
|
|
||||||
if ( self.showSoftwareManager == True ):
|
if self.showSoftwareManager:
|
||||||
if os.path.exists("/usr/bin/mintinstall"):
|
if os.path.exists("/usr/bin/mintinstall"):
|
||||||
Button1 = easyButton("mintinstall", self.iconsize, [_("Software Manager")], -1, -1)
|
Button1 = easyButton("mintinstall", self.iconsize, [_("Software Manager")], -1, -1)
|
||||||
Button1.connect("clicked", self.ButtonClicked, "mintinstall")
|
Button1.connect("clicked", self.ButtonClicked, "mintinstall")
|
||||||
@ -158,21 +157,21 @@ class pluginclass( object ):
|
|||||||
self.systemBtnHolder.pack_start(Button1, False, False, 0)
|
self.systemBtnHolder.pack_start(Button1, False, False, 0)
|
||||||
self.mintMenuWin.setTooltip(Button1, _("Browse and install available software"))
|
self.mintMenuWin.setTooltip(Button1, _("Browse and install available software"))
|
||||||
|
|
||||||
if ( self.showPackageManager == True ):
|
if self.showPackageManager:
|
||||||
Button2 = easyButton("applications-system", self.iconsize, [_("Package Manager")], -1, -1)
|
Button2 = easyButton("applications-system", self.iconsize, [_("Package Manager")], -1, -1)
|
||||||
Button2.connect("clicked", self.ButtonClicked, "synaptic-pkexec")
|
Button2.connect("clicked", self.ButtonClicked, "synaptic-pkexec")
|
||||||
Button2.show()
|
Button2.show()
|
||||||
self.systemBtnHolder.pack_start(Button2, False, False, 0)
|
self.systemBtnHolder.pack_start(Button2, False, False, 0)
|
||||||
self.mintMenuWin.setTooltip(Button2, _("Install, remove and upgrade software packages"))
|
self.mintMenuWin.setTooltip(Button2, _("Install, remove and upgrade software packages"))
|
||||||
|
|
||||||
if ( self.showControlCenter == True ):
|
if self.showControlCenter:
|
||||||
Button3 = easyButton("gtk-preferences", self.iconsize, [_("Control Center")], -1, -1)
|
Button3 = easyButton("gtk-preferences", self.iconsize, [_("Control Center")], -1, -1)
|
||||||
Button3.connect("clicked", self.ButtonClicked, self.settings_cmd)
|
Button3.connect("clicked", self.ButtonClicked, self.settings_cmd)
|
||||||
Button3.show()
|
Button3.show()
|
||||||
self.systemBtnHolder.pack_start(Button3, False, False, 0)
|
self.systemBtnHolder.pack_start(Button3, False, False, 0)
|
||||||
self.mintMenuWin.setTooltip(Button3, _("Configure your system"))
|
self.mintMenuWin.setTooltip(Button3, _("Configure your system"))
|
||||||
|
|
||||||
if ( self.showTerminal == True ):
|
if self.showTerminal:
|
||||||
Button4 = easyButton("terminal", self.iconsize, [_("Terminal")], -1, -1)
|
Button4 = easyButton("terminal", self.iconsize, [_("Terminal")], -1, -1)
|
||||||
if os.path.exists(self.terminal_cmd):
|
if os.path.exists(self.terminal_cmd):
|
||||||
Button4.connect("clicked", self.ButtonClicked, self.terminal_cmd)
|
Button4.connect("clicked", self.ButtonClicked, self.terminal_cmd)
|
||||||
@ -182,21 +181,21 @@ class pluginclass( object ):
|
|||||||
self.systemBtnHolder.pack_start(Button4, False, False, 0)
|
self.systemBtnHolder.pack_start(Button4, False, False, 0)
|
||||||
self.mintMenuWin.setTooltip(Button4, _("Use the command line"))
|
self.mintMenuWin.setTooltip(Button4, _("Use the command line"))
|
||||||
|
|
||||||
if ( self.showLockScreen == True ):
|
if self.showLockScreen:
|
||||||
Button5 = easyButton("system-lock-screen", self.iconsize, [_("Lock Screen")], -1, -1)
|
Button5 = easyButton("system-lock-screen", self.iconsize, [_("Lock Screen")], -1, -1)
|
||||||
Button5.connect("clicked", self.ButtonClicked, self.lock_cmd)
|
Button5.connect("clicked", self.ButtonClicked, self.lock_cmd)
|
||||||
Button5.show()
|
Button5.show()
|
||||||
self.systemBtnHolder.pack_start(Button5, False, False, 0)
|
self.systemBtnHolder.pack_start(Button5, False, False, 0)
|
||||||
self.mintMenuWin.setTooltip(Button5, _("Requires password to unlock"))
|
self.mintMenuWin.setTooltip(Button5, _("Requires password to unlock"))
|
||||||
|
|
||||||
if ( self.showLogout == True ):
|
if self.showLogout:
|
||||||
Button6 = easyButton("system-log-out", self.iconsize, [_("Logout")], -1, -1)
|
Button6 = easyButton("system-log-out", self.iconsize, [_("Logout")], -1, -1)
|
||||||
Button6.connect("clicked", self.ButtonClicked, self.logout_cmd)
|
Button6.connect("clicked", self.ButtonClicked, self.logout_cmd)
|
||||||
Button6.show()
|
Button6.show()
|
||||||
self.systemBtnHolder.pack_start(Button6, False, False, 0)
|
self.systemBtnHolder.pack_start(Button6, False, False, 0)
|
||||||
self.mintMenuWin.setTooltip(Button6, _("Log out or switch user"))
|
self.mintMenuWin.setTooltip(Button6, _("Log out or switch user"))
|
||||||
|
|
||||||
if ( self.showQuit == True ):
|
if self.showQuit:
|
||||||
Button7 = easyButton("system-shutdown", self.iconsize, [_("Quit")], -1, -1)
|
Button7 = easyButton("system-shutdown", self.iconsize, [_("Quit")], -1, -1)
|
||||||
Button7.connect("clicked", self.ButtonClicked, self.shutdown_cmd)
|
Button7.connect("clicked", self.ButtonClicked, self.shutdown_cmd)
|
||||||
Button7.show()
|
Button7.show()
|
||||||
|
Loading…
Reference in New Issue
Block a user