- more cleanup, and speed-up
- more fixes, including many icon and encoding related issues - replace some icons and remove compile.py - prepare for python3 port as much as possible
This commit is contained in:
parent
8b42c0f32f
commit
67eee16da8
13
debian/control
vendored
13
debian/control
vendored
@ -11,15 +11,18 @@ Depends:
|
||||
${python:Depends},
|
||||
${misc:Depends},
|
||||
python (>= 2.4), python (<< 3),
|
||||
mint-common,
|
||||
python-mate-menu, python-xdg, xdg-utils,
|
||||
python-apt,
|
||||
python-configobj,
|
||||
python-setproctitle,
|
||||
mate-menus,
|
||||
gvfs-bin,
|
||||
python-xlib,
|
||||
gir1.2-mate-panel, gir1.2-gtk-3.0, gir1.2-mate-desktop,
|
||||
python-xdg,
|
||||
xdg-utils,
|
||||
libglib2.0-bin,
|
||||
mate-menus,
|
||||
python-mate-menu,
|
||||
gir1.2-matepanelapplet-4.0,
|
||||
gir1.2-gtk-3.0,
|
||||
gir1.2-mate-desktop,
|
||||
mozo
|
||||
Description: Advanced MATE menu
|
||||
One of the most advanced menus under Linux. MintMenu supports filtering,
|
||||
|
1
debian/postinst
vendored
1
debian/postinst
vendored
@ -19,6 +19,7 @@ set -e
|
||||
case "$1" in
|
||||
configure)
|
||||
glib-compile-schemas /usr/share/glib-2.0/schemas
|
||||
python -m compileall -qf /usr/lib/linuxmint/mintMenu/
|
||||
;;
|
||||
|
||||
abort-upgrade|abort-remove|abort-deconfigure)
|
||||
|
@ -1,5 +0,0 @@
|
||||
#!/usr/bin/python2
|
||||
|
||||
import compileall
|
||||
|
||||
compileall.compile_dir(".", force=1)
|
@ -29,7 +29,7 @@ gi.require_version("Gtk", "3.0")
|
||||
|
||||
from Xlib.display import Display
|
||||
from Xlib import X, error
|
||||
from gi.repository import Gtk, Gdk, GdkX11, GObject, GLib
|
||||
from gi.repository import Gtk, Gdk, GObject, GLib
|
||||
import threading
|
||||
|
||||
SPECIAL_MODS = (["Super_L", "<Super>"],
|
||||
|
@ -20,7 +20,6 @@ import pointerMonitor
|
||||
import setproctitle
|
||||
from plugins.execute import Execute
|
||||
|
||||
|
||||
GObject.threads_init()
|
||||
|
||||
# Rename the process
|
||||
@ -71,7 +70,7 @@ class MainWindow(object):
|
||||
|
||||
self.window.stick()
|
||||
|
||||
plugindir = os.path.join(os.path.expanduser("~"), ".linuxmint/mintMenu/plugins")
|
||||
plugindir = os.path.join(os.environ["HOME"], ".linuxmint/mintMenu/plugins")
|
||||
sys.path.append(plugindir)
|
||||
|
||||
self.panelSettings = Gio.Settings.new("org.mate.panel")
|
||||
@ -162,7 +161,7 @@ class MainWindow(object):
|
||||
|
||||
for plugin in self.pluginlist:
|
||||
if plugin in self.plugins:
|
||||
print u"Duplicate plugin in list: ", plugin
|
||||
print("Duplicate plugin in list: %s" % plugin)
|
||||
continue
|
||||
|
||||
if plugin != "newpane":
|
||||
@ -205,8 +204,7 @@ class MainWindow(object):
|
||||
MyPlugin.add(MyPlugin.content_holder)
|
||||
MyPlugin.width = 270
|
||||
MyPlugin.icon = 'mate-logo-icon.png'
|
||||
print u"Unable to load " + plugin + " plugin :-("
|
||||
|
||||
print("Unable to load %s plugin" % plugin)
|
||||
|
||||
self.panesToColor.append(MyPlugin.content_holder)
|
||||
MyPlugin.content_holder.show()
|
||||
@ -352,7 +350,6 @@ class MainWindow(object):
|
||||
widget.set_tooltip_text(tip)
|
||||
|
||||
def RegenPlugins(self, *args, **kargs):
|
||||
#print
|
||||
#print u"Reloading Plugins..."
|
||||
for item in self.paneholder:
|
||||
item.destroy()
|
||||
@ -473,11 +470,11 @@ class MenuWin(object):
|
||||
self.keybinder.connect("activate", self.onBindingPress)
|
||||
self.keybinder.start()
|
||||
self.settings.connect("changed::hot-key", self.hotkeyChanged)
|
||||
print "Binding to Hot Key: " + self.hotkeyText
|
||||
except Exception, cause:
|
||||
print("Binding to Hot Key: %s" % self.hotkeyText)
|
||||
except Exception as e:
|
||||
self.keybinder = None
|
||||
print "** WARNING ** - Keybinder Error"
|
||||
print "Error Report :\n", str(cause)
|
||||
print("** WARNING ** - Keybinder Error")
|
||||
print("Error Report :\n", e)
|
||||
|
||||
self.applet.set_can_focus(False)
|
||||
|
||||
@ -485,9 +482,9 @@ class MenuWin(object):
|
||||
self.pointerMonitor = pointerMonitor.PointerMonitor()
|
||||
self.pointerMonitor.connect("activate", self.onPointerOutside)
|
||||
self.mainwin.window.connect("realize", self.onRealize)
|
||||
except Exception, cause:
|
||||
print "** WARNING ** - Pointer Monitor Error"
|
||||
print "Error Report :\n", str(cause)
|
||||
except Exception as e:
|
||||
print("** WARNING ** - Pointer Monitor Error")
|
||||
print("Error Report :\n", e)
|
||||
|
||||
def onWindowMap(self, *args):
|
||||
self.applet.get_style_context().set_state(Gtk.StateFlags.SELECTED)
|
||||
@ -522,9 +519,9 @@ class MenuWin(object):
|
||||
|
||||
def leave_notify(self, applet, event):
|
||||
# Hack for mate-panel-test-applets focus issue (this can be commented)
|
||||
if event.state & Gdk.ModifierType.BUTTON1_MASK and applet.get_style_context().get_state() & Gtk.StateFlags.SELECTED:
|
||||
if event.x >= 0 and event.y >= 0 and event.x < applet.get_window().get_width() and event.y < applet.get_window().get_height():
|
||||
self.mainwin.stopHiding()
|
||||
# if event.state & Gdk.ModifierType.BUTTON1_MASK and applet.get_style_context().get_state() & Gtk.StateFlags.SELECTED:
|
||||
# if event.x >= 0 and event.y >= 0 and event.x < applet.get_window().get_width() and event.y < applet.get_window().get_height():
|
||||
# self.mainwin.stopHiding()
|
||||
|
||||
self.do_image(self.buttonIcon, False)
|
||||
|
||||
@ -542,10 +539,11 @@ class MenuWin(object):
|
||||
self.do_image(self.buttonIcon, False)
|
||||
self.systemlabel = Gtk.Label(label= "%s " % self.buttonText)
|
||||
if os.path.isfile("/etc/linuxmint/info"):
|
||||
info = open("/etc/linuxmint/info").readlines() #TODO py3 encoding="utf-8"
|
||||
with open("/etc/linuxmint/info") as info:
|
||||
for line in info:
|
||||
line = line.decode("utf-8")
|
||||
if line.startswith("DESCRIPTION="):
|
||||
tooltip = line.split("=",1)[1].replace('"','')
|
||||
tooltip = line.split("=",1)[1].strip('"\n')
|
||||
self.systemlabel.set_tooltip_text(tooltip)
|
||||
self.button_icon.set_tooltip_text(tooltip)
|
||||
break
|
||||
@ -568,17 +566,13 @@ 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()
|
||||
|
||||
self.button_box.get_style_context().add_class('mintmenu')
|
||||
|
||||
self.applet.add(self.button_box)
|
||||
self.applet.set_background_widget(self.applet)
|
||||
|
||||
|
||||
def loadSettings(self, *args, **kargs):
|
||||
self.hideIcon = self.settings.get_boolean("hide-applet-icon")
|
||||
self.buttonText = self.settings.get_string("applet-text")
|
||||
@ -637,7 +631,6 @@ class MenuWin(object):
|
||||
self.updateButton()
|
||||
self.applet.add(self.button_box)
|
||||
|
||||
|
||||
def updateButton(self):
|
||||
self.systemlabel.set_text(self.buttonText)
|
||||
self.button_icon.clear()
|
||||
@ -676,22 +669,17 @@ class MenuWin(object):
|
||||
self.updateButton()
|
||||
|
||||
def showAboutDialog(self, action, userdata = None):
|
||||
|
||||
about = Gtk.AboutDialog()
|
||||
about.set_name("mintMenu")
|
||||
import commands
|
||||
version = commands.getoutput("/usr/lib/linuxmint/common/version.py mintmenu")
|
||||
about.set_version(version)
|
||||
import subprocess
|
||||
(stdout, stderr) = subprocess.Popen(["/usr/lib/linuxmint/common/version.py", "mintmenu"],
|
||||
stdout=subprocess.PIPE).communicate()
|
||||
about.set_version(stdout.strip())
|
||||
try:
|
||||
h = open('/usr/share/common-licenses/GPL','r')
|
||||
s = h.readlines()
|
||||
gpl = ""
|
||||
for line in s:
|
||||
gpl += line
|
||||
h.close()
|
||||
gpl = open('/usr/share/common-licenses/GPL','r').read()
|
||||
about.set_license(gpl)
|
||||
except Exception, detail:
|
||||
print detail
|
||||
except Exception as e:
|
||||
print(e)
|
||||
about.set_comments(_("Advanced MATE Menu"))
|
||||
# about.set_authors(["Clement Lefebvre <clem@linuxmint.com>", "Lars-Peter Clausen <lars@laprican.de>"])
|
||||
about.set_translator_credits(("translator-credits"))
|
||||
@ -700,7 +688,6 @@ class MenuWin(object):
|
||||
about.connect("response", lambda dialog, r: dialog.destroy())
|
||||
about.show()
|
||||
|
||||
|
||||
def showPreferences(self, action, userdata = None):
|
||||
# Execute("mateconf-editor /apps/mintMenu")
|
||||
Execute(os.path.join(PATH, "mintMenuConfig.py"))
|
||||
@ -831,8 +818,8 @@ class MenuWin(object):
|
||||
self.de = "mate"
|
||||
elif os.path.exists("/usr/bin/thunar"):
|
||||
self.de = "xfce"
|
||||
except Exception, detail:
|
||||
print detail
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
def applet_factory(applet, iid, data):
|
||||
MenuWin(applet, iid)
|
||||
|
@ -1,21 +1,16 @@
|
||||
#!/usr/bin/python2
|
||||
|
||||
import gettext
|
||||
import os
|
||||
import sys
|
||||
from glob import glob
|
||||
|
||||
import gi
|
||||
gi.require_version("Gtk", "3.0")
|
||||
|
||||
from gi.repository import Gtk, Gdk, GdkPixbuf
|
||||
|
||||
import keybinding
|
||||
|
||||
|
||||
try:
|
||||
import gettext
|
||||
import os
|
||||
import commands
|
||||
except Exception, e:
|
||||
print e
|
||||
sys.exit( 1 )
|
||||
from plugins.easygsettings import EasyGSettings
|
||||
|
||||
PATH = os.path.abspath(os.path.dirname(sys.argv[0]))
|
||||
|
||||
@ -24,8 +19,6 @@ sys.path.append( os.path.join( PATH , "plugins") )
|
||||
# i18n
|
||||
gettext.install("mintmenu", "/usr/share/linuxmint/locale")
|
||||
|
||||
from easygsettings import EasyGSettings
|
||||
|
||||
class mintMenuConfig(object):
|
||||
|
||||
def __init__(self):
|
||||
@ -106,9 +99,9 @@ class mintMenuConfig( object ):
|
||||
self.builder.get_object("logoutcheckbutton").set_label(_("Log Out"))
|
||||
self.builder.get_object("quitcheckbutton").set_label(_("Quit"))
|
||||
|
||||
self.editPlaceDialogTitle = (_("Edit Place"))
|
||||
self.newPlaceDialogTitle = (_("New Place"))
|
||||
self.folderChooserDialogTitle = (_("Select a folder"))
|
||||
self.editPlaceDialogTitle = _("Edit Place")
|
||||
self.newPlaceDialogTitle = _("New Place")
|
||||
self.folderChooserDialogTitle = _("Select a folder")
|
||||
|
||||
self.startWithFavorites = self.builder.get_object("startWithFavorites")
|
||||
self.showAppComments = self.builder.get_object("showAppComments")
|
||||
@ -162,7 +155,7 @@ class mintMenuConfig( object ):
|
||||
self.allowPlacesScrollbarToggle = self.builder.get_object("allowscrollbarcheckbutton")
|
||||
self.showgtkbookmarksToggle = self.builder.get_object("showgtkbookmarkscheckbutton")
|
||||
self.placesHeightButton = self.builder.get_object("placesHeightSpinButton")
|
||||
if (self.allowPlacesScrollbarToggle.get_active() == False):
|
||||
if not self.allowPlacesScrollbarToggle.get_active():
|
||||
self.placesHeightButton.set_sensitive(False)
|
||||
self.allowPlacesScrollbarToggle.connect("toggled", self.togglePlacesHeightEnabled)
|
||||
self.softwareManagerToggle = self.builder.get_object("softwaremanagercheckbutton")
|
||||
@ -174,7 +167,8 @@ class mintMenuConfig( object ):
|
||||
self.quitToggle = self.builder.get_object("quitcheckbutton")
|
||||
self.allowSystemScrollbarToggle = self.builder.get_object("allowscrollbarcheckbutton1")
|
||||
self.systemHeightButton = self.builder.get_object("systemHeightSpinButton")
|
||||
if (self.allowSystemScrollbarToggle.get_active() == False): self.systemHeightButton.set_sensitive(False)
|
||||
if not self.allowSystemScrollbarToggle.get_active():
|
||||
self.systemHeightButton.set_sensitive(False)
|
||||
self.allowSystemScrollbarToggle.connect("toggled", self.toggleSystemHeightEnabled)
|
||||
if os.path.exists("/usr/bin/mintinstall"):
|
||||
self.builder.get_object("softwaremanagercheckbutton").show()
|
||||
@ -183,7 +177,6 @@ class mintMenuConfig( object ):
|
||||
|
||||
self.builder.get_object("closeButton").connect("clicked", Gtk.main_quit)
|
||||
|
||||
|
||||
self.settings = EasyGSettings("com.linuxmint.mintmenu")
|
||||
self.settingsApplications = EasyGSettings("com.linuxmint.mintmenu.plugins.applications")
|
||||
self.settingsPlaces = EasyGSettings("com.linuxmint.mintmenu.plugins.places")
|
||||
@ -269,8 +262,7 @@ class mintMenuConfig( object ):
|
||||
|
||||
#Detect themes and show theme here
|
||||
theme_name = self.settings.get("string", "theme-name")
|
||||
themes = commands.getoutput("find /usr/share/themes -name gtkrc")
|
||||
themes = themes.split("\n")
|
||||
themes = glob("/usr/share/themes/*/*/gtkrc")
|
||||
model = Gtk.ListStore(str, str)
|
||||
self.builder.get_object("themesCombo").set_model(model)
|
||||
selected_theme = model.append([_("Desktop theme"), "default"])
|
||||
@ -366,7 +358,7 @@ class mintMenuConfig( object ):
|
||||
args[1](color)
|
||||
|
||||
def callGetter(self, settings, setting_type, key, getter):
|
||||
if (setting_type == "int"):
|
||||
if setting_type == "int":
|
||||
settings.set(setting_type, key, int(getter()))
|
||||
else:
|
||||
settings.set(setting_type, key, getter())
|
||||
@ -391,18 +383,19 @@ class mintMenuConfig( object ):
|
||||
def moveUp(self, upButton):
|
||||
|
||||
treeselection = self.customplacestree.get_selection()
|
||||
currentiter = (treeselection.get_selected())[1]
|
||||
currentiter = treeselection.get_selected()[1]
|
||||
|
||||
if ( treeselection != None ):
|
||||
if treeselection:
|
||||
|
||||
lagiter = self.customplacestreemodel.get_iter_first()
|
||||
nextiter = self.customplacestreemodel.get_iter_first()
|
||||
|
||||
while ( (self.customplacestreemodel.get_path(nextiter) != self.customplacestreemodel.get_path(currentiter)) & (nextiter != None)):
|
||||
while nextiter and self.customplacestreemodel.get_path(nextiter) != \
|
||||
self.customplacestreemodel.get_path(currentiter):
|
||||
lagiter = nextiter
|
||||
nextiter = self.customplacestreemodel.iter_next(nextiter)
|
||||
|
||||
if (nextiter != None):
|
||||
if nextiter:
|
||||
self.customplacestreemodel.swap(currentiter, lagiter)
|
||||
|
||||
return
|
||||
@ -422,20 +415,20 @@ class mintMenuConfig( object ):
|
||||
folderButton = self.builder.get_object("folderButton")
|
||||
def chooseFolder(folderButton):
|
||||
currentPath = newPlacePath.get_text()
|
||||
if (currentPath!=""):
|
||||
if currentPath:
|
||||
folderChooserDialog.select_filename(currentPath)
|
||||
response = folderChooserDialog.run()
|
||||
folderChooserDialog.hide()
|
||||
if (response == Gtk.ResponseType.OK):
|
||||
if response == Gtk.ResponseType.OK:
|
||||
newPlacePath.set_text(folderChooserDialog.get_filenames()[0])
|
||||
folderButton.connect("clicked", chooseFolder)
|
||||
|
||||
response = newPlaceDialog.run()
|
||||
newPlaceDialog.hide()
|
||||
if (response == Gtk.ResponseType.OK ):
|
||||
if response == Gtk.ResponseType.OK:
|
||||
name = newPlaceName.get_text()
|
||||
path = newPlacePath.get_text()
|
||||
if (name != "" and path !=""):
|
||||
if name and path:
|
||||
self.customplacestreemodel.append((name, path))
|
||||
|
||||
def editPlace(self, editButton):
|
||||
@ -452,9 +445,9 @@ class mintMenuConfig( object ):
|
||||
editPlacePath = self.builder.get_object("pathEntryBox")
|
||||
folderButton = self.builder.get_object("folderButton")
|
||||
treeselection = self.customplacestree.get_selection()
|
||||
currentiter = (treeselection.get_selected())[1]
|
||||
currentiter = treeselection.get_selected()[1]
|
||||
|
||||
if (currentiter != None):
|
||||
if currentiter:
|
||||
|
||||
initName = self.customplacestreemodel.get_value(currentiter, 0)
|
||||
initPath = self.customplacestreemodel.get_value(currentiter, 1)
|
||||
@ -463,70 +456,69 @@ class mintMenuConfig( object ):
|
||||
editPlacePath.set_text(initPath)
|
||||
def chooseFolder(folderButton):
|
||||
currentPath = editPlacePath.get_text()
|
||||
if (currentPath!=""):
|
||||
if currentPath:
|
||||
folderChooserDialog.select_filename(currentPath)
|
||||
response = folderChooserDialog.run()
|
||||
folderChooserDialog.hide()
|
||||
if (response == Gtk.ResponseType.OK):
|
||||
if response == Gtk.ResponseType.OK:
|
||||
editPlacePath.set_text(folderChooserDialog.get_filenames()[0])
|
||||
folderButton.connect("clicked", chooseFolder)
|
||||
response = editPlaceDialog.run()
|
||||
editPlaceDialog.hide()
|
||||
if (response == Gtk.ResponseType.OK):
|
||||
if response == Gtk.ResponseType.OK:
|
||||
name = editPlaceName.get_text()
|
||||
path = editPlacePath.get_text()
|
||||
if (name != "" and path != ""):
|
||||
if name and path:
|
||||
self.customplacestreemodel.set_value(currentiter, 0, name)
|
||||
self.customplacestreemodel.set_value(currentiter, 1, path)
|
||||
|
||||
def moveDown(self, downButton):
|
||||
|
||||
treeselection = self.customplacestree.get_selection()
|
||||
currentiter = (treeselection.get_selected())[1]
|
||||
currentiter = treeselection.get_selected()[1]
|
||||
|
||||
nextiter = self.customplacestreemodel.iter_next(currentiter)
|
||||
|
||||
if (nextiter != None):
|
||||
if nextiter:
|
||||
self.customplacestreemodel.swap(currentiter, nextiter)
|
||||
|
||||
return
|
||||
|
||||
|
||||
def removePlace(self, removeButton):
|
||||
|
||||
treeselection = self.customplacestree.get_selection()
|
||||
currentiter = (treeselection.get_selected())[1]
|
||||
currentiter = treeselection.get_selected()[1]
|
||||
|
||||
if (currentiter != None):
|
||||
if currentiter:
|
||||
self.customplacestreemodel.remove(currentiter)
|
||||
|
||||
return
|
||||
|
||||
def togglePlacesHeightEnabled(self, toggle):
|
||||
if (toggle.get_active() == True):
|
||||
if toggle.get_active():
|
||||
self.placesHeightButton.set_sensitive(True)
|
||||
else:
|
||||
self.placesHeightButton.set_sensitive(False)
|
||||
|
||||
def toggleSystemHeightEnabled(self, toggle):
|
||||
if (toggle.get_active() == True):
|
||||
if toggle.get_active():
|
||||
self.systemHeightButton.set_sensitive(True)
|
||||
else:
|
||||
self.systemHeightButton.set_sensitive(False)
|
||||
|
||||
def updatePlacesGSettings(self, treemodel, path, iter = None, new_order = None):
|
||||
# Do only if not partway though an append operation; Append = insert+change+change and each creates a signal
|
||||
if ((iter == None) or (self.customplacestreemodel.get_value(iter, 1) != None)):
|
||||
# Do only if not partway though an append operation;
|
||||
# Append = insert+change+change and each creates a signal
|
||||
if not iter or self.customplacestreemodel.get_value(iter, 1):
|
||||
treeiter = self.customplacestreemodel.get_iter_first()
|
||||
customplacenames = []
|
||||
customplacepaths = []
|
||||
while( treeiter != None ):
|
||||
while treeiter:
|
||||
customplacenames = customplacenames + [self.customplacestreemodel.get_value(treeiter, 0)]
|
||||
customplacepaths = customplacepaths + [self.customplacestreemodel.get_value(treeiter, 1)]
|
||||
treeiter = self.customplacestreemodel.iter_next(treeiter)
|
||||
self.settingsPlaces.set("list-string", "custom-paths", customplacepaths)
|
||||
self.settingsPlaces.set("list-string", "custom-names", customplacenames)
|
||||
|
||||
|
||||
window = mintMenuConfig()
|
||||
Gtk.main()
|
||||
|
@ -1,30 +1,29 @@
|
||||
#!/usr/bin/python2
|
||||
|
||||
import commands
|
||||
import cgi
|
||||
import filecmp
|
||||
import gettext
|
||||
import os
|
||||
import pipes
|
||||
import string
|
||||
import subprocess
|
||||
import threading
|
||||
import time
|
||||
from user import home
|
||||
import urllib
|
||||
|
||||
import gi
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, Pango, Gdk, Gio, GLib
|
||||
from gi.repository import Gtk, Gdk, GdkPixbuf, Gio, GLib
|
||||
|
||||
import matemenu
|
||||
import plugins.recentHelper as RecentHelper
|
||||
from plugins.easybuttons import (CategoryButton, FavApplicationLauncher,
|
||||
from plugins.easybuttons import (ApplicationLauncher, CategoryButton,
|
||||
FavApplicationLauncher,
|
||||
MenuApplicationLauncher)
|
||||
from plugins.easygsettings import EasyGSettings
|
||||
from plugins.execute import Execute
|
||||
|
||||
|
||||
# i18n
|
||||
gettext.install("mintmenu", "/usr/share/linuxmint/locale")
|
||||
home = os.environ.get("HOME")
|
||||
|
||||
class PackageDescriptor():
|
||||
def __init__(self, name, summary, description):
|
||||
@ -32,23 +31,24 @@ class PackageDescriptor():
|
||||
self.summary = summary
|
||||
self.description = description
|
||||
|
||||
def print_timing(func):
|
||||
def wrapper(*arg):
|
||||
t1 = time.time()
|
||||
res = func(*arg)
|
||||
t2 = time.time()
|
||||
print '%s took %0.3f ms' % (func.func_name, (t2-t1)*1000.0)
|
||||
return res
|
||||
return wrapper
|
||||
# import time
|
||||
# def print_timing(func):
|
||||
# def wrapper(*arg):
|
||||
# t1 = time.time()
|
||||
# res = func(*arg)
|
||||
# t2 = time.time()
|
||||
# print('%s took %0.3f ms' % (func.func_name, (t2-t1)*1000.0))
|
||||
# return res
|
||||
# return wrapper
|
||||
|
||||
# Helper function for retrieving the user's location for storing new or modified menu items
|
||||
def get_user_item_path():
|
||||
item_dir = None
|
||||
|
||||
if os.environ.has_key('XDG_DATA_HOME'):
|
||||
if 'XDG_DATA_HOME' in os.environ:
|
||||
item_dir = os.path.join(os.environ['XDG_DATA_HOME'], 'applications')
|
||||
else:
|
||||
item_dir = os.path.join(os.environ['HOME'], '.local', 'share', 'applications')
|
||||
item_dir = os.path.join(home, '.local/share/applications')
|
||||
|
||||
if not os.path.isdir(item_dir):
|
||||
os.makedirs(item_dir)
|
||||
@ -57,33 +57,32 @@ def get_user_item_path():
|
||||
|
||||
def get_system_item_paths():
|
||||
item_dirs = []
|
||||
if os.environ.has_key('XDG_DATA_DIRS'):
|
||||
if 'XDG_DATA_DIRS' in os.environ:
|
||||
item_dirs = os.environ['XDG_DATA_DIRS'].split(":")
|
||||
item_dirs.append(os.path.join('/usr', 'share'))
|
||||
return item_dirs
|
||||
|
||||
def rel_path(target, base=os.curdir):
|
||||
|
||||
if not os.path.exists(target):
|
||||
raise OSError, 'Target does not exist: '+target
|
||||
raise OSError("Target does not exist: %s" % target)
|
||||
|
||||
if not os.path.isdir(base):
|
||||
raise OSError, 'Base is not a directory or does not exist: '+base
|
||||
raise OSError("Base is not a directory or does not exist: %s" % base)
|
||||
|
||||
base_list = (os.path.abspath(base)).split(os.sep)
|
||||
target_list = (os.path.abspath(target)).split(os.sep)
|
||||
|
||||
for i in range(min(len(base_list), len(target_list))):
|
||||
if base_list[i] <> target_list[i]: break
|
||||
if base_list[i] != target_list[i]:
|
||||
break
|
||||
else:
|
||||
i += 1
|
||||
|
||||
rel_list = [os.pardir] * (len(base_list) - i) + target_list[i:]
|
||||
|
||||
return os.path.join(*rel_list)
|
||||
|
||||
|
||||
class Menu:
|
||||
|
||||
def __init__(self, MenuToLookup):
|
||||
self.tree = matemenu.lookup_tree(MenuToLookup)
|
||||
self.directory = self.tree.get_root_directory()
|
||||
@ -99,7 +98,9 @@ class Menu:
|
||||
|
||||
def getItems(self, menu):
|
||||
for item in menu.get_contents():
|
||||
if item.get_type() == matemenu.TYPE_ENTRY and item.get_desktop_file_id()[-19:] != '-usercustom.desktop' and self.__isVisible(item):
|
||||
if item.get_type() == matemenu.TYPE_ENTRY and \
|
||||
item.get_desktop_file_id()[-19:] != '-usercustom.desktop' and \
|
||||
self.__isVisible(item):
|
||||
yield item
|
||||
|
||||
def __isVisible(self, item):
|
||||
@ -108,36 +109,31 @@ class Menu:
|
||||
if item.get_type() == matemenu.TYPE_DIRECTORY and len(item.get_contents()):
|
||||
return True
|
||||
|
||||
|
||||
|
||||
class SuggestionButton(Gtk.Button):
|
||||
|
||||
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)
|
||||
Align1 = Gtk.Alignment()
|
||||
Align1.set(0, 0.5, 1.0, 0)
|
||||
HBox1 = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
|
||||
labelBox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=2)
|
||||
self.image = Gtk.Image()
|
||||
self.image.set_from_icon_name(self.iconName, Gtk.IconSize.INVALID)
|
||||
if iconName.startswith("/"):
|
||||
self.image = Gtk.Image.new_from_pixbuf(GdkPixbuf.Pixbuf.new_from_file_at_size(iconName, iconSize, iconSize))
|
||||
else:
|
||||
self.image = Gtk.Image.new_from_icon_name(iconName, Gtk.IconSize.DIALOG)
|
||||
self.image.set_pixel_size(iconSize)
|
||||
self.image.show()
|
||||
HBox1.pack_start(self.image, False, False, 5)
|
||||
self.label = Gtk.Label()
|
||||
self.label.set_ellipsize(Pango.EllipsizeMode.END)
|
||||
self.label.set_markup(label)
|
||||
self.label.set_ellipsize(3)
|
||||
self.label.set_alignment(0.0, 1.0)
|
||||
self.label.show()
|
||||
labelBox.pack_start(self.label, True, True, 2)
|
||||
labelBox.show()
|
||||
HBox1.pack_start(labelBox, True, True, 2)
|
||||
HBox1.show()
|
||||
Align1.add(HBox1)
|
||||
Align1.show()
|
||||
self.add(Align1)
|
||||
self.show()
|
||||
self.show_all()
|
||||
|
||||
def set_image(self, path):
|
||||
self.image.set_from_file(path)
|
||||
@ -155,13 +151,11 @@ class pluginclass(object):
|
||||
toFav = (Gtk.TargetEntry.new("FAVORITES", Gtk.TargetFlags.SAME_APP, 81), Gtk.TargetEntry.new("text/plain", 0, 100), Gtk.TargetEntry.new("text/uri-list", 0, 101))
|
||||
fromFav = (Gtk.TargetEntry.new("FAVORITES", Gtk.TargetFlags.SAME_APP, 81), Gtk.TargetEntry.new("FAVORITES", Gtk.TargetFlags.SAME_APP, 81))
|
||||
|
||||
@print_timing
|
||||
#@print_timing
|
||||
def __init__(self, mintMenuWin, toggleButton, de):
|
||||
self.mintMenuWin = mintMenuWin
|
||||
RecentHelper.mintMenuWin = mintMenuWin
|
||||
|
||||
self.mainMenus = []
|
||||
|
||||
self.toggleButton = toggleButton
|
||||
self.de = de
|
||||
|
||||
@ -217,7 +211,6 @@ class pluginclass(object):
|
||||
self.keyPress_handler = self.mintMenuWin.window.connect("key-press-event", self.keyPress)
|
||||
|
||||
self.favoritesBox.connect("drag-data-received", self.ReceiveCallback)
|
||||
|
||||
self.favoritesBox.drag_dest_set (Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT | Gtk.DestDefaults.DROP, self.toButton, Gdk.DragAction.COPY)
|
||||
self.showFavoritesButton.connect("drag-data-received", self.ReceiveCallback)
|
||||
self.showFavoritesButton.drag_dest_set (Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT | Gtk.DestDefaults.DROP, self.toButton, Gdk.DragAction.COPY)
|
||||
@ -245,8 +238,8 @@ class pluginclass(object):
|
||||
self.settings.bindGSettingsEntryToVar("bool", "enable-internet-search", self, "enableInternetSearch")
|
||||
self.settings.bindGSettingsEntryToVar("string", "search-command", self, "searchtool")
|
||||
self.settings.bindGSettingsEntryToVar("int", "default-tab", self, "defaultTab")
|
||||
except Exception, detail:
|
||||
print detail
|
||||
except Exception as e:
|
||||
print(e)
|
||||
self.currentFavCol = 0
|
||||
self.favorites = []
|
||||
|
||||
@ -280,13 +273,15 @@ class pluginclass(object):
|
||||
|
||||
self.builder.get_object("searchButton").connect("button-press-event", self.searchPopup)
|
||||
|
||||
self.icon_theme = Gtk.IconTheme.get_default()
|
||||
self.icon_theme.connect("changed", self.on_icon_theme_changed)
|
||||
# self.icon_theme = Gtk.IconTheme.get_default()
|
||||
# self.icon_theme.connect("changed", self.on_icon_theme_changed)
|
||||
|
||||
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)
|
||||
path = "%s/.linuxmint/mintMenu" % home
|
||||
if not os.path.exists(path):
|
||||
os.makedirs(path)
|
||||
subprocess.Popen(["/usr/lib/linuxmint/mintMenu/plugins/get_apt_cache.py", "%s/apt.cache" % path])
|
||||
|
||||
def get_panel(self):
|
||||
panelsettings = Gio.Settings.new("org.mate.panel")
|
||||
@ -301,17 +296,19 @@ 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 + " &")
|
||||
subprocess.Popen(["xdg-open", "apt://%s" % 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()
|
||||
|
||||
def __del__(self):
|
||||
print u"Applications plugin deleted"
|
||||
#print("Applications plugin deleted")
|
||||
return
|
||||
|
||||
def wake(self):
|
||||
pass
|
||||
return
|
||||
|
||||
def destroy(self):
|
||||
self.content_holder.destroy()
|
||||
@ -431,13 +428,22 @@ class pluginclass(object):
|
||||
self.GetGSettingsEntries()
|
||||
|
||||
# if the config hasn't changed return
|
||||
if oldcategories_mouse_over == self.categories_mouse_over and oldiconsize == self.iconSize and oldfaviconsize == self.faviconsize and oldswapgeneric == self.swapgeneric and oldshowcategoryicons == self.showcategoryicons and oldcategoryhoverdelay == self.categoryhoverdelay and oldsticky == self.sticky and oldminimized == self.minimized and oldicon == self.icon and oldhideseparator == self.hideseparator and oldshowapplicationcomments == self.showapplicationcomments:
|
||||
if (oldcategories_mouse_over == self.categories_mouse_over and
|
||||
oldiconsize == self.iconSize and
|
||||
oldfaviconsize == self.faviconsize and
|
||||
oldswapgeneric == self.swapgeneric and
|
||||
oldshowcategoryicons == self.showcategoryicons and
|
||||
oldcategoryhoverdelay == self.categoryhoverdelay and
|
||||
oldsticky == self.sticky and
|
||||
oldminimized == self.minimized and
|
||||
oldicon == self.icon and
|
||||
oldhideseparator == self.hideseparator and
|
||||
oldshowapplicationcomments == self.showapplicationcomments
|
||||
):
|
||||
return
|
||||
|
||||
self.Todos()
|
||||
self.buildFavorites()
|
||||
# TODO all this runs whether the plugin is enabled or not
|
||||
print "applications.RegenPlugin calling buildRecentApps"
|
||||
RecentHelper.buildRecentApps()
|
||||
self.RebuildPlugin()
|
||||
|
||||
@ -461,7 +467,6 @@ class pluginclass(object):
|
||||
self.lastActiveTab = self.settings.get("int", "last-active-tab")
|
||||
self.defaultTab = self.settings.get("int", "default-tab")
|
||||
|
||||
|
||||
# Allow plugin to be minimized to the left plugin pane
|
||||
self.sticky = self.settings.get("bool", "sticky")
|
||||
self.minimized = self.settings.get("bool", "minimized")
|
||||
@ -495,11 +500,10 @@ class pluginclass(object):
|
||||
return True
|
||||
except:
|
||||
pass
|
||||
|
||||
return False
|
||||
|
||||
def onShowMenu(self):
|
||||
if len(self.favorites):
|
||||
if self.favorites:
|
||||
if self.defaultTab == -1:
|
||||
self.changeTab(self.lastActiveTab)
|
||||
else:
|
||||
@ -523,7 +527,6 @@ class pluginclass(object):
|
||||
self.focusSearchEntry(clear)
|
||||
self.lastActiveTab = tabNum
|
||||
|
||||
|
||||
def Todos(self):
|
||||
self.searchEntry.connect("popup-menu", self.blockOnPopup)
|
||||
self.searchEntry.connect("button-press-event", self.blockOnRightPress)
|
||||
@ -557,9 +560,7 @@ class pluginclass(object):
|
||||
self.stopBuildingButtonList = True
|
||||
GLib.timeout_add(100, self.buildButtonList)
|
||||
return
|
||||
|
||||
self.stopBuildingButtonList = False
|
||||
|
||||
self.updateBoxes(False)
|
||||
|
||||
def categoryBtnFocus(self, widget, event, category):
|
||||
@ -577,60 +578,33 @@ class pluginclass(object):
|
||||
GLib.source_remove(self.filterTimer)
|
||||
self.filterTimer = None
|
||||
|
||||
def add_suggestion(self, icon=None, label=None, tooltip=None, callback=None, *args):
|
||||
if icon:
|
||||
item = SuggestionButton(icon, self.iconSize, label)
|
||||
item.connect("clicked", callback, *args)
|
||||
if tooltip:
|
||||
item.set_tooltip_text(tooltip)
|
||||
else:
|
||||
item = Gtk.SeparatorMenuItem()
|
||||
item.show_all()
|
||||
self.applicationsBox.add(item)
|
||||
self.suggestions.append(item)
|
||||
|
||||
def add_search_suggestions(self, text):
|
||||
|
||||
text = "<b>%s</b>" % text
|
||||
|
||||
text = "<b>%s</b>" % cgi.escape(text)
|
||||
if self.enableInternetSearch:
|
||||
suggestionButton = SuggestionButton("list-add", self.iconSize, "")
|
||||
suggestionButton.connect("clicked", self.search_ddg)
|
||||
suggestionButton.set_text(_("Search DuckDuckGo for %s") % text)
|
||||
suggestionButton.set_image("/usr/lib/linuxmint/mintMenu/search_engines/ddg.png")
|
||||
self.applicationsBox.add(suggestionButton)
|
||||
self.suggestions.append(suggestionButton)
|
||||
self.add_suggestion("/usr/lib/linuxmint/mintMenu/search_engines/ddg.svg", _("Search DuckDuckGo for %s") % text, None, self.search_ddg)
|
||||
self.add_suggestion("/usr/lib/linuxmint/mintMenu/search_engines/wikipedia.svg", _("Search Wikipedia for %s") % text, None, self.search_wikipedia)
|
||||
self.add_suggestion()
|
||||
|
||||
suggestionButton = SuggestionButton("list-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.png")
|
||||
self.applicationsBox.add(suggestionButton)
|
||||
self.suggestions.append(suggestionButton)
|
||||
self.add_suggestion("accessories-dictionary", _("Lookup %s in Dictionary") % text, None, self.search_dictionary)
|
||||
self.add_suggestion("edit-find", _("Search Computer for %s") % text, None, self.Search)
|
||||
|
||||
separator = Gtk.EventBox()
|
||||
separator.add(Gtk.Separator(orientation=Gtk.Orientation.HORIZONTAL))
|
||||
separator.set_visible_window(False)
|
||||
separator.set_size_request(-1, 20)
|
||||
separator.type = "separator"
|
||||
separator.show_all()
|
||||
self.applicationsBox.add(separator)
|
||||
self.suggestions.append(separator)
|
||||
|
||||
suggestionButton = SuggestionButton("list-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)
|
||||
|
||||
suggestionButton = SuggestionButton("edit-find", self.iconSize, "")
|
||||
suggestionButton.connect("clicked", self.Search)
|
||||
suggestionButton.set_text(_("Search Computer for %s") % text)
|
||||
self.applicationsBox.add(suggestionButton)
|
||||
self.suggestions.append(suggestionButton)
|
||||
|
||||
#self.last_separator = Gtk.EventBox()
|
||||
#self.last_separator.add(Gtk.Separator(orientation=Gtk.Orientation.HORIZONTAL))
|
||||
#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.applicationsBox.get_children()[-1].grab_focus()
|
||||
|
||||
def add_apt_filter_results(self, keyword):
|
||||
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
|
||||
@ -638,18 +612,17 @@ class pluginclass(object):
|
||||
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':pipes.quote(word)}
|
||||
pkgs = commands.getoutput(command)
|
||||
pkgs = pkgs.split("\n")
|
||||
num_pkg_found = 0
|
||||
path = os.path.join(home, ".linuxmint/mintMenu/apt.cache")
|
||||
if not os.path.isfile(path):
|
||||
return
|
||||
with open(path) as aptcache:
|
||||
pkgs = [line for line in aptcache.readlines() if all(keyword in line for keyword in keywords)]
|
||||
for pkg in pkgs:
|
||||
values = string.split(pkg, "###")
|
||||
values = pkg.split("###")
|
||||
if len(values) == 4:
|
||||
status = values[0]
|
||||
if status == "ERROR":
|
||||
print "Could not refresh APT cache"
|
||||
print("Could not refresh APT cache")
|
||||
elif status == "CACHE":
|
||||
name = values[1]
|
||||
summary = values[2]
|
||||
@ -667,21 +640,12 @@ class pluginclass(object):
|
||||
found_in_name.append(package)
|
||||
else:
|
||||
found_elsewhere.append(package)
|
||||
num_pkg_found+=1
|
||||
else:
|
||||
print "Invalid status code: " + status
|
||||
|
||||
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:
|
||||
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.show_all()
|
||||
self.applicationsBox.add(last_separator)
|
||||
self.suggestions.append(last_separator)
|
||||
self.add_suggestion()
|
||||
#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]
|
||||
@ -690,13 +654,10 @@ class pluginclass(object):
|
||||
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)
|
||||
suggestionButton.set_text(_("Install package '%s'") % name)
|
||||
suggestionButton.set_tooltip_text("%s\n\n%s\n\n%s" % (pkg.name, pkg.summary, pkg.description))
|
||||
suggestionButton.set_icon_size(self.iconSize)
|
||||
self.applicationsBox.add(suggestionButton)
|
||||
self.suggestions.append(suggestionButton)
|
||||
self.add_suggestion(Gtk.STOCK_ADD,
|
||||
_("Install package '%s'") % name,
|
||||
"%s\n\n%s\n\n%s" % (pkg.name, pkg.summary, pkg.description),
|
||||
self.apturl_install, pkg.name)
|
||||
#if cache != self.current_results:
|
||||
# self.current_results.append(pkg)
|
||||
|
||||
@ -708,9 +669,8 @@ class pluginclass(object):
|
||||
# finally:
|
||||
# gtk.gdk.threads_leave()
|
||||
|
||||
except Exception, detail:
|
||||
print detail
|
||||
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
def add_apt_filter_results_sync(self, cache, keyword):
|
||||
try:
|
||||
@ -729,34 +689,24 @@ class pluginclass(object):
|
||||
found_packages.append(pkg)
|
||||
|
||||
if 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.show_all()
|
||||
self.applicationsBox.add(last_separator)
|
||||
self.suggestions.append(last_separator)
|
||||
self.add_suggestion()
|
||||
|
||||
for pkg in found_packages:
|
||||
name = pkg.name
|
||||
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)
|
||||
suggestionButton.set_text(_("Install package '%s'") % name)
|
||||
suggestionButton.set_tooltip_text("%s\n\n%s\n\n%s" % (pkg.name, pkg.summary.capitalize(), pkg.description))
|
||||
suggestionButton.set_icon_size(self.iconSize)
|
||||
self.applicationsBox.add(suggestionButton)
|
||||
self.suggestions.append(suggestionButton)
|
||||
self.add_suggestion(Gtk.STOCK_ADD,
|
||||
_("Install package '%s'") % name,
|
||||
"%s\n\n%s\n\n%s" % (pkg.name, pkg.summary, pkg.description),
|
||||
self.apturl_install, pkg.name)
|
||||
|
||||
#if len(found_packages) == 0:
|
||||
# self.applicationsBox.remove(self.last_separator)
|
||||
# self.suggestions.remove(self.last_separator)
|
||||
|
||||
except Exception, detail:
|
||||
print detail
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
def Filter(self, widget, category = None):
|
||||
self.filterTimer = None
|
||||
@ -854,7 +804,8 @@ class pluginclass(object):
|
||||
return False
|
||||
|
||||
def favPopup(self, widget, event):
|
||||
if event.button == 3:
|
||||
if not event.button == 3:
|
||||
return
|
||||
if event.y > widget.get_allocation().height / 2:
|
||||
insertBefore = False
|
||||
else:
|
||||
@ -865,7 +816,6 @@ class pluginclass(object):
|
||||
mTree.set_events(Gdk.EventMask.POINTER_MOTION_MASK | Gdk.EventMask.POINTER_MOTION_HINT_MASK |
|
||||
Gdk.EventMask.BUTTON_PRESS_MASK | Gdk.EventMask.BUTTON_RELEASE_MASK)
|
||||
#i18n
|
||||
|
||||
desktopMenuItem = Gtk.MenuItem(_("Add to desktop"))
|
||||
panelMenuItem = Gtk.MenuItem(_("Add to panel"))
|
||||
separator1 = Gtk.SeparatorMenuItem()
|
||||
@ -906,11 +856,6 @@ class pluginclass(object):
|
||||
mTree.append(removeFromFavMenuItem)
|
||||
mTree.append(separator4)
|
||||
mTree.append(propsMenuItem)
|
||||
|
||||
mTree.show_all()
|
||||
self.mintMenuWin.stopHiding()
|
||||
mTree.attach_to_widget(widget, None)
|
||||
mTree.popup(None, None, None, None, event.button, event.time)
|
||||
else:
|
||||
mTree = Gtk.Menu()
|
||||
mTree.set_events(Gdk.EventMask.POINTER_MOTION_MASK | Gdk.EventMask.POINTER_MOTION_HINT_MASK |
|
||||
@ -923,17 +868,21 @@ class pluginclass(object):
|
||||
mTree.append(removeMenuItem)
|
||||
mTree.append(insertSpaceMenuItem)
|
||||
mTree.append(insertSeparatorMenuItem)
|
||||
mTree.show_all()
|
||||
|
||||
removeMenuItem.connect("activate", self.onFavoritesRemove, widget)
|
||||
insertSpaceMenuItem.connect("activate", self.onFavoritesInsertSpace, widget, insertBefore)
|
||||
insertSeparatorMenuItem.connect("activate", self.onFavoritesInsertSeparator, widget, insertBefore)
|
||||
mTree.show_all()
|
||||
self.mintMenuWin.stopHiding()
|
||||
mTree.attach_to_widget(widget, None)
|
||||
if (Gtk.MAJOR_VERSION, Gtk.MINOR_VERSION) >= (3, 22):
|
||||
mTree.popup_at_pointer(event)
|
||||
else:
|
||||
mTree.popup(None, None, None, None, event.button, event.time)
|
||||
|
||||
def menuPopup(self, widget, event):
|
||||
if event.button == 3:
|
||||
if not event.button == 3:
|
||||
return
|
||||
mTree = Gtk.Menu()
|
||||
#i18n
|
||||
desktopMenuItem = Gtk.MenuItem(_("Add to desktop"))
|
||||
@ -955,24 +904,18 @@ class pluginclass(object):
|
||||
|
||||
mTree.append(favoriteMenuItem)
|
||||
mTree.append(startupMenuItem)
|
||||
|
||||
mTree.append(separator2)
|
||||
|
||||
mTree.append(launchMenuItem)
|
||||
mTree.append(uninstallMenuItem)
|
||||
if home in widget.desktopFile:
|
||||
mTree.append(deleteMenuItem)
|
||||
deleteMenuItem.connect("activate", self.delete_from_menu, widget)
|
||||
|
||||
mTree.append(separator3)
|
||||
|
||||
mTree.append(propsMenuItem)
|
||||
|
||||
mTree.show_all()
|
||||
|
||||
desktopMenuItem.connect("activate", self.add_to_desktop, widget)
|
||||
panelMenuItem.connect("activate", self.add_to_panel, widget)
|
||||
|
||||
launchMenuItem.connect("activate", self.onLaunchApp, widget)
|
||||
propsMenuItem.connect("activate", self.onPropsApp, widget)
|
||||
uninstallMenuItem.connect("activate", self.onUninstallApp, widget)
|
||||
@ -995,81 +938,37 @@ class pluginclass(object):
|
||||
mTree.attach_to_widget(widget, None)
|
||||
mTree.popup(None, None, None, None, event.button, event.time)
|
||||
|
||||
def searchPopup(self, widget, event):
|
||||
def add_menu_item(icon=None, text=None, callback=None):
|
||||
box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
|
||||
if icon == None:
|
||||
menuItem = Gtk.SeparatorMenuItem()
|
||||
else:
|
||||
if icon.startswith("/"):
|
||||
icon = Gtk.Image.new_from_pixbuf(GdkPixbuf.Pixbuf.new_from_file_at_size(icon, 16, 16))
|
||||
else:
|
||||
icon = Gtk.Image.new_from_icon_name(icon, Gtk.IconSize.SMALL_TOOLBAR)
|
||||
box.add(icon)
|
||||
box.pack_start(Gtk.Label.new(text), False, False, 5)
|
||||
menuItem = Gtk.MenuItem()
|
||||
menuItem.connect("activate", callback)
|
||||
menuItem.add(box)
|
||||
menu.append(menuItem)
|
||||
|
||||
def searchPopup(self, widget=None, event=None):
|
||||
menu = Gtk.Menu()
|
||||
|
||||
if self.enableInternetSearch:
|
||||
add_menu_item('/usr/lib/linuxmint/mintMenu/search_engines/ddg.svg', _("Search DuckDuckGo"), self.search_ddg)
|
||||
add_menu_item('/usr/lib/linuxmint/mintMenu/search_engines/wikipedia.svg', _("Search Wikipedia"), self.search_wikipedia)
|
||||
|
||||
menuItem = Gtk.ImageMenuItem(_("Search DuckDuckGo"))
|
||||
img = Gtk.Image()
|
||||
img.set_from_file('/usr/lib/linuxmint/mintMenu/search_engines/ddg.png')
|
||||
menuItem.set_image(img)
|
||||
menuItem.connect("activate", self.search_ddg)
|
||||
menu.append(menuItem)
|
||||
|
||||
menuItem = Gtk.ImageMenuItem(_("Search Wikipedia"))
|
||||
img = Gtk.Image()
|
||||
img.set_from_file('/usr/lib/linuxmint/mintMenu/search_engines/wikipedia.png')
|
||||
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_icon_name("edit-find", Gtk.IconSize.INVALID)
|
||||
img.set_pixel_size(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)
|
||||
add_menu_item('accessories-dictionary', _("Search Dictionary"), self.search_dictionary)
|
||||
add_menu_item("edit-find", _("Search Computer"), self.Search)
|
||||
add_menu_item()
|
||||
add_menu_item('/usr/lib/linuxmint/mintMenu/search_engines/software.png', _("Find Software"), self.search_mint_software)
|
||||
add_menu_item('/usr/lib/linuxmint/mintMenu/search_engines/tutorials.png', _("Find Tutorials"), self.search_mint_tutorials)
|
||||
add_menu_item('/usr/lib/linuxmint/mintMenu/search_engines/hardware.png', _("Find Hardware"), self.search_mint_hardware)
|
||||
add_menu_item('/usr/lib/linuxmint/mintMenu/search_engines/ideas.png', _("Find Ideas"), self.search_mint_ideas)
|
||||
add_menu_item('/usr/lib/linuxmint/mintMenu/search_engines/users.png', _("Find Users"), self.search_mint_users)
|
||||
|
||||
menu.show_all()
|
||||
|
||||
@ -1077,68 +976,55 @@ class pluginclass(object):
|
||||
menu.attach_to_widget(self.searchButton, None)
|
||||
menu.popup(None, None, None, None, event.button, event.time)
|
||||
|
||||
#menu.reposition()
|
||||
#menu.reposition()
|
||||
#self.mintMenuWin.grab()
|
||||
self.focusSearchEntry(clear = False)
|
||||
return True
|
||||
|
||||
# TODO: Is this in use?
|
||||
# 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_ddg(self, widget):
|
||||
text = self.searchEntry.get_text()
|
||||
text = text.replace(" ", "+")
|
||||
os.system("xdg-open \"https://duckduckgo.com/?q=%s&t=lm&ia=web\" &" % text)
|
||||
text = urllib.quote_plus(self.searchEntry.get_text().strip())
|
||||
subprocess.Popen(["xdg-open", "https://duckduckgo.com/?q=%s" % text])
|
||||
self.mintMenuWin.hide()
|
||||
|
||||
def search_google(self, widget):
|
||||
text = urllib.quote_plus(self.searchEntry.get_text().strip())
|
||||
subprocess.Popen(["xdg-open", "https://www.google.com/search?q=%s" % text])
|
||||
self.mintMenuWin.hide()
|
||||
|
||||
def search_wikipedia(self, widget):
|
||||
text = self.searchEntry.get_text()
|
||||
text = text.replace(" ", "+")
|
||||
os.system("xdg-open \"https://%s.wikipedia.org/wiki/Special:Search?search=%s\" &" % (self.lang, text))
|
||||
text = urllib.quote_plus(self.searchEntry.get_text().strip())
|
||||
subprocess.Popen(["xdg-open", "https://en.wikipedia.org/wiki/Special:Search?search=%s" % text])
|
||||
self.mintMenuWin.hide()
|
||||
|
||||
def search_dictionary(self, widget):
|
||||
text = self.searchEntry.get_text()
|
||||
os.system("mate-dictionary \"" + text + "\" &")
|
||||
text = self.searchEntry.get_text().strip()
|
||||
subprocess.Popen(["mate-dictionary", "%s" % text])
|
||||
self.mintMenuWin.hide()
|
||||
|
||||
def search_mint_tutorials(self, widget):
|
||||
text = self.searchEntry.get_text()
|
||||
text = text.replace(" ", "%20")
|
||||
os.system("xdg-open \"https://community.linuxmint.com/index.php/tutorial/search/0/" + text + "\" &")
|
||||
text = urllib.quote(self.searchEntry.get_text().strip())
|
||||
subprocess.Popen(["xdg-open", "https://community.linuxmint.com/index.php/tutorial/search/0/%s" % text])
|
||||
self.mintMenuWin.hide()
|
||||
|
||||
def search_mint_ideas(self, widget):
|
||||
text = self.searchEntry.get_text()
|
||||
text = text.replace(" ", "%20")
|
||||
os.system("xdg-open \"https://community.linuxmint.com/index.php/idea/search/0/" + text + "\" &")
|
||||
text = urllib.quote(self.searchEntry.get_text().strip())
|
||||
subprocess.Popen(["xdg-open", "https://community.linuxmint.com/index.php/idea/search/0/%s" % text])
|
||||
self.mintMenuWin.hide()
|
||||
|
||||
def search_mint_users(self, widget):
|
||||
text = self.searchEntry.get_text()
|
||||
text = text.replace(" ", "%20")
|
||||
os.system("xdg-open \"https://community.linuxmint.com/index.php/user/search/0/" + text + "\" &")
|
||||
text = urllib.quote(self.searchEntry.get_text().strip())
|
||||
subprocess.Popen(["xdg-open", "https://community.linuxmint.com/index.php/user/search/0/%s" % text])
|
||||
self.mintMenuWin.hide()
|
||||
|
||||
def search_mint_hardware(self, widget):
|
||||
text = self.searchEntry.get_text()
|
||||
text = text.replace(" ", "%20")
|
||||
os.system("xdg-open \"https://community.linuxmint.com/index.php/hardware/search/0/" + text + "\" &")
|
||||
text = urllib.quote(self.searchEntry.get_text().strip())
|
||||
subprocess.Popen(["xdg-open", "https://community.linuxmint.com/index.php/hardware/search/0/%s" % text])
|
||||
self.mintMenuWin.hide()
|
||||
|
||||
def search_mint_software(self, widget):
|
||||
text = self.searchEntry.get_text()
|
||||
text = text.replace(" ", "%20")
|
||||
os.system("xdg-open \"https://community.linuxmint.com/index.php/software/search/0/" + text + "\" &")
|
||||
text = urllib.quote(self.searchEntry.get_text())
|
||||
subprocess.Popen(["xdg-open", "https://community.linuxmint.com/index.php/software/search/0/%s" % text])
|
||||
self.mintMenuWin.hide()
|
||||
|
||||
def add_to_desktop(self, widget, desktopEntry):
|
||||
os.system("xdg-desktop-icon install --novendor %s" % desktopEntry.desktopFile)
|
||||
subprocess.Popen(["xdg-desktop-icon", "install", "--novendor", desktopEntry.desktopFile])
|
||||
|
||||
def add_to_panel(self, widget, desktopEntry):
|
||||
self.get_panel()
|
||||
@ -1164,22 +1050,20 @@ class pluginclass(object):
|
||||
|
||||
def delete_from_menu(self, widget, desktopEntry):
|
||||
try:
|
||||
os.system("rm \"%s\" &" % desktopEntry.desktopFile)
|
||||
except Exception, detail:
|
||||
print detail
|
||||
os.unlink(desktopEntry.desktopFile)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
def onLaunchApp(self, menu, widget):
|
||||
widget.execute()
|
||||
self.mintMenuWin.hide()
|
||||
|
||||
def onPropsApp(self, menu, widget):
|
||||
|
||||
newFileFlag = False
|
||||
sysPaths = get_system_item_paths()
|
||||
|
||||
for path in sysPaths:
|
||||
path = os.path.join(path, "applications")
|
||||
|
||||
relPath = os.path.relpath(widget.desktopFile, path)
|
||||
|
||||
if widget.desktopFile == os.path.join(path, relPath):
|
||||
@ -1205,23 +1089,18 @@ class pluginclass(object):
|
||||
subprocess.Popen.communicate(editProcess)
|
||||
|
||||
if newFileFlag:
|
||||
|
||||
if filecmp.cmp(widget.desktopFile, filePath):
|
||||
os.remove(filePath)
|
||||
|
||||
else:
|
||||
favoriteChange = 0
|
||||
|
||||
for favorite in self.favorites:
|
||||
if favorite.type == "location":
|
||||
if favorite.desktopFile == widget.desktopFile:
|
||||
favorite.desktopFile = filePath
|
||||
favoriteChange = 1
|
||||
|
||||
if favoriteChange == 1:
|
||||
self.favoritesSave()
|
||||
self.buildFavorites()
|
||||
|
||||
else:
|
||||
self.buildFavorites()
|
||||
|
||||
@ -1280,9 +1159,6 @@ class pluginclass(object):
|
||||
def do_plugin(self):
|
||||
self.Todos()
|
||||
self.buildFavorites()
|
||||
# TODO all this runs whether the plugin is enabled or not
|
||||
# print "applications.do_plugin calling buildRecentApps"
|
||||
# RecentHelper.buildRecentApps()
|
||||
|
||||
# Scroll button into view
|
||||
def scrollItemIntoView(self, widget, event = None):
|
||||
@ -1322,7 +1198,7 @@ class pluginclass(object):
|
||||
try:
|
||||
ButtonIcon = None
|
||||
# For Folders and Network Shares
|
||||
location = string.join(location.split("%20"))
|
||||
location = "".join(location.split("%20"))
|
||||
|
||||
if location.startswith("file"):
|
||||
ButtonIcon = "mate-fs-directory"
|
||||
@ -1330,6 +1206,7 @@ class pluginclass(object):
|
||||
if location.startswith("smb") or location.startswith("ssh") or location.startswith("network"):
|
||||
ButtonIcon = "mate-fs-network"
|
||||
|
||||
# TODO: Do we still need this?
|
||||
#For Special locations
|
||||
if location == "x-nautilus-desktop:///computer":
|
||||
location = "/usr/share/applications/nautilus-computer.desktop"
|
||||
@ -1359,8 +1236,8 @@ class pluginclass(object):
|
||||
self.mintMenuWin.setTooltip(favButton, favButton.getTooltip())
|
||||
favButton.type = "location"
|
||||
return favButton
|
||||
except Exception, e:
|
||||
print u"File in favorites not found: '" + location + "'", e
|
||||
except Exception as e:
|
||||
print("File in favorites not found: '%s': %s" % (location, e))
|
||||
|
||||
return None
|
||||
|
||||
@ -1371,7 +1248,7 @@ class pluginclass(object):
|
||||
os.system("mkdir -p " + path)
|
||||
os.system("cp /usr/lib/linuxmint/mintMenu/applications.list " + path)
|
||||
|
||||
applicationsList = open(path).readlines() # TODO py3 encoding="UTF-8"
|
||||
applicationsList = open(path).readlines()
|
||||
|
||||
self.favorites = []
|
||||
|
||||
@ -1395,7 +1272,6 @@ class pluginclass(object):
|
||||
else:
|
||||
favButton = None
|
||||
|
||||
|
||||
if favButton:
|
||||
favButton.position = position
|
||||
self.favorites.append(favButton)
|
||||
@ -1407,8 +1283,8 @@ class pluginclass(object):
|
||||
position += 1
|
||||
|
||||
self.favoritesSave()
|
||||
except Exception, e:
|
||||
print e
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
def favoritesPositionOnGrid(self, favorite):
|
||||
row = 0
|
||||
@ -1423,7 +1299,6 @@ class pluginclass(object):
|
||||
if fav.type == "separator" or fav.type == "space":
|
||||
row += 1
|
||||
col = 0
|
||||
|
||||
if col >= self.favCols:
|
||||
row += 1
|
||||
col = 0
|
||||
@ -1497,7 +1372,7 @@ class pluginclass(object):
|
||||
appListFile.write("location:" + favorite.desktopFile + "\n")
|
||||
else:
|
||||
appListFile.write(favorite.type + "\n")
|
||||
except Exception, e:
|
||||
except Exception as 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.run()
|
||||
@ -1507,33 +1382,33 @@ class pluginclass(object):
|
||||
for fav in self.favorites:
|
||||
if fav.type == "location" and fav.desktopFile == location:
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
def on_drag_data_get(self, widget, context, selection, info, time):
|
||||
if info == self.TARGET_TYPE_FAV:
|
||||
self.drag_origin = widget.position
|
||||
# FIXME: This fails in python3:
|
||||
selection.set(selection.get_target(), 8, str(widget.position))
|
||||
|
||||
def on_drag_data_received(self, widget, context, x, y, selection, info, time):
|
||||
if info == self.TARGET_TYPE_FAV:
|
||||
self.favoritesReorder(int(selection.get_data()), widget.position)
|
||||
|
||||
def on_icon_theme_changed(self, theme):
|
||||
print "on_icon_theme_changed"
|
||||
self.menuChanged(0, 0)
|
||||
# def on_icon_theme_changed(self, theme):
|
||||
# print("on_icon_theme_changed")
|
||||
# self.menuChanged(0, 0)
|
||||
|
||||
def menuChanged(self, x, y):
|
||||
print("menuChanged")
|
||||
# print("menuChanged")
|
||||
# wait 1s, to avoid building the menu multiple times concurrently
|
||||
if self.menuChangedTimer:
|
||||
GLib.source_remove(self.menuChangedTimer)
|
||||
|
||||
self.menuChangedTimer = GLib.timeout_add(1000, self.updateBoxes, True)
|
||||
|
||||
@print_timing
|
||||
#@print_timing
|
||||
def updateBoxes(self, menu_has_changed):
|
||||
print("updateBoxes")
|
||||
# print("updateBoxes")
|
||||
# FIXME: This is really bad!
|
||||
if self.rebuildLock:
|
||||
return
|
||||
@ -1583,8 +1458,8 @@ class pluginclass(object):
|
||||
self.categoryList.remove(item)
|
||||
button.destroy()
|
||||
del item
|
||||
except Exception, e:
|
||||
print e
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
if addedCategories:
|
||||
sortedCategoryList = []
|
||||
@ -1592,10 +1467,10 @@ class pluginclass(object):
|
||||
try:
|
||||
self.categoriesBox.remove(item["button"])
|
||||
sortedCategoryList.append((str(item["index"]) + item["name"], item["button"]))
|
||||
except Exception, e:
|
||||
print e
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
# Create new category buttons and add the to the list
|
||||
# Create new category buttons and add them to the list
|
||||
for item in addedCategories:
|
||||
try:
|
||||
item["button"] = CategoryButton(item["icon"], categoryIconSize, [item["name"]], item["filter"])
|
||||
@ -1614,16 +1489,16 @@ class pluginclass(object):
|
||||
|
||||
self.categoryList.append(item)
|
||||
sortedCategoryList.append((str(item["index"]) + item["name"], item["button"]))
|
||||
except Exception, e:
|
||||
print e
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
sortedCategoryList.sort()
|
||||
|
||||
for item in sortedCategoryList:
|
||||
try:
|
||||
self.categoriesBox.pack_start(item[1], False, False, 0)
|
||||
except Exception, e:
|
||||
print e
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
# Find added and removed applications add update the application list
|
||||
newApplicationList = self.buildApplicationList()
|
||||
@ -1693,8 +1568,8 @@ class pluginclass(object):
|
||||
button.hide()
|
||||
else:
|
||||
launcherNames.append(launcherName)
|
||||
except Exception, e:
|
||||
print e
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
self.rebuildLock = False
|
||||
|
||||
@ -1721,7 +1596,6 @@ class pluginclass(object):
|
||||
|
||||
# Build a list containing the DesktopEntry object and the category of each application in the menu
|
||||
def buildApplicationList(self):
|
||||
|
||||
newApplicationsList = []
|
||||
|
||||
def find_applications_recursively(app_list, directory, catName):
|
||||
|
@ -7,10 +7,9 @@ import xdg.DesktopEntry
|
||||
import xdg.Menu
|
||||
|
||||
import gi
|
||||
gi.require_version('MateDesktop', '2.0')
|
||||
from gi.repository import Gtk, Gdk, GLib
|
||||
from gi.repository import Pango
|
||||
from gi.repository import GObject
|
||||
gi.require_version("Gtk", "3.0")
|
||||
gi.require_version("MateDesktop", "2.0")
|
||||
from gi.repository import Gtk, Gdk, GdkPixbuf, GLib, GObject, Pango, MateDesktop
|
||||
|
||||
from plugins.execute import Execute
|
||||
from plugins.filemonitor import monitor as filemonitor
|
||||
@ -37,7 +36,7 @@ class IconManager(GObject.GObject):
|
||||
#self.themes = map( createTheme, [d for d in os.listdir("/usr/share/icons") if os.path.isdir(os.path.join("/usr/share/icons", d))])
|
||||
|
||||
self.defaultTheme = Gtk.IconTheme.get_default()
|
||||
defaultKdeTheme = createTheme("kde.default")
|
||||
#defaultKdeTheme = createTheme("kde.default")
|
||||
|
||||
# Setup and clean up the temp icon dir
|
||||
configDir = GLib.get_user_config_dir()
|
||||
@ -49,19 +48,17 @@ class IconManager(GObject.GObject):
|
||||
os.remove(os.path.join(self.iconDir, fn))
|
||||
|
||||
self.defaultTheme.append_search_path(self.iconDir)
|
||||
|
||||
# Themes with the same content as the default them aren't needed
|
||||
#self.themes = [theme for theme in self.themes if theme.list_icons() != defaultTheme.list_icons()]
|
||||
|
||||
self.themes = [self.defaultTheme, defaultKdeTheme]
|
||||
#self.themes = [self.defaultTheme, defaultKdeTheme]
|
||||
self.themes = [self.defaultTheme]
|
||||
|
||||
# Listen for changes in the themes
|
||||
for theme in self.themes:
|
||||
theme.connect("changed", self.themeChanged)
|
||||
|
||||
# for theme in self.themes:
|
||||
# theme.connect("changed", self.themeChanged)
|
||||
|
||||
def getIcon(self, iconName, iconSize):
|
||||
|
||||
if not iconName:
|
||||
return None
|
||||
|
||||
@ -89,22 +86,12 @@ class IconManager(GObject.GObject):
|
||||
shutil.copyfile(iconFileName, os.path.join(self.iconDir, tmpIconName))
|
||||
self.defaultTheme.append_search_path(self.iconDir)
|
||||
|
||||
image = Gtk.Image()
|
||||
icon_found = False
|
||||
for theme in self.themes:
|
||||
if theme.lookup_icon(realIconName, 0, Gtk.IconLookupFlags.FORCE_REGULAR):
|
||||
icon_found = True
|
||||
break
|
||||
|
||||
if icon_found:
|
||||
image.set_from_icon_name(realIconName, Gtk.IconSize.DND)
|
||||
image = Gtk.Image.new_from_icon_name(realIconName, Gtk.IconSize.DND)
|
||||
image.set_pixel_size(iconSize)
|
||||
else:
|
||||
image = None
|
||||
|
||||
return image
|
||||
except Exception, e:
|
||||
print "Exception " + e.__class__.__name__ + ": " + e.message
|
||||
|
||||
except Exception as e:
|
||||
print("Exception %s: %s" % (e.__class__.__name__, e))
|
||||
return None
|
||||
|
||||
def themeChanged(self, theme):
|
||||
@ -128,14 +115,11 @@ class easyButton(Gtk.Button):
|
||||
HBox1 = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
|
||||
self.labelBox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=2)
|
||||
|
||||
|
||||
self.buttonImage = self.getIcon(self.iconSize)
|
||||
if not self.buttonImage:
|
||||
self.buttonImage = Gtk.Image()
|
||||
icon = self.getIcon(self.iconSize)
|
||||
if icon:
|
||||
self.buttonImage = icon
|
||||
else:
|
||||
#[iW, iH] = iconManager.getIconSize(self.iconSize)
|
||||
self.buttonImage.set_size_request(self.iconSize, self.iconSize)
|
||||
|
||||
self.image_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
|
||||
self.image_box.pack_start(self.buttonImage, False, False, 5)
|
||||
self.image_box.show_all()
|
||||
@ -158,7 +142,7 @@ class easyButton(Gtk.Button):
|
||||
self.connectSelf("destroy", self.onDestroy)
|
||||
self.connect("released", self.onRelease)
|
||||
# Reload icons when the theme changed
|
||||
self.themeChangedHandlerId = iconManager.connect("changed", self.themeChanged)
|
||||
# self.themeChangedHandlerId = iconManager.connect("changed", self.themeChanged)
|
||||
|
||||
def connectSelf(self, event, callback):
|
||||
self.connections.append(self.connect(event, callback))
|
||||
@ -168,12 +152,11 @@ class easyButton(Gtk.Button):
|
||||
|
||||
def onDestroy(self, widget):
|
||||
self.buttonImage.clear()
|
||||
iconManager.disconnect(self.themeChangedHandlerId)
|
||||
# iconManager.disconnect(self.themeChangedHandlerId)
|
||||
for connection in self.connections:
|
||||
self.disconnect(connection)
|
||||
del self.connections
|
||||
|
||||
|
||||
def addLabel(self, text, styles = None):
|
||||
label = Gtk.Label()
|
||||
if "<b>" in text or "<span" in text:
|
||||
@ -193,15 +176,10 @@ class easyButton(Gtk.Button):
|
||||
label.show()
|
||||
self.labelBox.pack_start(label , True, True, 0)
|
||||
|
||||
|
||||
def getIcon(self, iconSize):
|
||||
if not self.iconName:
|
||||
return None
|
||||
|
||||
icon = iconManager.getIcon(self.iconName, iconSize)
|
||||
if icon is None:
|
||||
icon = iconManager.getIcon("application-default-icon", iconSize)
|
||||
|
||||
return icon
|
||||
|
||||
def setIcon(self, iconName):
|
||||
@ -248,7 +226,6 @@ class ApplicationLauncher(easyButton):
|
||||
desktopFile = desktopItem.filename
|
||||
self.appDirs = [os.path.dirname(desktopItem.filename)]
|
||||
else:
|
||||
# XXX: All menu entries on LM19.1 end here
|
||||
desktopItem = xdg.DesktopEntry.DesktopEntry(desktopFile)
|
||||
self.appDirs = [os.path.dirname(desktopFile)]
|
||||
|
||||
@ -260,8 +237,8 @@ class ApplicationLauncher(easyButton):
|
||||
self.desktopEntryMonitors = []
|
||||
|
||||
base = os.path.basename(self.desktopFile)
|
||||
for dir in self.appDirs:
|
||||
self.desktopEntryMonitors.append(filemonitor.addMonitor(os.path.join(dir, base) , self.desktopEntryFileChangedCallback))
|
||||
for directory in self.appDirs:
|
||||
self.desktopEntryMonitors.append(filemonitor.addMonitor(os.path.join(directory, base) , self.desktopEntryFileChangedCallback))
|
||||
|
||||
easyButton.__init__(self, self.appIconName, iconSize)
|
||||
self.setupLabels()
|
||||
@ -271,11 +248,7 @@ class ApplicationLauncher(easyButton):
|
||||
|
||||
targets = (Gtk.TargetEntry.new("text/plain", 0, 100), Gtk.TargetEntry.new("text/uri-list", 0, 101))
|
||||
self.drag_source_set(Gdk.ModifierType.BUTTON1_MASK, targets, Gdk.DragAction.COPY)
|
||||
|
||||
icon = self.getIcon(Gtk.IconSize.DND)
|
||||
if icon:
|
||||
iconName, s = icon.get_icon_name()
|
||||
self.drag_source_set_icon_name(iconName)
|
||||
self.drag_source_set_icon_name(self.iconName)
|
||||
|
||||
self.connectSelf("focus-in-event", self.onFocusIn)
|
||||
self.connectSelf("focus-out-event", self.onFocusOut)
|
||||
@ -301,14 +274,14 @@ class ApplicationLauncher(easyButton):
|
||||
self.appComment = self.appComment.strip()
|
||||
|
||||
basename = os.path.basename(self.desktopFile)
|
||||
self.startupFilePath = os.path.join(os.path.expanduser("~"), ".config", "autostart", basename)
|
||||
self.startupFilePath = os.path.join(os.environ['HOME'], ".config/autostart", basename)
|
||||
if self.startupMonitorId:
|
||||
filemonitor.removeMonitor(self.startupMonitorId )
|
||||
if os.path.exists(self.startupFilePath):
|
||||
self.startupMonitorId = filemonitor.addMonitor(self.startupFilePath, self.startupFileChanged)
|
||||
|
||||
except Exception, e:
|
||||
print e
|
||||
except Exception as e:
|
||||
print(e)
|
||||
self.appName = ""
|
||||
self.appGenericName = ""
|
||||
self.appComment = ""
|
||||
@ -338,7 +311,6 @@ class ApplicationLauncher(easyButton):
|
||||
if keyw != "" and appName.find(keyw) == -1 and appGenericName.find(keyw) == -1 and appComment.find(keyw) == -1 and appExec.find(keyw) == -1:
|
||||
self.hide()
|
||||
return False
|
||||
|
||||
self.show()
|
||||
return True
|
||||
|
||||
@ -392,39 +364,39 @@ class ApplicationLauncher(easyButton):
|
||||
def startupFileChanged(self, *args):
|
||||
self.inStartup = os.path.exists(self.startupFilePath)
|
||||
|
||||
# def addToStartup(self):
|
||||
# startupDir = os.path.join(os.path.expanduser("~"), ".config", "autostart")
|
||||
# if not os.path.exists(startupDir):
|
||||
# os.makedirs(startupDir)
|
||||
def addToStartup(self):
|
||||
startupDir = os.path.join(os.path.dirname(self.startupFilePath))
|
||||
if not os.path.exists(startupDir):
|
||||
os.makedirs(startupDir)
|
||||
|
||||
# shutil.copyfile(self.desktopFile, self.startupFilePath)
|
||||
shutil.copyfile(self.desktopFile, self.startupFilePath)
|
||||
|
||||
# # Remove %u, etc. from Exec entry, because MATE will not replace them when it starts the app
|
||||
# item = MateDesktop.DesktopItem.new_from_uri(self.startupFilePath, MateDesktop.DesktopItemLoadFlags.ONLY_IF_EXISTS)
|
||||
# if item:
|
||||
# r = re.compile("%[A-Za-z]");
|
||||
# tmp = r.sub("", item.get_string(MateDesktop.DESKTOP_ITEM_EXEC)).strip()
|
||||
# item.set_string(MateDesktop.DESKTOP_ITEM_EXEC, tmp)
|
||||
# item.save(self.startupFilePath, 0)
|
||||
# Remove %u, etc. from Exec entry, because MATE will not replace them when it starts the app
|
||||
item = MateDesktop.DesktopItem.new_from_uri(self.startupFilePath, MateDesktop.DesktopItemLoadFlags.ONLY_IF_EXISTS)
|
||||
if item:
|
||||
r = re.compile("%[A-Za-z]")
|
||||
tmp = r.sub("", item.get_string(MateDesktop.DESKTOP_ITEM_EXEC)).strip()
|
||||
item.set_string(MateDesktop.DESKTOP_ITEM_EXEC, tmp)
|
||||
item.save(self.startupFilePath, 0)
|
||||
|
||||
# def removeFromStartup(self):
|
||||
# if os.path.exists(self.startupFilePath):
|
||||
# os.remove(self.startupFilePath)
|
||||
def removeFromStartup(self):
|
||||
if os.path.exists(self.startupFilePath):
|
||||
os.remove(self.startupFilePath)
|
||||
|
||||
# def addToFavourites(self):
|
||||
# favouritesDir = os.path.join(os.path.expanduser("~"), ".linuxmint", "mintMenu", "applications")
|
||||
# if not os.path.exists(favouritesDir):
|
||||
# os.makedirs(favouritesDir)
|
||||
def addToFavourites(self):
|
||||
favouritesDir = os.path.join(os.environ['HOME'], ".linuxmint/mintMenu/applications")
|
||||
if not os.path.exists(favouritesDir):
|
||||
os.makedirs(favouritesDir)
|
||||
|
||||
# shutil.copyfile(self.desktopFile, self.favouritesFilePath)
|
||||
shutil.copyfile(self.desktopFile, self.favouritesFilePath)
|
||||
|
||||
# def removeFromFavourites(self):
|
||||
# if os.path.exists(self.favouritesFilePath):
|
||||
# os.remove(self.favouritesFilePath)
|
||||
def removeFromFavourites(self):
|
||||
if os.path.exists(self.favouritesFilePath):
|
||||
os.remove(self.favouritesFilePath)
|
||||
|
||||
# def isInStartup(self):
|
||||
# #return self.inStartup
|
||||
# return os.path.exists(self.startupFilePath)
|
||||
def isInStartup(self):
|
||||
#return self.inStartup
|
||||
return os.path.exists(self.startupFilePath)
|
||||
|
||||
def onDestroy(self, widget):
|
||||
easyButton.onDestroy(self, widget)
|
||||
@ -439,10 +411,10 @@ class ApplicationLauncher(easyButton):
|
||||
def onDesktopEntryFileChanged(self):
|
||||
exists = False
|
||||
base = os.path.basename(self.desktopFile)
|
||||
for dir in self.appDirs:
|
||||
if os.path.exists(os.path.join(dir, base)):
|
||||
for directory in self.appDirs:
|
||||
if os.path.exists(os.path.join(directory, base)):
|
||||
# print os.path.join(dir, base), self.desktopFile
|
||||
self.loadDesktopEntry(xdg.DesktopEntry.DesktopEntry(os.path.join(dir, base)))
|
||||
self.loadDesktopEntry(xdg.DesktopEntry.DesktopEntry(os.path.join(directory, base)))
|
||||
for child in self.labelBox:
|
||||
child.destroy()
|
||||
|
||||
@ -468,7 +440,6 @@ class MenuApplicationLauncher(ApplicationLauncher):
|
||||
|
||||
ApplicationLauncher.__init__(self, desktopFile, iconSize)
|
||||
|
||||
|
||||
def filterCategory(self, category):
|
||||
if self.appCategory == category or category == "":
|
||||
self.show()
|
||||
@ -491,17 +462,16 @@ class MenuApplicationLauncher(ApplicationLauncher):
|
||||
#appComment = "<b>%s</b>" % (appComment);
|
||||
appName = "<b>%s</b>" % appName
|
||||
appComment = "<b>%s</b>" % appComment
|
||||
except Exception, detail:
|
||||
print detail
|
||||
pass
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
if self.showComment and self.appComment != "":
|
||||
if self.iconSize <= 2:
|
||||
self.addLabel('<span size="small">%s</span>' % appName)
|
||||
self.addLabel('<span size="x-small">%s</span>' % appComment)
|
||||
self.addLabel('<span size="small">%s</span>\n<span size="x-small">%s</span>' %
|
||||
(appName, appComment))
|
||||
else:
|
||||
self.addLabel(appName)
|
||||
self.addLabel('<span size="small">%s</span>' % appComment)
|
||||
self.addLabel('%s\n<span size="small">%s</span>' %
|
||||
(appName, appComment))
|
||||
else:
|
||||
self.addLabel(appName)
|
||||
|
||||
@ -548,12 +518,10 @@ class FavApplicationLauncher(ApplicationLauncher):
|
||||
|
||||
self.setupLabels()
|
||||
|
||||
|
||||
class CategoryButton(easyButton):
|
||||
|
||||
def __init__(self, iconName, iconSize, labels , f):
|
||||
easyButton.__init__(self, iconName, iconSize, labels)
|
||||
self.filter = f
|
||||
|
||||
|
||||
iconManager = IconManager()
|
||||
|
@ -37,6 +37,6 @@ def Execute(cmd , commandCwd=None, desktopFile=None):
|
||||
os.chdir(cwd)
|
||||
os.system(cmd + " &")
|
||||
return True
|
||||
except Exception as err:
|
||||
print err
|
||||
except Exception as e:
|
||||
print(e)
|
||||
return False
|
||||
|
@ -32,7 +32,7 @@ if hasInotify:
|
||||
mId = self.wm.add_watch(filename, mask, rec = True)[filename]
|
||||
if mId >= 0:
|
||||
self.callbacks[mId] = (callback, args)
|
||||
except Exception, detail:
|
||||
except:
|
||||
mId = 0
|
||||
return mId
|
||||
|
||||
|
@ -1,16 +1,27 @@
|
||||
#!/usr/bin/python2
|
||||
|
||||
import apt, sys
|
||||
import sys
|
||||
|
||||
try:
|
||||
cache = apt.Cache()
|
||||
for pkg in cache:
|
||||
if not pkg.is_installed:
|
||||
name = pkg.name
|
||||
summary = pkg.candidate.summary.capitalize()
|
||||
description = pkg.candidate.description.replace("\n", "~~~")
|
||||
print "CACHE" + "###" + str(name) + "###" + str(summary) + "###" + str(description)
|
||||
except Exception, detail:
|
||||
print "ERROR###ERROR###ERROR###ERROR"
|
||||
print detail
|
||||
import apt_pkg
|
||||
|
||||
if len(sys.argv) != 2:
|
||||
sys.exit(1)
|
||||
try:
|
||||
apt_pkg.init()
|
||||
cache = apt_pkg.Cache()
|
||||
package_records = apt_pkg.PackageRecords(cache)
|
||||
known_packages = set()
|
||||
with open(sys.argv[1], "w") as f:
|
||||
for pkg in cache.packages:
|
||||
if pkg.selected_state or not pkg.version_list or pkg.name in known_packages:
|
||||
continue
|
||||
name = pkg.name
|
||||
package_records.lookup(pkg.version_list.pop(0).translated_description.file_list.pop(0))
|
||||
summary = package_records.short_desc
|
||||
description = package_records.long_desc.replace(summary + "\n ", "").replace("\n .\n ", "~~~").replace("\n", "")
|
||||
f.write("CACHE###%s###%s###%s\n" % (name, summary, description))
|
||||
known_packages.add(name)
|
||||
except Exception as e:
|
||||
print("ERROR###ERROR###ERROR###ERROR")
|
||||
print(e)
|
||||
sys.exit(1)
|
||||
|
@ -1,11 +1,10 @@
|
||||
#!/usr/bin/python2
|
||||
|
||||
from glob import glob
|
||||
import gettext
|
||||
import os
|
||||
import string
|
||||
from glob import glob
|
||||
from urllib import unquote
|
||||
from user import home
|
||||
|
||||
import gi
|
||||
gi.require_version("Gtk", "3.0")
|
||||
@ -18,6 +17,7 @@ from plugins.execute import Execute
|
||||
|
||||
# i18n
|
||||
gettext.install("mintmenu", "/usr/share/linuxmint/locale")
|
||||
home = os.environ.get("HOME")
|
||||
|
||||
class pluginclass(object):
|
||||
|
||||
@ -173,8 +173,8 @@ class pluginclass(object):
|
||||
tmpdesktopDir = config['XDG_DESKTOP_DIR']
|
||||
if os.path.exists(os.path.expandvars(tmpdesktopDir)):
|
||||
desktopDir = tmpdesktopDir
|
||||
except Exception, detail:
|
||||
print detail
|
||||
except Exception as e:
|
||||
print(e)
|
||||
Button4 = easyButton("desktop", self.iconsize, [_("Desktop")], -1, -1)
|
||||
Button4.connect("clicked", self.ButtonClicked, "xdg-open \"" + desktopDir + "\"")
|
||||
Button4.show()
|
||||
|
@ -1,14 +1,15 @@
|
||||
#!/usr/bin/python2
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
import gi
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, Pango
|
||||
from gi.repository import Gtk
|
||||
|
||||
from plugins.execute import Execute
|
||||
import plugins.recentHelper as RecentHelper
|
||||
from plugins.easygsettings import EasyGSettings
|
||||
from plugins.execute import Execute
|
||||
|
||||
|
||||
class pluginclass:
|
||||
@ -70,7 +71,7 @@ class pluginclass:
|
||||
self.builder.get_object("ClrBtn").connect("clicked", self.clrmenu)
|
||||
|
||||
def wake(self):
|
||||
pass
|
||||
return
|
||||
|
||||
def destroy(self):
|
||||
self.recentBox.destroy()
|
||||
@ -111,8 +112,6 @@ class pluginclass:
|
||||
|
||||
def RebuildPlugin(self):
|
||||
self.content_holder.set_size_request(self.recentw, self.recenth)
|
||||
# TODO
|
||||
print "recent.RebuildPlugin calling recent.DoRecent"
|
||||
self.DoRecent()
|
||||
|
||||
def DoRecent(self, *args, **kargs):
|
||||
@ -135,18 +134,13 @@ class pluginclass:
|
||||
self.AddRecentBtn(Name, self.IconList[loc])
|
||||
loc = loc + 1
|
||||
|
||||
# TODO
|
||||
print "recent.DoRecent calling RecentHelper.doRecentApps"
|
||||
RecentHelper.doRecentApps()
|
||||
|
||||
return True
|
||||
|
||||
def clrmenu(self, *args, **kargs):
|
||||
self.RecManagerInstance.purge_items()
|
||||
# TODO
|
||||
print "recent.clrmenu calling recent.DoRecent"
|
||||
self.DoRecent()
|
||||
return
|
||||
|
||||
def AddRecentBtn(self, Name, RecentImage):
|
||||
DispName=os.path.basename(Name)
|
||||
@ -166,7 +160,7 @@ class pluginclass:
|
||||
Box1.add(ButtonIcon)
|
||||
|
||||
Label1 = Gtk.Label(DispName)
|
||||
Label1.set_ellipsize(Pango.EllipsizeMode.END)
|
||||
Label1.set_ellipsize(3)
|
||||
Box1.add(Label1)
|
||||
|
||||
AButton.add(Box1)
|
||||
@ -174,27 +168,22 @@ class pluginclass:
|
||||
|
||||
self.recentBox.pack_start(AButton, False, True, 0)
|
||||
|
||||
def callback(self, widget, filename=None):
|
||||
def callback(self, widget, filename):
|
||||
self.Win.hide()
|
||||
|
||||
x = os.system("gvfs-open \""+filename+"\"")
|
||||
if x == 256:
|
||||
dia = Gtk.Dialog('File not found!',
|
||||
None, #the toplevel wgt of your app
|
||||
Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, #binary flags or'ed together
|
||||
("Ok", 77))
|
||||
dia.vbox.pack_start(Gtk.Label('The location or file could not be found!'), False, False, 0)
|
||||
dia.vbox.show_all()
|
||||
dia.show()
|
||||
result = dia.run()
|
||||
if result == 77:
|
||||
dia.destroy()
|
||||
try:
|
||||
subprocess.check_call(["xdg-open", filename])
|
||||
except subprocess.CalledProcessError:
|
||||
dialog = Gtk.MessageDialog(self.window, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT,
|
||||
Gtk.MessageType.ERROR, Gtk.ButtonsType.OK, _("The file or location could not be opened."))
|
||||
dialog.set_title("mintMenu")
|
||||
dialog.run()
|
||||
dialog.destroy()
|
||||
|
||||
def GetRecent(self, *args, **kargs):
|
||||
FileString=[]
|
||||
IconString=[]
|
||||
RecentInfo=self.RecManagerInstance.get_items()
|
||||
# print RecentInfo[0].get_icon(Gtk.IconSize.MENU)
|
||||
count=0
|
||||
MaxEntries=self.numentries
|
||||
if self.numentries == -1:
|
||||
@ -225,7 +214,6 @@ class pluginclass:
|
||||
self.Win.plugins["applications"].wTree.get_widget("entry1").grab_focus()
|
||||
Execute(w, self.Exec)
|
||||
|
||||
# TODO - skipping this because we're already doing this on __init__
|
||||
# def do_plugin(self):
|
||||
# print "recent.do_plugin calling recent.DoRecent"
|
||||
def do_plugin(self):
|
||||
return
|
||||
# self.DoRecent()
|
||||
|
@ -1,7 +1,6 @@
|
||||
#!/usr/bin/python2
|
||||
|
||||
import os
|
||||
from user import home
|
||||
|
||||
import gi
|
||||
gi.require_version("Gtk", "3.0")
|
||||
@ -9,7 +8,7 @@ from gi.repository import Gtk
|
||||
|
||||
from plugins.easybuttons import ApplicationLauncher
|
||||
|
||||
|
||||
home = os.environ.get("HOME")
|
||||
recentApps = []
|
||||
mintMenuWin = None
|
||||
recentAppBox = None
|
||||
@ -35,8 +34,8 @@ def recentAppsSave():
|
||||
else:
|
||||
recentAppListFile.write(recentApp.type + "\n")
|
||||
|
||||
except Exception, e:
|
||||
print e
|
||||
except Exception as 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.run()
|
||||
@ -74,18 +73,16 @@ def recentAppBuildLauncher(location):
|
||||
appButton.connect("clicked", applicationButtonClicked)
|
||||
appButton.type = "location"
|
||||
return appButton
|
||||
except Exception, e:
|
||||
print u"File in recentapp not found: '" + location + "'", e
|
||||
except Exception as e:
|
||||
print("File in recentapp not found: '%s': %s" % (location, e))
|
||||
|
||||
return None
|
||||
|
||||
def buildRecentApps():
|
||||
print "-- recentHelper.buildRecentApps"
|
||||
del recentApps[:]
|
||||
try:
|
||||
path = os.path.join(home, ".linuxmint/mintMenu/recentApplications.list")
|
||||
if not os.path.exists(path):
|
||||
print "does not exist"
|
||||
recentApplicationsList = []
|
||||
else:
|
||||
recentApplicationsList = open(path).readlines()
|
||||
@ -103,12 +100,11 @@ def buildRecentApps():
|
||||
|
||||
if appButton:
|
||||
recentApps.append(appButton)
|
||||
except Exception, e:
|
||||
print e
|
||||
except Exception as e:
|
||||
print(e)
|
||||
return recentApps
|
||||
|
||||
def doRecentApps():
|
||||
print "-- recentHelper.doRecentApps"
|
||||
if recentAppBox is not None:
|
||||
# recentAppBox is initiated by the recent plugin
|
||||
# only build UI widgets if it's enabled
|
||||
|
@ -66,7 +66,7 @@ class PointerMonitor(GObject.GObject, threading.Thread):
|
||||
else:
|
||||
self.display.allow_events(X.ReplayPointer, X.CurrentTime)
|
||||
except Exception as e:
|
||||
print "Unexpected error: " + str(e)
|
||||
print("Unexpected error:", e)
|
||||
|
||||
def stop(self):
|
||||
self.running = False
|
||||
|
Binary file not shown.
Before ![]() (image error) Size: 573 B |
60
usr/lib/linuxmint/mintMenu/search_engines/ddg.svg
Normal file
60
usr/lib/linuxmint/mintMenu/search_engines/ddg.svg
Normal file
@ -0,0 +1,60 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 23.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 127 127" style="enable-background:new 0 0 127 127;" xml:space="preserve">
|
||||
<style type="text/css">
|
||||
.st0{fill:#DE5833;}
|
||||
.st1{fill:#FFFFFF;}
|
||||
.st2{fill-rule:evenodd;clip-rule:evenodd;fill:#FED30A;}
|
||||
.st3{fill:#2D4F8D;}
|
||||
.st4{fill:#D5D7D8;}
|
||||
.st5{fill:#67BD47;}
|
||||
.st6{fill:#43A347;}
|
||||
.st7{fill:#4C4C4C;}
|
||||
</style>
|
||||
<g>
|
||||
<g>
|
||||
<circle class="st0" cx="63.3" cy="63.3" r="60"/>
|
||||
<path class="st1" d="M114.1,41.8c-2.8-6.6-6.8-12.5-11.8-17.5c-5.1-5.1-11-9-17.5-11.8c-6.8-2.9-14-4.3-21.5-4.3
|
||||
s-14.7,1.5-21.5,4.3c-6.6,2.8-12.5,6.8-17.5,11.8c-5.1,5.1-9,11-11.8,17.5c-2.9,6.8-4.3,14-4.3,21.5c0,7.4,1.5,14.7,4.3,21.5
|
||||
c2.8,6.6,6.8,12.5,11.8,17.5c5.1,5.1,11,9,17.5,11.8c6.8,2.9,14,4.3,21.5,4.3s14.7-1.5,21.5-4.3c6.6-2.8,12.5-6.8,17.5-11.8
|
||||
c5.1-5.1,9-11,11.8-17.5c2.9-6.8,4.3-14,4.3-21.5C118.4,55.8,117,48.6,114.1,41.8z M75.3,112.8c-3.2-5.4-11.6-20.5-11.6-31.7
|
||||
c0-25.8,17.3-3.7,17.3-24.3c0-4.9-2.4-22.1-17.4-25.7c-3.7-4.9-12.4-9.6-26.2-7.7c0,0,2.3,0.7,4.9,2c0,0-5,0.7-5.2,4.1
|
||||
c0,0,9.9-0.5,15.5,1.3c-12.9,1.7-19.6,8.4-18.4,20.8c1.7,17.5,9.1,48.7,11.7,59.6c-19.6-7.1-33.7-25.9-33.7-48
|
||||
c0-28.1,22.8-51,51-51s51,22.8,51,51C114.2,87.3,97.6,107.4,75.3,112.8z"/>
|
||||
<path id="Beak_2_" class="st2" d="M60.5,71.6c0-6.6,9-8.7,12.4-8.7c9.2,0,22.2-5.9,25.4-5.8c3.3,0.1,5.4,1.4,5.4,2.9
|
||||
c0,2.2-18.4,10.5-25.5,9.8c-6.8-0.6-8.4,0.1-8.4,2.9c0,2.4,4.9,4.6,10.3,4.6c8.1,0,16-3.6,18.4-1.9c2.1,1.5-5.5,6.9-14.2,6.9
|
||||
S60.5,78.2,60.5,71.6z"/>
|
||||
<g>
|
||||
<path class="st3" d="M76.5,43.6c-2.4-3.1-6.7-3.2-8.2,0.4C70.6,42.2,73.4,41.8,76.5,43.6z"/>
|
||||
<path class="st3" d="M49.7,43.7c-3.3-2-8.8-2.2-8.5,4.1C42.9,43.9,45.1,43.2,49.7,43.7z"/>
|
||||
<path class="st3" d="M74.5,49.5c-1.8,0-3.3,1.5-3.3,3.3c0,1.8,1.5,3.3,3.3,3.3s3.3-1.5,3.3-3.3C77.8,51,76.3,49.5,74.5,49.5z
|
||||
M75.7,52.5c-0.5,0-1-0.4-1-1c0-0.5,0.4-1,1-1s1,0.4,1,1C76.6,52.1,76.2,52.5,75.7,52.5z"/>
|
||||
<path class="st3" d="M48.9,51.3c-2.1,0-3.8,1.7-3.8,3.8c0,2.1,1.7,3.8,3.8,3.8c2.1,0,3.8-1.7,3.8-3.8C52.7,53,51,51.3,48.9,51.3z
|
||||
M50.3,54.8c-0.6,0-1.1-0.5-1.1-1.1c0-0.6,0.5-1.1,1.1-1.1c0.6,0,1.1,0.5,1.1,1.1C51.4,54.3,50.9,54.8,50.3,54.8z"/>
|
||||
</g>
|
||||
<g>
|
||||
<path class="st4" d="M40.6,35.1c-4.8,3.5-7,8.9-6.3,16.5c1.7,17.5,9.1,48.8,11.7,59.7c0.9,0.3,1.8,0.6,2.7,0.9
|
||||
c-1.6-6.6-9.3-38.8-12.7-63.5C35.1,42.1,37.6,38.2,40.6,35.1z"/>
|
||||
<path class="st4" d="M52.5,30.8c0.4,0,0.7-0.1,0.7-0.1c-5.2-2.5-13.4-2.6-15.6-2.6c-0.2,0.4-0.4,0.9-0.4,1.4
|
||||
C37.1,29.6,46.8,29,52.5,30.8z"/>
|
||||
<path class="st4" d="M43.1,25.4c-1.6-1.1-2.9-1.8-3.7-2.2c-0.7,0.1-1.3,0.1-2,0.2c0,0,2.3,0.7,4.9,2c0,0-0.1,0-0.2,0
|
||||
C42.7,25.4,43.1,25.4,43.1,25.4z"/>
|
||||
</g>
|
||||
<g>
|
||||
<path class="st5" d="M83.4,91.9c-1.7-0.4-8.3,4.3-10.8,6.1c-0.1-0.5-0.2-0.9-0.3-1.1c-0.3-1-6.7-0.4-8.2,1.2
|
||||
c-4-1.9-12-5.6-12.1-3.3c-0.3,3,0,15.5,1.6,16.4c1.2,0.7,8-3,11.4-4.9c0,0,0,0,0.1,0c2.1,0.5,6,0,7.4-0.9
|
||||
c0.2-0.1,0.3-0.3,0.4-0.5c3.1,1.2,9.8,3.6,11.2,3.1C85.9,107.5,85.5,92.4,83.4,91.9z"/>
|
||||
<path class="st6" d="M65.1,106.3c-2.1-0.4-1.4-2.5-1.4-7.4c0,0,0,0,0,0c-0.5,0.3-0.9,0.7-0.9,1.1c0,4.9-0.8,7.1,1.4,7.4
|
||||
c2.1,0.5,6,0,7.6-0.9c0.3-0.2,0.4-0.5,0.5-1C70.8,106.4,67.1,106.8,65.1,106.3z"/>
|
||||
</g>
|
||||
</g>
|
||||
<g>
|
||||
<path class="st7" d="M110.5,106.4c-0.9,0-1.7,0.7-1.7,1.6c0,0.9,0.7,1.7,1.7,1.7c0.9,0,1.7-0.7,1.7-1.7
|
||||
C112.2,107.2,111.5,106.4,110.5,106.4z M110.6,109.4c-0.7,0-1.3-0.6-1.3-1.3c0-0.7,0.5-1.3,1.3-1.3c0.7,0,1.3,0.6,1.3,1.3
|
||||
C111.8,108.8,111.3,109.4,110.6,109.4z"/>
|
||||
<path class="st7" d="M110.6,107.4c0.2,0,0.3,0.1,0.4,0.3l0.3-0.2c-0.1-0.2-0.4-0.5-0.7-0.5c-0.5,0-1,0.4-1,1c0,0.6,0.4,1,1,1
|
||||
c0.4,0,0.6-0.2,0.7-0.5l-0.3-0.2c-0.1,0.2-0.2,0.3-0.4,0.3c-0.3,0-0.6-0.3-0.6-0.6C110.1,107.7,110.3,107.4,110.6,107.4z"/>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After (image error) Size: 3.8 KiB |
Binary file not shown.
Before ![]() (image error) Size: 733 B |
Binary file not shown.
Before ![]() (image error) Size: 443 B |
5
usr/lib/linuxmint/mintMenu/search_engines/wikipedia.svg
Normal file
5
usr/lib/linuxmint/mintMenu/search_engines/wikipedia.svg
Normal file
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="128" height="128" stroke-miterlimit="10" style="shape-rendering:geometricPrecision; fill-rule:evenodd">
|
||||
<rect width="100%" height="100%" fill="white"/>
|
||||
<path d="M 120.85,29.21 C 120.85,29.62 120.72,29.99 120.47,30.33 C 120.21,30.66 119.94,30.83 119.63,30.83 C 117.14,31.07 115.09,31.87 113.51,33.24 C 111.92,34.6 110.29,37.21 108.6,41.05 L 82.8,99.19 C 82.63,99.73 82.16,100 81.38,100 C 80.77,100 80.3,99.73 79.96,99.19 L 65.49,68.93 L 48.85,99.19 C 48.51,99.73 48.04,100 47.43,100 C 46.69,100 46.2,99.73 45.96,99.19 L 20.61,41.05 C 19.03,37.44 17.36,34.92 15.6,33.49 C 13.85,32.06 11.4,31.17 8.27,30.83 C 8,30.83 7.74,30.69 7.51,30.4 C 7.27,30.12 7.15,29.79 7.15,29.42 C 7.15,28.47 7.42,28 7.96,28 C 10.22,28 12.58,28.1 15.05,28.3 C 17.34,28.51 19.5,28.61 21.52,28.61 C 23.58,28.61 26.01,28.51 28.81,28.3 C 31.74,28.1 34.34,28 36.6,28 C 37.14,28 37.41,28.47 37.41,29.42 C 37.41,30.36 37.24,30.83 36.91,30.83 C 34.65,31 32.87,31.58 31.57,32.55 C 30.27,33.53 29.62,34.81 29.62,36.4 C 29.62,37.21 29.89,38.22 30.43,39.43 L 51.38,86.74 L 63.27,64.28 L 52.19,41.05 C 50.2,36.91 48.56,34.23 47.28,33.03 C 46,31.84 44.06,31.1 41.46,30.83 C 41.22,30.83 41,30.69 40.78,30.4 C 40.56,30.12 40.45,29.79 40.45,29.42 C 40.45,28.47 40.68,28 41.16,28 C 43.42,28 45.49,28.1 47.38,28.3 C 49.2,28.51 51.14,28.61 53.2,28.61 C 55.22,28.61 57.36,28.51 59.62,28.3 C 61.95,28.1 64.24,28 66.5,28 C 67.04,28 67.31,28.47 67.31,29.42 C 67.31,30.36 67.15,30.83 66.81,30.83 C 62.29,31.14 60.03,32.42 60.03,34.68 C 60.03,35.69 60.55,37.26 61.6,39.38 L 68.93,54.26 L 76.22,40.65 C 77.23,38.73 77.74,37.11 77.74,35.79 C 77.74,32.69 75.48,31.04 70.96,30.83 C 70.55,30.83 70.35,30.36 70.35,29.42 C 70.35,29.08 70.45,28.76 70.65,28.46 C 70.86,28.15 71.06,28 71.26,28 C 72.88,28 74.87,28.1 77.23,28.3 C 79.49,28.51 81.35,28.61 82.8,28.61 C 83.84,28.61 85.38,28.52 87.4,28.35 C 89.96,28.12 92.11,28 93.83,28 C 94.23,28 94.43,28.4 94.43,29.21 C 94.43,30.29 94.06,30.83 93.32,30.83 C 90.69,31.1 88.57,31.83 86.97,33.01 C 85.37,34.19 83.37,36.87 80.98,41.05 L 71.26,59.02 L 84.42,85.83 L 103.85,40.65 C 104.52,39 104.86,37.48 104.86,36.1 C 104.86,32.79 102.6,31.04 98.08,30.83 C 97.67,30.83 97.47,30.36 97.47,29.42 C 97.47,28.47 97.77,28 98.38,28 C 100.03,28 101.99,28.1 104.25,28.3 C 106.34,28.51 108.1,28.61 109.51,28.61 C 111,28.61 112.72,28.51 114.67,28.3 C 116.7,28.1 118.52,28 120.14,28 C 120.61,28 120.85,28.4 120.85,29.21 z" />
|
||||
</svg>
|
After (image error) Size: 2.4 KiB |
Loading…
Reference in New Issue
Block a user