diff --git a/debian/control b/debian/control index cca03e8..82c9d1b 100644 --- a/debian/control +++ b/debian/control @@ -15,6 +15,7 @@ Depends: python-apt, python-configobj, python-setproctitle, + python-xapp, python-xlib, python-xdg, xdg-utils, @@ -24,6 +25,7 @@ Depends: gir1.2-matepanelapplet-4.0, gir1.2-gtk-3.0, gir1.2-mate-desktop, + gir1.2-xapp-1.0, mozo Description: Advanced MATE menu One of the most advanced menus under Linux. MintMenu supports filtering, diff --git a/usr/lib/linuxmint/mintMenu/mintMenu.py b/usr/lib/linuxmint/mintMenu/mintMenu.py index 275d885..73dee25 100755 --- a/usr/lib/linuxmint/mintMenu/mintMenu.py +++ b/usr/lib/linuxmint/mintMenu/mintMenu.py @@ -113,11 +113,11 @@ class MainWindow(object): def toggleCustomBackgroundColor(self, settings, key): self.customcolor = settings.get_string(key) - self.SetPaneColors(self.panesToColor) + self.setCustomColors() def toggleCustomHeadingColor(self, settings, key): self.customheadingcolor = settings.get_string(key) - self.SetHeadingStyle(self.headingsToColor) + self.setCustomColors() def getSetGSettingEntries(self): self.dottedfile = os.path.join(self.path, "dotted.png") @@ -196,13 +196,14 @@ class MainWindow(object): VBox1 = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) if MyPlugin.heading != "": - Label1 = Gtk.Label(label= MyPlugin.heading) + label1 = Gtk.Label() + label1.set_markup("%s" % MyPlugin.heading) Align1 = Gtk.Alignment.new(0, 0, 0, 0) Align1.set_padding(10, 5, 10, 0) - Align1.add(Label1) - self.headingsToColor.append(Label1) + Align1.add(label1) + self.headingsToColor.append(label1) Align1.show() - Label1.show() + label1.show() if not hasattr(MyPlugin, 'sticky') or MyPlugin.sticky: heading = Gtk.EventBox() @@ -297,34 +298,29 @@ class MainWindow(object): return {"fg": fgColor, "bg": bgColor} def loadTheme(self): - colors = self.getDefaultColors() - self.SetPaneColors(self.panesToColor, colors["bg"]) - self.SetHeadingStyle(self.headingsToColor) + self.setCustomColors() - def SetPaneColors(self, items, color = None): - for item in items: + def setCustomColors(self): + # Panes + for item in self.panesToColor: context = item.get_style_context() if self.usecustomcolor: - bgColor = Gdk.RGBA() - bgColor.parse(self.customcolor) - item.override_background_color(context.get_state(), bgColor) - elif color is not None: + color = Gdk.RGBA() + color.parse(self.customcolor) item.override_background_color(context.get_state(), color) - - def SetHeadingStyle(self, items): - if self.usecustomcolor: - color = self.customheadingcolor - else: - color = None - - for item in items: - item.set_use_markup(True) - text = item.get_text() - if color == None: - markup = '%s' % (text) else: - markup = '%s' % (color, text) - item.set_markup(markup) + 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: + color = Gdk.RGBA() + color.parse(self.customheadingcolor) + item.override_color(context.get_state(), color) + else: + colors = self.getDefaultColors() + item.override_color(context.get_state(), colors["fg"]) def setTooltip(self, widget, tip): self.tooltipsWidgets.append(widget) @@ -424,7 +420,7 @@ class MenuWin(object): self.settings.connect("changed::theme-name", self.changeTheme) self.settings.connect("changed::hot-key", 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.applet.set_flags(MatePanelApplet.AppletFlags.EXPAND_MINOR) @@ -556,7 +552,7 @@ class MenuWin(object): self.applet.set_background_widget(self.applet) 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.theme_name = self.settings.get_string("theme-name") self.hotkeyText = self.settings.get_string("hot-key") @@ -624,10 +620,10 @@ class MenuWin(object): self.keybinder.rebind(self.hotkeyText) def sizeButton(self): - if self.hideIcon: - self.button_icon.hide() - else: + if self.showIcon: self.button_icon.show() + else: + self.button_icon.hide() # This code calculates width and height for the button_box # 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_scale = self.systemlabel.get_scale_factor() if self.applet.get_orient() == MatePanelApplet.AppletOrient.UP or self.applet.get_orient() == MatePanelApplet.AppletOrient.DOWN: - if self.hideIcon: - self.applet.set_size_request(sl_req.width / sl_scale + 2, bi_req.height) - else: + if self.showIcon: self.applet.set_size_request(sl_req.width / sl_scale + bi_req.width / bi_scale + 5, bi_req.height) - else: - if self.hideIcon: - self.applet.set_size_request(bi_req.width, sl_req.height / sl_scale + 2) else: + self.applet.set_size_request(sl_req.width / sl_scale + 2, bi_req.height) + else: + if self.showIcon: 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): self.loadSettings() @@ -668,8 +664,7 @@ class MenuWin(object): about.show() def showPreferences(self, action, userdata = None): - # Execute("mateconf-editor /apps/mintMenu") - Execute(os.path.join(PATH, "mintMenuConfig.py")) + Execute("/usr/lib/linuxmint/mintMenu/preferences.py") def showMenuEditor(self, action, userdata = None): Execute("mozo") diff --git a/usr/lib/linuxmint/mintMenu/mintMenuConfig.glade b/usr/lib/linuxmint/mintMenu/mintMenuConfig.glade deleted file mode 100644 index ec2ba76..0000000 --- a/usr/lib/linuxmint/mintMenu/mintMenuConfig.glade +++ /dev/null @@ -1,1756 +0,0 @@ - - - - - - 10 - 1 - - - 1 - 128 - 1 - 1 - - - 100 - 1 - - - 1 - 128 - 1 - 1 - - - 1000 - 100 - 1 - 2 - - - 1 - 4 - 1 - 1 - - - 1 - 128 - 1 - 1 - - - 10000 - 1 - 10 - - - 1 - 128 - 1 - 1 - - - 10000 - 1 - 10 - - - False - 5 - Edit Place - True - center-on-parent - True - dialog - - - - - - True - False - 2 - - - True - False - end - - - gtk-ok - True - True - True - True - True - - - False - False - 0 - - - - - gtk-cancel - True - True - True - True - True - - - False - False - 1 - - - - - False - True - end - 0 - - - - - True - False - 5 - 2 - - - True - False - Name - - - 0 - 0 - - - - - True - True - - True - False - False - - - 1 - 0 - - - - - True - False - Path - - - 0 - 1 - - - - - True - False - - - True - True - - True - False - False - - - True - True - 0 - - - - - True - True - True - - - True - False - gtk-directory - - - - - False - False - 1 - - - - - 1 - 1 - - - - - False - True - 2 - - - - - - okButton - cancelButton - - - - False - 5 - True - center-on-parent - True - dialog - select-folder - - - - - - True - False - 2 - - - True - False - end - - - gtk-ok - True - True - True - True - True - - - False - False - 0 - - - - - gtk-cancel - True - True - True - True - True - - - False - False - 1 - - - - - False - True - end - 0 - - - - - - - - - button1 - button2 - - - - - - - - - - Default - - - - - False - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 5 - center - True - - - - - - True - False - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - vertical - - - True - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - - - True - False - 10 - 0 - none - - - True - False - True - True - 5 - 10 - - - Show button icon - True - True - False - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - start - True - - - 0 - 0 - 2 - - - - - True - False - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - start - Button text: - - - 0 - 1 - - - - - True - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - - False - False - - - 1 - 1 - - - - - True - False - start - Button icon: - - - 0 - 2 - - - - - True - False - 6 - - - True - False - - - True - True - 0 - - - - - True - False - gtk-missing-image - - - True - True - 1 - - - - - 1 - 2 - - - - - True - False - start - Keyboard shortcut: - - - 0 - 3 - - - - - - - - - - - - True - False - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - Main button - - - False - - - - - True - False - 10 - 0 - none - - - True - False - vertical - 5 - - - Show applications plugin - True - True - False - start - True - - - False - False - 0 - - - - - Show system plugin - True - True - False - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - start - True - - - False - False - 1 - - - - - Show places plugin - True - True - False - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - start - True - - - False - False - 2 - - - - - Show recently used applications and documents plugin - True - True - False - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - start - True - - - False - False - 3 - - - - - Show tooltips - True - True - False - start - True - - - False - False - 4 - - - - - - - 1 - - - - - True - False - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - Plugins - - - 1 - False - - - - - True - False - 10 - 0 - none - - - True - False - True - True - 5 - 10 - - - True - False - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - start - Headings: - start - - - 0 - 1 - - - - - True - True - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - - - 1 - 1 - - - - - True - False - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - start - Background: - - - 0 - 2 - - - - - True - True - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - - - 1 - 2 - - - - - True - False - start - Theme: - - - 0 - 3 - - - - - True - False - model1 - - - - 0 - - - - - 1 - 3 - - - - - Use custom colors - True - True - False - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - start - 5 - True - - - 0 - 0 - 2 - - - - - - - 2 - - - - - True - False - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - Colors - - - 2 - False - - - - - True - False - 10 - 0 - none - - - True - False - 5 - 10 - - - Show application comments - True - True - False - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - start - 11 - True - - - 0 - 0 - 2 - - - - - Show category icons - True - True - False - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - start - True - - - 0 - 1 - 2 - - - - - Hover - True - True - False - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - start - True - - - 0 - 2 - 2 - - - - - True - False - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - start - Hover delay (seconds): - - - 0 - 3 - - - - - True - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - - False - False - adjustment4 - 100 - - - 1 - 3 - - - - - True - False - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - start - Icon size: - - - 0 - 4 - - - - - True - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - - False - False - adjustment3 - 1 - - - 1 - 4 - - - - - True - False - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - start - Search command: - - - 0 - 5 - - - - - True - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_STRUCTURE_MASK - - False - False - - - 1 - 5 - - - - - Search for packages to install - True - True - False - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - start - True - - - 0 - 6 - 2 - - - - - Remember the last category or search - True - True - False - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - start - True - - - 0 - 7 - 2 - - - - - Enable Internet search - True - True - False - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - start - True - - - 0 - 8 - 2 - - - - - Show search bar on top - True - True - False - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - start - True - - - 0 - 9 - 2 - - - - - - - 3 - - - - - True - False - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - Applications - - - 3 - False - - - - - True - False - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 10 - 0 - none - - - True - False - 5 - 10 - - - True - False - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - start - Number of columns: - - - 0 - 0 - - - - - True - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - False - False - adjustment5 - 1 - - - 1 - 0 - - - - - True - False - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - start - Icon size: - - - 0 - 1 - - - - - True - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - False - False - adjustment6 - 1 - - - 1 - 1 - - - - - Swap name and generic name - True - True - False - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - start - True - - - 0 - 2 - 2 - - - - - Always start with favorites pane - True - True - False - start - True - - - 0 - 3 - 2 - - - - - - - 4 - - - - - True - False - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - Favorites - - - 4 - False - - - - - True - False - 10 - 0 - none - - - True - False - vertical - 5 - - - True - False - 5 - 10 - - - True - False - start - Height: - - - 0 - 1 - - - - - True - True - 5 - - 0 - False - False - False - adjustment7 - True - - - 1 - 1 - - - - - True - False - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - start - Icon size: - - - 0 - 2 - - - - - True - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - - False - False - adjustment8 - - - 1 - 2 - - - - - Allow Scrollbar - True - True - False - start - True - - - 0 - 0 - 2 - - - - - False - True - 0 - - - - - True - False - 10 - 10 - 0 - none - - - True - False - 5 - 10 - vertical - 5 - - - Computer - True - True - False - start - True - - - False - False - 0 - - - - - Home Folder - True - True - False - start - True - - - True - True - 1 - - - - - Network - True - True - False - start - True - - - True - True - 2 - - - - - Desktop - True - True - False - start - True - - - True - True - 3 - - - - - Trash - True - True - False - start - True - - - True - True - 4 - - - - - - - True - False - Toggle Default Places: - True - - - - - False - False - 1 - - - - - Show GTK bookmarks - True - True - False - start - True - - - True - True - 2 - - - - - True - False - 10 - 10 - 0 - none - - - True - False - 9 - - - True - True - etched-in - - - True - True - True - - - - - - - - True - True - 0 - - - - - True - False - vertical - - - True - False - vertical - 5 - expand - - - gtk-new - True - True - True - True - - - False - False - 0 - - - - - gtk-edit - True - True - True - True - - - False - False - 1 - - - - - False - False - 6 - 0 - - - - - True - False - vertical - expand - - - gtk-go-up - True - True - True - True - - - False - False - 0 - - - - - gtk-go-down - True - True - True - True - - - False - False - 1 - - - - - False - False - 5 - 1 - - - - - True - False - vertical - expand - - - gtk-remove - True - True - True - True - - - False - False - 0 - - - - - False - False - 5 - 2 - - - - - False - False - 6 - 1 - - - - - - - True - False - Custom Places: - True - - - - - True - True - 3 - - - - - - - 5 - - - - - True - False - Places - - - 5 - False - - - - - True - False - 10 - 0 - none - - - True - False - vertical - 5 - - - True - False - 5 - 10 - - - Allow Scrollbar - True - True - False - start - True - - - 0 - 0 - 2 - - - - - True - False - start - Height: - True - - - 0 - 1 - - - - - True - True - 5 - - False - False - False - adjustment9 - True - - - 1 - 1 - - - - - True - False - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - start - Icon size: - - - 0 - 2 - - - - - True - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - - False - False - adjustment10 - - - 1 - 2 - - - - - False - True - 0 - - - - - True - False - 10 - 10 - 0 - none - - - True - False - 5 - 10 - vertical - 5 - - - Software Manager - True - True - False - start - True - - - False - False - 0 - - - - - Package Manager - True - True - False - start - True - - - False - False - 1 - - - - - Control Center - True - True - False - start - True - - - True - True - 2 - - - - - Terminal - True - True - False - start - none - True - - - True - True - 3 - - - - - Lock Screen - True - True - False - start - True - - - True - True - 4 - - - - - Logout - True - True - False - start - True - - - True - True - 5 - - - - - Quit - True - True - False - start - True - - - True - True - 6 - - - - - - - True - False - Toggle Default Items: - True - - - - - False - True - 1 - - - - - - - 6 - - - - - True - False - System - - - 6 - False - - - - - True - True - 0 - - - - - True - False - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 3 - spread - - - gtk-close - True - True - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - True - - - False - False - 0 - - - - - False - False - 1 - - - - - - diff --git a/usr/lib/linuxmint/mintMenu/mintMenuConfig.py b/usr/lib/linuxmint/mintMenu/mintMenuConfig.py deleted file mode 100755 index 4f6175c..0000000 --- a/usr/lib/linuxmint/mintMenu/mintMenuConfig.py +++ /dev/null @@ -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() diff --git a/usr/lib/linuxmint/mintMenu/plugins/applications.glade b/usr/lib/linuxmint/mintMenu/plugins/applications.glade index 8f901c2..7793f3b 100644 --- a/usr/lib/linuxmint/mintMenu/plugins/applications.glade +++ b/usr/lib/linuxmint/mintMenu/plugins/applications.glade @@ -50,8 +50,11 @@ 10 10 Favorites - True 0 + + + + True @@ -195,6 +198,10 @@ 10 Applications 0 + + + + True diff --git a/usr/lib/linuxmint/mintMenu/preferences.py b/usr/lib/linuxmint/mintMenu/preferences.py new file mode 100755 index 0000000..040aef1 --- /dev/null +++ b/usr/lib/linuxmint/mintMenu/preferences.py @@ -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() diff --git a/usr/share/glib-2.0/schemas/com.linuxmint.mintmenu.gschema.xml b/usr/share/glib-2.0/schemas/com.linuxmint.mintmenu.gschema.xml index 124f180..4b1ed9b 100644 --- a/usr/share/glib-2.0/schemas/com.linuxmint.mintmenu.gschema.xml +++ b/usr/share/glib-2.0/schemas/com.linuxmint.mintmenu.gschema.xml @@ -2,8 +2,8 @@ - - false + + true diff --git a/usr/share/linuxmint/mintmenu/preferences.ui b/usr/share/linuxmint/mintmenu/preferences.ui new file mode 100644 index 0000000..1206802 --- /dev/null +++ b/usr/share/linuxmint/mintmenu/preferences.ui @@ -0,0 +1,332 @@ + + + + + + + True + False + 9 + + + True + True + etched-in + + + True + True + True + + + + + + + + True + True + 0 + + + + + True + False + vertical + + + True + False + vertical + True + expand + + + gtk-new + True + True + True + True + + + False + False + 0 + + + + + gtk-edit + True + True + True + True + + + False + False + 1 + + + + + False + False + 6 + 0 + + + + + True + False + vertical + True + expand + + + gtk-go-up + True + True + True + True + + + False + False + 0 + + + + + gtk-go-down + True + True + True + True + + + False + False + 1 + + + + + False + False + 5 + 1 + + + + + True + False + vertical + True + expand + + + gtk-remove + True + True + True + True + + + False + False + 0 + + + + + False + False + 5 + 2 + + + + + False + False + 6 + 1 + + + + + False + + + + + + True + False + + + True + False + main_stack + + + False + True + 0 + + + + + True + False + + + True + False + vertical + + + + + + + + + + + + page1 + General + + + + + True + False + vertical + + + + + + + + + + + + page0 + Appearance + 1 + + + + + True + False + vertical + + + + + + + + + + + + page2 + Applications + 2 + + + + + True + False + vertical + + + + + + + + + + + + page3 + Favorites + 3 + + + + + True + False + vertical + + + + + + + + + + + + page4 + System + 4 + + + + + True + False + vertical + + + + + + + + + + + + page5 + Places + 5 + + + + + False + True + 1 + + + + + + + + + + + + + Default + + + +