Applications.py: Clean up more whitespace and line lengths
This commit is contained in:
parent
4ee04c3869
commit
37cd852738
@ -144,10 +144,14 @@ class SuggestionButton(Gtk.Button):
|
|||||||
|
|
||||||
class pluginclass(object):
|
class pluginclass(object):
|
||||||
TARGET_TYPE_TEXT = 80
|
TARGET_TYPE_TEXT = 80
|
||||||
toButton = (Gtk.TargetEntry.new("text/uri-list", 0, TARGET_TYPE_TEXT), Gtk.TargetEntry.new("text/uri-list", 0, TARGET_TYPE_TEXT))
|
toButton = (Gtk.TargetEntry.new("text/uri-list", 0, TARGET_TYPE_TEXT),
|
||||||
|
Gtk.TargetEntry.new("text/uri-list", 0, TARGET_TYPE_TEXT))
|
||||||
TARGET_TYPE_FAV = 81
|
TARGET_TYPE_FAV = 81
|
||||||
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))
|
toFav = (Gtk.TargetEntry.new("FAVORITES", Gtk.TargetFlags.SAME_APP, 81),
|
||||||
fromFav = (Gtk.TargetEntry.new("FAVORITES", Gtk.TargetFlags.SAME_APP, 81), 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):
|
def __init__(self, mintMenuWin, toggleButton, de):
|
||||||
@ -192,7 +196,9 @@ class pluginclass(object):
|
|||||||
self.content_holder = self.builder.get_object("Applications")
|
self.content_holder = self.builder.get_object("Applications")
|
||||||
|
|
||||||
# Items to get custom colors
|
# Items to get custom colors
|
||||||
self.itemstocolor = [self.builder.get_object("viewport1"),self.builder.get_object("viewport2"),self.builder.get_object("viewport3")]
|
self.itemstocolor = [self.builder.get_object("viewport1"),
|
||||||
|
self.builder.get_object("viewport2"),
|
||||||
|
self.builder.get_object("viewport3")]
|
||||||
|
|
||||||
# Unset all timers
|
# Unset all timers
|
||||||
self.filterTimer = None
|
self.filterTimer = None
|
||||||
@ -201,9 +207,15 @@ class pluginclass(object):
|
|||||||
self.keyPress_handler = self.mintMenuWin.window.connect("key-press-event", self.keyPress)
|
self.keyPress_handler = self.mintMenuWin.window.connect("key-press-event", self.keyPress)
|
||||||
|
|
||||||
self.favoritesBox.connect("drag-data-received", self.ReceiveCallback)
|
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.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.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)
|
self.showFavoritesButton.drag_dest_set(Gtk.DestDefaults.MOTION |
|
||||||
|
Gtk.DestDefaults.HIGHLIGHT |
|
||||||
|
Gtk.DestDefaults.DROP,
|
||||||
|
self.toButton, Gdk.DragAction.COPY)
|
||||||
|
|
||||||
# self.searchButton.connect("button_release_event", self.SearchWithButton)
|
# self.searchButton.connect("button_release_event", self.SearchWithButton)
|
||||||
try:
|
try:
|
||||||
@ -278,7 +290,7 @@ class pluginclass(object):
|
|||||||
panelsettings = Gio.Settings.new("org.mate.panel")
|
panelsettings = Gio.Settings.new("org.mate.panel")
|
||||||
applet_list = panelsettings.get_strv("object-id-list")
|
applet_list = panelsettings.get_strv("object-id-list")
|
||||||
for applet in applet_list:
|
for applet in applet_list:
|
||||||
object_schema = Gio.Settings.new_with_path("org.mate.panel.object", "/org/mate/panel/objects/%s/" % (applet))
|
object_schema = Gio.Settings.new_with_path("org.mate.panel.object", "/org/mate/panel/objects/%s/" % applet)
|
||||||
keys = object_schema.list_keys()
|
keys = object_schema.list_keys()
|
||||||
if "applet-iid" in keys:
|
if "applet-iid" in keys:
|
||||||
iid = object_schema.get_string("applet-iid")
|
iid = object_schema.get_string("applet-iid")
|
||||||
@ -400,7 +412,9 @@ class pluginclass(object):
|
|||||||
def RegenPlugin(self, *args, **kargs):
|
def RegenPlugin(self, *args, **kargs):
|
||||||
self.refresh_apt_cache()
|
self.refresh_apt_cache()
|
||||||
|
|
||||||
# save old config - this is necessary because the app will notified when it sets the default values and you don't want the to reload itself several times
|
# save old config - this is necessary because the app will notified
|
||||||
|
# when it sets the default values and you don't want the to reload
|
||||||
|
# itself several times
|
||||||
oldcategories_mouse_over = self.categories_mouse_over
|
oldcategories_mouse_over = self.categories_mouse_over
|
||||||
oldiconsize = self.iconSize
|
oldiconsize = self.iconSize
|
||||||
oldfaviconsize = self.faviconsize
|
oldfaviconsize = self.faviconsize
|
||||||
@ -581,11 +595,14 @@ class pluginclass(object):
|
|||||||
def add_search_suggestions(self, text):
|
def add_search_suggestions(self, text):
|
||||||
text = "<b>%s</b>" % cgi.escape(text)
|
text = "<b>%s</b>" % cgi.escape(text)
|
||||||
if self.enableInternetSearch:
|
if self.enableInternetSearch:
|
||||||
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/ddg.svg",
|
||||||
self.add_suggestion("/usr/lib/linuxmint/mintMenu/search_engines/wikipedia.svg", _("Search Wikipedia for %s") % text, None, self.search_wikipedia)
|
_("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()
|
self.add_suggestion()
|
||||||
|
|
||||||
self.add_suggestion("accessories-dictionary", _("Lookup %s in Dictionary") % text, None, self.search_dictionary)
|
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)
|
self.add_suggestion("edit-find", _("Search Computer for %s") % text, None, self.Search)
|
||||||
|
|
||||||
self.applicationsBox.get_children()[-1].grab_focus()
|
self.applicationsBox.get_children()[-1].grab_focus()
|
||||||
@ -634,7 +651,8 @@ class pluginclass(object):
|
|||||||
found_packages.extend(found_elsewhere)
|
found_packages.extend(found_elsewhere)
|
||||||
if keyword == self.searchEntry.get_text() and len(found_packages) > 0:
|
if keyword == self.searchEntry.get_text() and len(found_packages) > 0:
|
||||||
self.add_suggestion()
|
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..
|
# Reduce the number of results to 10 max...
|
||||||
|
# it takes a HUGE amount of time to add the GTK box in the menu otherwise..
|
||||||
if len(found_packages) > 10:
|
if len(found_packages) > 10:
|
||||||
found_packages = found_packages[:10]
|
found_packages = found_packages[:10]
|
||||||
for pkg in found_packages:
|
for pkg in found_packages:
|
||||||
@ -784,8 +802,10 @@ class pluginclass(object):
|
|||||||
|
|
||||||
if widget.type == "location":
|
if widget.type == "location":
|
||||||
mTree = Gtk.Menu()
|
mTree = Gtk.Menu()
|
||||||
mTree.set_events(Gdk.EventMask.POINTER_MOTION_MASK | Gdk.EventMask.POINTER_MOTION_HINT_MASK |
|
mTree.set_events(Gdk.EventMask.POINTER_MOTION_MASK |
|
||||||
Gdk.EventMask.BUTTON_PRESS_MASK | Gdk.EventMask.BUTTON_RELEASE_MASK)
|
Gdk.EventMask.POINTER_MOTION_HINT_MASK |
|
||||||
|
Gdk.EventMask.BUTTON_PRESS_MASK |
|
||||||
|
Gdk.EventMask.BUTTON_RELEASE_MASK)
|
||||||
#i18n
|
#i18n
|
||||||
desktopMenuItem = Gtk.MenuItem(_("Add to desktop"))
|
desktopMenuItem = Gtk.MenuItem(_("Add to desktop"))
|
||||||
panelMenuItem = Gtk.MenuItem(_("Add to panel"))
|
panelMenuItem = Gtk.MenuItem(_("Add to panel"))
|
||||||
@ -829,8 +849,10 @@ class pluginclass(object):
|
|||||||
mTree.append(propsMenuItem)
|
mTree.append(propsMenuItem)
|
||||||
else:
|
else:
|
||||||
mTree = Gtk.Menu()
|
mTree = Gtk.Menu()
|
||||||
mTree.set_events(Gdk.EventMask.POINTER_MOTION_MASK | Gdk.EventMask.POINTER_MOTION_HINT_MASK |
|
mTree.set_events(Gdk.EventMask.POINTER_MOTION_MASK |
|
||||||
Gdk.EventMask.BUTTON_PRESS_MASK | Gdk.EventMask.BUTTON_RELEASE_MASK)
|
Gdk.EventMask.POINTER_MOTION_HINT_MASK |
|
||||||
|
Gdk.EventMask.BUTTON_PRESS_MASK |
|
||||||
|
Gdk.EventMask.BUTTON_RELEASE_MASK)
|
||||||
|
|
||||||
#i18n
|
#i18n
|
||||||
removeMenuItem = Gtk.MenuItem(_("Remove"))
|
removeMenuItem = Gtk.MenuItem(_("Remove"))
|
||||||
@ -1248,7 +1270,10 @@ class pluginclass(object):
|
|||||||
self.favorites.append(favButton)
|
self.favorites.append(favButton)
|
||||||
self.favoritesPositionOnGrid(favButton)
|
self.favoritesPositionOnGrid(favButton)
|
||||||
favButton.drag_source_set(Gdk.ModifierType.BUTTON1_MASK, self.toFav, Gdk.DragAction.COPY)
|
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.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-get", self.on_drag_data_get)
|
||||||
favButton.connect("drag-data-received", self.on_drag_data_received)
|
favButton.connect("drag-data-received", self.on_drag_data_received)
|
||||||
position += 1
|
position += 1
|
||||||
@ -1284,7 +1309,8 @@ class pluginclass(object):
|
|||||||
return
|
return
|
||||||
tmp = self.favorites[oldposition]
|
tmp = self.favorites[oldposition]
|
||||||
if newposition > oldposition:
|
if newposition > oldposition:
|
||||||
if (self.favorites[newposition - 1].type == "space" or self.favorites[newposition - 1].type == "separator") and self.favCols > 1:
|
if (self.favorites[newposition - 1].type == "space" or
|
||||||
|
self.favorites[newposition - 1].type == "separator") and self.favCols > 1:
|
||||||
newposition = newposition - 1
|
newposition = newposition - 1
|
||||||
for i in range(oldposition, newposition):
|
for i in range(oldposition, newposition):
|
||||||
self.favorites[i] = self.favorites[i + 1]
|
self.favorites[i] = self.favorites[i + 1]
|
||||||
@ -1309,7 +1335,10 @@ class pluginclass(object):
|
|||||||
self.favoritesPositionOnGrid(favButton)
|
self.favoritesPositionOnGrid(favButton)
|
||||||
|
|
||||||
favButton.connect("drag-data-received", self.on_drag_data_received)
|
favButton.connect("drag-data-received", self.on_drag_data_received)
|
||||||
favButton.drag_dest_set(Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT | Gtk.DestDefaults.DROP, 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-get", self.on_drag_data_get)
|
||||||
favButton.drag_source_set(Gdk.ModifierType.BUTTON1_MASK, self.toFav, Gdk.DragAction.COPY)
|
favButton.drag_source_set(Gdk.ModifierType.BUTTON1_MASK, self.toFav, Gdk.DragAction.COPY)
|
||||||
|
|
||||||
@ -1345,7 +1374,8 @@ class pluginclass(object):
|
|||||||
appListFile.write(favorite.type + "\n")
|
appListFile.write(favorite.type + "\n")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
msgDlg = Gtk.MessageDialog(None, Gtk.DialogFlags.MODAL, Gtk.MessageType.ERROR, Gtk.ButtonsType.OK,
|
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__() + ")")
|
_("Couldn't save favorites. Check if you have write access to ~/.linuxmint/mintMenu") +
|
||||||
|
"\n(" + e.__str__() + ")")
|
||||||
msgDlg.run()
|
msgDlg.run()
|
||||||
msgDlg.destroy()
|
msgDlg.destroy()
|
||||||
|
|
||||||
@ -1403,7 +1433,11 @@ class pluginclass(object):
|
|||||||
found = False
|
found = False
|
||||||
for item2 in self.categoryList:
|
for item2 in self.categoryList:
|
||||||
pass
|
pass
|
||||||
if item["name"] == item2["name"] and item["icon"] == item2["icon"] and item["tooltip"] == item2["tooltip"] and item["index"] == item2["index"]:
|
if (item["name"] == item2["name"] and
|
||||||
|
item["icon"] == item2["icon"] and
|
||||||
|
item["tooltip"] == item2["tooltip"] and
|
||||||
|
item["index"] == item2["index"]
|
||||||
|
):
|
||||||
found = True
|
found = True
|
||||||
break
|
break
|
||||||
if not found:
|
if not found:
|
||||||
@ -1412,7 +1446,11 @@ class pluginclass(object):
|
|||||||
for item in self.categoryList:
|
for item in self.categoryList:
|
||||||
found = False
|
found = False
|
||||||
for item2 in newCategoryList:
|
for item2 in newCategoryList:
|
||||||
if item["name"] == item2["name"] and item["icon"] == item2["icon"] and item["tooltip"] == item2["tooltip"] and item["index"] == item2["index"]:
|
if (item["name"] == item2["name"] and
|
||||||
|
item["icon"] == item2["icon"] and
|
||||||
|
item["tooltip"] == item2["tooltip"] and
|
||||||
|
item["index"] == item2["index"]
|
||||||
|
):
|
||||||
found = True
|
found = True
|
||||||
break
|
break
|
||||||
if not found:
|
if not found:
|
||||||
@ -1513,7 +1551,9 @@ class pluginclass(object):
|
|||||||
self.applicationsBox.remove(item["button"])
|
self.applicationsBox.remove(item["button"])
|
||||||
sortedApplicationList.append((item["button"].appName, item["button"]))
|
sortedApplicationList.append((item["button"].appName, item["button"]))
|
||||||
for item in addedApplications:
|
for item in addedApplications:
|
||||||
item["button"] = MenuApplicationLauncher(item["entry"].get_desktop_file_path(), self.iconSize, item["category"], self.showapplicationcomments, highlight=(True and menu_has_changed))
|
item["button"] = MenuApplicationLauncher(item["entry"].get_desktop_file_path(),
|
||||||
|
self.iconSize, item["category"], self.showapplicationcomments,
|
||||||
|
highlight=(True and menu_has_changed))
|
||||||
if item["button"].appExec:
|
if item["button"].appExec:
|
||||||
self.mintMenuWin.setTooltip(item["button"], item["button"].getTooltip())
|
self.mintMenuWin.setTooltip(item["button"], item["button"].getTooltip())
|
||||||
item["button"].connect("button-press-event", self.menuPopup)
|
item["button"].connect("button-press-event", self.menuPopup)
|
||||||
@ -1552,7 +1592,10 @@ class pluginclass(object):
|
|||||||
|
|
||||||
# Build a list of all categories in the menu ([{"name", "icon", tooltip"}]
|
# Build a list of all categories in the menu ([{"name", "icon", tooltip"}]
|
||||||
def buildCategoryList(self):
|
def buildCategoryList(self):
|
||||||
newCategoryList = [{"name": _("All"), "icon": "edit-select-all", "tooltip": _("Show all applications"), "filter":"", "index": 0}]
|
newCategoryList = [{"name": _("All"),
|
||||||
|
"icon": "edit-select-all",
|
||||||
|
"tooltip": _("Show all applications"),
|
||||||
|
"filter":"", "index": 0}]
|
||||||
num = 1
|
num = 1
|
||||||
for menu in self.menuFiles:
|
for menu in self.menuFiles:
|
||||||
for child in menu.directory.get_contents():
|
for child in menu.directory.get_contents():
|
||||||
@ -1561,7 +1604,11 @@ class pluginclass(object):
|
|||||||
#if (icon == "preferences-system"):
|
#if (icon == "preferences-system"):
|
||||||
# self.adminMenu = child.name
|
# self.adminMenu = child.name
|
||||||
#if (icon != "applications-system" and icon != "applications-other"):
|
#if (icon != "applications-system" and icon != "applications-other"):
|
||||||
newCategoryList.append({"name": child.name, "icon": child.icon, "tooltip": child.name, "filter": child.name, "index": num})
|
newCategoryList.append({"name": child.name,
|
||||||
|
"icon": child.icon,
|
||||||
|
"tooltip": child.name,
|
||||||
|
"filter": child.name,
|
||||||
|
"index": num})
|
||||||
num += 1
|
num += 1
|
||||||
return newCategoryList
|
return newCategoryList
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user