forked from ChWick/gnomesome
-
Notifications
You must be signed in to change notification settings - Fork 0
/
prefs.js
258 lines (216 loc) · 7.27 KB
/
prefs.js
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
/* -*- mode: js; js-basic-offset: 4; indent-tabs-mode: spaces -*- */
const Gtk = imports.gi.Gtk;
const GLib = imports.gi.GLib
const Config = imports.misc.config;
const Me = imports.misc.extensionUtils.getCurrentExtension();
const GnomesomeSettings = Me.imports.gnomesome_settings;
const Gettext = imports.gettext.domain('gnomesome');
const _ = Gettext.gettext;
function init(){
// TODO: Translation
// GnomesomeSettings.initTranslations();
}
function buildPrefsWidget() {
let settings = new GnomesomeSettings.Prefs();
let frame = new Gtk.Box({
orientation: Gtk.Orientation.VERTICAL,
border_width: 10
});
let vbox = new Gtk.Box({
orientation: Gtk.Orientation.VERTICAL,
spacing: 14
});
// General
// ===============================================================
(function() {
let label = new Gtk.Label({
label: _("<b>General:</b>"),
use_markup: true,
xalign: 0
});
vbox.add(label)
})();
(function() {
var hbox = new Gtk.Box({
orientation: Gtk.Orientation.HORIZONTAL,
spacing: 20
});
var label = new Gtk.Label({ label: _("Launch new terminal command:")} );
var textfield = new Gtk.Entry();
hbox.pack_start(label, false, false, 0);
hbox.pack_start(textfield, false, false, 0);
vbox.add(hbox);
var pref = settings.LAUNCH_TERMINAL;
textfield.set_text(pref.get());
textfield.connect('activate', function() {
pref.set(textfield.get_text());
});
})();
(function() {
var hbox = new Gtk.Box({
orientation: Gtk.Orientation.HORIZONTAL,
spacing: 20
});
var checkbutton = new Gtk.CheckButton({ label: _("Show indicator in status panel") });
hbox.pack_end(checkbutton, true, true, 0);
vbox.add(hbox);
var pref = settings.SHOW_INDICATOR;
checkbutton.set_active(pref.get());
checkbutton.connect('toggled', function(sw) {
var newval = sw.get_active();
if (newval !== pref.get()) {
pref.set(newval);
}
});
})();
(function() {
var hbox = new Gtk.Box({
orientation: Gtk.Orientation.HORIZONTAL,
spacing: 20
});
var checkbutton = new Gtk.CheckButton({ label: _("Pointer follows focus") });
hbox.pack_end(checkbutton, true, true, 0);
vbox.add(hbox);
var pref = settings.POINTER_FOLLOWS_FOCUS;
checkbutton.set_active(pref.get());
checkbutton.connect('toggled', function(sw) {
var newval = sw.get_active();
if (newval !== pref.get()) {
pref.set(newval);
}
});
})();
// Tiling
// ===============================================================
(function() {
let label = new Gtk.Label({
label: _("<b>Tiling:</b>"),
use_markup: true,
xalign: 0
});
vbox.add(label);
})();
(function() {
var hbox = new Gtk.Box({
orientation: Gtk.Orientation.HORIZONTAL,
spacing: 20
});
var label = new Gtk.Label({ label: _("Default layout:"), });
var radio_box = new Gtk.Box({
orientation: Gtk.Orientation.VERTICAL,
spacing: 2
});
var r_floating = new Gtk.RadioButton( { label: _("Floating") });
var r_vertical = new Gtk.RadioButton( { label: _("Vertical"), group: r_floating });
var r_horizontal = new Gtk.RadioButton({ label: _("Horizontal"), group: r_floating });
var r_maximized = new Gtk.RadioButton({ label: _("Maximized"), group: r_floating });
var layout_radios =
{
'floating': r_floating,
'horizontal': r_horizontal,
'vertical': r_vertical,
'maximized': r_maximized
};
var pref = settings.DEFAULT_LAYOUT;
var active = layout_radios[pref.get()];
if(active) {
active.set_active(true);
}
var init_radio = function(k) {
var radio = layout_radios[k];
radio.connect('toggled', function() {
if(radio.get_active()) {
pref.set(k);
}
});
radio_box.add(radio);
};
init_radio('floating');
init_radio('vertical');
init_radio('horizontal');
init_radio('maximized');
hbox.add(label);
hbox.add(radio_box);
vbox.add(hbox);
})();
(function() {
var hbox = new Gtk.Box({
orientation: Gtk.Orientation.HORIZONTAL,
spacing: 20
});
var label = new Gtk.Label({ label: _("Inner gaps:")} );
var spin = new Gtk.SpinButton();
spin.set_range(0, 100);
spin.set_increments(1, 5);
hbox.add(label);
hbox.add(spin);
vbox.add(hbox);
var pref = settings.INNER_GAPS;
spin.set_value(pref.get());
spin.connect('value-changed', function() {
pref.set(spin.get_value_as_int());
});
})();
(function() {
var hbox = new Gtk.Box({
orientation: Gtk.Orientation.HORIZONTAL,
spacing: 20
});
var label = new Gtk.Label({ label: _("Outer gaps:")} );
var spin = new Gtk.SpinButton();
spin.set_range(0, 100);
spin.set_increments(1, 5);
hbox.add(label);
hbox.add(spin);
vbox.add(hbox);
var pref = settings.OUTER_GAPS;
spin.set_value(pref.get());
spin.connect('value-changed', function() {
pref.set(spin.get_value_as_int());
});
})();
let sep = new Gtk.HSeparator();
vbox.add(sep);
// Keybindings
// ===============================================================
(function() {
let label = new Gtk.Label({
label: _("<b>Advanced settings:</b>"),
use_markup: true,
xalign: 0
});
vbox.add(label);
})();
(function() {
var hbox = new Gtk.Box({
orientation: Gtk.Orientation.HORIZONTAL,
spacing: 20
});
var label = new Gtk.Label({
label: _("Edit keyboard settings") +
"\n<small>"+_("(make sure you have dconf-editor installed)")+"\n" +
_("Navigate to")+" org/gnome/shell/extensions/gnomesome.keybindings</small>",
use_markup: true});
var button = new Gtk.Button({
label: 'dconf-editor'
});
var error_msg = new Gtk.Label();
button.connect('clicked', function(sw) {
try {
// The magic sauce that lets dconf-editor see our local schema:
var envp = GnomesomeSettings.envp_with_gnomesome_xdg_data_dir();
GLib.spawn_async(null, ['dconf-editor'], envp, GLib.SpawnFlags.SEARCH_PATH, null);
} catch(e) {
error_msg.set_label(_("ERROR: Could not launch dconf-editor. Is it installed?"));
throw e;
}
});
hbox.add(label);
hbox.pack_end(button, false, false, 0);
vbox.add(hbox);
vbox.add(error_msg);
})();
frame.add(vbox);
frame.show_all();
return frame;
}