-
Notifications
You must be signed in to change notification settings - Fork 11
/
prefs.js
75 lines (62 loc) · 2.71 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
'use strict';
const Gtk = imports.gi.Gtk;
const Gio = imports.gi.Gio;
const ExtensionUtils = imports.misc.extensionUtils;
const Me = ExtensionUtils.getCurrentExtension();
let settings;
function init() {
settings = ExtensionUtils.getSettings('org.gnome.shell.extensions.zenbook-duo');
}
function buildPrefsWidget() {
let buildable = new Gtk.Builder();
buildable.add_from_file(Me.dir.get_path() + '/prefs.ui');
let box = buildable.get_object('prefs_widget');
let version_label = buildable.get_object('version_label');
version_label.set_text(`Version ${Me.metadata.version.toString()}`);
settings.bind('myasus-cmd', buildable.get_object('entry_myasus_cmd'), 'text', Gio.SettingsBindFlags.DEFAULT);
settings.connect('changed::screenshot-type', () => update_screenshot_type_buttons(buildable));
update_screenshot_type_buttons(buildable);
const screenshot_screen = buildable.get_object('screenshot_screen');
screenshot_screen.connect('toggled', (x) => {
if (screenshot_screen.get_active()) settings.set_string('screenshot-type', 'Screen');
});
const screenshot_window = buildable.get_object('screenshot_window');
screenshot_window.connect('toggled', (x) => {
if (screenshot_window.get_active()) settings.set_string('screenshot-type', 'Window');
});
const screenshot_selection = buildable.get_object('screenshot_selection');
screenshot_selection.connect('toggled', (x) => {
if (screenshot_selection.get_active()) settings.set_string('screenshot-type', 'Selection');
});
const screenshot_interactive = buildable.get_object('screenshot_interactive');
screenshot_interactive.connect('toggled', (x) => {
if (screenshot_interactive.get_active()) settings.set_string('screenshot-type', 'Interactive');
});
settings.bind(
'screenshot-include-cursor',
buildable.get_object('switch_screenshot_cursor'),
'active',
Gio.SettingsBindFlags.DEFAULT
);
const button_uninstall = buildable.get_object('button_uninstall');
button_uninstall.connect('clicked', () => {
settings.set_boolean('uninstall', true);
});
return box;
}
function update_screenshot_type_buttons(buildable) {
switch (settings.get_string('screenshot-type')) {
case 'Screen':
buildable.get_object('screenshot_screen').set_active(true);
break;
case 'Window':
buildable.get_object('screenshot_window').set_active(true);
break;
case 'Selection':
buildable.get_object('screenshot_selection').set_active(true);
break;
case 'Interactive':
buildable.get_object('screenshot_interactive').set_active(true);
break;
}
}