-
Notifications
You must be signed in to change notification settings - Fork 20
/
prefs.js
69 lines (55 loc) · 2.07 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
import Gtk from 'gi://Gtk?version=4.0';
import GLib from 'gi://GLib';
import * as Convenience from './convenience.js';
import {ExtensionPreferences} from 'resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js';
import Gio from 'gi://Gio';
import Adw from 'gi://Adw';
export default class RunOrRaisePreferences extends ExtensionPreferences {
fillPreferencesWindow(window) {
window._settings = this.getSettings();
const page = new Adw.PreferencesPage();
page.add(this.getShortcutConfig());
page.add(this.getBehaviourConfig());
window.add(page);
}
getShortcutConfig() {
const group = new Adw.PreferencesGroup({
title: "Shortcuts",
});
const row = new Adw.ActionRow({
title: 'Open shortcuts.conf file',
subtitle: 'Edit the file to add your shortcuts, then reload this extension (no logout required)',
});
let editorButton = new Gtk.Button({
iconName: "document-open-symbolic",
valign: Gtk.Align.CENTER,
halign: Gtk.Align.CENTER
});
editorButton.connect("clicked", function() {
GLib.spawn_command_line_sync("xdg-open .config/run-or-raise/shortcuts.conf");
});
row.add_suffix(editorButton);
row.set_activatable_widget(editorButton);
group.add(row);
return group;
}
getBehaviourConfig() {
const group = new Adw.PreferencesGroup({
title: "Behaviour",
description: "Configure various behaviours of run or raise"
});
let convData = Convenience.getSchemaData(this.getSettings());
convData.basicSchema.forEach(function(data) {
group.add(booleanBox(data, convData.settings));
});
return group;
}
}
function booleanBox(data, settings) {
const row = new Adw.SwitchRow({
title: data.summary,
subtitle: data.description ? data.description : "",
});
settings.bind(data.name, row, 'active', Gio.SettingsBindFlags.DEFAULT);
return row
}