-
Notifications
You must be signed in to change notification settings - Fork 0
/
prefs.js
61 lines (45 loc) · 1.3 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
// Gnome imports
imports.gi.versions.Gtk = "3.0";
const { Gtk } = imports.gi;
// Extension imports
const ExtensionUtils = imports.misc.extensionUtils;
const Me = ExtensionUtils.getCurrentExtension();
// Application imports
const logging = Me.imports.logger;
function init() {
}
function buildPrefsWidget() {
let prefsWidget = new Gtk.Grid({
margin: 18,
column_spacing: 12,
row_spacing: 12
});
createLoggingCombo(prefsWidget);
// show the grid
prefsWidget.show_all();
return prefsWidget;
}
/**
* Create logging level changer in preferences
* @param {grid} grid
*/
function createLoggingCombo(grid) {
let logLabel = new Gtk.Label({
label: `Log Level`,
halign: Gtk.Align.START
});
grid.attach(logLabel, 0, 0, 1, 1);
let logCombo = new Gtk.ComboBoxText();
let itemId = 0;
for (const key in logging.LOG_LEVELS) {
logCombo.append(`${logging.LOG_LEVELS[key]}`, key);
}
let currentLogLevelVal = logging.getLogLevel();
logCombo.set_active_id(`${currentLogLevelVal}`);
logCombo.connect("changed", () => {
let settings = ExtensionUtils.getSettings();
let activeId = logCombo.get_active_id();
settings.set_uint("log-level", activeId);
});
grid.attach(logCombo, 1, 0, 1, 1);
}