Debian Codegraph @

extensions/workspace-indicator/workspacePrefs.js

raw
1 // SPDX-FileCopyrightText: 2012 Giovanni Campagna <[email protected]>
2 // SPDX-FileCopyrightText: 2014 Florian Müllner <[email protected]>
3 //
4 // SPDX-License-Identifier: GPL-2.0-or-later
5
6 import Adw from 'gi://Adw';
7 import Gio from 'gi://Gio';
8 import GObject from 'gi://GObject';
9 import Gtk from 'gi://Gtk';
10
11 import {gettext as _} from 'resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js';
12
13 class GeneralGroup extends Adw.PreferencesGroup {
14 static {
15 GObject.registerClass(this);
16 }
17
18 constructor(settings) {
19 super({
20 title: _('Indicator'),
21 });
22
23 const previewCheck = new Gtk.CheckButton();
24 const previewRow = new Adw.ActionRow({
25 title: _('Previews'),
26 activatable_widget: previewCheck,
27 });
28 previewRow.add_prefix(previewCheck);
29 this.add(previewRow);
30
31 const nameCheck = new Gtk.CheckButton({
32 group: previewCheck,
33 });
34 const nameRow = new Adw.ActionRow({
35 title: _('Workspace Name'),
36 activatable_widget: nameCheck,
37 });
38 nameRow.add_prefix(nameCheck);
39 this.add(nameRow);
40
41 if (settings.get_boolean('embed-previews'))
42 previewCheck.active = true;
43 else
44 nameCheck.active = true;
45
46 settings.bind('embed-previews',
47 previewCheck, 'active',
48 Gio.SettingsBindFlags.DEFAULT);
49 }
50 }
51
52 class BehaviorGroup extends Adw.PreferencesGroup {
53 static {
54 GObject.registerClass(this);
55 }
56
57 constructor() {
58 super({
59 title: _('Behavior'),
60 });
61
62 const dynamicCheck = new Gtk.CheckButton();
63 const dynamicRow = new Adw.ActionRow({
64 title: _('Dynamic'),
65 subtitle: _('Automatically removes empty workspaces.'),
66 activatable_widget: dynamicCheck,
67 });
68 dynamicRow.add_prefix(dynamicCheck);
69 this.add(dynamicRow);
70
71 const fixedCheck = new Gtk.CheckButton({
72 group: dynamicCheck,
73 });
74 const fixedRow = new Adw.ActionRow({
75 title: _('Fixed Number'),
76 subtitle: _('Specify a number of permanent workspaces.'),
77 activatable_widget: fixedCheck,
78 });
79 fixedRow.add_prefix(fixedCheck);
80 this.add(fixedRow);
81
82 const adjustment = new Gtk.Adjustment({
83 lower: 1,
84 step_increment: 1,
85 value: 4,
86 upper: 36, // hard limit in mutter
87 });
88 const numRow = new Adw.SpinRow({
89 title: _('Number of Workspaces'),
90 adjustment,
91 });
92 this.add(numRow);
93
94 const mutterSettings = new Gio.Settings({
95 schema_id: 'org.gnome.mutter',
96 });
97
98 if (mutterSettings.get_boolean('dynamic-workspaces'))
99 dynamicCheck.active = true;
100 else
101 fixedCheck.active = true;
102
103 mutterSettings.bind('dynamic-workspaces',
104 dynamicCheck, 'active',
105 Gio.SettingsBindFlags.DEFAULT);
106
107 const desktopSettings = new Gio.Settings({
108 schema_id: 'org.gnome.desktop.wm.preferences',
109 });
110
111 desktopSettings.bind('num-workspaces',
112 numRow, 'value',
113 Gio.SettingsBindFlags.DEFAULT);
114
115 fixedCheck.bind_property('active',
116 numRow, 'sensitive',
117 GObject.BindingFlags.SYNC_CREATE);
118 }
119 }
120
121 export class WorkspacesPage extends Adw.PreferencesPage {
122 static {
123 GObject.registerClass(this);
124 }
125
126 constructor(settings) {
127 super({
128 title: _('Workspaces'),
129 icon_name: 'view-grid-symbolic',
130 });
131
132 this.add(new GeneralGroup(settings));
133 this.add(new BehaviorGroup());
134 }
135 }