From b7a1fa0b9411151a51f9edd1b347ac84e383cbab Mon Sep 17 00:00:00 2001 From: Clement Lefebvre Date: Mon, 22 Jul 2019 13:20:51 +0200 Subject: [PATCH] Remove support for custom colors Since the move to GTK3 custom color support is extremely hacky and buggy: - It relies on gtk_widget_override_color() which is deprecated - Only one call to gtk_widget_override_color() is functional, successive calls are ignored, leading to the menu not changing colors when the custom colors are changed or enabled/disabled. - RegenPlugins leads to a loss of color. - Theme changes are broken due to overridden colors. The feature is also very niche and quite unecessary. If a custom color is better than the default one we should apply the change in the theme or define a new theme which inherits ours and simply defines the menu differently. The way to do this, in line with GTK's design, is via CSS at theme level. --- usr/lib/linuxmint/mintMenu/mintMenu.py | 75 ------------------- .../mintMenu/plugins/applications.py | 6 -- .../linuxmint/mintMenu/plugins/easybuttons.py | 9 --- .../mintMenu/plugins/system_management.py | 3 - usr/lib/linuxmint/mintMenu/preferences.py | 8 +- .../com.linuxmint.mintmenu.gschema.xml | 17 ----- 6 files changed, 4 insertions(+), 114 deletions(-) diff --git a/usr/lib/linuxmint/mintMenu/mintMenu.py b/usr/lib/linuxmint/mintMenu/mintMenu.py index 05e127e..2e1a9de 100755 --- a/usr/lib/linuxmint/mintMenu/mintMenu.py +++ b/usr/lib/linuxmint/mintMenu/mintMenu.py @@ -63,9 +63,6 @@ class MainWindow(object): builder.connect_signals(self) - self.panesToColor = [] - self.headingsToColor = [] - self.window.connect("key-press-event", self.onKeyPress) self.window.connect("focus-in-event", self.onFocusIn) self.loseFocusId = self.window.connect("focus-out-event", self.onFocusOut) @@ -79,9 +76,6 @@ class MainWindow(object): self.settings.connect("changed::plugins-list", self.RegenPlugins) self.settings.connect("changed::start-with-favorites", self.toggleStartWithFavorites) self.settings.connect("changed::tooltips-enabled", self.toggleTooltipsEnabled) - self.settings.connect("changed::use-custom-color", self.toggleUseCustomColor) - self.settings.connect("changed::custom-heading-color", self.toggleCustomHeadingColor) - self.settings.connect("changed::custom-color", self.toggleCustomBackgroundColor) self.getSetGSettingEntries() @@ -110,38 +104,20 @@ class MainWindow(object): def toggleStartWithFavorites(self, settings, key): self.startWithFavorites = settings.get_boolean(key) - def toggleUseCustomColor(self, settings, key): - self.usecustomcolor = settings.get_boolean(key) - self.loadTheme() - - def toggleCustomBackgroundColor(self, settings, key): - self.customcolor = settings.get_string(key) - self.setCustomColors() - - def toggleCustomHeadingColor(self, settings, key): - self.customheadingcolor = settings.get_string(key) - self.setCustomColors() - def getSetGSettingEntries(self): self.dottedfile = os.path.join(self.path, "dotted.png") self.pluginlist = self.settings.get_strv("plugins-list") - self.usecustomcolor = self.settings.get_boolean("use-custom-color") - self.customcolor = self.settings.get_string("custom-color") - self.customheadingcolor = self.settings.get_string("custom-heading-color") self.offset = self.settings.get_int("offset") self.enableTooltips = self.settings.get_boolean("tooltips-enabled") self.startWithFavorites = self.settings.get_boolean("start-with-favorites") def PopulatePlugins(self): - self.panesToColor = [] - self.headingsToColor = [] PluginPane = Gtk.EventBox() PluginPane.show() PaneLadder = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) PluginPane.add(PaneLadder) ImageBox = Gtk.EventBox() ImageBox.show() - self.panesToColor.extend([PluginPane, ImageBox]) seperatorImage = GdkPixbuf.Pixbuf.new_from_file(self.dottedfile) @@ -194,7 +170,6 @@ class MainWindow(object): MyPlugin.icon = 'mate-logo-icon.png' print("Unable to load %s plugin" % plugin) - self.panesToColor.append(MyPlugin.content_holder) MyPlugin.content_holder.show() VBox1 = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) @@ -204,7 +179,6 @@ class MainWindow(object): Align1 = Gtk.Alignment.new(0, 0, 0, 0) Align1.set_padding(10, 5, 10, 0) Align1.add(label1) - self.headingsToColor.append(label1) Align1.show() label1.show() heading = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) @@ -232,10 +206,6 @@ class MainWindow(object): MyPlugin.do_plugin() if hasattr(MyPlugin, 'height'): MyPlugin.content_holder.set_size_request(-1, MyPlugin.height) - if hasattr(MyPlugin, 'itemstocolor'): - self.panesToColor.extend(MyPlugin.itemstocolor) - if hasattr(MyPlugin, 'headingstocolor'): - self.headingsToColor.extend(MyPlugin.headingstocolor) except: # create traceback info = sys.exc_info() @@ -254,7 +224,6 @@ class MainWindow(object): PaneLadder = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) PluginPane.add(PaneLadder) ImageBox = Gtk.EventBox() - self.panesToColor.extend([PluginPane, ImageBox]) ImageBox.show() PluginPane.show_all() @@ -274,47 +243,6 @@ class MainWindow(object): self.paneholder.pack_start(ImageBox, False, False, 0) self.paneholder.pack_start(PluginPane, False, False, 0) - # A little bit hacky but works. - @staticmethod - def getDefaultColors(): - widget = Gtk.EventBox() - widget.show() - - context = widget.get_style_context() - context.set_state(Gtk.StateFlags.NORMAL) - context.add_class(Gtk.STYLE_CLASS_DEFAULT) - context.add_class(Gtk.STYLE_CLASS_BACKGROUND) - - fgColor = context.get_color(context.get_state()) - bgColor = context.get_background_color(context.get_state()) - - return {"fg": fgColor, "bg": bgColor} - - def loadTheme(self): - self.setCustomColors() - - def setCustomColors(self): - # Panes - for item in self.panesToColor: - context = item.get_style_context() - if self.usecustomcolor: - color = Gdk.RGBA() - color.parse(self.customcolor) - item.override_background_color(context.get_state(), color) - else: - 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) widget.set_tooltip_text(tip) @@ -343,7 +271,6 @@ class MainWindow(object): self.getSetGSettingEntries() self.PopulatePlugins() self.toggleTooltipsEnabled(self.settings, "tooltips-enabled") - self.loadTheme() #print NAME+u" reloaded" @@ -430,7 +357,6 @@ class MenuWin(object): self.mainwin.window.set_name("mintmenu") # Name used in Gtk RC files self.applyTheme() - self.mainwin.loadTheme() if self.mainwin.icon: Gtk.Window.set_default_icon_name(self.mainwin.icon) @@ -567,7 +493,6 @@ class MenuWin(object): def changeTheme(self, *args): self.reloadSettings() self.applyTheme() - self.mainwin.loadTheme() def applyTheme(self): style_settings = Gtk.Settings.get_default() diff --git a/usr/lib/linuxmint/mintMenu/plugins/applications.py b/usr/lib/linuxmint/mintMenu/plugins/applications.py index 9f4f6bc..2a84a25 100755 --- a/usr/lib/linuxmint/mintMenu/plugins/applications.py +++ b/usr/lib/linuxmint/mintMenu/plugins/applications.py @@ -212,7 +212,6 @@ class pluginclass(object): self.applicationsScrolledWindow = self.builder.get_object("applicationsScrolledWindow") - self.headingstocolor = [self.builder.get_object("label6"), self.builder.get_object("label2")] self.numApps = 0 # These properties are NECESSARY to maintain consistency @@ -225,11 +224,6 @@ class pluginclass(object): # This should be the first item added to the window in glade self.content_holder = self.builder.get_object("Applications") - # Items to get custom colors - self.itemstocolor = [self.builder.get_object("viewport1"), - self.builder.get_object("viewport2"), - self.builder.get_object("viewport3")] - # Unset all timers self.filterTimer = None self.menuChangedTimer = None diff --git a/usr/lib/linuxmint/mintMenu/plugins/easybuttons.py b/usr/lib/linuxmint/mintMenu/plugins/easybuttons.py index adf561c..e0ae576 100755 --- a/usr/lib/linuxmint/mintMenu/plugins/easybuttons.py +++ b/usr/lib/linuxmint/mintMenu/plugins/easybuttons.py @@ -453,15 +453,6 @@ class MenuApplicationLauncher(ApplicationLauncher): appComment = self.appComment if self.highlight: try: - #color = self.labelBox.get_style_context().get_color(Gtk.StateFlags.SELECTED).to_string() - #if len(color) > 0 and color[0] == "#": - #appName = "%s" % (color, appName); - #appComment = "%s" % (color, appComment); - #appName = "%s" % (appName); - #appComment = "%s" % (appComment); - #else: - #appName = "%s" % (appName); - #appComment = "%s" % (appComment); appName = "%s" % appName appComment = "%s" % appComment except Exception as e: diff --git a/usr/lib/linuxmint/mintMenu/plugins/system_management.py b/usr/lib/linuxmint/mintMenu/plugins/system_management.py index 673ee5d..cae13af 100755 --- a/usr/lib/linuxmint/mintMenu/plugins/system_management.py +++ b/usr/lib/linuxmint/mintMenu/plugins/system_management.py @@ -43,9 +43,6 @@ class pluginclass(object): # This should be the first item added to the window in glade self.content_holder = self.builder.get_object("System") - # Items to get custom colors - self.itemstocolor = [self.builder.get_object("viewport2")] - # Gconf stuff self.settings = Gio.Settings("com.linuxmint.mintmenu.plugins.system_management") diff --git a/usr/lib/linuxmint/mintMenu/preferences.py b/usr/lib/linuxmint/mintMenu/preferences.py index 040aef1..c342fdc 100755 --- a/usr/lib/linuxmint/mintMenu/preferences.py +++ b/usr/lib/linuxmint/mintMenu/preferences.py @@ -93,10 +93,10 @@ class mintMenuPreferences(): 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") + section = page.add_section(_("Appearance"), _("Custom 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") 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 16697af..c78d476 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 @@ -8,12 +8,6 @@ - - false - - - - false @@ -68,17 +62,6 @@ - - "#DEDEDE" - - - - - - "#3C3C3C" - - -