Commit 72e5f6da authored by Jeremy Bicha's avatar Jeremy Bicha 🎹

appearance: remove Global Dark Theme tweak

And turn it off when the Applications theme is changed.

https://bugzilla.gnome.org/show_bug.cgi?id=783666
parent 7102e259
...@@ -17,7 +17,8 @@ from gtweak.utils import walk_directories, make_combo_list_with_default, extract ...@@ -17,7 +17,8 @@ from gtweak.utils import walk_directories, make_combo_list_with_default, extract
from gtweak.tweakmodel import Tweak from gtweak.tweakmodel import Tweak
from gtweak.gshellwrapper import GnomeShellFactory from gtweak.gshellwrapper import GnomeShellFactory
from gtweak.gsettings import GSettingsSetting from gtweak.gsettings import GSettingsSetting
from gtweak.widgets import ListBoxTweakGroup, GSettingsSwitchTweak, GSettingsComboTweak, DarkThemeSwitcher, Title, build_combo_box_text,build_label_beside_widget, FileChooserButton from gtweak.gtksettings import GtkSettingsManager
from gtweak.widgets import ListBoxTweakGroup, GSettingsSwitchTweak, GSettingsComboTweak, Title, build_combo_box_text,build_label_beside_widget, FileChooserButton
_shell = GnomeShellFactory().get_shell() _shell = GnomeShellFactory().get_shell()
_shell_loaded = _shell is not None _shell_loaded = _shell is not None
...@@ -31,6 +32,9 @@ class GtkThemeSwitcher(GSettingsComboTweak): ...@@ -31,6 +32,9 @@ class GtkThemeSwitcher(GSettingsComboTweak):
make_combo_list_with_default(self._get_valid_themes(), "Adwaita"), make_combo_list_with_default(self._get_valid_themes(), "Adwaita"),
**options) **options)
self._gtksettings3 = GtkSettingsManager('3.0')
self._gtksettings4 = GtkSettingsManager('4.0')
def _get_valid_themes(self): def _get_valid_themes(self):
""" Only shows themes that have variations for gtk3""" """ Only shows themes that have variations for gtk3"""
gtk_ver = Gtk.MINOR_VERSION gtk_ver = Gtk.MINOR_VERSION
...@@ -46,6 +50,22 @@ class GtkThemeSwitcher(GSettingsComboTweak): ...@@ -46,6 +50,22 @@ class GtkThemeSwitcher(GSettingsComboTweak):
os.path.exists(os.path.join(d, "gtk-3.{}".format(gtk_ver)))) os.path.exists(os.path.join(d, "gtk-3.{}".format(gtk_ver))))
return set(valid) return set(valid)
def _on_combo_changed(self, combo):
_iter = combo.get_active_iter()
if _iter:
value = combo.get_model().get_value(_iter, 0)
self.settings.set_string(self.key_name, value)
# Turn off Global Dark Theme when theme is changed.
# https://bugzilla.gnome.org/783666
try:
self._gtksettings3.set_integer("gtk-application-prefer-dark-theme",
0)
self._gtksettings4.set_integer("gtk-application-prefer-dark-theme",
0)
except:
self.notify_information(_("Error writing setting"))
class IconThemeSwitcher(GSettingsComboTweak): class IconThemeSwitcher(GSettingsComboTweak):
def __init__(self, **options): def __init__(self, **options):
GSettingsComboTweak.__init__(self, GSettingsComboTweak.__init__(self,
...@@ -243,7 +263,6 @@ class ShellThemeTweak(Gtk.Box, Tweak): ...@@ -243,7 +263,6 @@ class ShellThemeTweak(Gtk.Box, Tweak):
TWEAK_GROUPS = [ TWEAK_GROUPS = [
ListBoxTweakGroup(_("Appearance"), ListBoxTweakGroup(_("Appearance"),
DarkThemeSwitcher(),
#GSettingsSwitchTweak("Buttons Icons","org.gnome.desktop.interface", "buttons-have-icons"), #GSettingsSwitchTweak("Buttons Icons","org.gnome.desktop.interface", "buttons-have-icons"),
#GSettingsSwitchTweak("Menu Icons","org.gnome.desktop.interface", "menus-have-icons"), #GSettingsSwitchTweak("Menu Icons","org.gnome.desktop.interface", "menus-have-icons"),
GSettingsSwitchTweak(_("Animations"), "org.gnome.desktop.interface", "enable-animations"), GSettingsSwitchTweak(_("Animations"), "org.gnome.desktop.interface", "enable-animations"),
......
...@@ -484,51 +484,6 @@ class GetterSetterSwitchTweak(Gtk.Box, Tweak): ...@@ -484,51 +484,6 @@ class GetterSetterSwitchTweak(Gtk.Box, Tweak):
def set_active(self, v): def set_active(self, v):
raise NotImplementedError() raise NotImplementedError()
class DarkThemeSwitcher(Gtk.Box, Tweak):
def __init__(self, **options):
Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL)
Tweak.__init__(self, _("Enable dark theme for all applications"),
_("Enable the dark theme hint for all the applications in the session"),
**options)
self._gtksettings3 = GtkSettingsManager('3.0')
self._gtksettings4 = GtkSettingsManager('4.0')
w = Gtk.Switch()
w.set_active(self._gtksettings3.get_integer("gtk-application-prefer-dark-theme"))
title = _("Global Dark Theme")
description = _("Applications need to be restarted for this change to take place.")
w.connect("notify::active", self._on_switch_changed)
hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
hbox.props.spacing = UI_BOX_SPACING
lbl = Gtk.Label(label=title)
lbl.props.ellipsize = Pango.EllipsizeMode.END
lbl.props.xalign = 0.0
hbox.pack_start(lbl, True, True, 0)
hbox.pack_start(w, False, False, 0)
lbl_des = Gtk.Label()
lbl_des.props.xalign = 0.0
lbl_des.get_style_context().add_class("dim-label")
lbl_des.set_markup("<span size='small'>"+GLib.markup_escape_text(description)+"</span>")
self.pack_start(hbox, False, False, 0)
self.pack_start(lbl_des, False, False,0)
self.widget_for_size_group = None
def _on_switch_changed(self, switch, param):
active = switch.get_active()
try:
self._gtksettings3.set_integer("gtk-application-prefer-dark-theme",
active)
self._gtksettings4.set_integer("gtk-application-prefer-dark-theme",
active)
except:
self.notify_information(_("Error writing setting"))
class Title(Gtk.Box, Tweak): class Title(Gtk.Box, Tweak):
def __init__(self, name, desc, **options): def __init__(self, name, desc, **options):
Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL) Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment