2015-06-26 01:36:36 +01:00
|
|
|
#!/usr/bin/python2
|
2009-07-27 11:45:34 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
import cgi
|
|
|
|
import filecmp
|
2009-07-27 11:45:34 +01:00
|
|
|
import gettext
|
2019-05-20 14:31:05 +01:00
|
|
|
import locale
|
2019-02-11 13:54:20 +00:00
|
|
|
import os
|
2010-02-06 07:42:31 +00:00
|
|
|
import subprocess
|
2019-02-11 13:54:20 +00:00
|
|
|
import threading
|
|
|
|
import urllib
|
2009-07-27 11:45:34 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
import gi
|
|
|
|
gi.require_version("Gtk", "3.0")
|
2019-07-05 10:31:30 +01:00
|
|
|
gi.require_version("MateMenu", "2.0")
|
|
|
|
from gi.repository import Gtk, Gdk, GdkPixbuf, Gio, GLib, MateMenu
|
2009-07-27 11:45:34 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
import plugins.recentHelper as RecentHelper
|
|
|
|
from plugins.easybuttons import (ApplicationLauncher, CategoryButton,
|
|
|
|
FavApplicationLauncher,
|
|
|
|
MenuApplicationLauncher)
|
2010-02-24 10:58:46 +00:00
|
|
|
|
2009-07-27 11:45:34 +01:00
|
|
|
# i18n
|
2009-11-03 11:29:52 +00:00
|
|
|
gettext.install("mintmenu", "/usr/share/linuxmint/locale")
|
2019-05-20 14:31:05 +01:00
|
|
|
locale.bindtextdomain("mintmenu", "/usr/share/linuxmint/locale")
|
|
|
|
locale.textdomain("mintmenu")
|
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
home = os.path.expanduser("~")
|
2009-07-27 11:45:34 +01:00
|
|
|
|
2010-10-26 12:02:47 +01:00
|
|
|
class PackageDescriptor():
|
|
|
|
def __init__(self, name, summary, description):
|
|
|
|
self.name = name
|
|
|
|
self.summary = summary
|
|
|
|
self.description = description
|
2010-09-06 15:21:26 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
# 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
|
2010-09-06 15:21:26 +01:00
|
|
|
|
2010-01-22 17:43:21 +00:00
|
|
|
# Helper function for retrieving the user's location for storing new or modified menu items
|
2010-02-06 06:56:44 +00:00
|
|
|
def get_user_item_path():
|
2010-09-06 15:21:26 +01:00
|
|
|
item_dir = None
|
2010-01-22 17:43:21 +00:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
if 'XDG_DATA_HOME' in os.environ:
|
2010-09-06 15:21:26 +01:00
|
|
|
item_dir = os.path.join(os.environ['XDG_DATA_HOME'], 'applications')
|
|
|
|
else:
|
2019-02-11 13:54:20 +00:00
|
|
|
item_dir = os.path.join(home, '.local/share/applications')
|
2010-01-22 17:43:21 +00:00
|
|
|
|
2010-09-06 15:21:26 +01:00
|
|
|
if not os.path.isdir(item_dir):
|
|
|
|
os.makedirs(item_dir)
|
2010-01-22 17:43:21 +00:00
|
|
|
|
2010-09-06 15:21:26 +01:00
|
|
|
return item_dir
|
2010-01-22 17:43:21 +00:00
|
|
|
|
2010-02-06 07:42:31 +00:00
|
|
|
def get_system_item_paths():
|
2015-09-20 14:34:36 +01:00
|
|
|
item_dirs = []
|
2019-02-11 13:54:20 +00:00
|
|
|
if 'XDG_DATA_DIRS' in os.environ:
|
2010-09-06 15:21:26 +01:00
|
|
|
item_dirs = os.environ['XDG_DATA_DIRS'].split(":")
|
2015-09-20 14:34:36 +01:00
|
|
|
item_dirs.append(os.path.join('/usr', 'share'))
|
2010-09-06 15:21:26 +01:00
|
|
|
return item_dirs
|
2010-02-06 06:56:44 +00:00
|
|
|
|
|
|
|
def rel_path(target, base=os.curdir):
|
2010-09-06 15:21:26 +01:00
|
|
|
if not os.path.exists(target):
|
2019-02-11 13:54:20 +00:00
|
|
|
raise OSError("Target does not exist: %s" % target)
|
2010-02-06 06:56:44 +00:00
|
|
|
|
2010-09-06 15:21:26 +01:00
|
|
|
if not os.path.isdir(base):
|
2019-02-11 13:54:20 +00:00
|
|
|
raise OSError("Base is not a directory or does not exist: %s" % base)
|
2010-02-06 06:56:44 +00:00
|
|
|
|
2010-09-06 15:21:26 +01:00
|
|
|
base_list = (os.path.abspath(base)).split(os.sep)
|
|
|
|
target_list = (os.path.abspath(target)).split(os.sep)
|
2010-02-06 06:56:44 +00:00
|
|
|
|
2010-09-06 15:21:26 +01:00
|
|
|
for i in range(min(len(base_list), len(target_list))):
|
2019-02-11 13:54:20 +00:00
|
|
|
if base_list[i] != target_list[i]:
|
|
|
|
break
|
2010-09-06 15:21:26 +01:00
|
|
|
else:
|
|
|
|
i += 1
|
2010-02-06 06:56:44 +00:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
rel_list = [os.pardir] * (len(base_list) - i) + target_list[i:]
|
2010-09-06 15:21:26 +01:00
|
|
|
return os.path.join(*rel_list)
|
2010-02-06 06:56:44 +00:00
|
|
|
|
2019-07-05 10:31:30 +01:00
|
|
|
def get_contents(item):
|
|
|
|
contents = []
|
|
|
|
item_iter = item.iter()
|
|
|
|
item_type = item_iter.next()
|
|
|
|
|
|
|
|
while item_type != MateMenu.TreeItemType.INVALID:
|
|
|
|
item = None
|
|
|
|
if item_type == MateMenu.TreeItemType.DIRECTORY:
|
|
|
|
item = item_iter.get_directory()
|
|
|
|
elif item_type == MateMenu.TreeItemType.ENTRY:
|
|
|
|
item = item_iter.get_entry()
|
|
|
|
elif item_type == MateMenu.TreeItemType.HEADER:
|
|
|
|
item = item_iter.get_header()
|
|
|
|
elif item_type == MateMenu.TreeItemType.ALIAS:
|
|
|
|
item = item_iter.get_alias()
|
|
|
|
elif item_type == MateMenu.TreeItemType.SEPARATOR:
|
|
|
|
item = item_iter.get_separator()
|
|
|
|
if item:
|
|
|
|
contents.append(item)
|
|
|
|
item_type = item_iter.next()
|
|
|
|
return contents
|
|
|
|
|
2009-07-27 11:45:34 +01:00
|
|
|
class Menu:
|
2019-02-11 13:54:20 +00:00
|
|
|
|
|
|
|
def __init__(self, MenuToLookup):
|
2019-07-05 10:31:30 +01:00
|
|
|
self.tree = MateMenu.Tree.new(MenuToLookup, MateMenu.TreeFlags.SORT_DISPLAY_NAME)
|
|
|
|
self.tree.load_sync()
|
2010-09-06 15:21:26 +01:00
|
|
|
self.directory = self.tree.get_root_directory()
|
2009-11-19 00:45:09 +00:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
def getMenus(self, parent=None):
|
2010-09-06 15:21:26 +01:00
|
|
|
if parent == None:
|
|
|
|
#gives top-level "Applications" item
|
|
|
|
yield self.tree.root
|
|
|
|
else:
|
2019-07-05 10:31:30 +01:00
|
|
|
for menu in get_contents(parent):
|
|
|
|
if isinstance(menu, MateMenu.TreeDirectory) and self.__isVisible(menu):
|
2010-09-06 15:21:26 +01:00
|
|
|
yield menu
|
2009-07-27 11:45:34 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
def getItems(self, menu):
|
2019-07-05 10:31:30 +01:00
|
|
|
for item in get_contents(menu):
|
|
|
|
if isinstance(item, MateMenu.TreeEntry) and \
|
2019-02-11 13:54:20 +00:00
|
|
|
item.get_desktop_file_id()[-19:] != '-usercustom.desktop' and \
|
|
|
|
self.__isVisible(item):
|
2010-09-06 15:21:26 +01:00
|
|
|
yield item
|
2009-07-27 11:45:34 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
def __isVisible(self, item):
|
2019-07-05 10:31:30 +01:00
|
|
|
if isinstance(item, MateMenu.TreeEntry):
|
2019-02-11 13:54:20 +00:00
|
|
|
return not(item.get_is_excluded() or item.get_is_nodisplay())
|
2019-07-05 10:31:30 +01:00
|
|
|
if isinstance(item, MateMenu.TreeDirectory) and len(get_contents(item)):
|
2010-09-06 15:21:26 +01:00
|
|
|
return True
|
2009-07-27 11:45:34 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
class SuggestionButton(Gtk.Button):
|
2009-07-27 11:45:34 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
def __init__(self, iconName, iconSize, label):
|
|
|
|
Gtk.Button.__init__(self)
|
|
|
|
self.set_relief(Gtk.ReliefStyle.NONE)
|
|
|
|
self.set_size_request(-1, -1)
|
2013-03-08 03:18:41 +00:00
|
|
|
Align1 = Gtk.Alignment()
|
2019-02-11 13:54:20 +00:00
|
|
|
Align1.set(0, 0.5, 1.0, 0)
|
|
|
|
HBox1 = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
|
|
|
|
labelBox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=2)
|
|
|
|
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)
|
|
|
|
HBox1.pack_start(self.image, False, False, 5)
|
2013-03-05 02:56:18 +00:00
|
|
|
self.label = Gtk.Label()
|
2019-02-11 13:54:20 +00:00
|
|
|
self.label.set_markup(label)
|
|
|
|
self.label.set_ellipsize(3)
|
|
|
|
self.label.set_alignment(0.0, 1.0)
|
|
|
|
labelBox.pack_start(self.label, True, True, 2)
|
|
|
|
HBox1.pack_start(labelBox, True, True, 2)
|
|
|
|
Align1.add(HBox1)
|
|
|
|
self.add(Align1)
|
|
|
|
self.show_all()
|
2016-05-21 17:11:36 +01:00
|
|
|
|
2010-09-06 21:56:27 +01:00
|
|
|
def set_image(self, path):
|
|
|
|
self.image.set_from_file(path)
|
2016-05-21 17:11:36 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
def set_text(self, text):
|
2010-09-06 15:21:26 +01:00
|
|
|
self.label.set_markup(text)
|
|
|
|
|
2016-05-21 17:11:36 +01:00
|
|
|
def set_icon_size (self, size):
|
2019-02-11 13:54:20 +00:00
|
|
|
self.image.set_pixel_size(size)
|
2009-07-27 11:45:34 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
class pluginclass(object):
|
2010-09-06 15:21:26 +01:00
|
|
|
TARGET_TYPE_TEXT = 80
|
2019-02-11 20:28:16 +00:00
|
|
|
toButton = (Gtk.TargetEntry.new("text/uri-list", 0, TARGET_TYPE_TEXT),
|
|
|
|
Gtk.TargetEntry.new("text/uri-list", 0, TARGET_TYPE_TEXT))
|
2010-09-06 15:21:26 +01:00
|
|
|
TARGET_TYPE_FAV = 81
|
2019-02-11 20:28:16 +00:00
|
|
|
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))
|
2010-09-06 15:21:26 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
#@print_timing
|
|
|
|
def __init__(self, mintMenuWin, toggleButton, de):
|
2010-09-06 15:21:26 +01:00
|
|
|
self.mintMenuWin = mintMenuWin
|
2017-11-11 08:56:14 +00:00
|
|
|
RecentHelper.mintMenuWin = mintMenuWin
|
2019-02-11 13:54:20 +00:00
|
|
|
self.mainMenus = []
|
2010-09-06 15:21:26 +01:00
|
|
|
self.toggleButton = toggleButton
|
2019-07-05 10:31:30 +01:00
|
|
|
self.menuFiles = []
|
2011-03-29 18:50:33 +01:00
|
|
|
self.de = de
|
2016-05-21 17:11:36 +01:00
|
|
|
|
2016-11-23 15:33:34 +00:00
|
|
|
# Detect the locale (this is used for the Wikipedia search)
|
|
|
|
self.lang = "en"
|
|
|
|
lang = os.getenv('LANG')
|
|
|
|
if lang is not None and lang != "":
|
|
|
|
self.lang = lang.split("_")[0]
|
|
|
|
|
2013-03-05 23:50:35 +00:00
|
|
|
self.builder = Gtk.Builder()
|
2019-05-20 14:31:05 +01:00
|
|
|
self.builder.set_translation_domain("mintmenu")
|
|
|
|
self.builder.add_from_file("/usr/share/linuxmint/mintmenu/applications.ui")
|
2010-09-06 15:21:26 +01:00
|
|
|
|
|
|
|
# Read GLADE file
|
2019-05-14 17:15:42 +01:00
|
|
|
self.main_box = self.builder.get_object("main_box")
|
|
|
|
self.notebook = self.builder.get_object("notebook2")
|
|
|
|
self.search_bar = self.builder.get_object("search_bar")
|
2019-02-11 20:28:16 +00:00
|
|
|
self.searchEntry = self.builder.get_object("searchEntry")
|
|
|
|
self.searchButton = self.builder.get_object("searchButton")
|
|
|
|
self.showAllAppsButton = self.builder.get_object("showAllAppsButton")
|
|
|
|
self.showFavoritesButton = self.builder.get_object("showFavoritesButton")
|
|
|
|
self.applicationsBox = self.builder.get_object("applicationsBox")
|
|
|
|
self.categoriesBox = self.builder.get_object("categoriesBox")
|
|
|
|
self.favoritesBox = self.builder.get_object("favoritesBox")
|
|
|
|
self.applicationsScrolledWindow = self.builder.get_object("applicationsScrolledWindow")
|
2010-09-06 15:21:26 +01:00
|
|
|
|
2019-02-12 13:13:28 +00:00
|
|
|
|
2010-09-06 15:21:26 +01:00
|
|
|
self.numApps = 0
|
|
|
|
# These properties are NECESSARY to maintain consistency
|
|
|
|
|
|
|
|
# Set 'window' property for the plugin (Must be the root widget)
|
2019-02-11 13:54:20 +00:00
|
|
|
self.window = self.builder.get_object("mainWindow")
|
2010-09-06 15:21:26 +01:00
|
|
|
|
|
|
|
# Set 'heading' property for plugin
|
2010-09-13 12:10:43 +01:00
|
|
|
self.heading = ""#_("Applications")
|
2010-09-06 15:21:26 +01:00
|
|
|
|
|
|
|
# This should be the first item added to the window in glade
|
2019-02-11 20:28:16 +00:00
|
|
|
self.content_holder = self.builder.get_object("Applications")
|
2010-09-06 15:21:26 +01:00
|
|
|
|
|
|
|
# Unset all timers
|
|
|
|
self.filterTimer = None
|
|
|
|
self.menuChangedTimer = None
|
|
|
|
# Hookup for text input
|
2019-02-11 13:54:20 +00:00
|
|
|
self.keyPress_handler = self.mintMenuWin.window.connect("key-press-event", self.keyPress)
|
2013-03-08 16:01:42 +00:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
self.favoritesBox.connect("drag-data-received", self.ReceiveCallback)
|
2019-02-11 20:28:16 +00:00
|
|
|
self.favoritesBox.drag_dest_set(Gtk.DestDefaults.MOTION |
|
|
|
|
Gtk.DestDefaults.HIGHLIGHT |
|
|
|
|
Gtk.DestDefaults.DROP,
|
|
|
|
self.toButton, Gdk.DragAction.COPY)
|
2019-02-11 13:54:20 +00:00
|
|
|
self.showFavoritesButton.connect("drag-data-received", self.ReceiveCallback)
|
2019-02-11 20:28:16 +00:00
|
|
|
self.showFavoritesButton.drag_dest_set(Gtk.DestDefaults.MOTION |
|
|
|
|
Gtk.DestDefaults.HIGHLIGHT |
|
|
|
|
Gtk.DestDefaults.DROP,
|
|
|
|
self.toButton, Gdk.DragAction.COPY)
|
2010-09-06 15:21:26 +01:00
|
|
|
|
2019-02-11 20:28:16 +00:00
|
|
|
# self.searchButton.connect("button_release_event", self.SearchWithButton)
|
2013-03-06 01:31:58 +00:00
|
|
|
try:
|
2017-08-26 16:35:45 +01:00
|
|
|
# GSettings stuff
|
2019-05-20 15:19:55 +01:00
|
|
|
self.settings = Gio.Settings("com.linuxmint.mintmenu.plugins.applications")
|
2013-03-06 01:31:58 +00:00
|
|
|
self.GetGSettingsEntries()
|
2019-05-20 15:19:55 +01:00
|
|
|
self.settings.connect("changed::icon-size", self.changeIconSize)
|
|
|
|
self.settings.connect("changed::favicon-size", self.changeFavIconSize)
|
|
|
|
self.settings.connect("changed::height", self.changePluginSize)
|
|
|
|
self.settings.connect("changed::width", self.changePluginSize)
|
|
|
|
self.settings.connect("changed::categories-mouse-over", self.changeCategoriesMouseOver)
|
|
|
|
self.settings.connect("changed::swap-generic-name", self.changeSwapGenericName)
|
|
|
|
self.settings.connect("changed::show-category-icons", self.changeShowCategoryIcons)
|
|
|
|
self.settings.connect("changed::show-application-comments", self.changeShowApplicationComments)
|
|
|
|
self.settings.connect("changed::search-on-top", self.positionSearchBar)
|
|
|
|
self.settings.connect("changed::use-apt", self.switchAPTUsage)
|
|
|
|
self.settings.connect("changed::fav-cols", self.changeFavCols)
|
|
|
|
self.settings.connect("changed::remember-filter", self.changeRememberFilter)
|
|
|
|
self.settings.connect("changed::enable-internet-search", self.changeEnableInternetSearch)
|
|
|
|
self.settings.connect("changed::category-hover-delay", self.GetGSettingsEntries)
|
|
|
|
self.settings.connect("changed::do-not-filter", self.GetGSettingsEntries)
|
|
|
|
self.settings.connect("changed::enable-internet-search", self.GetGSettingsEntries)
|
|
|
|
self.settings.connect("changed::search-command", self.GetGSettingsEntries)
|
|
|
|
self.settings.connect("changed::default-tab", self.GetGSettingsEntries)
|
2019-02-11 13:54:20 +00:00
|
|
|
except Exception as e:
|
|
|
|
print(e)
|
2019-02-11 19:49:27 +00:00
|
|
|
|
2019-05-14 17:15:42 +01:00
|
|
|
self.positionSearchBar()
|
|
|
|
|
2010-09-06 15:21:26 +01:00
|
|
|
self.currentFavCol = 0
|
|
|
|
self.favorites = []
|
2019-01-21 15:37:01 +00:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
self.content_holder.set_size_request(self.width, self.height)
|
2019-05-14 14:20:37 +01:00
|
|
|
# Calculate applicationsBox width based on categoryBox width, but since
|
|
|
|
# we won't have that until the menu has been shown go with an estimate
|
|
|
|
self.applicationsBox.set_size_request(self.width - 155, -1)
|
|
|
|
# Add margin for scrollbars to categoriesBox
|
|
|
|
categoriesScrolledWindow = self.builder.get_object("categoriesScrolledWindow")
|
|
|
|
scrollbar_width = categoriesScrolledWindow.get_vscrollbar().get_preferred_width()
|
|
|
|
self.categoriesBox.set_margin_right(scrollbar_width.natural_width + 2)
|
2010-09-06 15:21:26 +01:00
|
|
|
|
|
|
|
self.buildingButtonList = False
|
|
|
|
self.stopBuildingButtonList = False
|
|
|
|
|
|
|
|
self.categoryList = []
|
|
|
|
self.applicationList = []
|
|
|
|
|
2013-03-08 20:25:14 +00:00
|
|
|
#dirty ugly hack, to get favorites drag origin position
|
|
|
|
self.drag_origin = None
|
|
|
|
|
2010-09-06 15:21:26 +01:00
|
|
|
self.rebuildLock = False
|
2013-04-21 00:19:32 +01:00
|
|
|
self.activeFilter = (1, "", self.searchEntry)
|
2010-09-06 15:21:26 +01:00
|
|
|
|
|
|
|
self.adminMenu = None
|
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
for mainitems in ["mate-applications.menu", "mate-settings.menu"]:
|
|
|
|
mymenu = Menu(mainitems)
|
2019-07-05 10:31:30 +01:00
|
|
|
mymenu.tree.connect("changed", self.menuChanged, None)
|
|
|
|
self.menuFiles.append(mymenu)
|
2016-05-21 17:11:36 +01:00
|
|
|
|
|
|
|
self.refresh_apt_cache()
|
2010-09-06 15:21:26 +01:00
|
|
|
self.suggestions = []
|
|
|
|
self.current_suggestion = None
|
2013-03-09 16:50:43 +00:00
|
|
|
self.panel = "top"
|
|
|
|
self.panel_position = -1
|
2013-03-09 16:46:36 +00:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
self.builder.get_object("searchButton").connect("button-press-event", self.searchPopup)
|
2010-09-06 15:21:26 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
# self.icon_theme = Gtk.IconTheme.get_default()
|
|
|
|
# self.icon_theme.connect("changed", self.on_icon_theme_changed)
|
2019-01-21 15:37:01 +00:00
|
|
|
|
2010-10-26 12:02:47 +01:00
|
|
|
def refresh_apt_cache(self):
|
|
|
|
if self.useAPT:
|
2019-02-11 13:54:20 +00:00
|
|
|
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])
|
2010-10-26 12:02:47 +01:00
|
|
|
|
2010-09-06 15:21:26 +01:00
|
|
|
def get_panel(self):
|
2013-03-09 05:34:24 +00:00
|
|
|
panelsettings = Gio.Settings.new("org.mate.panel")
|
|
|
|
applet_list = panelsettings.get_strv("object-id-list")
|
|
|
|
for applet in applet_list:
|
2019-02-11 20:28:16 +00:00
|
|
|
object_schema = Gio.Settings.new_with_path("org.mate.panel.object", "/org/mate/panel/objects/%s/" % applet)
|
2013-03-09 05:34:24 +00:00
|
|
|
keys = object_schema.list_keys()
|
|
|
|
if "applet-iid" in keys:
|
|
|
|
iid = object_schema.get_string("applet-iid")
|
2013-03-09 16:43:54 +00:00
|
|
|
if iid is not None and iid.find("MintMenu") != -1:
|
2013-03-09 05:34:24 +00:00
|
|
|
self.panel = object_schema.get_string("toplevel-id")
|
|
|
|
self.panel_position = object_schema.get_int("position") + 1
|
|
|
|
|
2010-09-06 15:21:26 +01:00
|
|
|
def apturl_install(self, widget, pkg_name):
|
2019-02-11 13:54:20 +00:00
|
|
|
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 + " &")
|
2016-05-21 17:11:36 +01:00
|
|
|
self.mintMenuWin.hide()
|
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
@staticmethod
|
|
|
|
def wake():
|
|
|
|
return
|
2010-09-06 15:21:26 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
def destroy(self):
|
2010-09-06 15:21:26 +01:00
|
|
|
self.content_holder.destroy()
|
|
|
|
self.searchEntry.destroy()
|
|
|
|
self.searchButton.destroy()
|
|
|
|
self.showAllAppsButton.destroy()
|
|
|
|
self.showFavoritesButton.destroy()
|
|
|
|
self.applicationsBox.destroy()
|
|
|
|
self.categoriesBox.destroy()
|
|
|
|
self.favoritesBox.destroy()
|
|
|
|
|
2019-01-21 15:37:01 +00:00
|
|
|
self.mintMenuWin.window.disconnect(self.keyPress_handler)
|
|
|
|
|
2019-05-20 15:19:55 +01:00
|
|
|
def changePluginSize(self, settings, key):
|
2013-03-06 01:31:58 +00:00
|
|
|
if key == "width":
|
|
|
|
self.width = settings.get_int(key)
|
2019-05-14 14:20:37 +01:00
|
|
|
self.applicationsBox.set_size_request(self.width - self.categoriesBox.get_preferred_width().natural_width, -1)
|
2010-09-06 15:21:26 +01:00
|
|
|
|
2013-03-06 01:31:58 +00:00
|
|
|
elif key == "height":
|
|
|
|
self.heigth = settings.get_int(key)
|
2019-02-11 13:54:20 +00:00
|
|
|
self.content_holder.set_size_request(self.width, self.height)
|
2010-09-06 15:21:26 +01:00
|
|
|
|
2019-05-20 15:19:55 +01:00
|
|
|
def changeSwapGenericName(self, settings, key):
|
2013-03-06 01:31:58 +00:00
|
|
|
self.swapgeneric = settings.get_boolean(key)
|
2010-09-06 15:21:26 +01:00
|
|
|
|
|
|
|
for child in self.favoritesBox:
|
2019-02-11 13:54:20 +00:00
|
|
|
if isinstance(child, FavApplicationLauncher):
|
|
|
|
child.setSwapGeneric(self.swapgeneric)
|
2010-09-06 15:21:26 +01:00
|
|
|
|
2019-05-20 15:19:55 +01:00
|
|
|
def changeShowCategoryIcons(self, settings, key):
|
2013-03-06 01:31:58 +00:00
|
|
|
self.showcategoryicons = settings.get_boolean(key)
|
2010-09-06 15:21:26 +01:00
|
|
|
|
|
|
|
if self.showcategoryicons:
|
|
|
|
categoryIconSize = self.iconSize
|
|
|
|
else:
|
|
|
|
categoryIconSize = 0
|
|
|
|
|
|
|
|
for child in self.categoriesBox:
|
2019-02-11 13:54:20 +00:00
|
|
|
child.setIconSize(categoryIconSize)
|
2010-09-06 15:21:26 +01:00
|
|
|
|
2019-05-20 15:19:55 +01:00
|
|
|
def changeIconSize(self, settings, key):
|
2013-03-06 01:31:58 +00:00
|
|
|
self.iconSize = settings.get_int(key)
|
2010-09-06 15:21:26 +01:00
|
|
|
|
|
|
|
if self.showcategoryicons:
|
|
|
|
categoryIconSize = self.iconSize
|
|
|
|
else:
|
|
|
|
categoryIconSize = 0
|
|
|
|
|
|
|
|
for child in self.categoriesBox:
|
2019-02-11 13:54:20 +00:00
|
|
|
child.setIconSize(categoryIconSize)
|
2010-09-06 15:21:26 +01:00
|
|
|
|
|
|
|
for child in self.applicationsBox:
|
|
|
|
try:
|
2019-02-11 13:54:20 +00:00
|
|
|
child.setIconSize(self.iconSize)
|
2010-09-06 15:21:26 +01:00
|
|
|
except:
|
2016-05-21 17:11:36 +01:00
|
|
|
pass
|
2010-09-06 15:21:26 +01:00
|
|
|
|
2019-05-20 15:19:55 +01:00
|
|
|
def changeFavIconSize(self, settings, key):
|
2013-03-06 01:31:58 +00:00
|
|
|
self.faviconsize = settings.get_int(key)
|
2010-09-06 15:21:26 +01:00
|
|
|
|
|
|
|
for child in self.favoritesBox:
|
2019-02-11 13:54:20 +00:00
|
|
|
if isinstance(child, FavApplicationLauncher):
|
|
|
|
child.setIconSize(self.faviconsize)
|
2016-05-21 17:11:36 +01:00
|
|
|
|
2019-05-20 15:19:55 +01:00
|
|
|
def positionSearchBar(self, settings=None, key=None):
|
2019-05-14 17:15:42 +01:00
|
|
|
self.main_box.remove(self.notebook)
|
|
|
|
self.main_box.remove(self.search_bar)
|
2019-05-20 15:19:55 +01:00
|
|
|
if self.settings.get_boolean("search-on-top"):
|
2019-05-14 17:15:42 +01:00
|
|
|
self.main_box.pack_start(self.search_bar, False, False, 0)
|
|
|
|
self.main_box.pack_start(self.notebook, True, True, 0)
|
|
|
|
else:
|
|
|
|
self.main_box.pack_start(self.notebook, True, True, 0)
|
|
|
|
self.main_box.pack_start(self.search_bar, False, False, 0)
|
|
|
|
|
2019-05-20 15:19:55 +01:00
|
|
|
def switchAPTUsage(self, settings, key):
|
2013-03-06 01:31:58 +00:00
|
|
|
self.useAPT = settings.get_boolean(key)
|
2010-10-26 12:02:47 +01:00
|
|
|
self.refresh_apt_cache()
|
2010-09-06 15:21:26 +01:00
|
|
|
|
2019-05-20 15:19:55 +01:00
|
|
|
def changeRememberFilter(self, settings, key):
|
2013-04-21 00:19:32 +01:00
|
|
|
self.rememberFilter = settings.get_boolean(key)
|
|
|
|
|
2019-05-20 15:19:55 +01:00
|
|
|
def changeEnableInternetSearch(self, settings, key):
|
2016-08-09 12:45:02 +01:00
|
|
|
self.enableInternetSearch = settings.get_boolean(key)
|
|
|
|
|
2019-05-20 15:19:55 +01:00
|
|
|
def changeShowApplicationComments(self, settings, key):
|
2013-03-06 01:31:58 +00:00
|
|
|
self.showapplicationcomments = settings.get_boolean(key)
|
2010-09-06 15:21:26 +01:00
|
|
|
for child in self.applicationsBox:
|
2019-02-11 13:54:20 +00:00
|
|
|
child.setShowComment(self.showapplicationcomments)
|
2010-09-06 15:21:26 +01:00
|
|
|
|
2019-05-20 15:19:55 +01:00
|
|
|
def changeCategoriesMouseOver(self, settings, key):
|
2013-03-06 01:31:58 +00:00
|
|
|
self.categories_mouse_over = settings.get_boolean(key)
|
2010-09-06 15:21:26 +01:00
|
|
|
for child in self.categoriesBox:
|
|
|
|
if self.categories_mouse_over and not child.mouseOverHandlerIds:
|
2019-02-11 13:54:20 +00:00
|
|
|
startId = child.connect("enter", self.StartFilter, child.filter)
|
|
|
|
stopId = child.connect("leave", self.StopFilter)
|
|
|
|
child.mouseOverHandlerIds = (startId, stopId)
|
2011-08-29 16:55:26 +01:00
|
|
|
elif not self.categories_mouse_over and child.mouseOverHandlerIds:
|
2019-02-11 13:54:20 +00:00
|
|
|
child.disconnect(child.mouseOverHandlerIds[0])
|
|
|
|
child.disconnect(child.mouseOverHandlerIds[1])
|
2010-09-06 15:21:26 +01:00
|
|
|
child.mouseOverHandlerIds = None
|
|
|
|
|
2019-05-20 15:19:55 +01:00
|
|
|
def changeFavCols(self, settings, key):
|
2013-03-06 01:31:58 +00:00
|
|
|
self.favCols = settings.get_int(key)
|
2010-09-06 15:21:26 +01:00
|
|
|
for fav in self.favorites:
|
2019-02-11 13:54:20 +00:00
|
|
|
self.favoritesBox.remove(fav)
|
|
|
|
self.favoritesPositionOnGrid(fav)
|
2010-09-06 15:21:26 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
def RegenPlugin(self, *args, **kargs):
|
2010-10-26 12:02:47 +01:00
|
|
|
self.refresh_apt_cache()
|
2016-05-21 17:11:36 +01:00
|
|
|
|
2019-02-11 20:28:16 +00:00
|
|
|
# save old config - this is necessary because the app will notified
|
|
|
|
# when it sets the default values and you don't want the to reload
|
|
|
|
# itself several times
|
2010-09-06 15:21:26 +01:00
|
|
|
oldcategories_mouse_over = self.categories_mouse_over
|
2014-11-03 18:18:48 +00:00
|
|
|
oldiconsize = self.iconSize
|
|
|
|
oldfaviconsize = self.faviconsize
|
|
|
|
oldswapgeneric = self.swapgeneric
|
|
|
|
oldshowcategoryicons = self.showcategoryicons
|
|
|
|
oldcategoryhoverdelay = self.categoryhoverdelay
|
2010-09-06 15:21:26 +01:00
|
|
|
oldicon = self.icon
|
|
|
|
oldhideseparator = self.hideseparator
|
|
|
|
oldshowapplicationcomments = self.showapplicationcomments
|
|
|
|
|
2013-03-06 01:31:58 +00:00
|
|
|
self.GetGSettingsEntries()
|
2010-09-06 15:21:26 +01:00
|
|
|
|
|
|
|
# if the config hasn't changed return
|
2019-02-11 13:54:20 +00:00
|
|
|
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
|
|
|
|
oldicon == self.icon and
|
|
|
|
oldhideseparator == self.hideseparator and
|
|
|
|
oldshowapplicationcomments == self.showapplicationcomments
|
|
|
|
):
|
2010-09-06 15:21:26 +01:00
|
|
|
return
|
|
|
|
|
|
|
|
self.Todos()
|
|
|
|
self.buildFavorites()
|
2017-11-11 08:56:14 +00:00
|
|
|
RecentHelper.buildRecentApps()
|
2010-09-06 15:21:26 +01:00
|
|
|
self.RebuildPlugin()
|
|
|
|
|
2019-05-20 15:19:55 +01:00
|
|
|
def GetGSettingsEntries(self, settings=None, key=None):
|
|
|
|
|
|
|
|
self.categories_mouse_over = self.settings.get_boolean("categories-mouse-over")
|
|
|
|
self.width = self.settings.get_int("width")
|
|
|
|
self.height = self.settings.get_int("height")
|
|
|
|
self.donotfilterapps = self.settings.get_boolean("do-not-filter")
|
|
|
|
self.iconSize = self.settings.get_int("icon-size")
|
|
|
|
self.faviconsize = self.settings.get_int("favicon-size")
|
|
|
|
self.favCols = self.settings.get_int("fav-cols")
|
|
|
|
self.swapgeneric = self.settings.get_boolean("swap-generic-name")
|
|
|
|
self.showcategoryicons = self.settings.get_boolean("show-category-icons")
|
|
|
|
self.categoryhoverdelay = self.settings.get_int("category-hover-delay")
|
|
|
|
self.showapplicationcomments = self.settings.get_boolean("show-application-comments")
|
|
|
|
self.useAPT = self.settings.get_boolean("use-apt")
|
|
|
|
self.rememberFilter = self.settings.get_boolean("remember-filter")
|
|
|
|
self.enableInternetSearch = self.settings.get_boolean("enable-internet-search")
|
|
|
|
|
|
|
|
self.lastActiveTab = self.settings.get_int("last-active-tab")
|
|
|
|
self.defaultTab = self.settings.get_int("default-tab")
|
2010-09-06 15:21:26 +01:00
|
|
|
|
|
|
|
# Search tool
|
2019-05-20 15:19:55 +01:00
|
|
|
self.searchtool = self.settings.get_string("search-command")
|
2010-09-06 15:21:26 +01:00
|
|
|
if self.searchtool == "beagle-search SEARCH_STRING":
|
2011-11-18 10:42:20 +00:00
|
|
|
self.searchtool = "mate-search-tool --named \"%s\" --start"
|
2019-05-20 15:19:55 +01:00
|
|
|
self.settings.set_string("search-command", "mate-search-tool --named \"%s\" --start")
|
2010-09-06 15:21:26 +01:00
|
|
|
|
|
|
|
# Plugin icon
|
2019-05-20 15:19:55 +01:00
|
|
|
self.icon = self.settings.get_string("icon")
|
2010-09-06 15:21:26 +01:00
|
|
|
|
|
|
|
# Hide vertical dotted separator
|
2019-05-20 15:19:55 +01:00
|
|
|
self.hideseparator = self.settings.get_boolean("hide-separator")
|
2010-09-06 15:21:26 +01:00
|
|
|
|
|
|
|
def RebuildPlugin(self):
|
2019-02-11 13:54:20 +00:00
|
|
|
self.content_holder.set_size_request(self.width, self.height)
|
2010-09-06 15:21:26 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
def checkMintMenuFolder(self):
|
|
|
|
if os.path.exists(os.path.join(os.path.expanduser("~"), ".linuxmint", "mintMenu", "applications")):
|
2010-09-06 15:21:26 +01:00
|
|
|
return True
|
|
|
|
try:
|
2019-02-11 13:54:20 +00:00
|
|
|
os.makedirs(os.path.join(os.path.expanduser("~"), ".linuxmint", "mintMenu", "applications"))
|
2010-09-06 15:21:26 +01:00
|
|
|
return True
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
return False
|
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
def onShowMenu(self):
|
|
|
|
if self.favorites:
|
2010-09-06 15:21:26 +01:00
|
|
|
if self.defaultTab == -1:
|
2019-02-11 13:54:20 +00:00
|
|
|
self.changeTab(self.lastActiveTab)
|
2010-09-06 15:21:26 +01:00
|
|
|
else:
|
2019-02-11 13:54:20 +00:00
|
|
|
self.changeTab((self.defaultTab - 1) * -1)
|
2010-09-06 15:21:26 +01:00
|
|
|
else:
|
2019-02-11 13:54:20 +00:00
|
|
|
self.changeTab(1)
|
2010-09-06 15:21:26 +01:00
|
|
|
|
2013-05-21 22:36:15 +01:00
|
|
|
if self.rememberFilter and self.searchEntry.get_text().strip() != "":
|
2013-04-21 00:19:32 +01:00
|
|
|
self.Filter(self.activeFilter[2], self.activeFilter[1])
|
2010-09-06 15:21:26 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
def onHideMenu(self):
|
2019-05-20 15:19:55 +01:00
|
|
|
self.settings.set_int("last-active-tab", self.lastActiveTab)
|
2010-09-06 15:21:26 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
def changeTab(self, tabNum, clear = True):
|
|
|
|
notebook = self.builder.get_object("notebook2")
|
2010-09-06 15:21:26 +01:00
|
|
|
if tabNum == 0:
|
2019-02-11 13:54:20 +00:00
|
|
|
notebook.set_current_page(0)
|
2010-09-06 15:21:26 +01:00
|
|
|
elif tabNum == 1:
|
2019-02-11 13:54:20 +00:00
|
|
|
notebook.set_current_page(1)
|
2010-09-06 15:21:26 +01:00
|
|
|
|
2014-05-07 16:32:18 +01:00
|
|
|
self.focusSearchEntry(clear)
|
2014-01-22 03:56:22 +00:00
|
|
|
self.lastActiveTab = tabNum
|
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
def Todos(self):
|
|
|
|
self.searchEntry.connect("popup-menu", self.blockOnPopup)
|
|
|
|
self.searchEntry.connect("button-press-event", self.blockOnRightPress)
|
|
|
|
self.searchEntry.connect("changed", self.Filter)
|
|
|
|
self.searchEntry.connect("activate", self.Search)
|
|
|
|
self.showAllAppsButton.connect("clicked", lambda widget: self.changeTab(1))
|
|
|
|
self.showFavoritesButton.connect("clicked", lambda widget: self.changeTab(0))
|
2010-09-06 15:21:26 +01:00
|
|
|
self.buildButtonList()
|
2016-05-21 17:11:36 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
def blockOnPopup(self, *args):
|
2014-01-22 20:16:27 +00:00
|
|
|
self.mintMenuWin.stopHiding()
|
|
|
|
return False
|
2016-05-21 17:11:36 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
def blockOnRightPress(self, widget, event):
|
2014-01-22 20:16:27 +00:00
|
|
|
if event.button == 3:
|
|
|
|
self.mintMenuWin.stopHiding()
|
|
|
|
return False
|
2010-09-06 15:21:26 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
def focusSearchEntry(self, clear = True):
|
2013-03-14 00:13:56 +00:00
|
|
|
# grab_focus() does select all text,
|
|
|
|
# restoring the original selection is somehow broken, so just select the end
|
|
|
|
# of the existing text, that's the most likely candidate anyhow
|
2010-09-06 15:21:26 +01:00
|
|
|
self.searchEntry.grab_focus()
|
2014-05-07 15:54:39 +01:00
|
|
|
if self.rememberFilter or not clear:
|
2019-02-11 13:54:20 +00:00
|
|
|
self.searchEntry.select_region(0, -1)
|
2013-04-21 00:19:32 +01:00
|
|
|
else:
|
|
|
|
self.searchEntry.set_text("")
|
2010-09-06 15:21:26 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
def buildButtonList(self):
|
2010-09-06 15:21:26 +01:00
|
|
|
if self.buildingButtonList:
|
|
|
|
self.stopBuildingButtonList = True
|
2019-02-11 13:54:20 +00:00
|
|
|
GLib.timeout_add(100, self.buildButtonList)
|
2010-09-06 15:21:26 +01:00
|
|
|
return
|
|
|
|
self.stopBuildingButtonList = False
|
2010-09-13 15:54:23 +01:00
|
|
|
self.updateBoxes(False)
|
2010-09-06 15:21:26 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
def categoryBtnFocus(self, widget, event, category):
|
|
|
|
self.scrollItemIntoView(widget)
|
|
|
|
self.StartFilter(widget, category)
|
2010-09-06 15:21:26 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
def StartFilter(self, widget, category):
|
2010-09-06 15:21:26 +01:00
|
|
|
# if there is a timer for a different category running stop it
|
|
|
|
if self.filterTimer:
|
2019-02-11 13:54:20 +00:00
|
|
|
GLib.source_remove(self.filterTimer)
|
|
|
|
self.filterTimer = GLib.timeout_add(self.categoryhoverdelay, self.Filter, widget, category)
|
2010-09-06 15:21:26 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
def StopFilter(self, widget):
|
2010-09-06 15:21:26 +01:00
|
|
|
if self.filterTimer:
|
2019-02-11 13:54:20 +00:00
|
|
|
GLib.source_remove(self.filterTimer)
|
2010-09-06 15:21:26 +01:00
|
|
|
self.filterTimer = None
|
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
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)
|
|
|
|
|
2010-09-06 21:56:27 +01:00
|
|
|
def add_search_suggestions(self, text):
|
2019-02-11 13:54:20 +00:00
|
|
|
text = "<b>%s</b>" % cgi.escape(text)
|
|
|
|
if self.enableInternetSearch:
|
2019-02-11 20:28:16 +00:00
|
|
|
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)
|
2019-02-11 13:54:20 +00:00
|
|
|
self.add_suggestion()
|
2016-05-21 17:11:36 +01:00
|
|
|
|
2019-02-11 20:28:16 +00:00
|
|
|
self.add_suggestion("accessories-dictionary", _("Lookup %s in Dictionary") % text, None,
|
|
|
|
self.search_dictionary)
|
2019-07-21 15:01:50 +01:00
|
|
|
self.add_suggestion("edit-find-symbolic", _("Search Computer for %s") % text, None, self.Search)
|
2016-05-21 17:11:36 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
self.applicationsBox.get_children()[-1].grab_focus()
|
2010-09-12 12:21:47 +01:00
|
|
|
|
2010-10-26 12:02:47 +01:00
|
|
|
def add_apt_filter_results(self, keyword):
|
2016-05-21 17:11:36 +01:00
|
|
|
try:
|
2010-09-12 12:21:47 +01:00
|
|
|
# Wait to see if the keyword has changed.. before doing anything
|
2013-03-08 13:02:48 +00:00
|
|
|
current_keyword = self.searchEntry.get_text()
|
2010-09-12 12:21:47 +01:00
|
|
|
if keyword != current_keyword:
|
2016-05-21 17:11:36 +01:00
|
|
|
return
|
2010-09-12 12:21:47 +01:00
|
|
|
found_packages = []
|
2010-10-26 12:02:47 +01:00
|
|
|
found_in_name = []
|
|
|
|
found_elsewhere = []
|
2010-09-12 12:21:47 +01:00
|
|
|
keywords = keyword.split(" ")
|
2019-02-11 13:54:20 +00:00
|
|
|
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)]
|
2010-10-26 12:02:47 +01:00
|
|
|
for pkg in pkgs:
|
2019-02-11 13:54:20 +00:00
|
|
|
values = pkg.split("###")
|
2010-10-26 12:02:47 +01:00
|
|
|
if len(values) == 4:
|
|
|
|
status = values[0]
|
2019-02-11 13:54:20 +00:00
|
|
|
if status == "ERROR":
|
|
|
|
print("Could not refresh APT cache")
|
|
|
|
elif status == "CACHE":
|
2010-10-26 12:02:47 +01:00
|
|
|
name = values[1]
|
|
|
|
summary = values[2]
|
|
|
|
description = values[3].replace("~~~", "\n")
|
|
|
|
package = PackageDescriptor(name, summary, description)
|
2019-02-11 20:28:16 +00:00
|
|
|
# See if all keywords are in the name (so we put these results at the top of the list)
|
2010-10-26 12:02:47 +01:00
|
|
|
some_found = False
|
|
|
|
some_not_found = False
|
|
|
|
for word in keywords:
|
|
|
|
if word in package.name:
|
|
|
|
some_found = True
|
|
|
|
else:
|
|
|
|
some_not_found = True
|
|
|
|
if some_found and not some_not_found:
|
|
|
|
found_in_name.append(package)
|
2016-05-21 17:11:36 +01:00
|
|
|
else:
|
|
|
|
found_elsewhere.append(package)
|
2010-10-26 12:02:47 +01:00
|
|
|
else:
|
2019-02-11 13:54:20 +00:00
|
|
|
print("Invalid status code:",status)
|
2010-10-26 12:02:47 +01:00
|
|
|
found_packages.extend(found_in_name)
|
|
|
|
found_packages.extend(found_elsewhere)
|
2016-05-21 17:11:36 +01:00
|
|
|
if keyword == self.searchEntry.get_text() and len(found_packages) > 0:
|
2019-02-11 13:54:20 +00:00
|
|
|
self.add_suggestion()
|
2019-02-11 20:28:16 +00:00
|
|
|
# Reduce the number of results to 10 max...
|
|
|
|
# it takes a HUGE amount of time to add the GTK box in the menu otherwise..
|
2013-05-03 14:46:47 +01:00
|
|
|
if len(found_packages) > 10:
|
|
|
|
found_packages = found_packages[:10]
|
2016-05-21 17:11:36 +01:00
|
|
|
for pkg in found_packages:
|
2013-03-08 13:02:48 +00:00
|
|
|
name = pkg.name
|
2016-05-21 17:11:36 +01:00
|
|
|
for word in keywords:
|
|
|
|
if word != "":
|
2019-02-11 13:54:20 +00:00
|
|
|
name = name.replace(word, "<b>%s</b>" % word)
|
2019-02-20 10:24:34 +00:00
|
|
|
self.add_suggestion("package-x-generic",
|
2019-02-11 13:54:20 +00:00
|
|
|
_("Install package '%s'") % name,
|
|
|
|
"%s\n\n%s\n\n%s" % (pkg.name, pkg.summary, pkg.description),
|
|
|
|
self.apturl_install, pkg.name)
|
2013-03-08 13:02:48 +00:00
|
|
|
#if cache != self.current_results:
|
|
|
|
# self.current_results.append(pkg)
|
|
|
|
|
2010-09-12 12:21:47 +01:00
|
|
|
#if len(found_packages) == 0:
|
|
|
|
# gtk.gdk.threads_enter()
|
|
|
|
# try:
|
|
|
|
# self.applicationsBox.remove(self.last_separator)
|
|
|
|
# self.suggestions.remove(self.last_separator)
|
|
|
|
# finally:
|
2016-05-21 17:11:36 +01:00
|
|
|
# gtk.gdk.threads_leave()
|
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
except Exception as e:
|
|
|
|
print(e)
|
2010-10-26 12:02:47 +01:00
|
|
|
|
2010-09-12 12:21:47 +01:00
|
|
|
def add_apt_filter_results_sync(self, cache, keyword):
|
2016-05-21 17:11:36 +01:00
|
|
|
try:
|
|
|
|
found_packages = []
|
2010-09-12 12:21:47 +01:00
|
|
|
keywords = keyword.split(" ")
|
|
|
|
if cache is not None:
|
2016-05-21 17:11:36 +01:00
|
|
|
for pkg in cache:
|
2010-09-12 12:21:47 +01:00
|
|
|
some_found = False
|
|
|
|
some_not_found = False
|
|
|
|
for word in keywords:
|
|
|
|
if word in pkg.name:
|
|
|
|
some_found = True
|
|
|
|
else:
|
|
|
|
some_not_found = True
|
|
|
|
if some_found and not some_not_found:
|
2016-05-21 17:11:36 +01:00
|
|
|
found_packages.append(pkg)
|
|
|
|
|
|
|
|
if len(found_packages) > 0:
|
2019-02-11 13:54:20 +00:00
|
|
|
self.add_suggestion()
|
2016-05-21 17:11:36 +01:00
|
|
|
|
2010-09-12 12:21:47 +01:00
|
|
|
for pkg in found_packages:
|
|
|
|
name = pkg.name
|
|
|
|
for word in keywords:
|
2016-05-21 17:11:36 +01:00
|
|
|
if word != "":
|
2019-02-11 13:54:20 +00:00
|
|
|
name = name.replace(word, "<b>%s</b>" % word)
|
|
|
|
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)
|
2016-05-21 17:11:36 +01:00
|
|
|
|
2010-09-12 12:21:47 +01:00
|
|
|
#if len(found_packages) == 0:
|
|
|
|
# self.applicationsBox.remove(self.last_separator)
|
|
|
|
# self.suggestions.remove(self.last_separator)
|
2016-05-21 17:11:36 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
except Exception as e:
|
|
|
|
print(e)
|
2016-05-21 17:11:36 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
def Filter(self, widget, category = None):
|
2010-09-06 15:21:26 +01:00
|
|
|
self.filterTimer = None
|
2016-05-21 17:11:36 +01:00
|
|
|
|
2010-09-06 15:21:26 +01:00
|
|
|
for suggestion in self.suggestions:
|
|
|
|
self.applicationsBox.remove(suggestion)
|
|
|
|
self.suggestions = []
|
|
|
|
|
|
|
|
if widget == self.searchEntry:
|
|
|
|
if self.donotfilterapps:
|
2019-02-11 13:54:20 +00:00
|
|
|
widget.set_text("")
|
2010-09-06 15:21:26 +01:00
|
|
|
else:
|
2013-10-23 18:05:38 +01:00
|
|
|
text = widget.get_text()
|
2013-04-21 00:19:32 +01:00
|
|
|
if self.lastActiveTab != 1:
|
2019-02-11 13:54:20 +00:00
|
|
|
self.changeTab(1, clear = False)
|
2010-09-06 15:21:26 +01:00
|
|
|
text = widget.get_text()
|
|
|
|
showns = False # Are any app shown?
|
2013-05-21 03:00:40 +01:00
|
|
|
shownList = []
|
2010-09-06 15:21:26 +01:00
|
|
|
for i in self.applicationsBox.get_children():
|
2019-02-11 13:54:20 +00:00
|
|
|
shown = i.filterText(text)
|
|
|
|
if shown:
|
2013-05-21 03:00:40 +01:00
|
|
|
dupe = False
|
|
|
|
for item in shownList:
|
|
|
|
if i.desktopFile == item.desktopFile:
|
|
|
|
dupe = True
|
|
|
|
if dupe:
|
|
|
|
i.hide()
|
|
|
|
else:
|
|
|
|
shownList.append(i)
|
2014-06-27 14:38:26 +01:00
|
|
|
#if this is the first matching item
|
|
|
|
#focus it
|
|
|
|
if(not showns):
|
|
|
|
i.grab_focus()
|
2013-05-21 03:00:40 +01:00
|
|
|
showns = True
|
2019-02-11 13:54:20 +00:00
|
|
|
if not showns:
|
2010-09-06 21:56:27 +01:00
|
|
|
if len(text) >= 3:
|
2019-02-11 13:54:20 +00:00
|
|
|
self.add_search_suggestions(text)
|
|
|
|
if self.useAPT:
|
|
|
|
GLib.timeout_add(300, self.add_apt_filter_results, text)
|
2010-09-06 15:21:26 +01:00
|
|
|
for i in self.categoriesBox.get_children():
|
2013-04-21 00:48:21 +01:00
|
|
|
i.released()
|
2019-02-11 13:54:20 +00:00
|
|
|
i.set_relief(Gtk.ReliefStyle.NONE)
|
2010-09-06 15:21:26 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
allButton = self.categoriesBox.get_children()[0]
|
|
|
|
allButton.set_relief(Gtk.ReliefStyle.HALF)
|
2013-04-21 00:19:32 +01:00
|
|
|
self.activeFilter = (0, text, widget)
|
2010-09-06 15:21:26 +01:00
|
|
|
else:
|
|
|
|
#print "CATFILTER"
|
2013-04-21 00:19:32 +01:00
|
|
|
self.activeFilter = (1, category, widget)
|
2010-09-06 15:21:26 +01:00
|
|
|
if category == "":
|
2011-09-02 22:21:38 +01:00
|
|
|
listedDesktopFiles = []
|
2010-09-06 15:21:26 +01:00
|
|
|
for i in self.applicationsBox.get_children():
|
2011-09-02 22:21:38 +01:00
|
|
|
if not i.desktop_file_path in listedDesktopFiles:
|
2019-02-11 13:54:20 +00:00
|
|
|
listedDesktopFiles.append(i.desktop_file_path)
|
2011-09-02 22:21:38 +01:00
|
|
|
i.show_all()
|
|
|
|
else:
|
|
|
|
i.hide()
|
2010-09-06 15:21:26 +01:00
|
|
|
else:
|
|
|
|
for i in self.applicationsBox.get_children():
|
2019-02-11 13:54:20 +00:00
|
|
|
i.filterCategory(category)
|
2010-09-06 15:21:26 +01:00
|
|
|
|
|
|
|
for i in self.categoriesBox.get_children():
|
2013-04-21 00:48:21 +01:00
|
|
|
i.released()
|
2019-02-11 13:54:20 +00:00
|
|
|
i.set_relief(Gtk.ReliefStyle.NONE)
|
|
|
|
widget.set_relief(Gtk.ReliefStyle.HALF)
|
2016-05-21 17:11:36 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
self.applicationsScrolledWindow.get_vadjustment().set_value(0)
|
2014-01-22 03:15:15 +00:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
def FilterAndClear(self, widget, category = None):
|
|
|
|
self.searchEntry.set_text("")
|
|
|
|
self.Filter(widget, category)
|
2016-05-21 17:11:36 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
def keyPress(self, widget, event):
|
2019-01-21 15:37:01 +00:00
|
|
|
""" Forward all text to the search box """
|
|
|
|
if event.string.strip() or event.keyval == Gdk.KEY_space:
|
2019-02-11 13:54:20 +00:00
|
|
|
self.searchEntry.event(event)
|
2010-09-06 15:21:26 +01:00
|
|
|
return True
|
|
|
|
return False
|
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
def favPopup(self, widget, event):
|
|
|
|
if not event.button == 3:
|
|
|
|
return
|
|
|
|
if event.y > widget.get_allocation().height / 2:
|
|
|
|
insertBefore = False
|
|
|
|
else:
|
|
|
|
insertBefore = True
|
|
|
|
|
|
|
|
if widget.type == "location":
|
2013-03-07 22:27:50 +00:00
|
|
|
mTree = Gtk.Menu()
|
2019-02-11 20:28:16 +00:00
|
|
|
mTree.set_events(Gdk.EventMask.POINTER_MOTION_MASK |
|
|
|
|
Gdk.EventMask.POINTER_MOTION_HINT_MASK |
|
|
|
|
Gdk.EventMask.BUTTON_PRESS_MASK |
|
|
|
|
Gdk.EventMask.BUTTON_RELEASE_MASK)
|
2010-09-06 15:21:26 +01:00
|
|
|
#i18n
|
2013-03-05 23:50:35 +00:00
|
|
|
desktopMenuItem = Gtk.MenuItem(_("Add to desktop"))
|
|
|
|
panelMenuItem = Gtk.MenuItem(_("Add to panel"))
|
|
|
|
separator1 = Gtk.SeparatorMenuItem()
|
2019-02-11 13:54:20 +00:00
|
|
|
insertSpaceMenuItem = Gtk.MenuItem(_("Insert space"))
|
|
|
|
insertSeparatorMenuItem = Gtk.MenuItem(_("Insert separator"))
|
2013-03-05 23:50:35 +00:00
|
|
|
separator2 = Gtk.SeparatorMenuItem()
|
2019-02-11 13:54:20 +00:00
|
|
|
startupMenuItem = Gtk.CheckMenuItem(_("Launch when I log in"))
|
2013-03-05 23:50:35 +00:00
|
|
|
separator3 = Gtk.SeparatorMenuItem()
|
2019-02-11 13:54:20 +00:00
|
|
|
launchMenuItem = Gtk.MenuItem(_("Launch"))
|
|
|
|
removeFromFavMenuItem = Gtk.MenuItem(_("Remove from favorites"))
|
|
|
|
separator4 = Gtk.SeparatorMenuItem()
|
2013-03-05 23:50:35 +00:00
|
|
|
propsMenuItem = Gtk.MenuItem(_("Edit properties"))
|
2010-09-06 15:21:26 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
desktopMenuItem.connect("activate", self.add_to_desktop, widget)
|
|
|
|
panelMenuItem.connect("activate", self.add_to_panel, widget)
|
|
|
|
insertSpaceMenuItem.connect("activate", self.onFavoritesInsertSpace, widget, insertBefore)
|
|
|
|
insertSeparatorMenuItem.connect("activate", self.onFavoritesInsertSeparator, widget, insertBefore)
|
|
|
|
if widget.isInStartup():
|
|
|
|
startupMenuItem.set_active(True)
|
|
|
|
startupMenuItem.connect("toggled", self.onRemoveFromStartup, widget)
|
|
|
|
else:
|
|
|
|
startupMenuItem.set_active(False)
|
|
|
|
startupMenuItem.connect("toggled", self.onAddToStartup, widget)
|
|
|
|
launchMenuItem.connect("activate", self.onLaunchApp, widget)
|
|
|
|
removeFromFavMenuItem.connect("activate", self.onFavoritesRemove, widget)
|
|
|
|
propsMenuItem.connect("activate", self.onPropsApp, widget)
|
|
|
|
|
2011-11-18 10:42:20 +00:00
|
|
|
if self.de == "mate":
|
2013-03-06 02:14:11 +00:00
|
|
|
mTree.append(desktopMenuItem)
|
|
|
|
mTree.append(panelMenuItem)
|
|
|
|
mTree.append(separator1)
|
2019-02-11 13:54:20 +00:00
|
|
|
mTree.append(insertSpaceMenuItem)
|
|
|
|
mTree.append(insertSeparatorMenuItem)
|
2013-03-06 02:14:11 +00:00
|
|
|
mTree.append(separator2)
|
2019-02-11 13:54:20 +00:00
|
|
|
mTree.append(startupMenuItem)
|
2013-03-06 02:14:11 +00:00
|
|
|
mTree.append(separator3)
|
2019-02-11 13:54:20 +00:00
|
|
|
mTree.append(launchMenuItem)
|
|
|
|
mTree.append(removeFromFavMenuItem)
|
|
|
|
mTree.append(separator4)
|
2013-03-06 02:14:11 +00:00
|
|
|
mTree.append(propsMenuItem)
|
2019-02-11 13:54:20 +00:00
|
|
|
else:
|
|
|
|
mTree = Gtk.Menu()
|
2019-02-11 20:28:16 +00:00
|
|
|
mTree.set_events(Gdk.EventMask.POINTER_MOTION_MASK |
|
|
|
|
Gdk.EventMask.POINTER_MOTION_HINT_MASK |
|
|
|
|
Gdk.EventMask.BUTTON_PRESS_MASK |
|
|
|
|
Gdk.EventMask.BUTTON_RELEASE_MASK)
|
2010-09-06 15:21:26 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
#i18n
|
|
|
|
removeMenuItem = Gtk.MenuItem(_("Remove"))
|
|
|
|
insertSpaceMenuItem = Gtk.MenuItem(_("Insert space"))
|
|
|
|
insertSeparatorMenuItem = Gtk.MenuItem(_("Insert separator"))
|
|
|
|
mTree.append(removeMenuItem)
|
|
|
|
mTree.append(insertSpaceMenuItem)
|
|
|
|
mTree.append(insertSeparatorMenuItem)
|
|
|
|
|
|
|
|
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)
|
2010-09-06 15:21:26 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
def menuPopup(self, widget, event):
|
|
|
|
if not event.button == 3:
|
|
|
|
return
|
|
|
|
mTree = Gtk.Menu()
|
|
|
|
#i18n
|
|
|
|
desktopMenuItem = Gtk.MenuItem(_("Add to desktop"))
|
|
|
|
panelMenuItem = Gtk.MenuItem(_("Add to panel"))
|
|
|
|
separator1 = Gtk.SeparatorMenuItem()
|
|
|
|
favoriteMenuItem = Gtk.CheckMenuItem(_("Show in my favorites"))
|
|
|
|
startupMenuItem = Gtk.CheckMenuItem(_("Launch when I log in"))
|
|
|
|
separator2 = Gtk.SeparatorMenuItem()
|
|
|
|
launchMenuItem = Gtk.MenuItem(_("Launch"))
|
|
|
|
uninstallMenuItem = Gtk.MenuItem(_("Uninstall"))
|
|
|
|
deleteMenuItem = Gtk.MenuItem(_("Delete from menu"))
|
|
|
|
separator3 = Gtk.SeparatorMenuItem()
|
|
|
|
propsMenuItem = Gtk.MenuItem(_("Edit properties"))
|
|
|
|
|
|
|
|
if self.de == "mate":
|
|
|
|
mTree.append(desktopMenuItem)
|
|
|
|
mTree.append(panelMenuItem)
|
|
|
|
mTree.append(separator1)
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
if self.isLocationInFavorites(widget.desktopFile):
|
|
|
|
favoriteMenuItem.set_active(True)
|
|
|
|
favoriteMenuItem.connect("toggled", self.onRemoveFromFavorites, widget)
|
|
|
|
else:
|
|
|
|
favoriteMenuItem.set_active(False)
|
|
|
|
favoriteMenuItem.connect("toggled", self.onAddToFavorites, widget)
|
2010-09-06 15:21:26 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
if widget.isInStartup():
|
|
|
|
startupMenuItem.set_active(True)
|
|
|
|
startupMenuItem.connect("toggled", self.onRemoveFromStartup, widget)
|
|
|
|
else:
|
|
|
|
startupMenuItem.set_active(False)
|
|
|
|
startupMenuItem.connect("toggled", self.onAddToStartup, widget)
|
2010-09-06 15:21:26 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
self.mintMenuWin.stopHiding()
|
|
|
|
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()
|
2010-09-06 15:21:26 +01:00
|
|
|
else:
|
2019-02-11 13:54:20 +00:00
|
|
|
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)
|
2016-05-21 17:11:36 +01:00
|
|
|
|
2013-03-07 01:16:45 +00:00
|
|
|
menu = Gtk.Menu()
|
|
|
|
|
2016-08-09 12:45:02 +01:00
|
|
|
if self.enableInternetSearch:
|
2019-02-11 13:54:20 +00:00
|
|
|
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)
|
|
|
|
|
|
|
|
add_menu_item('accessories-dictionary', _("Search Dictionary"), self.search_dictionary)
|
2019-07-21 15:01:50 +01:00
|
|
|
add_menu_item("edit-find-symbolic", _("Search Computer"), self.Search)
|
2019-02-11 13:54:20 +00:00
|
|
|
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)
|
2016-05-21 17:11:36 +01:00
|
|
|
|
2010-09-06 21:56:27 +01:00
|
|
|
menu.show_all()
|
2013-03-07 22:27:50 +00:00
|
|
|
|
2014-01-22 20:16:27 +00:00
|
|
|
self.mintMenuWin.stopHiding()
|
2017-04-28 13:44:09 +01:00
|
|
|
menu.attach_to_widget(self.searchButton, None)
|
2016-09-06 15:58:34 +01:00
|
|
|
menu.popup(None, None, None, None, event.button, event.time)
|
2013-03-07 22:27:50 +00:00
|
|
|
|
2014-05-07 15:54:39 +01:00
|
|
|
self.focusSearchEntry(clear = False)
|
2016-05-21 17:11:36 +01:00
|
|
|
|
2016-11-23 15:13:29 +00:00
|
|
|
def search_ddg(self, widget):
|
2019-02-11 13:54:20 +00:00
|
|
|
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])
|
2010-09-06 21:56:27 +01:00
|
|
|
self.mintMenuWin.hide()
|
2016-05-21 17:11:36 +01:00
|
|
|
|
2010-09-06 21:56:27 +01:00
|
|
|
def search_wikipedia(self, widget):
|
2019-02-11 13:54:20 +00:00
|
|
|
text = urllib.quote_plus(self.searchEntry.get_text().strip())
|
|
|
|
subprocess.Popen(["xdg-open", "https://en.wikipedia.org/wiki/Special:Search?search=%s" % text])
|
2016-05-21 17:11:36 +01:00
|
|
|
self.mintMenuWin.hide()
|
|
|
|
|
2010-09-06 21:56:27 +01:00
|
|
|
def search_dictionary(self, widget):
|
2019-02-11 13:54:20 +00:00
|
|
|
text = self.searchEntry.get_text().strip()
|
|
|
|
subprocess.Popen(["mate-dictionary", "%s" % text])
|
2010-09-06 21:56:27 +01:00
|
|
|
self.mintMenuWin.hide()
|
2016-05-21 17:11:36 +01:00
|
|
|
|
2010-09-06 21:56:27 +01:00
|
|
|
def search_mint_tutorials(self, widget):
|
2019-02-11 13:54:20 +00:00
|
|
|
text = urllib.quote(self.searchEntry.get_text().strip())
|
|
|
|
subprocess.Popen(["xdg-open", "https://community.linuxmint.com/index.php/tutorial/search/0/%s" % text])
|
2010-09-06 21:56:27 +01:00
|
|
|
self.mintMenuWin.hide()
|
2016-05-21 17:11:36 +01:00
|
|
|
|
2010-09-06 21:56:27 +01:00
|
|
|
def search_mint_ideas(self, widget):
|
2019-02-11 13:54:20 +00:00
|
|
|
text = urllib.quote(self.searchEntry.get_text().strip())
|
|
|
|
subprocess.Popen(["xdg-open", "https://community.linuxmint.com/index.php/idea/search/0/%s" % text])
|
2010-09-06 21:56:27 +01:00
|
|
|
self.mintMenuWin.hide()
|
2016-05-21 17:11:36 +01:00
|
|
|
|
2010-09-06 21:56:27 +01:00
|
|
|
def search_mint_users(self, widget):
|
2019-02-11 13:54:20 +00:00
|
|
|
text = urllib.quote(self.searchEntry.get_text().strip())
|
|
|
|
subprocess.Popen(["xdg-open", "https://community.linuxmint.com/index.php/user/search/0/%s" % text])
|
2010-09-06 21:56:27 +01:00
|
|
|
self.mintMenuWin.hide()
|
2016-05-21 17:11:36 +01:00
|
|
|
|
2010-09-06 21:56:27 +01:00
|
|
|
def search_mint_hardware(self, widget):
|
2019-02-11 13:54:20 +00:00
|
|
|
text = urllib.quote(self.searchEntry.get_text().strip())
|
|
|
|
subprocess.Popen(["xdg-open", "https://community.linuxmint.com/index.php/hardware/search/0/%s" % text])
|
2010-09-06 21:56:27 +01:00
|
|
|
self.mintMenuWin.hide()
|
2016-05-21 17:11:36 +01:00
|
|
|
|
2010-09-06 21:56:27 +01:00
|
|
|
def search_mint_software(self, widget):
|
2019-02-11 13:54:20 +00:00
|
|
|
text = urllib.quote(self.searchEntry.get_text())
|
|
|
|
subprocess.Popen(["xdg-open", "https://community.linuxmint.com/index.php/software/search/0/%s" % text])
|
2010-09-06 21:56:27 +01:00
|
|
|
self.mintMenuWin.hide()
|
2016-05-21 17:11:36 +01:00
|
|
|
|
2010-09-06 15:21:26 +01:00
|
|
|
def add_to_desktop(self, widget, desktopEntry):
|
2019-02-11 13:54:20 +00:00
|
|
|
subprocess.Popen(["xdg-desktop-icon", "install", "--novendor", desktopEntry.desktopFile])
|
2010-09-06 15:21:26 +01:00
|
|
|
|
|
|
|
def add_to_panel(self, widget, desktopEntry):
|
2013-03-09 16:46:36 +00:00
|
|
|
self.get_panel()
|
2013-03-09 16:43:54 +00:00
|
|
|
i = 0
|
|
|
|
panel_schema = Gio.Settings.new("org.mate.panel")
|
|
|
|
applet_list = panel_schema.get_strv("object-id-list")
|
|
|
|
|
|
|
|
while True:
|
2019-02-11 13:54:20 +00:00
|
|
|
test_obj = "object_%d" % i
|
2013-03-09 16:43:54 +00:00
|
|
|
if test_obj in applet_list:
|
|
|
|
i += 1
|
|
|
|
else:
|
|
|
|
break
|
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
path = "/org/mate/panel/objects/%s/" % test_obj
|
2013-03-09 16:43:54 +00:00
|
|
|
new_schema = Gio.Settings.new_with_path("org.mate.panel.object", path)
|
|
|
|
new_schema.set_string("launcher-location", desktopEntry.desktopFile)
|
|
|
|
new_schema.set_string("object-type", "launcher")
|
|
|
|
new_schema.set_string("toplevel-id", self.panel)
|
|
|
|
new_schema.set_int("position", self.panel_position)
|
|
|
|
applet_list.append(test_obj)
|
|
|
|
panel_schema.set_strv("object-id-list", applet_list)
|
2010-09-06 15:21:26 +01:00
|
|
|
|
|
|
|
def delete_from_menu(self, widget, desktopEntry):
|
|
|
|
try:
|
2019-02-11 13:54:20 +00:00
|
|
|
os.unlink(desktopEntry.desktopFile)
|
|
|
|
except Exception as e:
|
|
|
|
print(e)
|
2010-09-06 15:21:26 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
def onLaunchApp(self, menu, widget):
|
2010-09-06 15:21:26 +01:00
|
|
|
widget.execute()
|
|
|
|
self.mintMenuWin.hide()
|
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
def onPropsApp(self, menu, widget):
|
2010-09-06 15:21:26 +01:00
|
|
|
newFileFlag = False
|
|
|
|
sysPaths = get_system_item_paths()
|
|
|
|
|
|
|
|
for path in sysPaths:
|
2015-09-20 14:34:36 +01:00
|
|
|
path = os.path.join(path, "applications")
|
2010-09-06 15:21:26 +01:00
|
|
|
relPath = os.path.relpath(widget.desktopFile, path)
|
|
|
|
|
|
|
|
if widget.desktopFile == os.path.join(path, relPath):
|
|
|
|
filePath = os.path.join(get_user_item_path(), relPath)
|
|
|
|
(head,tail) = os.path.split(filePath)
|
|
|
|
|
|
|
|
if not os.path.isdir(head):
|
|
|
|
os.makedirs(head)
|
|
|
|
|
|
|
|
if not os.path.isfile(filePath):
|
|
|
|
data = open(widget.desktopFile).read()
|
|
|
|
open(filePath, 'w').write(data)
|
|
|
|
newFileFlag = True
|
|
|
|
break
|
|
|
|
|
|
|
|
else:
|
|
|
|
filePath = widget.desktopFile
|
|
|
|
|
|
|
|
self.mintMenuWin.hide()
|
2013-03-05 23:50:35 +00:00
|
|
|
Gdk.flush()
|
2010-09-06 15:21:26 +01:00
|
|
|
|
2011-11-18 10:42:20 +00:00
|
|
|
editProcess = subprocess.Popen(["/usr/bin/mate-desktop-item-edit", filePath])
|
2010-09-06 15:21:26 +01:00
|
|
|
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()
|
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
def onUninstallApp(self, menu, widget):
|
2010-09-06 15:21:26 +01:00
|
|
|
widget.uninstall()
|
|
|
|
self.mintMenuWin.hide()
|
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
def onFavoritesInsertSpace(self, menu, widget, insertBefore):
|
2010-09-06 15:21:26 +01:00
|
|
|
if insertBefore:
|
2019-02-11 13:54:20 +00:00
|
|
|
self.favoritesAdd(self.favoritesBuildSpace(), widget.position)
|
2010-09-06 15:21:26 +01:00
|
|
|
else:
|
2019-02-11 13:54:20 +00:00
|
|
|
self.favoritesAdd(self.favoritesBuildSpace(), widget.position + 1)
|
2010-09-06 15:21:26 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
def onFavoritesInsertSeparator(self, menu, widget, insertBefore):
|
2010-09-06 15:21:26 +01:00
|
|
|
if insertBefore:
|
2019-02-11 13:54:20 +00:00
|
|
|
self.favoritesAdd(self.favoritesBuildSeparator(), widget.position)
|
2010-09-06 15:21:26 +01:00
|
|
|
else:
|
2019-02-11 13:54:20 +00:00
|
|
|
self.favoritesAdd(self.favoritesBuildSeparator(), widget.position + 1)
|
2010-09-06 15:21:26 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
def onFavoritesRemove(self, menu, widget):
|
|
|
|
self.favoritesRemove(widget.position)
|
2010-09-06 15:21:26 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
def onAddToStartup(self, menu, widget):
|
2010-09-06 15:21:26 +01:00
|
|
|
widget.addToStartup()
|
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
def onRemoveFromStartup(self, menu, widget):
|
2010-09-06 15:21:26 +01:00
|
|
|
widget.removeFromStartup()
|
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
def onAddToFavorites(self, menu, widget):
|
|
|
|
self.favoritesAdd(self.favoritesBuildLauncher(widget.desktopFile))
|
2010-09-06 15:21:26 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
def onRemoveFromFavorites(self, menu, widget):
|
|
|
|
self.favoritesRemoveLocation(widget.desktopFile)
|
2010-09-06 15:21:26 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
def ReceiveCallback(self, widget, context, x, y, selection, targetType, time):
|
2010-09-06 15:21:26 +01:00
|
|
|
if targetType == self.TARGET_TYPE_TEXT:
|
|
|
|
for uri in selection.get_uris():
|
2019-02-11 13:54:20 +00:00
|
|
|
self.favoritesAdd(self.favoritesBuildLauncher(uri))
|
2014-06-27 14:38:26 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
def Search(self, widget):
|
2010-09-06 15:21:26 +01:00
|
|
|
text = self.searchEntry.get_text().strip()
|
2016-05-21 17:11:36 +01:00
|
|
|
if text != "":
|
2014-06-27 14:38:26 +01:00
|
|
|
for app_button in self.applicationsBox.get_children():
|
2019-02-11 13:54:20 +00:00
|
|
|
if(isinstance(app_button, ApplicationLauncher) and app_button.filterText(text)):
|
2014-06-27 14:38:26 +01:00
|
|
|
app_button.execute()
|
|
|
|
self.mintMenuWin.hide()
|
|
|
|
return
|
|
|
|
|
2010-09-06 15:21:26 +01:00
|
|
|
self.mintMenuWin.hide()
|
2019-02-11 13:54:20 +00:00
|
|
|
fullstring = self.searchtool.replace("%s", text)
|
2016-05-21 17:11:36 +01:00
|
|
|
os.system(fullstring + " &")
|
2009-07-27 11:45:34 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
def SearchWithButton(self, widget, event):
|
|
|
|
self.Search(widget)
|
2009-07-27 11:45:34 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
def do_plugin(self):
|
2010-09-06 15:21:26 +01:00
|
|
|
self.Todos()
|
2016-05-21 17:11:36 +01:00
|
|
|
self.buildFavorites()
|
2010-09-06 15:21:26 +01:00
|
|
|
|
|
|
|
# Scroll button into view
|
2019-02-11 13:54:20 +00:00
|
|
|
def scrollItemIntoView(self, widget, event = None):
|
2016-09-06 15:58:34 +01:00
|
|
|
viewport = widget.get_parent()
|
2019-02-11 13:54:20 +00:00
|
|
|
while not isinstance(viewport, Gtk.Viewport):
|
2016-09-06 15:58:34 +01:00
|
|
|
if not viewport.get_parent():
|
2010-09-06 15:21:26 +01:00
|
|
|
return
|
2016-09-06 15:58:34 +01:00
|
|
|
viewport = viewport.get_parent()
|
2010-09-06 15:21:26 +01:00
|
|
|
aloc = widget.get_allocation()
|
|
|
|
viewport.get_vadjustment().clamp_page(aloc.y, aloc.y + aloc.height)
|
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
def favoritesBuildSpace(self):
|
2013-03-05 23:50:35 +00:00
|
|
|
space = Gtk.EventBox()
|
2019-02-11 13:54:20 +00:00
|
|
|
space.set_size_request(-1, 20)
|
2013-03-14 14:11:15 +00:00
|
|
|
space.set_visible_window(False)
|
2019-02-11 13:54:20 +00:00
|
|
|
space.connect("button-press-event", self.favPopup)
|
2010-09-06 15:21:26 +01:00
|
|
|
space.type = "space"
|
|
|
|
space.show()
|
|
|
|
return space
|
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
def favoritesBuildSeparator(self):
|
|
|
|
separator = Gtk.Separator(orientation=Gtk.Orientation.HORIZONTAL)
|
|
|
|
separator.set_margin_top(5)
|
|
|
|
separator.set_margin_bottom(5)
|
2010-09-06 15:21:26 +01:00
|
|
|
separator.type = "separator"
|
|
|
|
|
|
|
|
separator.show_all()
|
2013-03-08 16:21:26 +00:00
|
|
|
box = Gtk.EventBox()
|
|
|
|
box.type = "separator"
|
|
|
|
box.add(separator)
|
2013-03-14 14:11:15 +00:00
|
|
|
box.set_visible_window(False)
|
2019-02-11 13:54:20 +00:00
|
|
|
box.connect("button-press-event", self.favPopup)
|
2013-03-08 16:21:26 +00:00
|
|
|
box.show_all()
|
|
|
|
return box
|
2010-09-06 15:21:26 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
def favoritesBuildLauncher(self, location):
|
2010-09-06 15:21:26 +01:00
|
|
|
try:
|
|
|
|
# For Folders and Network Shares
|
2019-02-11 13:54:20 +00:00
|
|
|
location = "".join(location.split("%20"))
|
2010-09-06 15:21:26 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
if location.startswith("file://"):
|
2010-09-06 15:21:26 +01:00
|
|
|
location = location[7:]
|
|
|
|
|
2019-07-21 15:52:46 +01:00
|
|
|
if not os.path.exists(location):
|
|
|
|
print("%s does not exist, skipping." % location)
|
|
|
|
return None
|
|
|
|
|
2010-09-06 15:21:26 +01:00
|
|
|
# Don't add a location twice
|
|
|
|
for fav in self.favorites:
|
|
|
|
if fav.type == "location" and fav.desktopFile == location:
|
|
|
|
return None
|
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
favButton = FavApplicationLauncher(location, self.faviconsize, self.swapgeneric)
|
2010-09-06 15:21:26 +01:00
|
|
|
if favButton.appExec:
|
|
|
|
favButton.show()
|
2019-02-11 13:54:20 +00:00
|
|
|
favButton.connect("popup-menu", self.favPopup)
|
|
|
|
favButton.connect("button-press-event", self.favPopup)
|
|
|
|
favButton.connect("focus-in-event", self.scrollItemIntoView)
|
|
|
|
favButton.connect("clicked", RecentHelper.applicationButtonClicked)
|
2010-09-06 15:21:26 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
self.mintMenuWin.setTooltip(favButton, favButton.getTooltip())
|
2010-09-06 15:21:26 +01:00
|
|
|
favButton.type = "location"
|
|
|
|
return favButton
|
2019-02-11 13:54:20 +00:00
|
|
|
except Exception as e:
|
|
|
|
print("File in favorites not found: '%s': %s" % (location, e))
|
2010-09-06 15:21:26 +01:00
|
|
|
|
|
|
|
return None
|
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
def buildFavorites(self):
|
2010-09-06 15:21:26 +01:00
|
|
|
try:
|
2019-02-11 13:54:20 +00:00
|
|
|
path = os.path.join(home, ".linuxmint/mintMenu/applications.list")
|
2019-07-17 14:49:04 +01:00
|
|
|
if os.path.isdir(path):
|
|
|
|
# dir created by a bug in mint 19.2 beta
|
|
|
|
os.system("rm -rf %s" % path)
|
2019-02-11 13:54:20 +00:00
|
|
|
if not os.path.exists(path):
|
2019-07-17 14:49:04 +01:00
|
|
|
os.system("mkdir -p ~/.linuxmint/mintMenu")
|
2019-02-11 13:54:20 +00:00
|
|
|
os.system("cp /usr/lib/linuxmint/mintMenu/applications.list " + path)
|
2010-09-06 15:21:26 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
applicationsList = open(path).readlines()
|
2010-09-06 15:21:26 +01:00
|
|
|
|
|
|
|
self.favorites = []
|
|
|
|
|
|
|
|
for child in self.favoritesBox:
|
|
|
|
child.destroy()
|
|
|
|
|
|
|
|
position = 0
|
|
|
|
|
2019-07-21 15:52:46 +01:00
|
|
|
for app in applicationsList:
|
|
|
|
try:
|
|
|
|
app = app.strip()
|
2010-09-06 15:21:26 +01:00
|
|
|
|
2019-07-21 15:52:46 +01:00
|
|
|
if app[0:9] == "location:":
|
|
|
|
favButton = self.favoritesBuildLauncher(app[9:])
|
|
|
|
elif app == "space":
|
|
|
|
favButton = self.favoritesBuildSpace()
|
|
|
|
elif app == "separator":
|
|
|
|
favButton = self.favoritesBuildSeparator()
|
2010-09-06 15:21:26 +01:00
|
|
|
else:
|
2019-07-21 15:52:46 +01:00
|
|
|
if app.endswith(".desktop"):
|
|
|
|
favButton = self.favoritesBuildLauncher(app)
|
|
|
|
else:
|
|
|
|
favButton = None
|
|
|
|
|
|
|
|
if favButton:
|
|
|
|
favButton.position = position
|
|
|
|
self.favorites.append(favButton)
|
|
|
|
self.favoritesPositionOnGrid(favButton)
|
|
|
|
favButton.drag_source_set(Gdk.ModifierType.BUTTON1_MASK, self.toFav, Gdk.DragAction.COPY)
|
|
|
|
favButton.drag_dest_set(Gtk.DestDefaults.MOTION |
|
|
|
|
Gtk.DestDefaults.HIGHLIGHT |
|
|
|
|
Gtk.DestDefaults.DROP,
|
|
|
|
self.toFav, Gdk.DragAction.COPY)
|
|
|
|
favButton.connect("drag-data-get", self.on_drag_data_get)
|
|
|
|
favButton.connect("drag-data-received", self.on_drag_data_received)
|
|
|
|
position += 1
|
|
|
|
except Exception as e:
|
|
|
|
print("Can't add favorite: %s" % app)
|
|
|
|
print (e)
|
2010-09-06 15:21:26 +01:00
|
|
|
|
|
|
|
self.favoritesSave()
|
2019-02-11 13:54:20 +00:00
|
|
|
except Exception as e:
|
|
|
|
print(e)
|
2010-09-06 15:21:26 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
def favoritesPositionOnGrid(self, favorite):
|
2010-09-06 15:21:26 +01:00
|
|
|
row = 0
|
|
|
|
col = 0
|
|
|
|
for fav in self.favorites:
|
2019-02-11 13:54:20 +00:00
|
|
|
if (fav.type == "separator" or fav.type == "space") and col != 0:
|
2010-09-06 15:21:26 +01:00
|
|
|
row += 1
|
|
|
|
col = 0
|
|
|
|
if fav.position == favorite.position:
|
|
|
|
break
|
|
|
|
col += 1
|
|
|
|
if fav.type == "separator" or fav.type == "space":
|
|
|
|
row += 1
|
|
|
|
col = 0
|
|
|
|
if col >= self.favCols:
|
|
|
|
row += 1
|
|
|
|
col = 0
|
|
|
|
|
|
|
|
if favorite.type == "separator" or favorite.type == "space":
|
2019-02-11 13:54:20 +00:00
|
|
|
self.favoritesBox.attach(favorite, col, row, self.favCols, 1)
|
2010-09-06 15:21:26 +01:00
|
|
|
else:
|
2019-02-11 13:54:20 +00:00
|
|
|
self.favoritesBox.attach(favorite, col, row, 1, 1)
|
2010-09-06 15:21:26 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
def favoritesReorder(self, oldposition, newposition):
|
2010-09-06 15:21:26 +01:00
|
|
|
if oldposition == newposition:
|
|
|
|
return
|
2019-02-11 13:54:20 +00:00
|
|
|
tmp = self.favorites[oldposition]
|
2010-09-06 15:21:26 +01:00
|
|
|
if newposition > oldposition:
|
2019-02-11 20:28:16 +00:00
|
|
|
if (self.favorites[newposition - 1].type == "space" or
|
|
|
|
self.favorites[newposition - 1].type == "separator") and self.favCols > 1:
|
2010-09-06 15:21:26 +01:00
|
|
|
newposition = newposition - 1
|
2019-02-11 13:54:20 +00:00
|
|
|
for i in range(oldposition, newposition):
|
|
|
|
self.favorites[i] = self.favorites[i + 1]
|
|
|
|
self.favorites[i].position = i
|
2010-09-06 15:21:26 +01:00
|
|
|
elif newposition < oldposition:
|
2019-02-11 13:54:20 +00:00
|
|
|
for i in range(0, oldposition - newposition):
|
|
|
|
self.favorites[oldposition - i] = self.favorites[oldposition - i - 1]
|
|
|
|
self.favorites[oldposition - i] .position = oldposition - i
|
|
|
|
self.favorites[newposition] = tmp
|
|
|
|
self.favorites[newposition].position = newposition
|
2010-09-06 15:21:26 +01:00
|
|
|
|
|
|
|
for fav in self.favorites:
|
2019-02-11 13:54:20 +00:00
|
|
|
self.favoritesBox.remove(fav)
|
|
|
|
self.favoritesPositionOnGrid(fav)
|
2010-09-06 15:21:26 +01:00
|
|
|
|
|
|
|
self.favoritesSave()
|
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
def favoritesAdd(self, favButton, position = -1):
|
2010-09-06 15:21:26 +01:00
|
|
|
if favButton:
|
2019-02-11 13:54:20 +00:00
|
|
|
favButton.position = len(self.favorites)
|
|
|
|
self.favorites.append(favButton)
|
|
|
|
self.favoritesPositionOnGrid(favButton)
|
2010-09-06 15:21:26 +01:00
|
|
|
|
2017-04-28 15:50:25 +01:00
|
|
|
favButton.connect("drag-data-received", self.on_drag_data_received)
|
2019-02-11 20:28:16 +00:00
|
|
|
favButton.drag_dest_set(Gtk.DestDefaults.MOTION |
|
|
|
|
Gtk.DestDefaults.HIGHLIGHT |
|
|
|
|
Gtk.DestDefaults.DROP,
|
|
|
|
self.toFav, Gdk.DragAction.COPY)
|
2017-04-28 15:50:25 +01:00
|
|
|
favButton.connect("drag-data-get", self.on_drag_data_get)
|
2019-02-11 13:54:20 +00:00
|
|
|
favButton.drag_source_set(Gdk.ModifierType.BUTTON1_MASK, self.toFav, Gdk.DragAction.COPY)
|
2010-09-06 15:21:26 +01:00
|
|
|
|
|
|
|
if position >= 0:
|
2019-02-11 13:54:20 +00:00
|
|
|
self.favoritesReorder(favButton.position, position)
|
2010-09-06 15:21:26 +01:00
|
|
|
|
|
|
|
self.favoritesSave()
|
2019-01-21 15:37:01 +00:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
def favoritesRemove(self, position):
|
|
|
|
tmp = self.favorites[position]
|
|
|
|
self.favorites.remove(self.favorites[position])
|
2010-09-06 15:21:26 +01:00
|
|
|
tmp.destroy()
|
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
for i in range(position, len(self.favorites)):
|
|
|
|
self.favorites[i].position = i
|
|
|
|
self.favoritesBox.remove(self.favorites[i])
|
|
|
|
self.favoritesPositionOnGrid(self.favorites[i])
|
2010-09-06 15:21:26 +01:00
|
|
|
self.favoritesSave()
|
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
def favoritesRemoveLocation(self, location):
|
2010-09-06 15:21:26 +01:00
|
|
|
for fav in self.favorites:
|
|
|
|
if fav.type == "location" and fav.desktopFile == location:
|
2019-02-11 13:54:20 +00:00
|
|
|
self.favoritesRemove(fav.position)
|
2010-09-06 15:21:26 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
def favoritesSave(self):
|
2010-09-06 15:21:26 +01:00
|
|
|
try:
|
|
|
|
self.checkMintMenuFolder()
|
2019-02-11 13:54:20 +00:00
|
|
|
with open(os.path.join(home, ".linuxmint/mintMenu/applications.list") , "w") as appListFile:
|
|
|
|
for favorite in self.favorites:
|
|
|
|
if favorite.type == "location":
|
|
|
|
appListFile.write("location:" + favorite.desktopFile + "\n")
|
|
|
|
else:
|
|
|
|
appListFile.write(favorite.type + "\n")
|
|
|
|
except Exception as e:
|
|
|
|
msgDlg = Gtk.MessageDialog(None, Gtk.DialogFlags.MODAL, Gtk.MessageType.ERROR, Gtk.ButtonsType.OK,
|
2019-02-11 20:28:16 +00:00
|
|
|
_("Couldn't save favorites. Check if you have write access to ~/.linuxmint/mintMenu") +
|
|
|
|
"\n(" + e.__str__() + ")")
|
2019-02-11 13:54:20 +00:00
|
|
|
msgDlg.run()
|
|
|
|
msgDlg.destroy()
|
|
|
|
|
|
|
|
def isLocationInFavorites(self, location):
|
2010-09-06 15:21:26 +01:00
|
|
|
for fav in self.favorites:
|
|
|
|
if fav.type == "location" and fav.desktopFile == location:
|
|
|
|
return True
|
|
|
|
return False
|
|
|
|
|
2017-04-28 15:50:25 +01:00
|
|
|
def on_drag_data_get(self, widget, context, selection, info, time):
|
|
|
|
if info == self.TARGET_TYPE_FAV:
|
2013-03-08 20:25:14 +00:00
|
|
|
self.drag_origin = widget.position
|
2019-02-11 13:54:20 +00:00
|
|
|
# FIXME: This fails in python3:
|
2017-04-28 15:50:25 +01:00
|
|
|
selection.set(selection.get_target(), 8, str(widget.position))
|
2010-09-06 15:21:26 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
def on_drag_data_received(self, widget, context, x, y, selection, info, time):
|
2017-04-28 15:50:25 +01:00
|
|
|
if info == self.TARGET_TYPE_FAV:
|
2019-02-11 13:54:20 +00:00
|
|
|
self.favoritesReorder(int(selection.get_data()), widget.position)
|
2010-09-06 15:21:26 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
# def on_icon_theme_changed(self, theme):
|
|
|
|
# print("on_icon_theme_changed")
|
|
|
|
# self.menuChanged(0, 0)
|
2016-05-21 18:33:00 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
def menuChanged(self, x, y):
|
|
|
|
# print("menuChanged")
|
2016-05-21 18:08:09 +01:00
|
|
|
# wait 1s, to avoid building the menu multiple times concurrently
|
2010-09-06 15:21:26 +01:00
|
|
|
if self.menuChangedTimer:
|
2019-02-11 13:54:20 +00:00
|
|
|
GLib.source_remove(self.menuChangedTimer)
|
2010-09-06 15:21:26 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
self.menuChangedTimer = GLib.timeout_add(1000, self.updateBoxes, True)
|
2010-09-06 15:21:26 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
#@print_timing
|
|
|
|
def updateBoxes(self, menu_has_changed):
|
|
|
|
# print("updateBoxes")
|
2010-09-06 15:21:26 +01:00
|
|
|
# FIXME: This is really bad!
|
2016-05-21 17:11:36 +01:00
|
|
|
if self.rebuildLock:
|
2010-09-06 15:21:26 +01:00
|
|
|
return
|
|
|
|
|
|
|
|
self.rebuildLock = True
|
|
|
|
self.menuChangedTimer = None
|
2016-05-21 17:11:36 +01:00
|
|
|
|
2016-05-21 18:08:09 +01:00
|
|
|
try:
|
|
|
|
self.loadMenuFiles()
|
2010-09-06 15:21:26 +01:00
|
|
|
|
2016-05-21 18:08:09 +01:00
|
|
|
# Find added and removed categories than update the category list
|
|
|
|
newCategoryList = self.buildCategoryList()
|
|
|
|
addedCategories = []
|
|
|
|
removedCategories = []
|
2016-05-21 17:11:36 +01:00
|
|
|
|
2016-05-21 18:08:09 +01:00
|
|
|
# TODO: optimize this!!!
|
|
|
|
if not self.categoryList:
|
|
|
|
addedCategories = newCategoryList
|
|
|
|
else:
|
|
|
|
for item in newCategoryList:
|
|
|
|
found = False
|
|
|
|
for item2 in self.categoryList:
|
|
|
|
pass
|
2019-02-11 20:28:16 +00:00
|
|
|
if (item["name"] == item2["name"] and
|
|
|
|
item["icon"] == item2["icon"] and
|
|
|
|
item["tooltip"] == item2["tooltip"] and
|
|
|
|
item["index"] == item2["index"]
|
|
|
|
):
|
2016-05-21 18:08:09 +01:00
|
|
|
found = True
|
|
|
|
break
|
|
|
|
if not found:
|
|
|
|
addedCategories.append(item)
|
|
|
|
|
|
|
|
for item in self.categoryList:
|
|
|
|
found = False
|
|
|
|
for item2 in newCategoryList:
|
2019-02-11 20:28:16 +00:00
|
|
|
if (item["name"] == item2["name"] and
|
|
|
|
item["icon"] == item2["icon"] and
|
|
|
|
item["tooltip"] == item2["tooltip"] and
|
|
|
|
item["index"] == item2["index"]
|
|
|
|
):
|
2016-05-21 18:08:09 +01:00
|
|
|
found = True
|
|
|
|
break
|
|
|
|
if not found:
|
2019-02-11 13:54:20 +00:00
|
|
|
removedCategories.append(item)
|
2016-05-21 18:08:09 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
if self.showcategoryicons:
|
2016-05-21 18:08:09 +01:00
|
|
|
categoryIconSize = self.iconSize
|
|
|
|
else:
|
|
|
|
categoryIconSize = 0
|
|
|
|
|
|
|
|
for item in removedCategories:
|
2013-11-25 16:06:22 +00:00
|
|
|
try:
|
2016-05-21 18:08:09 +01:00
|
|
|
button = item["button"]
|
|
|
|
self.categoryList.remove(item)
|
|
|
|
button.destroy()
|
|
|
|
del item
|
2019-02-11 13:54:20 +00:00
|
|
|
except Exception as e:
|
|
|
|
print(e)
|
2010-09-06 15:21:26 +01:00
|
|
|
|
2016-05-21 18:08:09 +01:00
|
|
|
if addedCategories:
|
|
|
|
sortedCategoryList = []
|
|
|
|
for item in self.categoryList:
|
|
|
|
try:
|
2019-02-11 13:54:20 +00:00
|
|
|
self.categoriesBox.remove(item["button"])
|
|
|
|
sortedCategoryList.append((str(item["index"]) + item["name"], item["button"]))
|
|
|
|
except Exception as e:
|
|
|
|
print(e)
|
2016-05-21 18:08:09 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
# Create new category buttons and add them to the list
|
2016-05-21 18:08:09 +01:00
|
|
|
for item in addedCategories:
|
|
|
|
try:
|
2019-02-11 13:54:20 +00:00
|
|
|
item["button"] = CategoryButton(item["icon"], categoryIconSize, [item["name"]], item["filter"])
|
2016-05-21 18:08:09 +01:00
|
|
|
|
|
|
|
if self.categories_mouse_over:
|
2019-02-11 13:54:20 +00:00
|
|
|
startId = item["button"].connect("enter", self.StartFilter, item["filter"])
|
|
|
|
stopId = item["button"].connect("leave", self.StopFilter)
|
|
|
|
item["button"].mouseOverHandlerIds = (startId, stopId)
|
2016-05-21 18:08:09 +01:00
|
|
|
else:
|
|
|
|
item["button"].mouseOverHandlerIds = None
|
2010-09-06 15:21:26 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
item["button"].connect("clicked", self.FilterAndClear, item["filter"])
|
|
|
|
item["button"].connect("focus-in-event", self.categoryBtnFocus, item["filter"])
|
2016-05-21 18:08:09 +01:00
|
|
|
item["button"].show()
|
2010-09-06 15:21:26 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
self.categoryList.append(item)
|
|
|
|
sortedCategoryList.append((str(item["index"]) + item["name"], item["button"]))
|
|
|
|
except Exception as e:
|
|
|
|
print(e)
|
2010-09-06 15:21:26 +01:00
|
|
|
|
2016-05-21 18:08:09 +01:00
|
|
|
sortedCategoryList.sort()
|
2010-09-06 15:21:26 +01:00
|
|
|
|
2016-05-21 18:08:09 +01:00
|
|
|
for item in sortedCategoryList:
|
|
|
|
try:
|
2019-02-11 13:54:20 +00:00
|
|
|
self.categoriesBox.pack_start(item[1], False, False, 0)
|
|
|
|
except Exception as e:
|
|
|
|
print(e)
|
2010-09-06 15:21:26 +01:00
|
|
|
|
2016-05-21 18:08:09 +01:00
|
|
|
# Find added and removed applications add update the application list
|
|
|
|
newApplicationList = self.buildApplicationList()
|
|
|
|
addedApplications = []
|
|
|
|
removedApplications = []
|
2016-05-21 17:11:36 +01:00
|
|
|
|
2016-05-21 18:08:09 +01:00
|
|
|
# TODO: optimize this!!!
|
|
|
|
if not self.applicationList:
|
|
|
|
addedApplications = newApplicationList
|
|
|
|
else:
|
|
|
|
for item in newApplicationList:
|
|
|
|
found = False
|
|
|
|
for item2 in self.applicationList:
|
|
|
|
if item["entry"].get_desktop_file_path() == item2["entry"].get_desktop_file_path():
|
|
|
|
found = True
|
|
|
|
break
|
|
|
|
if not found:
|
|
|
|
addedApplications.append(item)
|
|
|
|
|
|
|
|
key = 0
|
|
|
|
for item in self.applicationList:
|
|
|
|
found = False
|
|
|
|
for item2 in newApplicationList:
|
|
|
|
if item["entry"].get_desktop_file_path() == item2["entry"].get_desktop_file_path():
|
|
|
|
found = True
|
|
|
|
break
|
|
|
|
if not found:
|
|
|
|
removedApplications.append(key)
|
2010-09-06 15:21:26 +01:00
|
|
|
else:
|
2016-05-21 18:08:09 +01:00
|
|
|
# don't increment the key if this item is going to be removed
|
|
|
|
# because when it is removed the index of all later items is
|
|
|
|
# going to be decreased
|
|
|
|
key += 1
|
|
|
|
|
|
|
|
for key in removedApplications:
|
|
|
|
self.applicationList[key]["button"].destroy()
|
|
|
|
del self.applicationList[key]
|
|
|
|
if addedApplications:
|
|
|
|
sortedApplicationList = []
|
|
|
|
for item in self.applicationList:
|
2019-02-11 13:54:20 +00:00
|
|
|
self.applicationsBox.remove(item["button"])
|
|
|
|
sortedApplicationList.append((item["button"].appName, item["button"]))
|
2016-05-21 18:08:09 +01:00
|
|
|
for item in addedApplications:
|
2019-02-11 20:28:16 +00:00
|
|
|
item["button"] = MenuApplicationLauncher(item["entry"].get_desktop_file_path(),
|
|
|
|
self.iconSize, item["category"], self.showapplicationcomments,
|
|
|
|
highlight=(True and menu_has_changed))
|
2016-05-21 18:08:09 +01:00
|
|
|
if item["button"].appExec:
|
2019-02-11 13:54:20 +00:00
|
|
|
self.mintMenuWin.setTooltip(item["button"], item["button"].getTooltip())
|
|
|
|
item["button"].connect("button-press-event", self.menuPopup)
|
|
|
|
item["button"].connect("focus-in-event", self.scrollItemIntoView)
|
|
|
|
item["button"].connect("clicked", RecentHelper.applicationButtonClicked)
|
2016-05-21 18:08:09 +01:00
|
|
|
if self.activeFilter[0] == 0:
|
2019-02-11 13:54:20 +00:00
|
|
|
item["button"].filterText(self.activeFilter[1])
|
2016-05-21 18:08:09 +01:00
|
|
|
else:
|
2019-02-11 13:54:20 +00:00
|
|
|
item["button"].filterCategory(self.activeFilter[1])
|
2016-05-21 18:08:09 +01:00
|
|
|
item["button"].desktop_file_path = item["entry"].get_desktop_file_path()
|
2019-02-11 13:54:20 +00:00
|
|
|
sortedApplicationList.append((item["button"].appName.upper(), item["button"]))
|
|
|
|
self.applicationList.append(item)
|
2016-05-21 18:08:09 +01:00
|
|
|
else:
|
|
|
|
item["button"].destroy()
|
2010-09-06 15:21:26 +01:00
|
|
|
|
2016-05-21 18:08:09 +01:00
|
|
|
sortedApplicationList.sort()
|
|
|
|
launcherNames = [] # Keep track of launcher names so we don't add them twice in the list..
|
|
|
|
for item in sortedApplicationList:
|
|
|
|
launcherName = item[0]
|
|
|
|
button = item[1]
|
2019-02-11 13:54:20 +00:00
|
|
|
self.applicationsBox.add(button)
|
2016-05-21 18:08:09 +01:00
|
|
|
if launcherName in launcherNames:
|
|
|
|
button.hide()
|
|
|
|
else:
|
|
|
|
launcherNames.append(launcherName)
|
2019-02-11 13:54:20 +00:00
|
|
|
except Exception as e:
|
|
|
|
print(e)
|
2016-05-21 17:11:36 +01:00
|
|
|
|
|
|
|
self.rebuildLock = False
|
2010-09-06 15:21:26 +01:00
|
|
|
|
|
|
|
# Reload the menufiles from the filesystem
|
2019-02-11 13:54:20 +00:00
|
|
|
def loadMenuFiles(self):
|
2019-07-05 10:31:30 +01:00
|
|
|
if len(self.menuFiles) > 0:
|
|
|
|
for menu in self.menuFiles:
|
|
|
|
menu.tree.disconnect_by_func(self.menuChanged)
|
|
|
|
self.menuFiles = []
|
2019-02-11 13:54:20 +00:00
|
|
|
for mainitems in ["mate-applications.menu", "mate-settings.menu"]:
|
2019-07-05 10:31:30 +01:00
|
|
|
mymenu = Menu(mainitems )
|
|
|
|
mymenu.tree.connect("changed", self.menuChanged, None)
|
|
|
|
self.menuFiles.append(mymenu)
|
2010-09-06 15:21:26 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
# Build a list of all categories in the menu ([{"name", "icon", tooltip"}]
|
|
|
|
def buildCategoryList(self):
|
2019-02-11 20:28:16 +00:00
|
|
|
newCategoryList = [{"name": _("All"),
|
2019-07-21 15:01:50 +01:00
|
|
|
"icon": "start-here-symbolic",
|
2019-02-11 20:28:16 +00:00
|
|
|
"tooltip": _("Show all applications"),
|
|
|
|
"filter":"", "index": 0}]
|
2010-09-06 15:21:26 +01:00
|
|
|
num = 1
|
|
|
|
for menu in self.menuFiles:
|
2019-07-05 10:31:30 +01:00
|
|
|
for child in get_contents(menu.directory):
|
|
|
|
if isinstance(child, MateMenu.TreeDirectory):
|
|
|
|
name = child.get_name()
|
|
|
|
icon = child.get_icon().to_string()
|
|
|
|
newCategoryList.append({"name": name,
|
|
|
|
"icon": icon,
|
|
|
|
"tooltip": name,
|
|
|
|
"filter": name,
|
2019-02-11 20:28:16 +00:00
|
|
|
"index": num})
|
2010-09-06 15:21:26 +01:00
|
|
|
num += 1
|
|
|
|
return newCategoryList
|
|
|
|
|
|
|
|
# Build a list containing the DesktopEntry object and the category of each application in the menu
|
2019-02-11 13:54:20 +00:00
|
|
|
def buildApplicationList(self):
|
2010-09-06 15:21:26 +01:00
|
|
|
newApplicationsList = []
|
|
|
|
|
|
|
|
def find_applications_recursively(app_list, directory, catName):
|
2019-07-05 10:31:30 +01:00
|
|
|
for item in get_contents(directory):
|
|
|
|
if isinstance(item, MateMenu.TreeEntry):
|
2019-02-11 13:54:20 +00:00
|
|
|
app_list.append({"entry": item, "category": catName})
|
2019-07-05 10:31:30 +01:00
|
|
|
elif isinstance(item, MateMenu.TreeDirectory):
|
2010-09-06 15:21:26 +01:00
|
|
|
find_applications_recursively(app_list, item, catName)
|
|
|
|
|
|
|
|
for menu in self.menuFiles:
|
|
|
|
directory = menu.directory
|
2019-07-05 10:31:30 +01:00
|
|
|
for entry in get_contents(directory):
|
|
|
|
if isinstance(entry, MateMenu.TreeDirectory) and len(get_contents(entry)):
|
2010-09-06 15:21:26 +01:00
|
|
|
#Entry is a top-level category
|
2019-07-05 10:31:30 +01:00
|
|
|
#catName = entry.get_name()
|
|
|
|
#icon = str(entry.get_icon().to_string())
|
2010-09-06 15:21:26 +01:00
|
|
|
#if (icon == "applications-system" or icon == "applications-other"):
|
|
|
|
# catName = self.adminMenu
|
2019-07-05 10:31:30 +01:00
|
|
|
for item in get_contents(entry):
|
|
|
|
if isinstance(item, MateMenu.TreeDirectory):
|
|
|
|
find_applications_recursively(newApplicationsList, item, entry.get_name())
|
|
|
|
elif isinstance(item, MateMenu.TreeEntry):
|
|
|
|
newApplicationsList.append({"entry": item, "category": entry.get_name()})
|
|
|
|
#elif isinstance(entry, MateMenu.TreeEntry):
|
2010-09-06 15:21:26 +01:00
|
|
|
# if not (entry.get_is_excluded() or entry.get_is_nodisplay()):
|
2019-07-05 10:31:30 +01:00
|
|
|
# print "=======>>> " + item.get_name() + " = top level"
|
2019-02-11 13:54:20 +00:00
|
|
|
# newApplicationsList.append({"entry": item, "category": ""})
|
2010-09-06 15:21:26 +01:00
|
|
|
|
|
|
|
return newApplicationsList
|