...
 
Commits (2)
# Copyright (c) 2011 John Stowers
# SPDX-License-Identifier: GPL-3.0+
# License-Filename: LICENSES/GPL-3.0
import gtweak
from gtweak.tweakmodel import Tweak
from gtweak.widgets import ListBoxTweakGroup, GSettingsComboEnumTweak, Title, GSettingsSwitchTweakValue, build_label_beside_widget, _GSettingsTweak
from gi.repository import Gtk
class ShowWindowButtons(GSettingsSwitchTweakValue):
def __init__(self, name, value, **options):
self.value = value
GSettingsSwitchTweakValue.__init__(self,
name,
"org.gnome.desktop.wm.preferences",
"button-layout",
**options)
def get_active(self):
return self.value in self.settings.get_string(self.key_name)
def set_active(self, v):
val = self.settings.get_string(self.key_name)
(left, colon, right) = val.partition(":")
if "close" in right:
rsplit = right.split(",")
rsplit = [x for x in rsplit if x in ['appmenu', 'minimize', 'maximize', 'close']]
if v:
rsplit.append(self.value)
else:
rsplit.remove(self.value)
rsplit.sort(key=lambda x: ["appmenu", "minimize", "maximize", "close"].index(x))
self.settings.set_string(self.key_name, left + colon + ",".join(rsplit))
else:
rsplit = left.split(",")
rsplit = [x for x in rsplit if x in ['appmenu', 'minimize', 'maximize', 'close']]
if v:
rsplit.append(self.value)
else:
rsplit.remove(self.value)
rsplit.sort(key=lambda x: ["close", "minimize", "maximize", "appmenu"].index(x))
self.settings.set_string(self.key_name, ",".join(rsplit) + colon + right)
class PlaceWindowButtons(Gtk.Box, _GSettingsTweak):
def __init__(self, **options):
name = _("Placement")
Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL, spacing=0)
_GSettingsTweak.__init__(self,
name,
"org.gnome.desktop.wm.preferences",
"button-layout",
**options)
box_btn = Gtk.ButtonBox()
box_btn.set_layout(Gtk.ButtonBoxStyle.EXPAND)
# Translators: For RTL languages, this is the "Right" direction since the
# interface is flipped
btn1 = Gtk.RadioButton.new_with_label_from_widget(None, _("Left"))
btn1.set_property("draw-indicator", False)
btn2 = Gtk.RadioButton.new_from_widget(btn1)
# Translators: For RTL languages, this is the "Left" direction since the
# interface is flipped
btn2.set_label(_("Right"))
btn2.set_property("draw-indicator", False)
val = self.settings.get_string(self.key_name)
(left, colon, right) = val.partition(":")
if "close" in right:
btn2.set_active(True)
btn2.connect("toggled", self.on_button_toggled)
box_btn.pack_start(btn1, True, True, 0)
box_btn.pack_start(btn2, True, True, 0)
build_label_beside_widget(name, box_btn, hbox=self)
def on_button_toggled(self, v):
val = self.settings.get_string(self.key_name)
(left, colon, right) = val.partition(":")
if "close" in left:
rsplit = left.split(",")
rsplit = [x for x in rsplit if x in ['appmenu', 'minimize', 'maximize', 'close']]
rsplit.sort(key=lambda x: ["appmenu", "minimize", "maximize", "close"].index(x))
self.settings.set_string(self.key_name, right + colon + ",".join(rsplit))
else:
rsplit = right.split(",")
rsplit = [x for x in rsplit if x in ['appmenu', 'minimize', 'maximize', 'close']]
rsplit.sort(key=lambda x: ["close", "minimize", "maximize", "appmenu"].index(x))
self.settings.set_string(self.key_name, ",".join(rsplit) + colon + left)
TWEAK_GROUPS = [
ListBoxTweakGroup(_("Window Titlebars"),
Title(_("Titlebar Actions"), "", uid="title-titlebar-actions"),
GSettingsComboEnumTweak(_("Double-Click"),"org.gnome.desktop.wm.preferences", "action-double-click-titlebar"),
GSettingsComboEnumTweak(_("Middle-Click"),"org.gnome.desktop.wm.preferences", "action-middle-click-titlebar"),
GSettingsComboEnumTweak(_("Secondary-Click"),"org.gnome.desktop.wm.preferences", "action-right-click-titlebar"),
Title(_("Titlebar Buttons"), "", uid="title-theme"),
ShowWindowButtons(_("Maximize"), "maximize"),
ShowWindowButtons(_("Minimize"), "minimize"),
PlaceWindowButtons(),
)
]
......@@ -3,9 +3,8 @@
# License-Filename: LICENSES/GPL-3.0
import gtweak
from gtweak.gshellwrapper import GnomeShellFactory
from gtweak.tweakmodel import Tweak
from gtweak.widgets import ListBoxTweakGroup, GSettingsComboEnumTweak, GSettingsComboTweak, GSettingsSwitchTweak, Title, GSettingsSwitchTweakValue, build_label_beside_widget, _GSettingsTweak
from gtweak.widgets import ListBoxTweakGroup, GSettingsComboTweak, GSettingsSwitchTweak, Title, build_label_beside_widget
from gtweak.utils import XSettingsOverrides
import gettext
......@@ -124,100 +123,6 @@ class Focus(Gtk.ListBox, Tweak):
self.check_mouse.show()
class ShowWindowButtons(GSettingsSwitchTweakValue):
def __init__(self, name, value, **options):
self.value = value
GSettingsSwitchTweakValue.__init__(self,
name,
"org.gnome.desktop.wm.preferences",
"button-layout",
**options)
def get_active(self):
return self.value in self.settings.get_string(self.key_name)
def set_active(self, v):
val = self.settings.get_string(self.key_name)
(left, colon, right) = val.partition(":")
if "close" in right:
rsplit = right.split(",")
rsplit = [x for x in rsplit if x in ['appmenu', 'minimize', 'maximize', 'close']]
if v:
rsplit.append(self.value)
else:
rsplit.remove(self.value)
rsplit.sort(key=lambda x: ["appmenu", "minimize", "maximize", "close"].index(x))
self.settings.set_string(self.key_name, left + colon + ",".join(rsplit))
else:
rsplit = left.split(",")
rsplit = [x for x in rsplit if x in ['appmenu', 'minimize', 'maximize', 'close']]
if v:
rsplit.append(self.value)
else:
rsplit.remove(self.value)
rsplit.sort(key=lambda x: ["close", "minimize", "maximize", "appmenu"].index(x))
self.settings.set_string(self.key_name, ",".join(rsplit) + colon + right)
class PlaceWindowButtons(Gtk.Box, _GSettingsTweak):
def __init__(self, **options):
name = _("Placement")
Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL, spacing=0)
_GSettingsTweak.__init__(self,
name,
"org.gnome.desktop.wm.preferences",
"button-layout",
**options)
box_btn = Gtk.ButtonBox()
box_btn.set_layout(Gtk.ButtonBoxStyle.EXPAND)
# Translators: For RTL languages, this is the "Right" direction since the
# interface is flipped
btn1 = Gtk.RadioButton.new_with_label_from_widget(None, _("Left"))
btn1.set_property("draw-indicator", False)
btn2 = Gtk.RadioButton.new_from_widget(btn1)
# Translators: For RTL languages, this is the "Left" direction since the
# interface is flipped
btn2.set_label(_("Right"))
btn2.set_property("draw-indicator", False)
val = self.settings.get_string(self.key_name)
(left, colon, right) = val.partition(":")
if "close" in right:
btn2.set_active(True)
btn2.connect("toggled", self.on_button_toggled)
box_btn.pack_start(btn1, True, True, 0)
box_btn.pack_start(btn2, True, True, 0)
build_label_beside_widget(name, box_btn, hbox=self)
def on_button_toggled(self, v):
val = self.settings.get_string(self.key_name)
(left, colon, right) = val.partition(":")
if "close" in left:
rsplit = left.split(",")
rsplit = [x for x in rsplit if x in ['appmenu', 'minimize', 'maximize', 'close']]
rsplit.sort(key=lambda x: ["appmenu", "minimize", "maximize", "close"].index(x))
self.settings.set_string(self.key_name, right + colon + ",".join(rsplit))
else:
rsplit = right.split(",")
rsplit = [x for x in rsplit if x in ['appmenu', 'minimize', 'maximize', 'close']]
rsplit.sort(key=lambda x: ["close", "minimize", "maximize", "appmenu"].index(x))
self.settings.set_string(self.key_name, ",".join(rsplit) + colon + left)
class WindowScalingFactorTweak(Gtk.Box, Tweak):
def __init__(self, **options):
Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL)
......@@ -298,6 +203,9 @@ TWEAK_GROUPS = [
ListBoxTweakGroup(_("Windows"),
GSettingsSwitchTweak(_("Attach Modal Dialogs"),"org.gnome.mutter", "attach-modal-dialogs",
desc=_("When on, modal dialog windows are attached to their parent windows, and cannot be moved.")),
# https://help.gnome.org/users/gnome-help/stable/shell-windows-tiled.html
GSettingsSwitchTweak(_("Edge Tiling"),"org.gnome.mutter", "edge-tiling",
desc=_("When on, windows are tiled when dragged to screen edges.")),
GSettingsSwitchTweak(_("Resize with Secondary-Click"),"org.gnome.desktop.wm.preferences", "resize-with-right-button"),
GSettingsComboTweak(_("Window Action Key"),
"org.gnome.desktop.wm.preferences",
......@@ -306,14 +214,6 @@ TWEAK_GROUPS = [
Title(_("Window Focus"), _("Click to Focus"), uid="title-theme"),
Focus(),
GSettingsSwitchTweak(_("Raise Windows When Focused"),"org.gnome.desktop.wm.preferences", "auto-raise", depends_on=Focus(), depends_how=depends_how),
Title(_("Titlebar Actions"), "", uid="title-titlebar-actions"),
GSettingsComboEnumTweak(_("Double-Click"),"org.gnome.desktop.wm.preferences", "action-double-click-titlebar"),
GSettingsComboEnumTweak(_("Middle-Click"),"org.gnome.desktop.wm.preferences", "action-middle-click-titlebar"),
GSettingsComboEnumTweak(_("Secondary-Click"),"org.gnome.desktop.wm.preferences", "action-right-click-titlebar"),
Title(_("Titlebar Buttons"), "", uid="title-theme"),
ShowWindowButtons(_("Maximize"), "maximize"),
ShowWindowButtons(_("Minimize"), "minimize"),
PlaceWindowButtons(),
)
]