Remove obsolete code

This commit is contained in:
Clement Lefebvre 2019-05-20 15:19:55 +01:00
parent 8ef7e15d19
commit 66f76df4d3
7 changed files with 126 additions and 325 deletions

View File

@ -207,18 +207,8 @@ class MainWindow(object):
self.headingsToColor.append(label1) self.headingsToColor.append(label1)
Align1.show() Align1.show()
label1.show() label1.show()
heading = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
if not hasattr(MyPlugin, 'sticky') or MyPlugin.sticky: heading.set_size_request(MyPlugin.width, -1)
heading = Gtk.EventBox()
Align1.set_padding(0, 0, 10, 0)
heading.set_visible_window(False)
heading.set_size_request(MyPlugin.width, 30)
else:
heading = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
#heading.set_relief(Gtk.ReliefStyle.NONE)
heading.set_size_request(MyPlugin.width, -1)
#heading.set_sensitive(False)
#heading.connect("button_press_event", self.TogglePluginView, VBox1, MyPlugin.icon, MyPlugin.heading, MyPlugin)
heading.add(Align1) heading.add(Align1)
heading.show() heading.show()

View File

@ -18,7 +18,6 @@ import plugins.recentHelper as RecentHelper
from plugins.easybuttons import (ApplicationLauncher, CategoryButton, from plugins.easybuttons import (ApplicationLauncher, CategoryButton,
FavApplicationLauncher, FavApplicationLauncher,
MenuApplicationLauncher) MenuApplicationLauncher)
from plugins.easygsettings import EasyGSettings
# i18n # i18n
gettext.install("mintmenu", "/usr/share/linuxmint/locale") gettext.install("mintmenu", "/usr/share/linuxmint/locale")
@ -227,27 +226,26 @@ class pluginclass(object):
# self.searchButton.connect("button_release_event", self.SearchWithButton) # self.searchButton.connect("button_release_event", self.SearchWithButton)
try: try:
# GSettings stuff # GSettings stuff
self.settings = EasyGSettings("com.linuxmint.mintmenu.plugins.applications") self.settings = Gio.Settings("com.linuxmint.mintmenu.plugins.applications")
self.GetGSettingsEntries() self.GetGSettingsEntries()
self.settings.notifyAdd("icon-size", self.changeIconSize) self.settings.connect("changed::icon-size", self.changeIconSize)
self.settings.notifyAdd("favicon-size", self.changeFavIconSize) self.settings.connect("changed::favicon-size", self.changeFavIconSize)
self.settings.notifyAdd("height", self.changePluginSize) self.settings.connect("changed::height", self.changePluginSize)
self.settings.notifyAdd("width", self.changePluginSize) self.settings.connect("changed::width", self.changePluginSize)
self.settings.notifyAdd("categories-mouse-over", self.changeCategoriesMouseOver) self.settings.connect("changed::categories-mouse-over", self.changeCategoriesMouseOver)
self.settings.notifyAdd("swap-generic-name", self.changeSwapGenericName) self.settings.connect("changed::swap-generic-name", self.changeSwapGenericName)
self.settings.notifyAdd("show-category-icons", self.changeShowCategoryIcons) self.settings.connect("changed::show-category-icons", self.changeShowCategoryIcons)
self.settings.notifyAdd("show-application-comments", self.changeShowApplicationComments) self.settings.connect("changed::show-application-comments", self.changeShowApplicationComments)
self.settings.notifyAdd("search-on-top", self.positionSearchBar) self.settings.connect("changed::search-on-top", self.positionSearchBar)
self.settings.notifyAdd("use-apt", self.switchAPTUsage) self.settings.connect("changed::use-apt", self.switchAPTUsage)
self.settings.notifyAdd("fav-cols", self.changeFavCols) self.settings.connect("changed::fav-cols", self.changeFavCols)
self.settings.notifyAdd("remember-filter", self.changeRememberFilter) self.settings.connect("changed::remember-filter", self.changeRememberFilter)
self.settings.notifyAdd("enable-internet-search", self.changeEnableInternetSearch) self.settings.connect("changed::enable-internet-search", self.changeEnableInternetSearch)
self.settings.connect("changed::category-hover-delay", self.GetGSettingsEntries)
self.settings.bindGSettingsEntryToVar("int", "category-hover-delay", self, "categoryhoverdelay") self.settings.connect("changed::do-not-filter", self.GetGSettingsEntries)
self.settings.bindGSettingsEntryToVar("bool", "do-not-filter", self, "donotfilterapps") self.settings.connect("changed::enable-internet-search", self.GetGSettingsEntries)
self.settings.bindGSettingsEntryToVar("bool", "enable-internet-search", self, "enableInternetSearch") self.settings.connect("changed::search-command", self.GetGSettingsEntries)
self.settings.bindGSettingsEntryToVar("string", "search-command", self, "searchtool") self.settings.connect("changed::default-tab", self.GetGSettingsEntries)
self.settings.bindGSettingsEntryToVar("int", "default-tab", self, "defaultTab")
except Exception as e: except Exception as e:
print(e) print(e)
@ -337,9 +335,7 @@ class pluginclass(object):
self.mintMenuWin.window.disconnect(self.keyPress_handler) self.mintMenuWin.window.disconnect(self.keyPress_handler)
self.settings.notifyRemoveAll() def changePluginSize(self, settings, key):
def changePluginSize(self, settings, key, args):
if key == "width": if key == "width":
self.width = settings.get_int(key) self.width = settings.get_int(key)
self.applicationsBox.set_size_request(self.width - self.categoriesBox.get_preferred_width().natural_width, -1) self.applicationsBox.set_size_request(self.width - self.categoriesBox.get_preferred_width().natural_width, -1)
@ -348,14 +344,14 @@ class pluginclass(object):
self.heigth = settings.get_int(key) self.heigth = settings.get_int(key)
self.content_holder.set_size_request(self.width, self.height) self.content_holder.set_size_request(self.width, self.height)
def changeSwapGenericName(self, settings, key, args): def changeSwapGenericName(self, settings, key):
self.swapgeneric = settings.get_boolean(key) self.swapgeneric = settings.get_boolean(key)
for child in self.favoritesBox: for child in self.favoritesBox:
if isinstance(child, FavApplicationLauncher): if isinstance(child, FavApplicationLauncher):
child.setSwapGeneric(self.swapgeneric) child.setSwapGeneric(self.swapgeneric)
def changeShowCategoryIcons(self, settings, key, args): def changeShowCategoryIcons(self, settings, key):
self.showcategoryicons = settings.get_boolean(key) self.showcategoryicons = settings.get_boolean(key)
if self.showcategoryicons: if self.showcategoryicons:
@ -366,7 +362,7 @@ class pluginclass(object):
for child in self.categoriesBox: for child in self.categoriesBox:
child.setIconSize(categoryIconSize) child.setIconSize(categoryIconSize)
def changeIconSize(self, settings, key, args): def changeIconSize(self, settings, key):
self.iconSize = settings.get_int(key) self.iconSize = settings.get_int(key)
if self.showcategoryicons: if self.showcategoryicons:
@ -383,39 +379,39 @@ class pluginclass(object):
except: except:
pass pass
def changeFavIconSize(self, settings, key, args): def changeFavIconSize(self, settings, key):
self.faviconsize = settings.get_int(key) self.faviconsize = settings.get_int(key)
for child in self.favoritesBox: for child in self.favoritesBox:
if isinstance(child, FavApplicationLauncher): if isinstance(child, FavApplicationLauncher):
child.setIconSize(self.faviconsize) child.setIconSize(self.faviconsize)
def positionSearchBar(self, settings=None, key=None, args=None): def positionSearchBar(self, settings=None, key=None):
self.main_box.remove(self.notebook) self.main_box.remove(self.notebook)
self.main_box.remove(self.search_bar) self.main_box.remove(self.search_bar)
if self.settings.get("bool", "search-on-top"): if self.settings.get_boolean("search-on-top"):
self.main_box.pack_start(self.search_bar, False, False, 0) self.main_box.pack_start(self.search_bar, False, False, 0)
self.main_box.pack_start(self.notebook, True, True, 0) self.main_box.pack_start(self.notebook, True, True, 0)
else: else:
self.main_box.pack_start(self.notebook, True, True, 0) self.main_box.pack_start(self.notebook, True, True, 0)
self.main_box.pack_start(self.search_bar, False, False, 0) self.main_box.pack_start(self.search_bar, False, False, 0)
def switchAPTUsage(self, settings, key, args): def switchAPTUsage(self, settings, key):
self.useAPT = settings.get_boolean(key) self.useAPT = settings.get_boolean(key)
self.refresh_apt_cache() self.refresh_apt_cache()
def changeRememberFilter(self, settings, key, args): def changeRememberFilter(self, settings, key):
self.rememberFilter = settings.get_boolean(key) self.rememberFilter = settings.get_boolean(key)
def changeEnableInternetSearch(self, settings, key, args): def changeEnableInternetSearch(self, settings, key):
self.enableInternetSearch = settings.get_boolean(key) self.enableInternetSearch = settings.get_boolean(key)
def changeShowApplicationComments(self, settings, key, args): def changeShowApplicationComments(self, settings, key):
self.showapplicationcomments = settings.get_boolean(key) self.showapplicationcomments = settings.get_boolean(key)
for child in self.applicationsBox: for child in self.applicationsBox:
child.setShowComment(self.showapplicationcomments) child.setShowComment(self.showapplicationcomments)
def changeCategoriesMouseOver(self, settings, key, args): def changeCategoriesMouseOver(self, settings, key):
self.categories_mouse_over = settings.get_boolean(key) self.categories_mouse_over = settings.get_boolean(key)
for child in self.categoriesBox: for child in self.categoriesBox:
if self.categories_mouse_over and not child.mouseOverHandlerIds: if self.categories_mouse_over and not child.mouseOverHandlerIds:
@ -427,7 +423,7 @@ class pluginclass(object):
child.disconnect(child.mouseOverHandlerIds[1]) child.disconnect(child.mouseOverHandlerIds[1])
child.mouseOverHandlerIds = None child.mouseOverHandlerIds = None
def changeFavCols(self, settings, key, args): def changeFavCols(self, settings, key):
self.favCols = settings.get_int(key) self.favCols = settings.get_int(key)
for fav in self.favorites: for fav in self.favorites:
self.favoritesBox.remove(fav) self.favoritesBox.remove(fav)
@ -445,8 +441,6 @@ class pluginclass(object):
oldswapgeneric = self.swapgeneric oldswapgeneric = self.swapgeneric
oldshowcategoryicons = self.showcategoryicons oldshowcategoryicons = self.showcategoryicons
oldcategoryhoverdelay = self.categoryhoverdelay oldcategoryhoverdelay = self.categoryhoverdelay
oldsticky = self.sticky
oldminimized = self.minimized
oldicon = self.icon oldicon = self.icon
oldhideseparator = self.hideseparator oldhideseparator = self.hideseparator
oldshowapplicationcomments = self.showapplicationcomments oldshowapplicationcomments = self.showapplicationcomments
@ -460,8 +454,6 @@ class pluginclass(object):
oldswapgeneric == self.swapgeneric and oldswapgeneric == self.swapgeneric and
oldshowcategoryicons == self.showcategoryicons and oldshowcategoryicons == self.showcategoryicons and
oldcategoryhoverdelay == self.categoryhoverdelay and oldcategoryhoverdelay == self.categoryhoverdelay and
oldsticky == self.sticky and
oldminimized == self.minimized and
oldicon == self.icon and oldicon == self.icon and
oldhideseparator == self.hideseparator and oldhideseparator == self.hideseparator and
oldshowapplicationcomments == self.showapplicationcomments oldshowapplicationcomments == self.showapplicationcomments
@ -473,47 +465,37 @@ class pluginclass(object):
RecentHelper.buildRecentApps() RecentHelper.buildRecentApps()
self.RebuildPlugin() self.RebuildPlugin()
def GetGSettingsEntries(self): def GetGSettingsEntries(self, settings=None, key=None):
self.categories_mouse_over = self.settings.get("bool", "categories-mouse-over") self.categories_mouse_over = self.settings.get_boolean("categories-mouse-over")
self.width = self.settings.get("int", "width") self.width = self.settings.get_int("width")
self.height = self.settings.get("int", "height") self.height = self.settings.get_int("height")
self.donotfilterapps = self.settings.get("bool", "do-not-filter") self.donotfilterapps = self.settings.get_boolean("do-not-filter")
self.iconSize = self.settings.get("int", "icon-size") self.iconSize = self.settings.get_int("icon-size")
self.faviconsize = self.settings.get("int", "favicon-size") self.faviconsize = self.settings.get_int("favicon-size")
self.favCols = self.settings.get("int", "fav-cols") self.favCols = self.settings.get_int("fav-cols")
self.swapgeneric = self.settings.get("bool", "swap-generic-name") self.swapgeneric = self.settings.get_boolean("swap-generic-name")
self.showcategoryicons = self.settings.get("bool", "show-category-icons") self.showcategoryicons = self.settings.get_boolean("show-category-icons")
self.categoryhoverdelay = self.settings.get("int", "category-hover-delay") self.categoryhoverdelay = self.settings.get_int("category-hover-delay")
self.showapplicationcomments = self.settings.get("bool", "show-application-comments") self.showapplicationcomments = self.settings.get_boolean("show-application-comments")
self.useAPT = self.settings.get("bool", "use-apt") self.useAPT = self.settings.get_boolean("use-apt")
self.rememberFilter = self.settings.get("bool", "remember-filter") self.rememberFilter = self.settings.get_boolean("remember-filter")
self.enableInternetSearch = self.settings.get("bool", "enable-internet-search") self.enableInternetSearch = self.settings.get_boolean("enable-internet-search")
self.lastActiveTab = self.settings.get("int", "last-active-tab") self.lastActiveTab = self.settings.get_int("last-active-tab")
self.defaultTab = self.settings.get("int", "default-tab") self.defaultTab = self.settings.get_int("default-tab")
# Allow plugin to be minimized to the left plugin pane
self.sticky = self.settings.get("bool", "sticky")
self.minimized = self.settings.get("bool", "minimized")
# Search tool # Search tool
self.searchtool = self.settings.get("string", "search-command") self.searchtool = self.settings.get_string("search-command")
if self.searchtool == "beagle-search SEARCH_STRING": if self.searchtool == "beagle-search SEARCH_STRING":
self.searchtool = "mate-search-tool --named \"%s\" --start" self.searchtool = "mate-search-tool --named \"%s\" --start"
self.settings.set("string", "search-command", "mate-search-tool --named \"%s\" --start") self.settings.set_string("search-command", "mate-search-tool --named \"%s\" --start")
# Plugin icon # Plugin icon
self.icon = self.settings.get("string", "icon") self.icon = self.settings.get_string("icon")
# Hide vertical dotted separator # Hide vertical dotted separator
self.hideseparator = self.settings.get("bool", "hide-separator") self.hideseparator = self.settings.get_boolean("hide-separator")
def SetHidden(self, minimized):
if minimized:
self.settings.set("bool", "minimized", True)
else:
self.settings.set("bool", "minimized", False)
def RebuildPlugin(self): def RebuildPlugin(self):
self.content_holder.set_size_request(self.width, self.height) self.content_holder.set_size_request(self.width, self.height)
@ -541,7 +523,7 @@ class pluginclass(object):
self.Filter(self.activeFilter[2], self.activeFilter[1]) self.Filter(self.activeFilter[2], self.activeFilter[1])
def onHideMenu(self): def onHideMenu(self):
self.settings.set("int", "last-active-tab", self.lastActiveTab) self.settings.set_int("last-active-tab", self.lastActiveTab)
def changeTab(self, tabNum, clear = True): def changeTab(self, tabNum, clear = True):
notebook = self.builder.get_object("notebook2") notebook = self.builder.get_object("notebook2")

