-
Notifications
You must be signed in to change notification settings - Fork 2
/
prefs.js
70 lines (55 loc) · 2.86 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 Adw from 'gi://Adw';
import Gio from 'gi://Gio';
import {ExtensionPreferences, gettext as _} from 'resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js';
import * as Constants from './constants.js';
export default class SaneAirplaneModePreferences extends ExtensionPreferences {
fillPreferencesWindow(window) {
const SettingsSchema = this.getSettings();
const page = new Adw.PreferencesPage();
const airplaneGroup = new Adw.PreferencesGroup({
title: _('When disabling airplane mode'),
});
const wifiRow = new Adw.SwitchRow({
title: _('Enable Wi-Fi'),
});
const bluetoothRow = new Adw.SwitchRow({
title: _('Enable Bluetooth'),
});
airplaneGroup.add(wifiRow);
airplaneGroup.add(bluetoothRow);
page.add(airplaneGroup);
const wifiGroup = new Adw.PreferencesGroup({
title: _('When disabling Wi-Fi (as the last active radio)'),
});
const enableAirplaneRow = new Adw.SwitchRow({
title: _('Enable airplane mode'),
});
wifiGroup.add(enableAirplaneRow);
page.add(wifiGroup);
const advancedGroup = new Adw.PreferencesGroup({
title: _('Advanced'),
});
const advancedExpander = new Adw.ExpanderRow({
title: _('Advanced settings'),
});
const enableDebugLogRow = new Adw.SwitchRow({
title: _('Enable debug log'),
});
const disableRadioIntervalRow = Adw.SpinRow.new_with_range(5, 1000, 5);
disableRadioIntervalRow.set_title(_('Disable radio interval (in ms)'));
const maxIntervalCountRow = Adw.SpinRow.new_with_range(0, 1000, 1);
maxIntervalCountRow.set_title(_('Maximum disable radio count'));
advancedExpander.add_row(enableDebugLogRow);
advancedExpander.add_row(disableRadioIntervalRow);
advancedExpander.add_row(maxIntervalCountRow);
advancedGroup.add(advancedExpander);
page.add(advancedGroup);
SettingsSchema.bind(Constants.Fields.ENABLE_WIFI, wifiRow, 'active', Gio.SettingsBindFlags.DEFAULT);
SettingsSchema.bind(Constants.Fields.ENABLE_BLUETOOTH, bluetoothRow, 'active', Gio.SettingsBindFlags.DEFAULT);
SettingsSchema.bind(Constants.Fields.ENABLE_AIRPLANE_MODE, enableAirplaneRow, 'active', Gio.SettingsBindFlags.DEFAULT);
SettingsSchema.bind(Constants.Fields.ENABLE_DEBUG_LOG, enableDebugLogRow, 'active', Gio.SettingsBindFlags.DEFAULT);
SettingsSchema.bind(Constants.Fields.DISABLE_RADIO_INTERVAL, disableRadioIntervalRow, 'value', Gio.SettingsBindFlags.DEFAULT);
SettingsSchema.bind(Constants.Fields.MAX_INTERVAL_COUNT, maxIntervalCountRow, 'value', Gio.SettingsBindFlags.DEFAULT);
window.add(page);
}
};