-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathprefs.js
More file actions
70 lines (58 loc) · 2.38 KB
/
prefs.js
File metadata and controls
70 lines (58 loc) · 2.38 KB
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
'use strict';
import Gio from 'gi://Gio';
import Gtk from 'gi://Gtk';
import Adw from 'gi://Adw';
import {ExtensionPreferences, gettext as _} from 'resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js';
import * as modsListNames from './src/modsListNames.js'
export default class extends ExtensionPreferences {
fillPreferencesWindow(window) {
const settings = this.getSettings()
const page = new Adw.PreferencesPage({
icon_name: 'dialog-information-symbolic',
});
window.add(page);
const group = new Adw.PreferencesGroup({
title: _('settings-mods-list'),
//description: _('settings-mods-list'),
});
page.add(group);
const mods_list = modsListNames.getNames()
for (let modNum = 0; modNum < mods_list.length; modNum++) {
const key = mods_list[modNum]
const rowNum = modNum + 1
let row = null
const value = settings.get_value(key)
switch (value.get_type_string()) {
case "s":
row = new Adw.ActionRow({
title: _(key),
})
const toggle = new Gtk.Box({halign: Gtk.Align.END, css_classes: ['linked']})
const value_enum = settings.get_enum(key)
const value_string = settings.get_string(key)
const values = settings.get_range(key).deep_unpack()[1].deep_unpack()
let btn = null
for (let v in values) {
btn = new Gtk.ToggleButton({
active: value_string === values[v],
label : values[v],
group : btn
})
toggle.append(btn)
btn.connect('toggled', button => {
button.active && settings.set_string(key, values[v])
})
}
row.add_suffix(toggle)
break
default:
row = new Adw.SwitchRow({
title: _(key),
//subtitle: _(key),
})
settings.bind(key, row, 'active', Gio.SettingsBindFlags.DEFAULT)
}
group.add(row);
}
}
}