View File

@ -1,92 +0,0 @@
#!/usr/bin/python2
from gi.repository import Gio
class EasyGSettings:
def __init__(self, schema = None):
self.schema = schema
self.settings = Gio.Settings.new(self.schema)
self.handlerIds = []
def get(self, type, key):
if type == "bool":
return self.settings.get_boolean(key)
if type == "string":
return self.settings.get_string(key)
if type == "int":
return self.settings.get_int(key)
if type == "color":
color = self.settings.get_string(key)
if not self.evalColor(color):
self.settings.set_string(key, "#ffffff")
return "#ffffff"
return color
t = type.split("-")
if len(t) == 2 and t[0] == "list":
return self.settings.get_strv(key)
return self.settings.get(key)
def set(self, type, key, value):
if type == "bool":
return self.settings.set_boolean(key, value)
if type == "string":
return self.settings.set_string(key, value)
if type == "int":
return self.settings.set_int(key, value)
if type == "color":
if self.evalColor(value):
return self.settings.set_string(key, value)
else:
return self.settings.set_string(key, "#ffffff")
t = type.split("-")
if len(t) == 2 and t[0] == "list":
return self.settings.set_strv(key, value)
return self.settings.set(key, value)
def notifyAdd(self, key, callback, args = None):
handlerId = self.settings.connect("changed::"+key, callback, args)
self.handlerIds.append(handlerId)
return handlerId
def notifyRemove(self, handlerId):
return self.settings.disconnect(handlerId)
def notifyRemoveAll(self):
for handlerId in self.handlerIds:
self.settings.disconnect(handlerId)
def evalColor(self, colorToTest):
if colorToTest[0] != '#' or len(colorToTest) != 7:
return False
for i in colorToTest[1:]:
if i not in ['a', 'A', 'b', 'B', 'c', 'C', 'd', 'D', 'e', 'E', 'f', 'F', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9']:
return False
return True
def bindGSettingsEntryToVar(self, type, key, obj, varName):
return self.notifyAdd(key, self.setVar, (type, obj, varName))
def setVar(self, settings, key, args):
type, obj, varName = args
if type == "string":
setattr(obj, varName, settings.get_string(key))
elif type == "int":
setattr(obj, varName, settings.get_int(key))
elif type == "float":
setattr(obj, varName, settings.get_float(key))
elif type == "bool":
setattr(obj, varName, settings.get_boolean(key))
else:
setattr(obj, varName, settings.get_value(key))

View File

@ -12,10 +12,8 @@ gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, Gio, GLib from gi.repository import Gtk, Gio, GLib
from plugins.easybuttons import easyButton from plugins.easybuttons import easyButton
from plugins.easygsettings import EasyGSettings
from plugins.execute import Execute from plugins.execute import Execute
# i18n # i18n
gettext.install("mintmenu", "/usr/share/linuxmint/locale") gettext.install("mintmenu", "/usr/share/linuxmint/locale")
locale.bindtextdomain("mintmenu", "/usr/share/linuxmint/locale") locale.bindtextdomain("mintmenu", "/usr/share/linuxmint/locale")
@ -54,19 +52,19 @@ class pluginclass(object):
self.itemstocolor = [builder.get_object("viewport2")] self.itemstocolor = [builder.get_object("viewport2")]
# Settings # Settings
self.settings = EasyGSettings("com.linuxmint.mintmenu.plugins.places") self.settings = Gio.Settings("com.linuxmint.mintmenu.plugins.places")
self.settings.notifyAdd("icon-size", self.RegenPlugin) self.settings.connect("changed::icon-size", self.RegenPlugin)
self.settings.notifyAdd("show-computer", self.RegenPlugin) self.settings.connect("changed::show-computer", self.RegenPlugin)
self.settings.notifyAdd("show-desktop", self.RegenPlugin) self.settings.connect("changed::show-desktop", self.RegenPlugin)
self.settings.notifyAdd("show-home_folder", self.RegenPlugin) self.settings.connect("changed::show-home_folder", self.RegenPlugin)
self.settings.notifyAdd("show-network", self.RegenPlugin) self.settings.connect("changed::show-network", self.RegenPlugin)
self.settings.notifyAdd("show-trash", self.RegenPlugin) self.settings.connect("changed::show-trash", self.RegenPlugin)
self.settings.notifyAdd("custom-names", self.RegenPlugin) self.settings.connect("changed::custom-names", self.RegenPlugin)
self.settings.notifyAdd("allow-scrollbar", self.RegenPlugin) self.settings.connect("changed::allow-scrollbar", self.RegenPlugin)
self.settings.notifyAdd("show-gtk-bookmarks", self.RegenPlugin) self.settings.connect("changed::show-gtk-bookmarks", self.RegenPlugin)
self.settings.notifyAdd("height", self.changePluginSize) self.settings.connect("changed::height", self.changePluginSize)
self.settings.notifyAdd("width", self.changePluginSize) self.settings.connect("changed::width", self.changePluginSize)
self.loadSettings() self.loadSettings()
@ -76,18 +74,15 @@ class pluginclass(object):
if self.showtrash: if self.showtrash:
self.refreshTrash() self.refreshTrash()
def destroy(self):
self.settings.notifyRemoveAll()
def changePluginSize(self, settings, key, args = None): def changePluginSize(self, settings, key, args = None):
self.allowScrollbar = self.settings.get("bool", "allow-scrollbar") self.allowScrollbar = self.settings.get_boolean("allow-scrollbar")
self.width = self.settings.get("int", "width") self.width = self.settings.get_int("width")
if not self.allowScrollbar: if not self.allowScrollbar:
self.height = -1 self.height = -1
self.scrolledWindow.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.NEVER) self.scrolledWindow.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.NEVER)
else: else:
self.scrolledWindow.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) self.scrolledWindow.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
self.height = self.settings.get("int", "height") self.height = self.settings.get_int("height")
self.content_holder.set_size_request(self.width, self.height) self.content_holder.set_size_request(self.width, self.height)
def RegenPlugin(self, *args, **kargs): def RegenPlugin(self, *args, **kargs):
@ -98,39 +93,36 @@ class pluginclass(object):
self.do_gtk_bookmarks() self.do_gtk_bookmarks()
def loadSettings(self): def loadSettings(self):
self.width = self.settings.get("int", "width") self.width = self.settings.get_int("width")
self.allowScrollbar = self.settings.get("bool", "allow-scrollbar") self.allowScrollbar = self.settings.get_boolean("allow-scrollbar")
self.showGTKBookmarks = self.settings.get("bool", "show-gtk-bookmarks") self.showGTKBookmarks = self.settings.get_boolean("show-gtk-bookmarks")
self.scrolledWindow.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) self.scrolledWindow.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
self.height = self.settings.get("int", "height") self.height = self.settings.get_int("height")
self.content_holder.set_size_request(self.width, self.height) self.content_holder.set_size_request(self.width, self.height)
if not self.allowScrollbar: if not self.allowScrollbar:
self.height = -1 self.height = -1
self.scrolledWindow.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.NEVER) self.scrolledWindow.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.NEVER)
self.content_holder.set_size_request(self.width, self.height) self.content_holder.set_size_request(self.width, self.height)
self.iconsize = self.settings.get("int", "icon-size") self.iconsize = self.settings.get_int("icon-size")
# Check default items # Check default items
self.showcomputer = self.settings.get("bool", "show-computer") self.showcomputer = self.settings.get_boolean("show-computer")
self.showhomefolder = self.settings.get("bool", "show-home-folder") self.showhomefolder = self.settings.get_boolean("show-home-folder")
self.shownetwork = self.settings.get("bool", "show-network") self.shownetwork = self.settings.get_boolean("show-network")
self.showdesktop = self.settings.get("bool", "show-desktop") self.showdesktop = self.settings.get_boolean("show-desktop")
self.showtrash = self.settings.get("bool", "show-trash") self.showtrash = self.settings.get_boolean("show-trash")
# Get paths for custom items # Get paths for custom items
self.custompaths = self.settings.get("list-string", "custom-paths") self.custompaths = self.settings.get_strv("custom-paths")
# Get names for custom items # Get names for custom items
self.customnames = self.settings.get("list-string", "custom-names") self.customnames = self.settings.get_strv("custom-names")
# Hide vertical dotted separator # Hide vertical dotted separator
self.hideseparator = self.settings.get("bool", "hide-separator") self.hideseparator = self.settings.get_boolean("hide-separator")
# Plugin icon # Plugin icon
self.icon = self.settings.get("string", "icon") self.icon = self.settings.get_string("icon")
# Allow plugin to be minimized to the left plugin pane
self.sticky = self.settings.get("bool", "sticky")
self.minimized = self.settings.get("bool", "minimized")
def ClearAll(self): def ClearAll(self):
for child in self.placesBtnHolder.get_children(): for child in self.placesBtnHolder.get_children():

