-
Notifications
You must be signed in to change notification settings - Fork 3
/
prefs.js
50 lines (38 loc) · 1.23 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
const Gtk = imports.gi.Gtk;
const Lang = imports.lang;
const ExtensionUtils = imports.misc.extensionUtils;
const Me = ExtensionUtils.getCurrentExtension();
const Convenience = Me.imports.convenience;
const FULLSCREEN_ENABLED_KEY = "fullscreen-enabled";
const Preferences = new Lang.Class({
Name: 'Preferences',
_init: function(params) {
this.settings = Convenience.getSettings();
this.widget = new Gtk.Box({
orientation: Gtk.Orientation.VERTICAL,
margin: 20
});
this.widget.add(this._createSwitch(
FULLSCREEN_ENABLED_KEY,
"Cascade fullscreen/maximized windows"
));
this.widget.show_all();
},
_createSwitch: function(key, text) {
let box = new Gtk.Box({ orientation: Gtk.Orientation.HORIZONTAL });
let label = new Gtk.Label({ label: text, halign: Gtk.Align.START });
let control = new Gtk.Switch({ active: this.settings.get_boolean(key) });
control.connect('notify::active', Lang.bind(this, function(control) {
this.settings.set_boolean(key, control.active);
}));
box.pack_start(label, true, true, 0);
box.add(control);
return box;
}
});
function init(){
}
function buildPrefsWidget() {
let preferences = new Preferences();
return preferences.widget;
}