2019-02-11 13:54:20 +00:00
|
|
|
#!/usr/bin/python3
|
2009-07-27 11:45:34 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
import gettext
|
|
|
|
import os
|
2009-07-27 11:45:34 +01:00
|
|
|
import sys
|
2019-02-11 13:54:20 +00:00
|
|
|
from glob import glob
|
2009-07-27 11:45:34 +01:00
|
|
|
|
2013-03-08 02:42:50 +00:00
|
|
|
import gi
|
2016-09-06 15:58:34 +01:00
|
|
|
gi.require_version("Gtk", "3.0")
|
2016-06-22 15:35:57 +01:00
|
|
|
from gi.repository import Gtk, Gdk, GdkPixbuf
|
2013-03-08 02:42:50 +00:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
import keybinding
|
|
|
|
from plugins.easygsettings import EasyGSettings
|
2013-03-08 02:42:50 +00:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
PATH = os.path.abspath(os.path.dirname(sys.argv[0]))
|
2009-07-27 11:45:34 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
sys.path.append(os.path.join(PATH , "plugins"))
|
2009-07-27 11:45:34 +01:00
|
|
|
|
|
|
|
# i18n
|
2009-11-03 11:29:52 +00:00
|
|
|
gettext.install("mintmenu", "/usr/share/linuxmint/locale")
|
2009-07-27 11:45:34 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
class mintMenuConfig(object):
|
2009-07-27 11:45:34 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
def __init__(self):
|
2010-09-13 12:10:43 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
self.path = os.path.abspath(os.path.dirname(sys.argv[0]))
|
2010-09-13 12:10:43 +01:00
|
|
|
|
|
|
|
# Load glade file and extract widgets
|
2013-03-08 02:42:50 +00:00
|
|
|
self.builder = Gtk.Builder()
|
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
self.builder.add_from_file(os.path.join(self.path, "mintMenuConfig.glade"))
|
2019-02-11 19:49:27 +00:00
|
|
|
self.mainWindow = self.builder.get_object("mainWindow")
|
2010-09-13 12:10:43 +01:00
|
|
|
|
|
|
|
#i18n
|
|
|
|
self.mainWindow.set_title(_("Menu preferences"))
|
|
|
|
self.mainWindow.set_icon_from_file("/usr/lib/linuxmint/mintMenu/icon.svg")
|
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
self.editPlaceDialogTitle = _("Edit Place")
|
|
|
|
self.newPlaceDialogTitle = _("New Place")
|
|
|
|
self.folderChooserDialogTitle = _("Select a folder")
|
|
|
|
|
|
|
|
self.startWithFavorites = self.builder.get_object("startWithFavorites")
|
|
|
|
self.showAppComments = self.builder.get_object("showAppComments")
|
|
|
|
self.useAPT = self.builder.get_object("use_apt")
|
|
|
|
self.showCategoryIcons = self.builder.get_object("showCategoryIcons")
|
|
|
|
self.showRecentPlugin = self.builder.get_object("showRecentPlugin")
|
|
|
|
self.showApplicationsPlugin = self.builder.get_object("showApplicationsPlugin")
|
|
|
|
self.showSystemPlugin = self.builder.get_object("showSystemPlugin")
|
|
|
|
self.showPlacesPlugin = self.builder.get_object("showPlacesPlugin")
|
2013-03-08 02:42:50 +00:00
|
|
|
self.swapGeneric = self.builder.get_object("swapGeneric")
|
2019-02-11 13:54:20 +00:00
|
|
|
self.hover = self.builder.get_object("hover")
|
|
|
|
self.hoverDelay = self.builder.get_object("hoverDelay")
|
|
|
|
self.rememberFilter = self.builder.get_object("remember_filter")
|
|
|
|
self.iconSize = self.builder.get_object("iconSize")
|
|
|
|
self.favIconSize = self.builder.get_object("favIconSize")
|
|
|
|
self.placesIconSize = self.builder.get_object("placesIconSize")
|
|
|
|
self.systemIconSize = self.builder.get_object("systemIconSize")
|
|
|
|
self.favCols = self.builder.get_object("numFavCols")
|
|
|
|
self.useCustomColors = self.builder.get_object("useCustomColors")
|
|
|
|
self.backgroundColor = self.builder.get_object("backgroundColor")
|
|
|
|
self.headingColor = self.builder.get_object("headingColor")
|
|
|
|
self.backgroundColorLabel = self.builder.get_object("backgroundColorLabel")
|
|
|
|
self.headingColorLabel = self.builder.get_object("headingColorLabel")
|
|
|
|
self.showButtonIcon = self.builder.get_object("showButtonIcon")
|
|
|
|
self.enableInternetSearch = self.builder.get_object("enableInternetSearch")
|
|
|
|
self.buttonText = self.builder.get_object("buttonText")
|
2019-05-14 14:09:45 +01:00
|
|
|
self.hotkeyWidget = keybinding.KeybindingWidget()
|
|
|
|
self.builder.get_object("main_grid").attach_next_to(self.hotkeyWidget,
|
|
|
|
self.builder.get_object("keybinding_label"),
|
|
|
|
Gtk.PositionType.RIGHT, 1, 1)
|
2019-02-11 13:54:20 +00:00
|
|
|
self.buttonIcon = self.builder.get_object("buttonIcon")
|
|
|
|
self.buttonIconChooser = self.builder.get_object("button_icon_chooser")
|
2013-03-08 02:42:50 +00:00
|
|
|
self.image_filter = Gtk.FileFilter()
|
2011-05-14 23:29:28 +01:00
|
|
|
self.image_filter.set_name(_("Images"))
|
|
|
|
self.image_filter.add_pattern("*.png")
|
|
|
|
self.image_filter.add_pattern("*.jpg")
|
|
|
|
self.image_filter.add_pattern("*.jpeg")
|
|
|
|
self.image_filter.add_pattern("*.bmp")
|
|
|
|
self.image_filter.add_pattern("*.ico")
|
|
|
|
self.image_filter.add_pattern("*.xpm")
|
|
|
|
self.image_filter.add_pattern("*.svg")
|
|
|
|
self.buttonIconChooser.add_filter(self.image_filter)
|
|
|
|
self.buttonIconChooser.set_filter(self.image_filter)
|
2013-03-08 02:42:50 +00:00
|
|
|
self.buttonIconImage = self.builder.get_object("image_button_icon")
|
2019-02-11 13:54:20 +00:00
|
|
|
self.searchCommand = self.builder.get_object("search_command")
|
|
|
|
self.computertoggle = self.builder.get_object("computercheckbutton")
|
|
|
|
self.homefoldertoggle = self.builder.get_object("homecheckbutton")
|
|
|
|
self.networktoggle = self.builder.get_object("networkcheckbutton")
|
|
|
|
self.desktoptoggle = self.builder.get_object("desktopcheckbutton")
|
|
|
|
self.trashtoggle = self.builder.get_object("trashcheckbutton")
|
|
|
|
self.customplacestree = self.builder.get_object("customplacestree")
|
|
|
|
self.allowPlacesScrollbarToggle = self.builder.get_object("allowscrollbarcheckbutton")
|
|
|
|
self.showgtkbookmarksToggle = self.builder.get_object("showgtkbookmarkscheckbutton")
|
|
|
|
self.placesHeightButton = self.builder.get_object("placesHeightSpinButton")
|
|
|
|
if not self.allowPlacesScrollbarToggle.get_active():
|
2010-09-13 12:10:43 +01:00
|
|
|
self.placesHeightButton.set_sensitive(False)
|
2019-02-11 13:54:20 +00:00
|
|
|
self.allowPlacesScrollbarToggle.connect("toggled", self.togglePlacesHeightEnabled)
|
|
|
|
self.softwareManagerToggle = self.builder.get_object("softwaremanagercheckbutton")
|
|
|
|
self.packageManagerToggle = self.builder.get_object("packagemanagercheckbutton")
|
|
|
|
self.controlCenterToggle = self.builder.get_object("controlcentercheckbutton")
|
|
|
|
self.terminalToggle = self.builder.get_object("terminalcheckbutton")
|
|
|
|
self.lockToggle = self.builder.get_object("lockcheckbutton")
|
|
|
|
self.logoutToggle = self.builder.get_object("logoutcheckbutton")
|
|
|
|
self.quitToggle = self.builder.get_object("quitcheckbutton")
|
|
|
|
self.allowSystemScrollbarToggle = self.builder.get_object("allowscrollbarcheckbutton1")
|
|
|
|
self.systemHeightButton = self.builder.get_object("systemHeightSpinButton")
|
|
|
|
if not self.allowSystemScrollbarToggle.get_active():
|
|
|
|
self.systemHeightButton.set_sensitive(False)
|
|
|
|
self.allowSystemScrollbarToggle.connect("toggled", self.toggleSystemHeightEnabled)
|
2016-01-21 16:32:58 +00:00
|
|
|
if os.path.exists("/usr/bin/mintinstall"):
|
2019-02-11 13:54:20 +00:00
|
|
|
self.builder.get_object("softwaremanagercheckbutton").show()
|
2010-09-13 12:10:43 +01:00
|
|
|
else:
|
2019-02-11 13:54:20 +00:00
|
|
|
self.builder.get_object("softwaremanagercheckbutton").hide()
|
|
|
|
|
|
|
|
self.builder.get_object("closeButton").connect("clicked", Gtk.main_quit)
|
|
|
|
|
|
|
|
self.settings = EasyGSettings("com.linuxmint.mintmenu")
|
|
|
|
self.settingsApplications = EasyGSettings("com.linuxmint.mintmenu.plugins.applications")
|
|
|
|
self.settingsPlaces = EasyGSettings("com.linuxmint.mintmenu.plugins.places")
|
|
|
|
self.settingsSystem = EasyGSettings("com.linuxmint.mintmenu.plugins.system_management")
|
|
|
|
|
|
|
|
self.useCustomColors.connect("toggled", self.toggleUseCustomColors)
|
|
|
|
|
|
|
|
self.bindGSettingsValueToWidget(self.settings, "bool", "start-with-favorites", self.startWithFavorites, "toggled", self.startWithFavorites.set_active, self.startWithFavorites.get_active)
|
|
|
|
self.bindGSettingsValueToWidget(self.settingsApplications, "bool", "show-application-comments", self.showAppComments, "toggled", self.showAppComments.set_active, self.showAppComments.get_active)
|
|
|
|
self.bindGSettingsValueToWidget(self.settingsApplications, "bool", "use-apt", self.useAPT, "toggled", self.useAPT.set_active, self.useAPT.get_active)
|
|
|
|
self.bindGSettingsValueToWidget(self.settingsApplications, "bool", "show-category-icons", self.showCategoryIcons, "toggled", self.showCategoryIcons.set_active, self.showCategoryIcons.get_active)
|
|
|
|
self.bindGSettingsValueToWidget(self.settingsApplications, "bool", "categories-mouse-over", self.hover, "toggled", self.hover.set_active, self.hover.get_active)
|
|
|
|
self.bindGSettingsValueToWidget(self.settingsApplications, "bool", "swap-generic-name", self.swapGeneric, "toggled", self.swapGeneric.set_active, self.swapGeneric.get_active)
|
|
|
|
|
|
|
|
self.bindGSettingsValueToWidget(self.settingsApplications, "int", "category-hover-delay", self.hoverDelay, "value-changed", self.hoverDelay.set_value, self.hoverDelay.get_value)
|
|
|
|
self.bindGSettingsValueToWidget(self.settingsApplications, "int", "icon-size", self.iconSize, "value-changed", self.iconSize.set_value, self.iconSize.get_value)
|
|
|
|
self.bindGSettingsValueToWidget(self.settingsApplications, "int", "favicon-size", self.favIconSize, "value-changed", self.favIconSize.set_value, self.favIconSize.get_value)
|
|
|
|
self.bindGSettingsValueToWidget(self.settingsApplications, "int", "fav-cols", self.favCols, "value-changed", self.favCols.set_value, self.favCols.get_value)
|
|
|
|
self.bindGSettingsValueToWidget(self.settingsApplications, "bool", "remember-filter", self.rememberFilter, "toggled", self.rememberFilter.set_active, self.rememberFilter.get_active)
|
|
|
|
self.bindGSettingsValueToWidget(self.settingsApplications, "bool", "enable-internet-search", self.enableInternetSearch, "toggled", self.enableInternetSearch.set_active, self.enableInternetSearch.get_active)
|
|
|
|
|
|
|
|
self.bindGSettingsValueToWidget(self.settingsPlaces, "int", "icon-size", self.placesIconSize, "value-changed", self.placesIconSize.set_value, self.placesIconSize.get_value)
|
|
|
|
self.bindGSettingsValueToWidget(self.settingsSystem, "int", "icon-size", self.systemIconSize, "value-changed", self.systemIconSize.set_value, self.systemIconSize.get_value)
|
|
|
|
|
|
|
|
self.bindGSettingsValueToWidget(self.settings, "bool", "use-custom-color", self.useCustomColors, "toggled", self.useCustomColors.set_active, self.useCustomColors.get_active)
|
|
|
|
self.bindGSettingsValueToWidget(self.settings, "color", "custom-color", self.backgroundColor, "color-set", self.backgroundColor.set_rgba, self.getBackgroundColor)
|
|
|
|
self.bindGSettingsValueToWidget(self.settings, "color", "custom-heading-color", self.headingColor, "color-set", self.headingColor.set_rgba, self.getHeadingColor)
|
|
|
|
self.bindGSettingsValueToWidget(self.settings, "bool", "hide-applet-icon", self.showButtonIcon, "toggled", self.setShowButtonIcon, self.getShowButtonIcon)
|
|
|
|
self.bindGSettingsValueToWidget(self.settings, "string", "applet-text", self.buttonText, "changed", self.buttonText.set_text, self.buttonText.get_text)
|
|
|
|
self.bindGSettingsValueToWidget(self.settings, "string", "hot-key", self.hotkeyWidget, "accel-edited", self.hotkeyWidget.set_val, self.hotkeyWidget.get_val)
|
|
|
|
self.bindGSettingsValueToWidget(self.settings, "string", "applet-icon", self.buttonIconChooser, "file-set", self.setButtonIcon, self.buttonIconChooser.get_filename)
|
|
|
|
self.bindGSettingsValueToWidget(self.settingsApplications, "string", "search-command", self.searchCommand, "changed", self.searchCommand.set_text, self.searchCommand.get_text)
|
2010-09-13 12:10:43 +01:00
|
|
|
|
|
|
|
self.getPluginsToggle()
|
2019-02-11 13:54:20 +00:00
|
|
|
self.showRecentPlugin.connect("toggled", self.setPluginsLayout)
|
|
|
|
self.showApplicationsPlugin.connect("toggled", self.setPluginsLayout)
|
|
|
|
self.showSystemPlugin.connect("toggled", self.setPluginsLayout)
|
|
|
|
self.showPlacesPlugin.connect("toggled", self.setPluginsLayout)
|
|
|
|
|
|
|
|
|
|
|
|
self.bindGSettingsValueToWidget(self.settingsPlaces, "bool", "show-computer", self.computertoggle, "toggled", self.computertoggle.set_active, self.computertoggle.get_active)
|
|
|
|
self.bindGSettingsValueToWidget(self.settingsPlaces, "bool", "show-home-folder", self.homefoldertoggle, "toggled", self.homefoldertoggle.set_active, self.homefoldertoggle.get_active)
|
|
|
|
self.bindGSettingsValueToWidget(self.settingsPlaces, "bool", "show-network", self.networktoggle, "toggled", self.networktoggle.set_active, self.networktoggle.get_active)
|
|
|
|
self.bindGSettingsValueToWidget(self.settingsPlaces, "bool", "show-desktop", self.desktoptoggle, "toggled", self.desktoptoggle.set_active, self.desktoptoggle.get_active)
|
|
|
|
self.bindGSettingsValueToWidget(self.settingsPlaces, "bool", "show-trash", self.trashtoggle, "toggled", self.trashtoggle.set_active, self.trashtoggle.get_active)
|
|
|
|
self.bindGSettingsValueToWidget(self.settingsPlaces, "int", "height", self.placesHeightButton, "value-changed", self.placesHeightButton.set_value, self.placesHeightButton.get_value_as_int)
|
|
|
|
self.bindGSettingsValueToWidget(self.settingsPlaces, "bool", "allow-scrollbar", self.allowPlacesScrollbarToggle, "toggled", self.allowPlacesScrollbarToggle.set_active, self.allowPlacesScrollbarToggle.get_active)
|
|
|
|
self.bindGSettingsValueToWidget(self.settingsPlaces, "bool", "show-gtk-bookmarks", self.showgtkbookmarksToggle, "toggled", self.showgtkbookmarksToggle.set_active, self.showgtkbookmarksToggle.get_active)
|
|
|
|
|
|
|
|
self.bindGSettingsValueToWidget(self.settingsSystem, "bool", "show-software-manager", self.softwareManagerToggle, "toggled", self.softwareManagerToggle.set_active, self.softwareManagerToggle.get_active)
|
|
|
|
self.bindGSettingsValueToWidget(self.settingsSystem, "bool", "show-package-manager", self.packageManagerToggle, "toggled", self.packageManagerToggle.set_active, self.packageManagerToggle.get_active)
|
|
|
|
self.bindGSettingsValueToWidget(self.settingsSystem, "bool", "show-control-center", self.controlCenterToggle, "toggled", self.controlCenterToggle.set_active, self.controlCenterToggle.get_active)
|
|
|
|
self.bindGSettingsValueToWidget(self.settingsSystem, "bool", "show-terminal", self.terminalToggle, "toggled", self.terminalToggle.set_active, self.terminalToggle.get_active)
|
|
|
|
self.bindGSettingsValueToWidget(self.settingsSystem, "bool", "show-lock-screen", self.lockToggle, "toggled", self.lockToggle.set_active, self.lockToggle.get_active)
|
|
|
|
self.bindGSettingsValueToWidget(self.settingsSystem, "bool", "show-logout", self.logoutToggle, "toggled", self.logoutToggle.set_active, self.logoutToggle.get_active)
|
|
|
|
self.bindGSettingsValueToWidget(self.settingsSystem, "bool", "show-quit", self.quitToggle, "toggled", self.quitToggle.set_active, self.quitToggle.get_active)
|
|
|
|
self.bindGSettingsValueToWidget(self.settingsSystem, "int", "height", self.systemHeightButton, "value-changed", self.systemHeightButton.set_value, self.systemHeightButton.get_value_as_int)
|
|
|
|
self.bindGSettingsValueToWidget(self.settingsSystem, "bool", "allow-scrollbar", self.allowSystemScrollbarToggle, "toggled", self.allowSystemScrollbarToggle.set_active, self.allowSystemScrollbarToggle.get_active)
|
|
|
|
|
|
|
|
self.customplacepaths = self.settingsPlaces.get("list-string", "custom-paths")
|
|
|
|
self.customplacenames = self.settingsPlaces.get("list-string", "custom-names")
|
|
|
|
|
|
|
|
self.customplacestreemodel = Gtk.ListStore(str, str)
|
2013-03-09 01:37:24 +00:00
|
|
|
self.cell = Gtk.CellRendererText()
|
2010-09-13 12:10:43 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
for count in range(len(self.customplacepaths)):
|
|
|
|
self.customplacestreemodel.append([self.customplacenames[count], self.customplacepaths[count]])
|
2010-09-13 12:10:43 +01:00
|
|
|
|
2013-05-31 18:14:02 +01:00
|
|
|
self.customplacestreemodel.connect("row-inserted", self.updatePlacesGSettings)
|
2013-03-09 02:29:49 +00:00
|
|
|
self.customplacestreemodel.connect("row-deleted", self.updatePlacesGSettings)
|
|
|
|
self.customplacestreemodel.connect("rows-reordered", self.updatePlacesGSettings)
|
2013-05-31 18:14:02 +01:00
|
|
|
self.customplacestreemodel.connect("row-changed", self.updatePlacesGSettings)
|
2019-02-11 13:54:20 +00:00
|
|
|
self.customplacestree.set_model(self.customplacestreemodel)
|
|
|
|
self.namescolumn = Gtk.TreeViewColumn(_("Name"), self.cell, text = 0)
|
|
|
|
self.placescolumn = Gtk.TreeViewColumn(_("Path"), self.cell, text = 1)
|
|
|
|
self.customplacestree.append_column(self.namescolumn)
|
|
|
|
self.customplacestree.append_column(self.placescolumn)
|
2013-03-08 02:42:50 +00:00
|
|
|
self.builder.get_object("newButton").connect("clicked", self.newPlace)
|
|
|
|
self.builder.get_object("editButton").connect("clicked", self.editPlace)
|
|
|
|
self.builder.get_object("upButton").connect("clicked", self.moveUp)
|
|
|
|
self.builder.get_object("downButton").connect("clicked", self.moveDown)
|
|
|
|
self.builder.get_object("removeButton").connect("clicked", self.removePlace)
|
2011-05-14 23:29:28 +01:00
|
|
|
|
2010-09-15 17:11:24 +01:00
|
|
|
#Detect themes and show theme here
|
2019-02-11 13:54:20 +00:00
|
|
|
theme_name = self.settings.get("string", "theme-name")
|
|
|
|
themes = glob("/usr/share/themes/*/*/gtkrc")
|
2013-03-09 01:37:24 +00:00
|
|
|
model = Gtk.ListStore(str, str)
|
2013-03-08 02:42:50 +00:00
|
|
|
self.builder.get_object("themesCombo").set_model(model)
|
2010-09-15 17:11:24 +01:00
|
|
|
selected_theme = model.append([_("Desktop theme"), "default"])
|
2015-03-15 02:46:07 +00:00
|
|
|
for theme in sorted(themes):
|
2010-09-15 17:11:24 +01:00
|
|
|
if theme.startswith("/usr/share/themes") and theme.endswith("/gtk-2.0/gtkrc"):
|
|
|
|
theme = theme.replace("/usr/share/themes/", "")
|
|
|
|
theme = theme.replace("gtk-2.0", "")
|
|
|
|
theme = theme.replace("gtkrc", "")
|
|
|
|
theme = theme.replace("/", "")
|
|
|
|
theme = theme.strip()
|
|
|
|
iter = model.append([theme, theme])
|
|
|
|
if theme == theme_name:
|
|
|
|
selected_theme = iter
|
2013-03-08 02:42:50 +00:00
|
|
|
self.builder.get_object("themesCombo").set_active_iter(selected_theme)
|
|
|
|
self.builder.get_object("themesCombo").connect("changed", self.set_theme)
|
2013-03-09 02:38:30 +00:00
|
|
|
|
|
|
|
self.toggleUseCustomColors(self.useCustomColors)
|
2010-09-13 12:10:43 +01:00
|
|
|
self.mainWindow.present()
|
|
|
|
self.getBackgroundColor()
|
2011-05-14 23:29:28 +01:00
|
|
|
|
2010-09-15 17:11:24 +01:00
|
|
|
def set_theme(self, widget):
|
|
|
|
model = widget.get_model()
|
|
|
|
iter = widget.get_active_iter()
|
|
|
|
theme_name = model.get_value(iter, 1)
|
2019-02-11 13:54:20 +00:00
|
|
|
self.settings.set("string", "theme-name", theme_name)
|
2010-09-13 12:10:43 +01:00
|
|
|
|
|
|
|
def getPluginsToggle(self):
|
2019-02-11 13:54:20 +00:00
|
|
|
array = self.settings.get("list-string", "plugins-list")
|
2013-03-09 02:29:49 +00:00
|
|
|
if "recent" in array:
|
2010-09-13 12:10:43 +01:00
|
|
|
self.showRecentPlugin.set_active(True)
|
|
|
|
else:
|
2013-03-09 02:29:49 +00:00
|
|
|
self.showRecentPlugin.set_active(False)
|
|
|
|
if "applications" in array:
|
2010-09-13 12:10:43 +01:00
|
|
|
self.showApplicationsPlugin.set_active(True)
|
|
|
|
else:
|
2013-03-09 02:29:49 +00:00
|
|
|
self.showApplicationsPlugin.set_active(False)
|
|
|
|
if "system_management" in array:
|
2010-09-13 12:10:43 +01:00
|
|
|
self.showSystemPlugin.set_active(True)
|
|
|
|
else:
|
2013-03-09 02:29:49 +00:00
|
|
|
self.showSystemPlugin.set_active(False)
|
|
|
|
if "places" in array:
|
2010-09-13 12:10:43 +01:00
|
|
|
self.showPlacesPlugin.set_active(True)
|
2013-03-09 02:29:49 +00:00
|
|
|
else:
|
|
|
|
self.showPlacesPlugin.set_active(False)
|
2010-09-13 12:10:43 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
def setPluginsLayout(self, widget):
|
2010-09-13 12:10:43 +01:00
|
|
|
visiblePlugins = []
|
|
|
|
if self.showPlacesPlugin.get_active():
|
|
|
|
visiblePlugins.append("places")
|
|
|
|
if self.showSystemPlugin.get_active():
|
|
|
|
visiblePlugins.append("system_management")
|
|
|
|
if self.showApplicationsPlugin.get_active():
|
|
|
|
if self.showPlacesPlugin.get_active() or self.showSystemPlugin.get_active():
|
|
|
|
visiblePlugins.append("newpane")
|
|
|
|
visiblePlugins.append("applications")
|
|
|
|
if self.showRecentPlugin.get_active():
|
|
|
|
if self.showApplicationsPlugin.get_active() or self.showPlacesPlugin.get_active() or self.showSystemPlugin.get_active():
|
|
|
|
visiblePlugins.append("newpane")
|
|
|
|
visiblePlugins.append("recent")
|
2019-02-11 13:54:20 +00:00
|
|
|
self.settings.set("list-string", "plugins-list", visiblePlugins)
|
2010-09-13 12:10:43 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
def setShowButtonIcon(self, value):
|
|
|
|
self.showButtonIcon.set_active(not value)
|
2010-09-13 12:10:43 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
def setButtonIcon(self, value):
|
2011-05-14 23:29:28 +01:00
|
|
|
self.buttonIconChooser.set_filename(value)
|
2016-06-22 15:35:57 +01:00
|
|
|
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(value, -1, 22)
|
|
|
|
self.buttonIconImage.set_from_pixbuf(pixbuf)
|
2010-09-13 12:10:43 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
def getShowButtonIcon(self):
|
2010-09-13 12:10:43 +01:00
|
|
|
return not self.showButtonIcon.get_active()
|
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
def bindGSettingsValueToWidget(self, settings, setting_type, key, widget, changeEvent, setter, getter):
|
|
|
|
settings.notifyAdd(key, self.callSetter, args = [setting_type, setter])
|
2013-03-09 01:06:06 +00:00
|
|
|
if setting_type == "color":
|
2016-09-06 15:58:34 +01:00
|
|
|
color = Gdk.RGBA()
|
2019-02-11 13:54:20 +00:00
|
|
|
color.parse(settings.get(setting_type, key))
|
|
|
|
setter(color)
|
2010-09-13 12:10:43 +01:00
|
|
|
else:
|
2019-02-11 13:54:20 +00:00
|
|
|
setter(settings.get(setting_type, key))
|
|
|
|
widget.connect(changeEvent, lambda *args: self.callGetter(settings, setting_type, key, getter))
|
2010-09-13 12:10:43 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
def callSetter(self, settings, key, args):
|
2010-09-13 12:10:43 +01:00
|
|
|
if args[0] == "bool":
|
2019-02-11 13:54:20 +00:00
|
|
|
args[1](settings.get_boolean(key))
|
2010-09-13 12:10:43 +01:00
|
|
|
elif args[0] == "string":
|
2019-02-11 13:54:20 +00:00
|
|
|
args[1](settings.get_string(key))
|
2010-09-13 12:10:43 +01:00
|
|
|
elif args[0] == "int":
|
2019-02-11 13:54:20 +00:00
|
|
|
args[1](settings.get_int(key))
|
2010-09-13 12:10:43 +01:00
|
|
|
elif args[0] == "color":
|
2016-09-06 15:58:34 +01:00
|
|
|
color = Gdk.RGBA()
|
2019-02-11 13:54:20 +00:00
|
|
|
color.parse(settings.get_string(key))
|
|
|
|
args[1](color)
|
2010-09-13 12:10:43 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
def callGetter(self, settings, setting_type, key, getter):
|
|
|
|
if setting_type == "int":
|
|
|
|
settings.set(setting_type, key, int(getter()))
|
2011-05-30 14:30:27 +01:00
|
|
|
else:
|
2019-02-11 13:54:20 +00:00
|
|
|
settings.set(setting_type, key, getter())
|
2010-09-13 12:10:43 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
def toggleUseCustomColors(self, widget):
|
|
|
|
self.backgroundColor.set_sensitive(widget.get_active())
|
|
|
|
self.headingColor.set_sensitive(widget.get_active())
|
|
|
|
self.backgroundColorLabel.set_sensitive(widget.get_active())
|
|
|
|
self.headingColorLabel.set_sensitive(widget.get_active())
|
2010-09-13 12:10:43 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
def getBackgroundColor(self):
|
2016-09-06 15:58:34 +01:00
|
|
|
color = self.backgroundColor.get_rgba()
|
2019-02-11 13:54:20 +00:00
|
|
|
return self.gdkRGBAToString(color)
|
2010-09-13 12:10:43 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
def getHeadingColor(self):
|
2016-09-06 15:58:34 +01:00
|
|
|
color = self.headingColor.get_rgba()
|
2019-02-11 13:54:20 +00:00
|
|
|
return self.gdkRGBAToString(color)
|
2016-09-06 15:58:34 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
def gdkRGBAToString(self, gdkRGBA):
|
|
|
|
return "#%.2X%.2X%.2X" % (int(gdkRGBA.red * 256), int(gdkRGBA.green * 256), int(gdkRGBA.blue * 256))
|
2010-09-13 12:10:43 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
def moveUp(self, upButton):
|
2010-09-13 12:10:43 +01:00
|
|
|
|
|
|
|
treeselection = self.customplacestree.get_selection()
|
2019-02-11 13:54:20 +00:00
|
|
|
currentiter = treeselection.get_selected()[1]
|
2010-09-13 12:10:43 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
if treeselection:
|
2010-09-13 12:10:43 +01:00
|
|
|
|
|
|
|
lagiter = self.customplacestreemodel.get_iter_first()
|
|
|
|
nextiter = self.customplacestreemodel.get_iter_first()
|
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
while nextiter and self.customplacestreemodel.get_path(nextiter) != \
|
|
|
|
self.customplacestreemodel.get_path(currentiter):
|
2010-09-13 12:10:43 +01:00
|
|
|
lagiter = nextiter
|
|
|
|
nextiter = self.customplacestreemodel.iter_next(nextiter)
|
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
if nextiter:
|
2010-09-13 12:10:43 +01:00
|
|
|
self.customplacestreemodel.swap(currentiter, lagiter)
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
def newPlace(self, newButton):
|
2013-03-08 02:42:50 +00:00
|
|
|
self.builder.get_object("label2").set_text(_("Name:"))
|
|
|
|
self.builder.get_object("label1").set_text(_("Path:"))
|
2019-02-11 13:54:20 +00:00
|
|
|
newPlaceDialog = self.builder.get_object("editPlaceDialog")
|
|
|
|
folderChooserDialog = self.builder.get_object("fileChooserDialog")
|
2010-09-13 12:10:43 +01:00
|
|
|
newPlaceDialog.set_transient_for(self.mainWindow)
|
|
|
|
newPlaceDialog.set_icon_from_file("/usr/lib/linuxmint/mintMenu/icon.svg")
|
|
|
|
newPlaceDialog.set_title(self.newPlaceDialogTitle)
|
|
|
|
folderChooserDialog.set_title(self.folderChooserDialogTitle)
|
2013-03-09 01:06:06 +00:00
|
|
|
newPlaceDialog.set_default_response(Gtk.ResponseType.OK)
|
2019-02-11 13:54:20 +00:00
|
|
|
newPlaceName = self.builder.get_object("nameEntryBox")
|
|
|
|
newPlacePath = self.builder.get_object("pathEntryBox")
|
|
|
|
folderButton = self.builder.get_object("folderButton")
|
2010-09-13 12:10:43 +01:00
|
|
|
def chooseFolder(folderButton):
|
|
|
|
currentPath = newPlacePath.get_text()
|
2019-02-11 13:54:20 +00:00
|
|
|
if currentPath:
|
2010-09-13 12:10:43 +01:00
|
|
|
folderChooserDialog.select_filename(currentPath)
|
|
|
|
response = folderChooserDialog.run()
|
|
|
|
folderChooserDialog.hide()
|
2019-02-11 13:54:20 +00:00
|
|
|
if response == Gtk.ResponseType.OK:
|
|
|
|
newPlacePath.set_text(folderChooserDialog.get_filenames()[0])
|
2010-09-13 12:10:43 +01:00
|
|
|
folderButton.connect("clicked", chooseFolder)
|
|
|
|
|
|
|
|
response = newPlaceDialog.run()
|
|
|
|
newPlaceDialog.hide()
|
2019-02-11 13:54:20 +00:00
|
|
|
if response == Gtk.ResponseType.OK:
|
2010-09-13 12:10:43 +01:00
|
|
|
name = newPlaceName.get_text()
|
|
|
|
path = newPlacePath.get_text()
|
2019-02-11 13:54:20 +00:00
|
|
|
if name and path:
|
|
|
|
self.customplacestreemodel.append((name, path))
|
2010-09-13 12:10:43 +01:00
|
|
|
|
|
|
|
def editPlace(self, editButton):
|
2013-03-08 02:42:50 +00:00
|
|
|
self.builder.get_object("label2").set_text(_("Name:"))
|
|
|
|
self.builder.get_object("label1").set_text(_("Path:"))
|
2019-02-11 13:54:20 +00:00
|
|
|
editPlaceDialog = self.builder.get_object("editPlaceDialog")
|
|
|
|
folderChooserDialog = self.builder.get_object("fileChooserDialog")
|
2010-09-13 12:10:43 +01:00
|
|
|
editPlaceDialog.set_transient_for(self.mainWindow)
|
|
|
|
editPlaceDialog.set_icon_from_file("/usr/lib/linuxmint/mintMenu/icon.svg")
|
|
|
|
editPlaceDialog.set_title(self.editPlaceDialogTitle)
|
|
|
|
folderChooserDialog.set_title(self.folderChooserDialogTitle)
|
2013-03-09 01:06:06 +00:00
|
|
|
editPlaceDialog.set_default_response(Gtk.ResponseType.OK)
|
2019-02-11 13:54:20 +00:00
|
|
|
editPlaceName = self.builder.get_object("nameEntryBox")
|
|
|
|
editPlacePath = self.builder.get_object("pathEntryBox")
|
|
|
|
folderButton = self.builder.get_object("folderButton")
|
2010-09-13 12:10:43 +01:00
|
|
|
treeselection = self.customplacestree.get_selection()
|
2019-02-11 13:54:20 +00:00
|
|
|
currentiter = treeselection.get_selected()[1]
|
2010-09-13 12:10:43 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
if currentiter:
|
2010-09-13 12:10:43 +01:00
|
|
|
|
|
|
|
initName = self.customplacestreemodel.get_value(currentiter, 0)
|
|
|
|
initPath = self.customplacestreemodel.get_value(currentiter, 1)
|
|
|
|
|
|
|
|
editPlaceName.set_text(initName)
|
|
|
|
editPlacePath.set_text(initPath)
|
|
|
|
def chooseFolder(folderButton):
|
|
|
|
currentPath = editPlacePath.get_text()
|
2019-02-11 13:54:20 +00:00
|
|
|
if currentPath:
|
2010-09-13 12:10:43 +01:00
|
|
|
folderChooserDialog.select_filename(currentPath)
|
|
|
|
response = folderChooserDialog.run()
|
|
|
|
folderChooserDialog.hide()
|
2019-02-11 13:54:20 +00:00
|
|
|
if response == Gtk.ResponseType.OK:
|
|
|
|
editPlacePath.set_text(folderChooserDialog.get_filenames()[0])
|
2010-09-13 12:10:43 +01:00
|
|
|
folderButton.connect("clicked", chooseFolder)
|
|
|
|
response = editPlaceDialog.run()
|
|
|
|
editPlaceDialog.hide()
|
2019-02-11 13:54:20 +00:00
|
|
|
if response == Gtk.ResponseType.OK:
|
2010-09-13 12:10:43 +01:00
|
|
|
name = editPlaceName.get_text()
|
|
|
|
path = editPlacePath.get_text()
|
2019-02-11 13:54:20 +00:00
|
|
|
if name and path:
|
2010-09-13 12:10:43 +01:00
|
|
|
self.customplacestreemodel.set_value(currentiter, 0, name)
|
|
|
|
self.customplacestreemodel.set_value(currentiter, 1, path)
|
|
|
|
|
|
|
|
def moveDown(self, downButton):
|
|
|
|
|
|
|
|
treeselection = self.customplacestree.get_selection()
|
2019-02-11 13:54:20 +00:00
|
|
|
currentiter = treeselection.get_selected()[1]
|
2010-09-13 12:10:43 +01:00
|
|
|
|
|
|
|
nextiter = self.customplacestreemodel.iter_next(currentiter)
|
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
if nextiter:
|
2010-09-13 12:10:43 +01:00
|
|
|
self.customplacestreemodel.swap(currentiter, nextiter)
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
def removePlace(self, removeButton):
|
|
|
|
|
|
|
|
treeselection = self.customplacestree.get_selection()
|
2019-02-11 13:54:20 +00:00
|
|
|
currentiter = treeselection.get_selected()[1]
|
2010-09-13 12:10:43 +01:00
|
|
|
|
2019-02-11 13:54:20 +00:00
|
|
|
if currentiter:
|
2010-09-13 12:10:43 +01:00
|
|
|
self.customplacestreemodel.remove(currentiter)
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
def togglePlacesHeightEnabled(self, toggle):
|
2019-02-11 13:54:20 +00:00
|
|
|
if toggle.get_active():
|
2010-09-13 12:10:43 +01:00
|
|
|
self.placesHeightButton.set_sensitive(True)
|
|
|
|
else:
|
|
|
|
self.placesHeightButton.set_sensitive(False)
|
|
|
|
|
|
|
|
def toggleSystemHeightEnabled(self, toggle):
|
2019-02-11 13:54:20 +00:00
|
|
|
if toggle.get_active():
|
2010-09-13 12:10:43 +01:00
|
|
|
self.systemHeightButton.set_sensitive(True)
|
|
|
|
else:
|
|
|
|
self.systemHeightButton.set_sensitive(False)
|
|
|
|
|
2013-03-09 02:29:49 +00:00
|
|
|
def updatePlacesGSettings(self, treemodel, path, iter = None, new_order = None):
|
2019-02-11 13:54:20 +00:00
|
|
|
# Do only if not partway though an append operation;
|
|
|
|
# Append = insert+change+change and each creates a signal
|
|
|
|
if not iter or self.customplacestreemodel.get_value(iter, 1):
|
2010-09-13 12:10:43 +01:00
|
|
|
treeiter = self.customplacestreemodel.get_iter_first()
|
2019-02-11 13:54:20 +00:00
|
|
|
customplacenames = []
|
|
|
|
customplacepaths = []
|
|
|
|
while treeiter:
|
|
|
|
customplacenames = customplacenames + [self.customplacestreemodel.get_value(treeiter, 0)]
|
|
|
|
customplacepaths = customplacepaths + [self.customplacestreemodel.get_value(treeiter, 1)]
|
2010-09-13 12:10:43 +01:00
|
|
|
treeiter = self.customplacestreemodel.iter_next(treeiter)
|
2019-02-11 13:54:20 +00:00
|
|
|
self.settingsPlaces.set("list-string", "custom-paths", customplacepaths)
|
|
|
|
self.settingsPlaces.set("list-string", "custom-names", customplacenames)
|
2009-07-27 11:45:34 +01:00
|
|
|
|
|
|
|
window = mintMenuConfig()
|
2013-03-09 01:06:06 +00:00
|
|
|
Gtk.main()
|