View File

@ -1,16 +1,15 @@
#!/usr/bin/python2 #!/usr/bin/python2
import os
import subprocess
import gettext import gettext
import locale import locale
import os
import subprocess
import gi import gi
gi.require_version("Gtk", "3.0") gi.require_version("Gtk", "3.0")
from gi.repository import Gtk from gi.repository import Gtk, Gio
import plugins.recentHelper as RecentHelper import plugins.recentHelper as RecentHelper
from plugins.easygsettings import EasyGSettings
from plugins.execute import Execute from plugins.execute import Execute
# i18n # i18n
@ -56,15 +55,11 @@ class pluginclass:
#Plugin icon #Plugin icon
self.icon = 'mate-folder.png' self.icon = 'mate-folder.png'
self.settings = EasyGSettings("com.linuxmint.mintmenu.plugins.recent") self.settings = Gio.Settings("com.linuxmint.mintmenu.plugins.recent")
self.settings.connect('changed', self.RegenPlugin)
self.settings.notifyAdd('height', self.RegenPlugin) self.appSettings = Gio.Settings("com.linuxmint.mintmenu.plugins.applications")
self.settings.notifyAdd('width', self.RegenPlugin) self.appSettings.connect("changed::icon-size", self.RegenPlugin)
self.settings.notifyAdd('num-recent-docs', self.RegenPlugin)
self.settings.notifyAdd('recent-font-size', self.RegenPlugin)
self.appSettings = EasyGSettings("com.linuxmint.mintmenu.plugins.applications")
self.appSettings.notifyAdd("icon-size", self.RegenPlugin)
self.FileList=[] self.FileList=[]
self.RecManagerInstance = Gtk.RecentManager.get_default() self.RecManagerInstance = Gtk.RecentManager.get_default()
@ -86,7 +81,6 @@ class pluginclass:
self.builder.get_object("RecentTabs").destroy() self.builder.get_object("RecentTabs").destroy()
self.builder.get_object("ClrBtn").destroy() self.builder.get_object("ClrBtn").destroy()
self.content_holder.destroy() self.content_holder.destroy()
self.settings.notifyRemoveAll()
if self.recentManagerId: if self.recentManagerId:
self.RecManagerInstance.disconnect(self.recentManagerId) self.RecManagerInstance.disconnect(self.recentManagerId)
@ -94,29 +88,19 @@ class pluginclass:
self.GetGSettingsEntries() self.GetGSettingsEntries()
def GetGSettingsEntries(self): def GetGSettingsEntries(self):
self.recenth = self.settings.get('int', 'height') self.recenth = self.settings.get_int("height")
self.recentw = self.settings.get('int', 'width') self.recentw = self.settings.get_int("width")
self.numentries = self.settings.get('int', 'num-recent-docs') self.numentries = self.settings.get_int("num-recent-docs")
RecentHelper.numentries = self.numentries RecentHelper.numentries = self.numentries
self.recentfontsize = self.settings.get_int("recent-font-size")
self.recentfontsize = self.settings.get('int', 'recent-font-size')
# Hide vertical dotted separator # Hide vertical dotted separator
self.hideseparator = self.settings.get("bool", "hide-separator") self.hideseparator = self.settings.get_boolean("hide-separator")
# Plugin icon # Plugin icon
self.icon = self.settings.get("string", 'icon') self.icon = self.settings.get_string("icon")
# Allow plugin to be minimized to the left plugin pane RecentHelper.iconSize = self.appSettings.get_int("icon-size")
self.sticky = self.settings.get("bool", "sticky")
self.minimized = self.settings.get("bool", "minimized")
RecentHelper.iconSize = self.appSettings.get("int", "icon-size")
self.RebuildPlugin() self.RebuildPlugin()
def SetHidden(self, minimized):
if minimized:
self.settings.set("bool", "minimized", True)
else:
self.settings.set("bool", "minimized", False)
def RebuildPlugin(self): def RebuildPlugin(self):
self.content_holder.set_size_request(self.recentw, self.recenth) self.content_holder.set_size_request(self.recentw, self.recenth)
self.DoRecent() self.DoRecent()

