Revamp preferences

Use xapp widgets
Rewrite
This commit is contained in:
Clement Lefebvre 2019-05-20 14:27:41 +01:00
parent e2e4531380
commit 2a4267673d
8 changed files with 679 additions and 2267 deletions

2
debian/control vendored
View File

@ -15,6 +15,7 @@ Depends:
python-apt, python-apt,
python-configobj, python-configobj,
python-setproctitle, python-setproctitle,
python-xapp,
python-xlib, python-xlib,
python-xdg, python-xdg,
xdg-utils, xdg-utils,
@ -24,6 +25,7 @@ Depends:
gir1.2-matepanelapplet-4.0, gir1.2-matepanelapplet-4.0,
gir1.2-gtk-3.0, gir1.2-gtk-3.0,
gir1.2-mate-desktop, gir1.2-mate-desktop,
gir1.2-xapp-1.0,
mozo mozo
Description: Advanced MATE menu Description: Advanced MATE menu
One of the most advanced menus under Linux. MintMenu supports filtering, One of the most advanced menus under Linux. MintMenu supports filtering,

View File

@ -113,11 +113,11 @@ class MainWindow(object):
def toggleCustomBackgroundColor(self, settings, key): def toggleCustomBackgroundColor(self, settings, key):
self.customcolor = settings.get_string(key) self.customcolor = settings.get_string(key)
self.SetPaneColors(self.panesToColor) self.setCustomColors()
def toggleCustomHeadingColor(self, settings, key): def toggleCustomHeadingColor(self, settings, key):
self.customheadingcolor = settings.get_string(key) self.customheadingcolor = settings.get_string(key)
self.SetHeadingStyle(self.headingsToColor) self.setCustomColors()
def getSetGSettingEntries(self): def getSetGSettingEntries(self):
self.dottedfile = os.path.join(self.path, "dotted.png") self.dottedfile = os.path.join(self.path, "dotted.png")
@ -196,13 +196,14 @@ class MainWindow(object):
VBox1 = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) VBox1 = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
if MyPlugin.heading != "": if MyPlugin.heading != "":
Label1 = Gtk.Label(label= MyPlugin.heading) label1 = Gtk.Label()
label1.set_markup("<span size=\"12000\" weight=\"bold\">%s</span>" % MyPlugin.heading)
Align1 = Gtk.Alignment.new(0, 0, 0, 0) Align1 = Gtk.Alignment.new(0, 0, 0, 0)
Align1.set_padding(10, 5, 10, 0) Align1.set_padding(10, 5, 10, 0)
Align1.add(Label1) Align1.add(label1)
self.headingsToColor.append(Label1) self.headingsToColor.append(label1)
Align1.show() Align1.show()
Label1.show() label1.show()
if not hasattr(MyPlugin, 'sticky') or MyPlugin.sticky: if not hasattr(MyPlugin, 'sticky') or MyPlugin.sticky:
heading = Gtk.EventBox() heading = Gtk.EventBox()
@ -297,34 +298,29 @@ class MainWindow(object):
return {"fg": fgColor, "bg": bgColor} return {"fg": fgColor, "bg": bgColor}
def loadTheme(self): def loadTheme(self):
colors = self.getDefaultColors() self.setCustomColors()
self.SetPaneColors(self.panesToColor, colors["bg"])
self.SetHeadingStyle(self.headingsToColor)
def SetPaneColors(self, items, color = None): def setCustomColors(self):
for item in items: # Panes
for item in self.panesToColor:
context = item.get_style_context() context = item.get_style_context()
if self.usecustomcolor: if self.usecustomcolor:
bgColor = Gdk.RGBA() color = Gdk.RGBA()
bgColor.parse(self.customcolor) color.parse(self.customcolor)
item.override_background_color(context.get_state(), bgColor)
elif color is not None:
item.override_background_color(context.get_state(), color) item.override_background_color(context.get_state(), color)
else:
def SetHeadingStyle(self, items): colors = self.getDefaultColors()
item.override_background_color(context.get_state(), colors["bg"])
# Headings
for item in self.headingsToColor:
context = item.get_style_context()
if self.usecustomcolor: if self.usecustomcolor:
color = self.customheadingcolor color = Gdk.RGBA()
color.parse(self.customheadingcolor)
item.override_color(context.get_state(), color)
else: else:
color = None colors = self.getDefaultColors()
item.override_color(context.get_state(), colors["fg"])
for item in items:
item.set_use_markup(True)
text = item.get_text()
if color == None:
markup = '<span size="12000" weight="bold">%s</span>' % (text)
else:
markup = '<span size="12000" weight="bold" color="%s">%s</span>' % (color, text)
item.set_markup(markup)
def setTooltip(self, widget, tip): def setTooltip(self, widget, tip):
self.tooltipsWidgets.append(widget) self.tooltipsWidgets.append(widget)
@ -424,7 +420,7 @@ class MenuWin(object):
self.settings.connect("changed::theme-name", self.changeTheme) self.settings.connect("changed::theme-name", self.changeTheme)
self.settings.connect("changed::hot-key", self.reloadSettings) self.settings.connect("changed::hot-key", self.reloadSettings)
self.settings.connect("changed::applet-icon", self.reloadSettings) self.settings.connect("changed::applet-icon", self.reloadSettings)
self.settings.connect("changed::hide-applet-icon", self.reloadSettings) self.settings.connect("changed::show-applet-icon", self.reloadSettings)
self.settings.connect("changed::applet-icon-size", self.reloadSettings) self.settings.connect("changed::applet-icon-size", self.reloadSettings)
self.applet.set_flags(MatePanelApplet.AppletFlags.EXPAND_MINOR) self.applet.set_flags(MatePanelApplet.AppletFlags.EXPAND_MINOR)
@ -556,7 +552,7 @@ class MenuWin(object):
self.applet.set_background_widget(self.applet) self.applet.set_background_widget(self.applet)
def loadSettings(self, *args, **kargs): def loadSettings(self, *args, **kargs):
self.hideIcon = self.settings.get_boolean("hide-applet-icon") self.showIcon = self.settings.get_boolean("show-applet-icon")
self.buttonText = self.settings.get_string("applet-text") self.buttonText = self.settings.get_string("applet-text")
self.theme_name = self.settings.get_string("theme-name") self.theme_name = self.settings.get_string("theme-name")
self.hotkeyText = self.settings.get_string("hot-key") self.hotkeyText = self.settings.get_string("hot-key")
@ -624,10 +620,10 @@ class MenuWin(object):
self.keybinder.rebind(self.hotkeyText) self.keybinder.rebind(self.hotkeyText)
def sizeButton(self): def sizeButton(self):
if self.hideIcon: if self.showIcon:
self.button_icon.hide()
else:
self.button_icon.show() self.button_icon.show()
else:
self.button_icon.hide()
# This code calculates width and height for the button_box # This code calculates width and height for the button_box
# and takes the orientation and scale factor in account # and takes the orientation and scale factor in account
@ -636,15 +632,15 @@ class MenuWin(object):
sl_req = self.systemlabel.get_preferred_size()[1] sl_req = self.systemlabel.get_preferred_size()[1]
sl_scale = self.systemlabel.get_scale_factor() sl_scale = self.systemlabel.get_scale_factor()
if self.applet.get_orient() == MatePanelApplet.AppletOrient.UP or self.applet.get_orient() == MatePanelApplet.AppletOrient.DOWN: if self.applet.get_orient() == MatePanelApplet.AppletOrient.UP or self.applet.get_orient() == MatePanelApplet.AppletOrient.DOWN:
if self.hideIcon: if self.showIcon:
self.applet.set_size_request(sl_req.width / sl_scale + 2, bi_req.height)
else:
self.applet.set_size_request(sl_req.width / sl_scale + bi_req.width / bi_scale + 5, bi_req.height) self.applet.set_size_request(sl_req.width / sl_scale + bi_req.width / bi_scale + 5, bi_req.height)
else: else:
if self.hideIcon: self.applet.set_size_request(sl_req.width / sl_scale + 2, bi_req.height)
self.applet.set_size_request(bi_req.width, sl_req.height / sl_scale + 2)
else: else:
if self.showIcon:
self.applet.set_size_request(bi_req.width, sl_req.height / sl_scale + bi_req.height / bi_scale + 5) self.applet.set_size_request(bi_req.width, sl_req.height / sl_scale + bi_req.height / bi_scale + 5)
else:
self.applet.set_size_request(bi_req.width, sl_req.height / sl_scale + 2)
def reloadSettings(self, *args): def reloadSettings(self, *args):
self.loadSettings() self.loadSettings()
@ -668,8 +664,7 @@ class MenuWin(object):
about.show() about.show()
def showPreferences(self, action, userdata = None): def showPreferences(self, action, userdata = None):
# Execute("mateconf-editor /apps/mintMenu") Execute("/usr/lib/linuxmint/mintMenu/preferences.py")
Execute(os.path.join(PATH, "mintMenuConfig.py"))
def showMenuEditor(self, action, userdata = None): def showMenuEditor(self, action, userdata = None):
Execute("mozo") Execute("mozo")

