Commit ad72f1c8 authored by Florian Müllner's avatar Florian Müllner Committed by John Stowers
Browse files

Generalize support for shell's schema overrides

GNOME Shell overrides some settings to use different default values
than standalone mutter. With the introduction of classic mode, things
got a little more complicated, as some of the overrides were reverted
again by extensions - to support either mode, we needed to pick the
right schema for all affected settings.
The shell has now introduced mode-specific overrides, and classic mode
started to use that instead of extensions; this means we will now need
to adapt all settings that *both* normal and classic mode override.
However rather than adjusting the affected settings, the new approach
allows us to generalize the support for schema overrides depending on
the current mode - this should allow us to handle future changes to
overrides in either normal or classic mode automatically.


parent 3d3adcb6
......@@ -28,28 +28,20 @@ from gtweak.utils import walk_directories, extract_zip_file, make_combo_list_wit
from gtweak.gsettings import GSettingsSetting, GSettingsMissingError, GSettingsFakeSetting
from gtweak.gshellwrapper import GnomeShellFactory
from gtweak.tweakmodel import Tweak, TweakGroup, TWEAK_GROUP_THEME, TWEAK_GROUP_SHELL, TWEAK_SORT_LAST
from gtweak.widgets import FileChooserButton, GSettingsComboTweak, GSettingsComboEnumTweak, GSettingsSwitchTweak, build_label_beside_widget, build_horizontal_sizegroup, build_combo_box_text, UI_BOX_SPACING
from gtweak.widgets import FileChooserButton, GSettingsComboTweak, GSettingsComboEnumTweak, GSettingsSwitchTweak, adjust_schema_for_overrides, build_label_beside_widget, build_horizontal_sizegroup, build_combo_box_text, UI_BOX_SPACING
_shell = GnomeShellFactory().get_shell()
_shell_loaded = _shell is not None
class ShowWindowButtons(GSettingsComboTweak):
def __init__(self, **options):
if (_shell is not None) and (_shell.mode in ['gdm', 'initial-setup', 'user']):
schema = ""
filename = ""
schema = "org.gnome.desktop.wm.preferences"
filename = None
((':close', _("Close Only")),
(':minimize,close', _("Minimize and Close")),
(':maximize,close', _("Maximize and Close")),
(':minimize,maximize,close', _("All"))),
......@@ -214,16 +206,11 @@ class StaticWorkspaceTweak(Tweak):
NUM_WORKSPACES_SCHEMA = "org.gnome.desktop.wm.preferences"
NUM_WORKSPACES_KEY = "num-workspaces"
if (_shell is not None) and (_shell.mode in ['gdm', 'initial-setup', 'user']):
DYNAMIC_SCHEMA = "org.gnome.mutter"
DYNAMIC_KEY = "dynamic-workspaces"
DYNAMIC_SCHEMA = "org.gnome.mutter"
def __init__(self, **options):
schema = adjust_schema_for_overrides(self.DYNAMIC_SCHEMA, self.DYNAMIC_KEY, options)
Tweak.__init__(self, _("Dynamic workspaces"), _("Disable gnome-shell dynamic workspace management, use static workspaces"), **options)
......@@ -233,7 +220,7 @@ class StaticWorkspaceTweak(Tweak):
nwsettings = GSettingsFakeSetting()
dsettings = GSettingsSetting(self.DYNAMIC_SCHEMA, schema_filename=self.DYNAMIC_SCHEMA_FILENAME, **options)
dsettings = GSettingsSetting(schema, **options)
except GSettingsMissingError:
self.loaded = False
dsettings = GSettingsFakeSetting()
......@@ -273,6 +260,6 @@ TWEAK_GROUPS = (
GSettingsComboEnumTweak("org.gnome.settings-daemon.plugins.power", "lid-close-ac-action", size_group=sg),
GSettingsComboEnumTweak("org.gnome.settings-daemon.plugins.power", "button-power", size_group=sg),
GSettingsComboEnumTweak("org.gnome.settings-daemon.plugins.xrandr", "default-monitors-setup", size_group=sg),
GSettingsSwitchTweak("", "workspaces-only-on-primary", schema_filename="", loaded=_shell_loaded),
GSettingsSwitchTweak("org.gnome.mutter", "workspaces-only-on-primary", schema_filename="", loaded=_shell_loaded),
StaticWorkspaceTweak(size_group=sg, loaded=_shell_loaded)),
......@@ -24,8 +24,10 @@ from gtweak.tweakmodel import Tweak
from gtweak.gsettings import GSettingsSetting, GSettingsFakeSetting, GSettingsMissingError
from gtweak.gtksettings import GtkSettingsManager
from gtweak.gconf import GConfSetting
from gtweak.gshellwrapper import GnomeShellFactory
_shell = GnomeShellFactory().get_shell()
def build_label_beside_widget(txt, *widget, **kwargs):
......@@ -118,8 +120,26 @@ def build_tight_button(stock_id):
button.get_style_context().add_provider(provider, 600)
return button
def adjust_schema_for_overrides(originalSchema, key, options):
if (_shell is None):
return originalSchema
if (_shell.mode == 'classic'):
overridesSchema = ""
overridesFile = None
overridesSchema = ""
overridesFile = ""
if (key in Gio.Settings(overridesSchema).list_keys()):
options['schema_filename'] = overridesFile
return overridesSchema
return originalSchema
class _GSettingsTweak(Tweak):
def __init__(self, schema_name, key_name, **options):
schema_name = adjust_schema_for_overrides(schema_name, key_name, options)
self.schema_name = schema_name
self.key_name = key_name
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