-
Notifications
You must be signed in to change notification settings - Fork 8
/
prefs.js
68 lines (56 loc) · 2.53 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
import Adw from 'gi://Adw';
import Gio from 'gi://Gio';
import GLib from 'gi://GLib';
import Gtk from 'gi://Gtk';
import {ExtensionPreferences} from 'resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js';
export default class SpoitifyAdBlockPreferences extends ExtensionPreferences {
fillPreferencesWindow(window) {
const settings = this.getSettings();
const prefsPage = new Adw.PreferencesPage({
name: 'general',
title: 'General',
icon_name: 'dialog-information-symbolic',
});
window.add(prefsPage);
const prefsGroup = new Adw.PreferencesGroup({
title: 'General',
});
prefsPage.add(prefsGroup);
const showIndicatorRow = new Adw.ActionRow({
title: 'Show indicator',
subtitle: 'Whether to show the panel indicator',
});
prefsGroup.add(showIndicatorRow);
const showIndicatorSwitch = new Gtk.Switch({
active: settings.get_boolean('show-indicator'),
valign: Gtk.Align.CENTER,
});
settings.bind('show-indicator', showIndicatorSwitch, 'active',
Gio.SettingsBindFlags.DEFAULT);
showIndicatorRow.add_suffix(showIndicatorSwitch);
showIndicatorRow.set_activatable_widget(showIndicatorSwitch);
const adVolumeRow = new Adw.ActionRow({
title: 'Volume percentage for ads',
subtitle: 'Volume percentage to use when ads are playing',
});
prefsGroup.add(adVolumeRow);
const adVolumeInput = Gtk.SpinButton.new_with_range(0, 100, 1);
// Without this, the number input expands to fill all the vertical space
adVolumeInput.set_valign(Gtk.Align.CENTER);
settings.bind('ad-volume-percentage', adVolumeInput, 'value',
Gio.SettingsBindFlags.DEFAULT)
adVolumeRow.add_suffix(adVolumeInput);
adVolumeRow.set_activatable_widget(adVolumeInput);
const unmuteDelayRow = new Adw.ActionRow({
title: 'Volume restore delay',
subtitle: 'Delay in milliseconds before restoring volume after ads are finished playing',
});
prefsGroup.add(unmuteDelayRow);
const unmuteDelayInput = Gtk.SpinButton.new_with_range(0, 10000, 100);
unmuteDelayInput.set_valign(Gtk.Align.CENTER);
settings.bind('unmute-delay', unmuteDelayInput, 'value',
Gio.SettingsBindFlags.DEFAULT)
unmuteDelayRow.add_suffix(unmuteDelayInput);
unmuteDelayRow.set_activatable_widget(unmuteDelayInput);
}
}