File diff suppressed because it is too large Load Diff

View File

@ -1,466 +0,0 @@
#!/usr/bin/python3
import gettext
import os
import sys
from glob import glob
import gi
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, Gdk, GdkPixbuf
import keybinding
from plugins.easygsettings import EasyGSettings
PATH = os.path.abspath(os.path.dirname(sys.argv[0]))
sys.path.append(os.path.join(PATH , "plugins"))
# i18n
gettext.install("mintmenu", "/usr/share/linuxmint/locale")
class mintMenuConfig(object):
def __init__(self):
self.path = os.path.abspath(os.path.dirname(sys.argv[0]))
# Load glade file and extract widgets
self.builder = Gtk.Builder()
self.builder.add_from_file(os.path.join(self.path, "mintMenuConfig.glade"))
self.mainWindow = self.builder.get_object("mainWindow")
#i18n
self.mainWindow.set_title(_("Menu preferences"))
self.mainWindow.set_icon_from_file("/usr/lib/linuxmint/mintMenu/icon.svg")
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")
self.showTooltips = self.builder.get_object("showToolTips")
self.showSearchOnTop = self.builder.get_object("showSearchOnTop")
self.swapGeneric = self.builder.get_object("swapGeneric")
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")
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)
self.buttonIcon = self.builder.get_object("buttonIcon")
self.buttonIconChooser = self.builder.get_object("button_icon_chooser")
self.image_filter = Gtk.FileFilter()
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)
self.buttonIconImage = self.builder.get_object("image_button_icon")
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():
self.placesHeightButton.set_sensitive(False)
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)
if os.path.exists("/usr/bin/mintinstall"):
self.builder.get_object("softwaremanagercheckbutton").show()
else:
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.settingsApplications, "string", "search-command", self.searchCommand, "changed", self.searchCommand.set_text, self.searchCommand.get_text)
self.bindGSettingsValueToWidget(self.settingsApplications, "bool", "search-on-top", self.showSearchOnTop, "toggled", self.showSearchOnTop.set_active, self.showSearchOnTop.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.settings, "bool", "tooltips-enabled", self.showTooltips, "toggled", self.showTooltips.set_active, self.showTooltips.get_active)
self.getPluginsToggle()
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)
self.cell = Gtk.CellRendererText()
for count in range(len(self.customplacepaths)):
self.customplacestreemodel.append([self.customplacenames[count], self.customplacepaths[count]])
self.customplacestreemodel.connect("row-inserted", self.updatePlacesGSettings)
self.customplacestreemodel.connect("row-deleted", self.updatePlacesGSettings)
self.customplacestreemodel.connect("rows-reordered", self.updatePlacesGSettings)
self.customplacestreemodel.connect("row-changed", self.updatePlacesGSettings)
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)
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)
#Detect themes and show theme here
theme_name = self.settings.get("string", "theme-name")
themes = glob("/usr/share/themes/*/*/gtkrc")
model = Gtk.ListStore(str, str)
self.builder.get_object("themesCombo").set_model(model)
selected_theme = model.append([_("Desktop theme"), "default"])
for theme in sorted(themes):
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
self.builder.get_object("themesCombo").set_active_iter(selected_theme)
self.builder.get_object("themesCombo").connect("changed", self.set_theme)
self.toggleUseCustomColors(self.useCustomColors)
self.mainWindow.present()
self.getBackgroundColor()
def set_theme(self, widget):
model = widget.get_model()
iter = widget.get_active_iter()
theme_name = model.get_value(iter, 1)
self.settings.set("string", "theme-name", theme_name)
def getPluginsToggle(self):
array = self.settings.get("list-string", "plugins-list")
if "recent" in array:
self.showRecentPlugin.set_active(True)
else:
self.showRecentPlugin.set_active(False)
if "applications" in array:
self.showApplicationsPlugin.set_active(True)
else:
self.showApplicationsPlugin.set_active(False)
if "system_management" in array:
self.showSystemPlugin.set_active(True)
else:
self.showSystemPlugin.set_active(False)
if "places" in array:
self.showPlacesPlugin.set_active(True)
else:
self.showPlacesPlugin.set_active(False)
def setPluginsLayout(self, widget):
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")
self.settings.set("list-string", "plugins-list", visiblePlugins)
def setShowButtonIcon(self, value):
self.showButtonIcon.set_active(not value)
def setButtonIcon(self, value):
self.buttonIconChooser.set_filename(value)
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(value, -1, 22)
self.buttonIconImage.set_from_pixbuf(pixbuf)
def getShowButtonIcon(self):
return not self.showButtonIcon.get_active()
def bindGSettingsValueToWidget(self, settings, setting_type, key, widget, changeEvent, setter, getter):
settings.notifyAdd(key, self.callSetter, args = [setting_type, setter])
if setting_type == "color":
color = Gdk.RGBA()
color.parse(settings.get(setting_type, key))
setter(color)
else:
setter(settings.get(setting_type, key))
widget.connect(changeEvent, lambda *args: self.callGetter(settings, setting_type, key, getter))
def callSetter(self, settings, key, args):
if args[0] == "bool":
args[1](settings.get_boolean(key))
elif args[0] == "string":
args[1](settings.get_string(key))
elif args[0] == "int":
args[1](settings.get_int(key))
elif args[0] == "color":
color = Gdk.RGBA()
color.parse(settings.get_string(key))
args[1](color)
def callGetter(self, settings, setting_type, key, getter):
if setting_type == "int":
settings.set(setting_type, key, int(getter()))
else:
settings.set(setting_type, key, getter())
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())
def getBackgroundColor(self):
color = self.backgroundColor.get_rgba()
return self.gdkRGBAToString(color)
def getHeadingColor(self):
color = self.headingColor.get_rgba()
return self.gdkRGBAToString(color)
def gdkRGBAToString(self, gdkRGBA):
return "#%.2X%.2X%.2X" % (int(gdkRGBA.red * 256), int(gdkRGBA.green * 256), int(gdkRGBA.blue * 256))
def moveUp(self, upButton):
treeselection = self.customplacestree.get_selection()
currentiter = treeselection.get_selected()[1]
if treeselection:
lagiter = self.customplacestreemodel.get_iter_first()
nextiter = self.customplacestreemodel.get_iter_first()
while nextiter and self.customplacestreemodel.get_path(nextiter) != \
self.customplacestreemodel.get_path(currentiter):
lagiter = nextiter
nextiter = self.customplacestreemodel.iter_next(nextiter)
if nextiter:
self.customplacestreemodel.swap(currentiter, lagiter)
return
def newPlace(self, newButton):
self.builder.get_object("label2").set_text(_("Name:"))
self.builder.get_object("label1").set_text(_("Path:"))
newPlaceDialog = self.builder.get_object("editPlaceDialog")
folderChooserDialog = self.builder.get_object("fileChooserDialog")
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)
newPlaceDialog.set_default_response(Gtk.ResponseType.OK)
newPlaceName = self.builder.get_object("nameEntryBox")
newPlacePath = self.builder.get_object("pathEntryBox")
folderButton = self.builder.get_object("folderButton")
def chooseFolder(folderButton):
currentPath = newPlacePath.get_text()
if currentPath:
folderChooserDialog.select_filename(currentPath)
response = folderChooserDialog.run()
folderChooserDialog.hide()
if response == Gtk.ResponseType.OK:
newPlacePath.set_text(folderChooserDialog.get_filenames()[0])
folderButton.connect("clicked", chooseFolder)
response = newPlaceDialog.run()
newPlaceDialog.hide()
if response == Gtk.ResponseType.OK:
name = newPlaceName.get_text()
path = newPlacePath.get_text()
if name and path:
self.customplacestreemodel.append((name, path))
def editPlace(self, editButton):
self.builder.get_object("label2").set_text(_("Name:"))
self.builder.get_object("label1").set_text(_("Path:"))
editPlaceDialog = self.builder.get_object("editPlaceDialog")
folderChooserDialog = self.builder.get_object("fileChooserDialog")
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)
editPlaceDialog.set_default_response(Gtk.ResponseType.OK)
editPlaceName = self.builder.get_object("nameEntryBox")
editPlacePath = self.builder.get_object("pathEntryBox")
folderButton = self.builder.get_object("folderButton")
treeselection = self.customplacestree.get_selection()
currentiter = treeselection.get_selected()[1]
if currentiter:
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()
if currentPath:
folderChooserDialog.select_filename(currentPath)
response = folderChooserDialog.run()
folderChooserDialog.hide()
if response == Gtk.ResponseType.OK:
editPlacePath.set_text(folderChooserDialog.get_filenames()[0])
folderButton.connect("clicked", chooseFolder)
response = editPlaceDialog.run()
editPlaceDialog.hide()
if response == Gtk.ResponseType.OK:
name = editPlaceName.get_text()
path = editPlacePath.get_text()
if name and path:
self.customplacestreemodel.set_value(currentiter, 0, name)
self.customplacestreemodel.set_value(currentiter, 1, path)
def moveDown(self, downButton):
treeselection = self.customplacestree.get_selection()
currentiter = treeselection.get_selected()[1]
nextiter = self.customplacestreemodel.iter_next(currentiter)
if nextiter:
self.customplacestreemodel.swap(currentiter, nextiter)
return
def removePlace(self, removeButton):
treeselection = self.customplacestree.get_selection()
currentiter = treeselection.get_selected()[1]
if currentiter:
self.customplacestreemodel.remove(currentiter)
return
def togglePlacesHeightEnabled(self, toggle):
if toggle.get_active():
self.placesHeightButton.set_sensitive(True)
else:
self.placesHeightButton.set_sensitive(False)
def toggleSystemHeightEnabled(self, toggle):
if toggle.get_active():
self.systemHeightButton.set_sensitive(True)
else:
self.systemHeightButton.set_sensitive(False)
def updatePlacesGSettings(self, treemodel, path, iter = None, new_order = None):
# Do only if not partway though an append operation;
# Append = insert+change+change and each creates a signal
if not iter or self.customplacestreemodel.get_value(iter, 1):
treeiter = self.customplacestreemodel.get_iter_first()
customplacenames = []
customplacepaths = []
while treeiter:
customplacenames = customplacenames + [self.customplacestreemodel.get_value(treeiter, 0)]
customplacepaths = customplacepaths + [self.customplacestreemodel.get_value(treeiter, 1)]
treeiter = self.customplacestreemodel.iter_next(treeiter)
self.settingsPlaces.set("list-string", "custom-paths", customplacepaths)
self.settingsPlaces.set("list-string", "custom-names", customplacenames)
window = mintMenuConfig()
Gtk.main()