View File

@ -6,10 +6,9 @@ import locale
import gi import gi
gi.require_version("Gtk", "3.0") gi.require_version("Gtk", "3.0")
from gi.repository import Gtk from gi.repository import Gtk, Gio
from plugins.easybuttons import easyButton from plugins.easybuttons import easyButton
from plugins.easygsettings import EasyGSettings
from plugins.execute import Execute from plugins.execute import Execute
# i18n # i18n
@ -48,33 +47,29 @@ class pluginclass(object):
self.itemstocolor = [self.builder.get_object("viewport2")] self.itemstocolor = [self.builder.get_object("viewport2")]
# Gconf stuff # Gconf stuff
self.settings = EasyGSettings("com.linuxmint.mintmenu.plugins.system_management") self.settings = Gio.Settings("com.linuxmint.mintmenu.plugins.system_management")
self.settings.notifyAdd("icon-size", self.RegenPlugin) self.settings.connect("changed::icon-size", self.RegenPlugin)
self.settings.notifyAdd("show-control-center", self.RegenPlugin) self.settings.connect("changed::show-control-center", self.RegenPlugin)
self.settings.notifyAdd("show-lock-screen", self.RegenPlugin) self.settings.connect("changed::show-lock-screen", self.RegenPlugin)
self.settings.notifyAdd("show-logout", self.RegenPlugin) self.settings.connect("changed::show-logout", self.RegenPlugin)
self.settings.notifyAdd("show-package-manager", self.RegenPlugin) self.settings.connect("changed::show-package-manager", self.RegenPlugin)
self.settings.notifyAdd("show-software-manager", self.RegenPlugin) self.settings.connect("changed::show-software-manager", self.RegenPlugin)
self.settings.notifyAdd("show-terminal", self.RegenPlugin) self.settings.connect("changed::show-terminal", self.RegenPlugin)
self.settings.notifyAdd("show-quit", self.RegenPlugin) self.settings.connect("changed::show-quit", self.RegenPlugin)
self.settings.notifyAdd("allow-scrollbar", self.RegenPlugin) self.settings.connect("changed::allow-scrollbar", self.RegenPlugin)
self.settings.notifyAdd("height", self.changePluginSize) self.settings.connect("changed::height", self.changePluginSize)
self.settings.notifyAdd("width", self.changePluginSize) self.settings.connect("changed::width", self.changePluginSize)
self.settings.bindGSettingsEntryToVar("bool", "sticky", self, "sticky")
self.GetGSettingsEntries() self.GetGSettingsEntries()
self.content_holder.set_size_request(self.width, self.height) self.content_holder.set_size_request(self.width, self.height)
def destroy(self):
self.settings.notifyRemoveAll()
def wake(self): def wake(self):
pass pass
def changePluginSize(self, settings, key, args): def changePluginSize(self, settings, key, args):
self.allowScrollbar = self.settings.get("bool", "allow-scrollbar") self.allowScrollbar = self.settings.get_boolean("allow-scrollbar")
if key == "width": if key == "width":
self.width = settings.get_int(key) self.width = settings.get_int(key)
elif key == "height": elif key == "height":
@ -95,25 +90,25 @@ class pluginclass(object):
def GetGSettingsEntries(self): def GetGSettingsEntries(self):
self.width = self.settings.get("int", "width") self.width = self.settings.get_int("width")
self.allowScrollbar = self.settings.get("bool", "allow-scrollbar") self.allowScrollbar = self.settings.get_boolean("allow-scrollbar")
self.scrolledWindow.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) self.scrolledWindow.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
self.height = self.settings.get("int", "height") self.height = self.settings.get_int("height")
self.content_holder.set_size_request(self.width, self.height) self.content_holder.set_size_request(self.width, self.height)
if not self.allowScrollbar: if not self.allowScrollbar:
self.height = -1 self.height = -1
self.scrolledWindow.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.NEVER) self.scrolledWindow.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.NEVER)
self.content_holder.set_size_request(self.width, self.height) self.content_holder.set_size_request(self.width, self.height)
self.iconsize = self.settings.get("int","icon-size") self.iconsize = self.settings.get_int("icon-size")
# Check toggles # Check toggles
self.showSoftwareManager = self.settings.get("bool", "show-software-manager") self.showSoftwareManager = self.settings.get_boolean("show-software-manager")
self.showPackageManager = self.settings.get("bool", "show-package-manager") self.showPackageManager = self.settings.get_boolean("show-package-manager")
self.showControlCenter = self.settings.get("bool", "show-control-center") self.showControlCenter = self.settings.get_boolean("show-control-center")
self.showTerminal = self.settings.get("bool", "show-terminal") self.showTerminal = self.settings.get_boolean("show-terminal")
self.showLockScreen = self.settings.get("bool", "show-lock-screen") self.showLockScreen = self.settings.get_boolean("show-lock-screen")
self.showLogout = self.settings.get("bool", "show-logout") self.showLogout = self.settings.get_boolean("show-logout")
self.showQuit = self.settings.get("bool", "show-quit") self.showQuit = self.settings.get_boolean("show-quit")
if self.de == "cinnamon": if self.de == "cinnamon":
self.lock_cmd = "cinnamon-screensaver-command --lock" self.lock_cmd = "cinnamon-screensaver-command --lock"
@ -137,12 +132,9 @@ class pluginclass(object):
self.settings_cmd = "mate-control-center" self.settings_cmd = "mate-control-center"
# Hide vertical dotted separator # Hide vertical dotted separator
self.hideseparator = self.settings.get("bool", "hide-separator") self.hideseparator = self.settings.get_boolean("hide-separator")
# Plugin icon # Plugin icon
self.icon = self.settings.get("string", "icon") self.icon = self.settings.get_string("icon")
# Allow plugin to be minimized to the left plugin pane
self.sticky = self.settings.get("bool", "sticky")
self.minimized = self.settings.get("bool", "minimized")
def ClearAll(self): def ClearAll(self):
for child in self.systemBtnHolder.get_children(): for child in self.systemBtnHolder.get_children():

