1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
|
# Copyright (c) 2011 John Stowers
# SPDX-License-Identifier: GPL-3.0+
# License-Filename: LICENSES/GPL-3.0
from gi.repository import Gio, GLib, Gtk
import gtweak
from gtweak.gshellwrapper import GnomeShellFactory
from gtweak.tweakmodel import Tweak
from gtweak.widgets import ListBoxTweakGroup, build_horizontal_sizegroup, Title, GSettingsSpinButtonTweak, _GSettingsTweak
_shell = GnomeShellFactory().get_shell()
_shell_loaded = _shell is not None
class StaticWorkspaceTweak(Gtk.ListBox, _GSettingsTweak):
def __init__(self, **options):
name = _("Dynamic Workspaces")
Gtk.ListBox.__init__(self)
_GSettingsTweak.__init__(self, name, "org.gnome.mutter", "dynamic-workspaces", loaded=_shell_loaded)
self.set_selection_mode(Gtk.SelectionMode.NONE)
# Needs other page elements to get margins too
# self.props.margin_left = 50
# self.props.margin_right = 50
row = Gtk.ListBoxRow()
hbox = Gtk.Box()
hbox.props.margin = 10
row.add(hbox)
vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
lbl = Gtk.Label(name, xalign=0)
lbl.props.xalign = 0.0
desc = _("Workspaces can be created on demand, and are automatically removed when empty.")
lbl_desc = Gtk.Label()
lbl_desc.set_line_wrap(True)
lbl_desc.get_style_context().add_class("dim-label")
lbl_desc.set_markup("<span size='small'>"+GLib.markup_escape_text(desc)+"</span>")
self.check1 = Gtk.Image.new_from_icon_name("object-select-symbolic", Gtk.IconSize.SMALL_TOOLBAR);
self.check1.set_no_show_all(True)
self.check1.set_visible(self.settings[self.key_name])
vbox.pack_start(lbl, False, False, 0)
vbox.pack_start(lbl_desc, False, False, 0)
hbox.pack_start(vbox, False, False, 0)
hbox.pack_end(self.check1, False, False, 0)
self.add(row)
row = Gtk.ListBoxRow()
hbox = Gtk.Box()
hbox.props.margin = 10
row.add(hbox)
vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
lbl = Gtk.Label(_("Static Workspaces"), xalign=0)
lbl.props.xalign = 0.0
desc = _("Number of workspaces is fixed.")
lbl_desc = Gtk.Label()
lbl_desc.set_line_wrap(True)
lbl_desc.get_style_context().add_class("dim-label")
lbl_desc.set_markup("<span size='small'>"+GLib.markup_escape_text(desc)+"</span>")
self.check2 = Gtk.Image.new_from_icon_name("object-select-symbolic", Gtk.IconSize.SMALL_TOOLBAR);
self.check2.set_no_show_all(True)
self.check2.set_visible(not self.settings[self.key_name])
vbox.pack_start(lbl, False, False, 0)
vbox.pack_start(lbl_desc, False, False, 0)
hbox.pack_start(vbox, False, False, 0)
hbox.pack_end(self.check2, False, False, 0)
self.add(row)
self.connect('row-activated', self.on_row_clicked)
def on_row_clicked(self, box, row):
if row.get_index() == 0:
self.settings[self.key_name] = True
self.check1.show()
self.check2.hide()
else:
self.settings[self.key_name] = False
self.check1.hide()
self.check2.show()
class PrimaryWorkspaceTweak(Gtk.ListBox, Tweak):
def __init__(self, **options):
name = _("Workspaces")
Gtk.ListBox.__init__(self)
Tweak.__init__(self, _("Display Handling"), _("Workspaces span displays"), loaded=_shell_loaded,)
_GSettingsTweak.__init__(self, name, "org.gnome.mutter", "workspaces-only-on-primary", loaded=_shell_loaded)
self.set_selection_mode(Gtk.SelectionMode.NONE)
# Needs other page elements to get margins too
# self.props.margin_left = 50
# self.props.margin_right = 50
row = Gtk.ListBoxRow()
hbox = Gtk.Box()
hbox.props.margin = 10
row.add(hbox)
vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
lbl = Gtk.Label(_("Workspaces on primary display only"), xalign=0)
lbl.props.xalign = 0.0
desc = _("Additional displays are treated as independent workspaces.")
lbl_desc = Gtk.Label()
lbl_desc.set_line_wrap(True)
lbl_desc.get_style_context().add_class("dim-label")
lbl_desc.set_markup("<span size='small'>"+GLib.markup_escape_text(desc)+"</span>")
self.check1 = Gtk.Image.new_from_icon_name("object-select-symbolic", Gtk.IconSize.SMALL_TOOLBAR);
self.check1.set_no_show_all(True)
self.check1.set_visible(self.settings[self.key_name])
vbox.pack_start(lbl, False, False, 0)
vbox.pack_start(lbl_desc, False, False, 0)
hbox.pack_start(vbox, False, False, 0)
hbox.pack_end(self.check1, False, False, 0)
self.add(row)
row = Gtk.ListBoxRow()
hbox = Gtk.Box()
hbox.props.margin = 10
row.add(hbox)
vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
lbl = Gtk.Label(_("Workspaces span displays"), xalign=0)
lbl.props.xalign = 0.0
desc = _("The current workspace includes additional displays.")
lbl_desc = Gtk.Label()
lbl_desc.set_line_wrap(True)
lbl_desc.get_style_context().add_class("dim-label")
lbl_desc.set_markup("<span size='small'>"+GLib.markup_escape_text(desc)+"</span>")
self.check2 = Gtk.Image.new_from_icon_name("object-select-symbolic", Gtk.IconSize.SMALL_TOOLBAR);
self.check2.set_no_show_all(True)
self.check2.set_visible(not self.settings[self.key_name])
vbox.pack_start(lbl, False, False, 0)
vbox.pack_start(lbl_desc, False, False, 0)
hbox.pack_start(vbox, False, False, 0)
hbox.pack_end(self.check2, False, False, 0)
self.add(row)
self.connect('row-activated', self.on_row_clicked)
def on_row_clicked(self, box, row):
if row.get_index() == 0:
self.settings[self.key_name] = True
self.check1.show()
self.check2.hide()
else:
self.settings[self.key_name] = False
self.check1.hide()
self.check2.show()
sg = build_horizontal_sizegroup()
sw = StaticWorkspaceTweak(size_group=sg, loaded=_shell_loaded)
depends_how = lambda x,kn: not(x.get_boolean(kn))
TWEAK_GROUPS = [
ListBoxTweakGroup(_("Workspaces"),
sw,
GSettingsSpinButtonTweak(_("Number of Workspaces"), "org.gnome.desktop.wm.preferences", "num-workspaces", depends_on = sw, depends_how=depends_how, size_group=sg, loaded=_shell_loaded),
Title(_("Display Handling"), "", uid="title-theme", loaded=_shell_loaded),
PrimaryWorkspaceTweak(),
)
]
|