View File

@ -50,8 +50,11 @@
<property name="margin_top">10</property> <property name="margin_top">10</property>
<property name="margin_bottom">10</property> <property name="margin_bottom">10</property>
<property name="label" translatable="yes">Favorites</property> <property name="label" translatable="yes">Favorites</property>
<property name="use_markup">True</property>
<property name="xalign">0</property> <property name="xalign">0</property>
<attributes>
<attribute name="weight" value="bold"/>
<attribute name="scale" value="1.2"/>
</attributes>
</object> </object>
<packing> <packing>
<property name="expand">True</property> <property name="expand">True</property>
@ -195,6 +198,10 @@
<property name="margin_bottom">10</property> <property name="margin_bottom">10</property>
<property name="label" translatable="yes">Applications</property> <property name="label" translatable="yes">Applications</property>
<property name="xalign">0</property> <property name="xalign">0</property>
<attributes>
<attribute name="weight" value="bold"/>
<attribute name="scale" value="1.2"/>
</attributes>
</object> </object>
<packing> <packing>
<property name="expand">True</property> <property name="expand">True</property>

View File

@ -0,0 +1,298 @@
#!/usr/bin/python3
import gettext
import glob
import locale
import setproctitle
import gi
gi.require_version("Gtk", "3.0")
gi.require_version('XApp', '1.0')
from gi.repository import Gtk, Gdk, GdkPixbuf, XApp
import keybinding
from xapp.GSettingsWidgets import *
# i18n
gettext.install("mintmenu", "/usr/share/linuxmint/locale")
locale.bindtextdomain("mintmenu", "/usr/share/linuxmint/locale")
locale.textdomain("mintmenu")
class CustomPlaceDialog (Gtk.Dialog):
def __init__(self):
Gtk.Dialog.__init__(self, title=_("Custom Place"), flags=Gtk.DialogFlags.MODAL,
buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
Gtk.STOCK_OK, Gtk.ResponseType.OK))
self.set_default_size(150, 100)
grid = Gtk.Grid()
grid.set_row_spacing(12)
grid.set_column_spacing(12)
grid.set_border_width(12)
self.name = Gtk.Entry()
grid.attach(Gtk.Label(_("Name:")), 0, 0, 1, 1)
grid.attach(self.name, 1, 0, 1, 1)
self.filechooser_button = Gtk.FileChooserButton()
self.filechooser_button.set_title(_("Select a folder"))
self.filechooser_button.set_action(Gtk.FileChooserAction.SELECT_FOLDER)
grid.attach(Gtk.Label(_("Folder:")), 0, 1, 1, 1)
grid.attach(self.filechooser_button, 1, 1, 1, 1)
self.get_content_area().add(grid)
self.show_all()
class mintMenuPreferences():
def __init__(self):
self.settings = Gio.Settings("com.linuxmint.mintmenu")
self.places_settings = Gio.Settings("com.linuxmint.mintmenu.plugins.places")
self.builder = Gtk.Builder()
self.builder.set_translation_domain("mintmenu")
self.builder.add_from_file("/usr/share/linuxmint/mintmenu/preferences.ui")
self.window = self.builder.get_object("main_window")
self.window.set_title(_("Menu preferences"))
self.window.set_icon_name("linuxmint-logo")
self.window.connect("destroy", Gtk.main_quit)
page = SettingsPage()
self.builder.get_object("box_general").add(page)
section = page.add_section(_("Menu button"), _("Applet button in the panel"))
section.add_row(GSettingsSwitch(_("Show button icon"), "com.linuxmint.mintmenu", "show-applet-icon"))
section.add_reveal_row(GSettingsEntry(_("Button text"), "com.linuxmint.mintmenu", "applet-text"), "com.linuxmint.mintmenu", "show-applet-icon")
section.add_reveal_row(GSettingsIconChooser(_("Button icon"), "com.linuxmint.mintmenu", "applet-icon"), "com.linuxmint.mintmenu", "show-applet-icon")
binding_widget = keybinding.KeybindingWidget()
binding_widget.set_val(self.settings.get_string("hot-key"))
binding_widget.connect("accel-edited", self.set_keyboard_shortcut)
label = SettingsLabel(_("Keyboard shortcut"))
setting_widget = SettingsWidget()
setting_widget.pack_start(label, False, False, 0)
setting_widget.pack_end(binding_widget, False, False, 0)
section.add_row(setting_widget)
section = page.add_section(_("Options"), _("General applet options"))
self.system_switch = Switch(_("Show system management"))
self.system_switch.content_widget.connect("notify::active", self.set_plugins)
section.add_row(self.system_switch)
self.places_switch = Switch(_("Show places"))
self.places_switch.content_widget.connect("notify::active", self.set_plugins)
section.add_row(self.places_switch)
self.recent_switch = Switch(_("Show recently used documents and applications"))
self.recent_switch.content_widget.connect("notify::active", self.set_plugins)
section.add_row(self.recent_switch)
self.set_plugins_switches()
section.add_row(GSettingsSwitch(_("Show tooltips"), "com.linuxmint.mintmenu", "tooltips-enabled"))
page = SettingsPage()
self.builder.get_object("box_appearance").add(page)
section = page.add_section(_("Colors"), _("Custom colors and theme"))
section.add_row(GSettingsSwitch(_("Use custom colors"), "com.linuxmint.mintmenu", "use-custom-color"))
section.add_reveal_row(GSettingsColorChooser(_("Headings"), "com.linuxmint.mintmenu", "custom-heading-color"), "com.linuxmint.mintmenu", "use-custom-color")
section.add_reveal_row(GSettingsColorChooser(_("Background"), "com.linuxmint.mintmenu", "custom-color"), "com.linuxmint.mintmenu", "use-custom-color")
options = []
options.append(["default", _("Desktop theme"), "default"])
themes = glob.glob("/usr/share/themes/*/*/gtkrc")
for theme in sorted(themes):
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()
options.append([theme, theme])
section.add_row(GSettingsComboBox(_("Theme:"), "com.linuxmint.mintmenu", "theme-name", options))
section = page.add_section(_("Icon sizes"), _("The size of the icons"))
section.add_row(GSettingsSpinButton(_("Favorites"), "com.linuxmint.mintmenu.plugins.applications", "favicon-size", mini=1, maxi=128, step=1, page=2))
section.add_row(GSettingsSpinButton(_("Applications"), "com.linuxmint.mintmenu.plugins.applications", "icon-size", mini=1, maxi=128, step=1, page=2))
section.add_row(GSettingsSpinButton(_("System"), "com.linuxmint.mintmenu.plugins.system_management", "icon-size", mini=1, maxi=128, step=1, page=2))
section.add_row(GSettingsSpinButton(_("Places"), "com.linuxmint.mintmenu.plugins.places", "icon-size", mini=1, maxi=128, step=1, page=2))
page = SettingsPage()
self.builder.get_object("box_applications").add(page)
section = page.add_section(_("Layout"), _("Section layout"))
section.add_row(GSettingsSwitch(_("Show search bar on top"), "com.linuxmint.mintmenu.plugins.applications", "search-on-top"))
section.add_row(GSettingsSwitch(_("Show applications comments"), "com.linuxmint.mintmenu.plugins.applications", "show-application-comments"))
section = page.add_section(_("Categories"), _("Applications categories"))
section.add_row(GSettingsSwitch(_("Show category icons"), "com.linuxmint.mintmenu.plugins.applications", "show-category-icons"))
section.add_row(GSettingsSwitch(_("Switch categories on hover"), "com.linuxmint.mintmenu.plugins.applications", "categories-mouse-over"))
section.add_reveal_row(GSettingsSpinButton(_("Hover delay"), "com.linuxmint.mintmenu.plugins.applications", "category-hover-delay", units=_("milliseconds"), mini=1, maxi=500, step=1, page=10), "com.linuxmint.mintmenu.plugins.applications", "categories-mouse-over")
section = page.add_section(_("Search"), _("Search options"))
section.add_row(GSettingsSwitch(_("Search for packages to install"), "com.linuxmint.mintmenu.plugins.applications", "use-apt"))
section.add_row(GSettingsSwitch(_("Remember the last category or search"), "com.linuxmint.mintmenu.plugins.applications", "remember-filter"))
section.add_row(GSettingsSwitch(_("Enable Internet search"), "com.linuxmint.mintmenu.plugins.applications", "enable-internet-search"))
section.add_row(GSettingsEntry(_("Search command"), "com.linuxmint.mintmenu.plugins.applications", "search-command"))
page = SettingsPage()
self.builder.get_object("box_favorites").add(page)
section = page.add_section(_("Layout"), _("Section layout"))
section.add_row(GSettingsSpinButton(_("Number of columns"), "com.linuxmint.mintmenu.plugins.applications", "fav-cols", mini=1, maxi=5, step=1, page=1))
section.add_row(GSettingsSwitch(_("Swap name and generic name"), "com.linuxmint.mintmenu.plugins.applications", "swap-generic-name"))
section.add_row(GSettingsSwitch(_("Show favorites when the menu is open"), "com.linuxmint.mintmenu", "start-with-favorites"))
page = SettingsPage()
self.builder.get_object("box_system").add(page)
section = page.add_section(_("Layout"), _("Section layout"))
section.add_row(GSettingsSwitch(_("Custom height"), "com.linuxmint.mintmenu.plugins.system_management", "allow-scrollbar"))
section.add_reveal_row(GSettingsSpinButton(_("Height"), "com.linuxmint.mintmenu.plugins.system_management", "height", mini=1, maxi=800, step=1, page=2), "com.linuxmint.mintmenu.plugins.system_management", "allow-scrollbar")
section = page.add_section(_("Items"), _("Toggle default items"))
section.add_row(GSettingsSwitch(_("Software Manager"), "com.linuxmint.mintmenu.plugins.system_management", "show-software-manager"))
section.add_row(GSettingsSwitch(_("Package Manager"), "com.linuxmint.mintmenu.plugins.system_management", "show-package-manager"))
section.add_row(GSettingsSwitch(_("Control Center"), "com.linuxmint.mintmenu.plugins.system_management", "show-control-center"))
section.add_row(GSettingsSwitch(_("Terminal"), "com.linuxmint.mintmenu.plugins.system_management", "show-terminal"))
section.add_row(GSettingsSwitch(_("Lock Screen"), "com.linuxmint.mintmenu.plugins.system_management", "show-lock-screen"))
section.add_row(GSettingsSwitch(_("Logout"), "com.linuxmint.mintmenu.plugins.system_management", "show-logout"))
section.add_row(GSettingsSwitch(_("Quit"), "com.linuxmint.mintmenu.plugins.system_management", "show-quit"))
page = SettingsPage()
self.builder.get_object("box_places").add(page)
section = page.add_section(_("Layout"), _("Section layout"))
section.add_row(GSettingsSwitch(_("Custom height"), "com.linuxmint.mintmenu.plugins.places", "allow-scrollbar"))
section.add_reveal_row(GSettingsSpinButton(_("Height"), "com.linuxmint.mintmenu.plugins.places", "height", mini=1, maxi=800, step=1, page=2), "com.linuxmint.mintmenu.plugins.places", "allow-scrollbar")
section = page.add_section(_("Items"), _("Toggle default items"))
section.add_row(GSettingsSwitch(_("Computer"), "com.linuxmint.mintmenu.plugins.places", "show-computer"))
section.add_row(GSettingsSwitch(_("Home Folder"), "com.linuxmint.mintmenu.plugins.places", "show-home-folder"))
section.add_row(GSettingsSwitch(_("Network"), "com.linuxmint.mintmenu.plugins.places", "show-network"))
section.add_row(GSettingsSwitch(_("Desktop"), "com.linuxmint.mintmenu.plugins.places", "show-desktop"))
section.add_row(GSettingsSwitch(_("Trash"), "com.linuxmint.mintmenu.plugins.places", "show-trash"))
section.add_row(GSettingsSwitch(_("GTK Bookmarks"), "com.linuxmint.mintmenu.plugins.places", "show-gtk-bookmarks"))
section = page.add_section(_("Custom places"), _("You can add your own places in the menu"))
box = self.builder.get_object("custom_places_box")
section.add(box)
self.custom_places_tree = self.builder.get_object("custom_places_tree")
self.custom_places_paths = self.places_settings.get_strv("custom-paths")
self.custom_places_names = self.places_settings.get_strv("custom-names")
self.custom_places_model = Gtk.ListStore(str, str)
self.cell = Gtk.CellRendererText()
for count in range(len(self.custom_places_paths)):
self.custom_places_model.append([self.custom_places_names[count], self.custom_places_paths[count]])
self.custom_places_model.connect("row-inserted", self.save_custom_places)
self.custom_places_model.connect("row-deleted", self.save_custom_places)
self.custom_places_model.connect("rows-reordered", self.save_custom_places)
self.custom_places_model.connect("row-changed", self.save_custom_places)
self.custom_places_tree.set_model(self.custom_places_model)
self.custom_places_tree.append_column(Gtk.TreeViewColumn(_("Name"), self.cell, text=0))
self.custom_places_tree.append_column(Gtk.TreeViewColumn(_("Path"), self.cell, text=1))
self.builder.get_object("newButton").connect("clicked", self.add_custom_place)
self.builder.get_object("editButton").connect("clicked", self.edit_custom_place)
self.builder.get_object("upButton").connect("clicked", self.move_up)
self.builder.get_object("downButton").connect("clicked", self.move_down)
self.builder.get_object("removeButton").connect("clicked", self.remove_custom_place)
self.window.show_all()
return
def set_keyboard_shortcut(self, widget):
self.settings.set_string("hot-key", widget.get_val())
def set_plugins_switches(self):
plugins = self.settings.get_strv("plugins-list")
self.recent_switch.content_widget.set_active("recent" in plugins)
self.system_switch.content_widget.set_active("system_management" in plugins)
self.places_switch.content_widget.set_active("places" in plugins)
def set_plugins(self, widget, param):
visible_plugins = []
if self.places_switch.content_widget.get_active():
visible_plugins.append("places")
if self.system_switch.content_widget.get_active():
visible_plugins.append("system_management")
if self.places_switch.content_widget.get_active() or self.system_switch.content_widget.get_active():
visible_plugins.append("newpane")
visible_plugins.append("applications")
if self.recent_switch.content_widget.get_active():
visible_plugins.append("newpane")
visible_plugins.append("recent")
self.settings.set_strv("plugins-list", visible_plugins)
def add_custom_place(self, newButton):
dialog = CustomPlaceDialog()
response = dialog.run()
if response == Gtk.ResponseType.OK:
name = dialog.name.get_text()
path = dialog.filechooser_button.get_filename()
if name and path and name != "":
self.custom_places_model.append((name, path))
dialog.destroy()
return
def edit_custom_place(self, editButton):
dialog = CustomPlaceDialog()
treeselection = self.custom_places_tree.get_selection()
currentiter = treeselection.get_selected()[1]
if currentiter:
initName = self.custom_places_model.get_value(currentiter, 0)
initPath = self.custom_places_model.get_value(currentiter, 1)
dialog.name.set_text(initName)
dialog.filechooser_button.set_filename(initPath)
response = dialog.run()
if response == Gtk.ResponseType.OK:
name = dialog.name.get_text()
path = dialog.filechooser_button.get_filename()
if name and path and name != "":
self.custom_places_model.set_value(currentiter, 0, name)
self.custom_places_model.set_value(currentiter, 1, path)
dialog.destroy()
def move_up(self, upButton):
treeselection = self.custom_places_tree.get_selection()
currentiter = treeselection.get_selected()[1]
if treeselection:
lagiter = self.custom_places_model.get_iter_first()
nextiter = self.custom_places_model.get_iter_first()
while nextiter and self.custom_places_model.get_path(nextiter) != \
self.custom_places_model.get_path(currentiter):
lagiter = nextiter
nextiter = self.custom_places_model.iter_next(nextiter)
if nextiter:
self.custom_places_model.swap(currentiter, lagiter)
return
def move_down(self, downButton):
treeselection = self.custom_places_tree.get_selection()
currentiter = treeselection.get_selected()[1]
nextiter = self.custom_places_model.iter_next(currentiter)
if nextiter:
self.custom_places_model.swap(currentiter, nextiter)
return
def remove_custom_place(self, removeButton):
treeselection = self.custom_places_tree.get_selection()
currentiter = treeselection.get_selected()[1]
if currentiter:
self.custom_places_model.remove(currentiter)
return
def save_custom_places(self, treemodel, path, iter = None, new_order = None):
if not iter or self.custom_places_model.get_value(iter, 1):
treeiter = self.custom_places_model.get_iter_first()
custom_places_names = []
custom_places_paths = []
while treeiter:
custom_places_names = custom_places_names + [self.custom_places_model.get_value(treeiter, 0)]
custom_places_paths = custom_places_paths + [self.custom_places_model.get_value(treeiter, 1)]
treeiter = self.custom_places_model.iter_next(treeiter)
self.places_settings.set_strv("custom-paths", custom_places_paths)
self.places_settings.set_strv("custom-names", custom_places_names)
if __name__ == "__main__":
setproctitle.setproctitle('mintmenu-preferences')
preferences = mintMenuPreferences()
Gtk.main()