View File

@ -83,17 +83,6 @@
<schema id="com.linuxmint.mintmenu.plugins.places" path="/com/linuxmint/mintmenu/plugins/places/"> <schema id="com.linuxmint.mintmenu.plugins.places" path="/com/linuxmint/mintmenu/plugins/places/">
<key type="b" name="sticky">
<default>false</default>
<summary></summary>
<description></description>
</key>
<key type="b" name="minimized">
<default>false</default>
<summary></summary>
<description></description>
</key>
<key type="b" name="allow-scrollbar"> <key type="b" name="allow-scrollbar">
<default>false</default> <default>false</default>
@ -266,18 +255,6 @@
<description></description> <description></description>
</key> </key>
<key type="b" name="sticky">
<default>false</default>
<summary></summary>
<description></description>
</key>
<key type="b" name="minimized">
<default>false</default>
<summary></summary>
<description></description>
</key>
<key type="s" name="search-command"> <key type="s" name="search-command">
<default>"mate-search-tool --named \"%s\" --start"</default> <default>"mate-search-tool --named \"%s\" --start"</default>
<summary></summary> <summary></summary>
@ -389,18 +366,6 @@
<description></description> <description></description>
</key> </key>
<key type="b" name="sticky">
<default>false</default>
<summary></summary>
<description></description>
</key>
<key type="b" name="minimized">
<default>false</default>
<summary></summary>
<description></description>
</key>
<key type="s" name="icon"> <key type="s" name="icon">
<default>"preferences-system"</default> <default>"preferences-system"</default>
<summary></summary> <summary></summary>
@ -446,18 +411,6 @@
<description></description> <description></description>
</key> </key>
<key type="b" name="sticky">
<default>false</default>
<summary></summary>
<description></description>
</key>
<key type="b" name="minimized">
<default>false</default>
<summary></summary>
<description></description>
</key>
</schema> </schema>
</schemalist> </schemalist>