forked from tuxor1337/hidetopbar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
prefs.js
294 lines (232 loc) · 9.72 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
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
const Gtk = imports.gi.Gtk;
const GObject = imports.gi.GObject;
const Gettext = imports.gettext.domain('hidetopbar');
const _ = Gettext.gettext;
const ExtensionUtils = imports.misc.extensionUtils;
const Me = ExtensionUtils.getCurrentExtension();
const Convenience = Me.imports.convenience;
let settings;
function init() {
settings = Convenience.getSettings();
Convenience.initTranslations("hidetopbar");
}
function buildPrefsWidget() {
let frame = new Gtk.VBox({border_width: 10});
/******************************************************************************
************************************** Section Sensitivity *******************
******************************************************************************/
frame.pack_start(new Gtk.Label({
label: _("<b>Sensitivity</b>"),
use_markup: true,
xalign: 0
}), false, false, 0);
let settings_vbox = new Gtk.VBox({margin_left: 20, margin_top: 10});
let settings_array = [
['mouse-sensitive',_("Show panel when mouse approaches edge of the screen")],
['hot-corner',_("Keep hot corner sensitive, even in hidden state")],
['mouse-triggers-overview',_("In the above case show overview, too")],
];
settings_array.forEach(function (s) {
let hbox = new Gtk.HBox();
let onoff = new Gtk.Switch({active: settings.get_boolean(s[0])});
hbox.pack_start(new Gtk.Label({
label: s[1],
use_markup: true,
xalign: 0
}), true, true, 0);
hbox.pack_end(onoff, false, false, 0);
settings.connect('changed::'+s[0], function(k,b) {
onoff.set_active(settings.get_boolean(b)); });
onoff.connect('notify::active', function(w) {
settings.set_boolean(s[0], w.active);
});
settings_vbox.pack_start(hbox, false,false, 0);
});
frame.pack_start(settings_vbox, true, true, 0);
let settings_vbox = new Gtk.VBox({margin_left: 20, margin_bottom: 10});
let settings_array = [
['pressure-threshold',_("Pressure barrier's threshold.")],
['pressure-timeout',_("Pressure barrier's timeout.")]
];
settings_array.forEach(function (s) {
let hbox = new Gtk.HBox();
let spin = Gtk.SpinButton.new_with_range(0,10000,1);
spin.set_value(settings.get_int(s[0]));
hbox.pack_start(new Gtk.Label({
label: s[1],
use_markup: true,
xalign: 0
}), true, true, 0);
hbox.pack_end(spin, false, false, 0);
settings.connect('changed::'+s[0], function(k,b) {
spin.set_value(settings.get_int(b)); });
spin.connect('value-changed', function(w) {
settings.set_int(s[0], w.get_value());
});
settings_vbox.pack_start(hbox, false,false, 0);
});
frame.pack_start(settings_vbox, true, true, 0);
/******************************************************************************
************************************** Section Animation *********************
******************************************************************************/
frame.pack_start(new Gtk.Label({
label: _("<b>Animation</b>"),
use_markup: true,
xalign: 0
}), false, false, 0);
let settings_vbox = new Gtk.VBox({margin_left: 20, margin_top: 10, margin_bottom: 10});
let settings_array = [
['animation-time-overview',_("Slide animation time when entering/leaving overview.")],
['animation-time-autohide',_("Slide animation time when mouse approaches edge of the screen.")]
];
settings_array.forEach(function (s) {
let hbox = new Gtk.HBox();
let spin = Gtk.SpinButton.new_with_range(0.0,1.0,0.1);
spin.set_value(settings.get_double(s[0]));
hbox.pack_start(new Gtk.Label({
label: s[1],
use_markup: true,
xalign: 0
}), true, true, 0);
hbox.pack_end(spin, false, false, 0);
settings.connect('changed::'+s[0], function(k,b) {
spin.set_value(settings.get_double(b)); });
spin.connect('value-changed', function(w) {
settings.set_double(s[0], w.get_value());
});
settings_vbox.pack_start(hbox, false,false, 0);
});
frame.pack_start(settings_vbox, true, true, 0);
/******************************************************************************
************************************** Section Shortcuts *********************
******************************************************************************/
frame.pack_start(new Gtk.Label({
label: _("<b>Keyboard shortcuts</b>"),
use_markup: true,
xalign: 0
}), false, false, 0);
let settings_vbox = new Gtk.VBox({margin_left: 20, margin_top: 10});
/* ++++++++++++++++++++++++++++++++++++ Keyboard accelerator +++++ */
let hbox = new Gtk.HBox();
let model = new Gtk.ListStore();
model.set_column_types([
GObject.TYPE_INT,
GObject.TYPE_INT
]);
let row = model.append();
let binding = settings.get_strv('shortcut-keybind')[0];
let key, mods;
if (binding) {
[key, mods] = Gtk.accelerator_parse(binding);
} else {
[key, mods] = [0, 0];
}
model.set(row, [0, 1], [mods, key]);
let treeview = new Gtk.TreeView({ 'expand': false, 'model': model });
let cellrend = new Gtk.CellRendererAccel({
'editable': true,
'accel-mode': Gtk.CellRendererAccelMode.GTK
});
cellrend.connect('accel-edited', function(rend, iter, key, mods) {
let value = Gtk.accelerator_name(key, mods);
let [succ, iterator] = model.get_iter_from_string(iter);
if (!succ) {
throw new Error("Error updating keybinding");
}
model.set(iterator, [0, 1], [mods, key]);
settings.set_strv('shortcut-keybind', [value]);
});
cellrend.connect('accel-cleared', function(rend, iter, key, mods) {
let [succ, iterator] = model.get_iter_from_string(iter);
if (!succ) {
throw new Error("Error clearing keybinding");
}
model.set(iterator, [0, 1], [0, 0]);
settings.set_strv('shortcut-keybind', []);
});
col = new Gtk.TreeViewColumn({ min_width: 200 });
col.pack_end(cellrend, false);
col.add_attribute(cellrend, 'accel-mods', 0);
col.add_attribute(cellrend, 'accel-key', 1);
treeview.append_column(col);
treeview.set_headers_visible(false);
hbox.pack_start(new Gtk.Label({
label: _("Key that triggers the bar to be shown."),
use_markup: true,
xalign: 0
}), true, true, 0);
hbox.pack_end(treeview, false, true, 0);
settings.connect('changed::shortcut-keybind', function(k, b) {
let row = model.get(0);
model.set(row, [0, 1], settings.get_strv(b));
});
settings_vbox.pack_start(hbox, false, false, 3);
/* ++++++++++++++++++++++++++++++++++++ End: Keyboard accelerator +++++ */
let hbox = new Gtk.HBox();
let spin = Gtk.SpinButton.new_with_range(0.0,2.0,0.1);
spin.set_value(settings.get_double('shortcut-delay'));
hbox.pack_start(new Gtk.Label({
label: _("Delay before the bar rehides after key press."),
use_markup: true,
xalign: 0
}), true, true, 0);
hbox.pack_end(spin, false, false, 0);
settings.connect('changed::shortcut-delay', function(k,b) {
spin.set_value(settings.get_double(b));
});
spin.connect('value-changed', function(w) {
settings.set_double('shortcut-delay', w.get_value());
});
settings_vbox.pack_start(hbox, false,false, 0);
let settings_array = [
['shortcut-toggles',_("Pressing the shortcut again rehides the panel.")],
];
settings_array.forEach(function (s) {
let hbox = new Gtk.HBox();
let onoff = new Gtk.Switch({active: settings.get_boolean(s[0])});
hbox.pack_start(new Gtk.Label({
label: s[1],
use_markup: true,
xalign: 0
}), true, true, 0);
hbox.pack_end(onoff, false, false, 0);
settings.connect('changed::'+s[0], function(k,b) {
onoff.set_active(settings.get_boolean(b)); });
onoff.connect('notify::active', function(w) {
settings.set_boolean(s[0], w.active);
});
settings_vbox.pack_start(hbox, false,false, 0);
});
frame.pack_start(settings_vbox, true, true, 0);
/******************************************************************************
************************************** Section Intellihide *******************
******************************************************************************/
frame.pack_start(new Gtk.Label({
label: _("<b>Intellihide</b>"),
use_markup: true,
xalign: 0
}), false, false, 0);
let settings_vbox = new Gtk.VBox({margin_left: 20, margin_top: 10});
let settings_array = [
['enable-intellihide',_("Only hide panel when a window takes the space")],
];
settings_array.forEach(function (s) {
let hbox = new Gtk.HBox();
let onoff = new Gtk.Switch({active: settings.get_boolean(s[0])});
hbox.pack_start(new Gtk.Label({
label: s[1],
use_markup: true,
xalign: 0
}), true, true, 0);
hbox.pack_end(onoff, false, false, 0);
settings.connect('changed::'+s[0], function(k,b) {
onoff.set_active(settings.get_boolean(b)); });
onoff.connect('notify::active', function(w) {
settings.set_boolean(s[0], w.active);
});
settings_vbox.pack_start(hbox, false,false, 0);
});
frame.pack_start(settings_vbox, true, true, 0);
frame.show_all();
return frame;
}