View File

@ -2,8 +2,8 @@
<schemalist> <schemalist>
<schema id="com.linuxmint.mintmenu" path="/com/linuxmint/mintmenu/"> <schema id="com.linuxmint.mintmenu" path="/com/linuxmint/mintmenu/">
<key type="b" name="hide-applet-icon"> <key type="b" name="show-applet-icon">
<default>false</default> <default>true</default>
<summary></summary> <summary></summary>
<description></description> <description></description>
</key> </key>

View File

@ -0,0 +1,332 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1 -->
<interface>
<requires lib="gtk+" version="3.18"/>
<requires lib="xapp" version="0.0"/>
<object class="GtkBox" id="custom_places_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_top">9</property>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="shadow_type">etched-in</property>
<child>
<object class="GtkTreeView" id="custom_places_tree">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="reorderable">True</property>
<child internal-child="selection">
<object class="GtkTreeSelection"/>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox" id="vbox3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkButtonBox" id="vbuttonbox1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="homogeneous">True</property>
<property name="layout_style">expand</property>
<child>
<object class="GtkButton" id="newButton">
<property name="label">gtk-new</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="editButton">
<property name="label">gtk-edit</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="padding">6</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButtonBox" id="vbuttonbox2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="homogeneous">True</property>
<property name="layout_style">expand</property>
<child>
<object class="GtkButton" id="upButton">
<property name="label">gtk-go-up</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="downButton">
<property name="label">gtk-go-down</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="padding">5</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButtonBox" id="vbuttonbox3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="homogeneous">True</property>
<property name="layout_style">expand</property>
<child>
<object class="GtkButton" id="removeButton">
<property name="label">gtk-remove</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="padding">5</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="padding">6</property>
<property name="position">1</property>
</packing>
</child>
</object>
<object class="GtkWindow" id="main_window">
<property name="can_focus">False</property>
<child>
<placeholder/>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="XAppStackSidebar" id="stack_switcher">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stack">main_stack</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkStack" id="main_stack">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkBox" id="box_general">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="name">page1</property>
<property name="title" translatable="yes">General</property>
</packing>
</child>
<child>
<object class="GtkBox" id="box_appearance">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="name">page0</property>
<property name="title" translatable="yes">Appearance</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkBox" id="box_applications">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="name">page2</property>
<property name="title" translatable="yes">Applications</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkBox" id="box_favorites">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="name">page3</property>
<property name="title" translatable="yes">Favorites</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkBox" id="box_system">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="name">page4</property>
<property name="title" translatable="yes">System</property>
<property name="position">4</property>
</packing>
</child>
<child>
<object class="GtkBox" id="box_places">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="name">page5</property>
<property name="title" translatable="yes">Places</property>
<property name="position">5</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
<object class="GtkListStore" id="model1">
<columns>
<!-- column-name gchararray -->
<column type="gchararray"/>
</columns>
<data>
<row>
<col id="0" translatable="yes">Default</col>
</row>
</data>
</object>
</interface>