forked from maniacx/Battery-Health-Charging
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprefs.js
91 lines (81 loc) · 2.58 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
'use strict';
const {Adw, GLib, GObject, Gio} = imports.gi;
const ExtensionUtils = imports.misc.extensionUtils;
const Me = ExtensionUtils.getCurrentExtension();
const Driver = Me.imports.driver;
const gettextDomain = Me.metadata['gettext-domain'];
const Gettext = imports.gettext.domain(gettextDomain);
const _ = Gettext.gettext;
/**
* Call button click call runInstaller from driver
*/
function runInstaller() {
Driver.runInstaller();
}
/**
* Call button click call runUninstaller from driver
*/
function runUninstaller() {
Driver.runUninstaller();
}
var Preferences = GObject.registerClass({
GTypeName: 'BHC_Preferences',
Template: `file://${GLib.build_filenamev([Me.path, 'preference.ui'])}`,
InternalChildren: [
'icon_style_mode',
'show_system_indicator',
'install_service',
'install_service_button',
],
}, class Preferences extends Adw.PreferencesPage {
constructor(settings) {
super({});
if (settings.get_boolean('install-service')) {
this._install_service_button.set_label(_('Remove'));
this._install_service_button.set_icon_name('user-trash-symbolic');
} else {
this._install_service_button.set_label(_('Install'));
this._install_service_button.set_icon_name('emblem-system-symbolic');
}
settings.bind(
'icon-style-type',
this._icon_style_mode,
'selected',
Gio.SettingsBindFlags.DEFAULT
);
settings.bind(
'show-system-indicator',
this._show_system_indicator,
'state',
Gio.SettingsBindFlags.DEFAULT
);
this._install_service.connect('clicked', () => {
if (settings.get_boolean('install-service'))
runUninstaller();
else
runInstaller();
});
settings.connect('changed::install-service', () => {
if (settings.get_boolean('install-service')) {
this._install_service_button.set_label(_('Remove'));
this._install_service_button.set_icon_name('user-trash-symbolic');
} else {
this._install_service_button.set_label(_('Install'));
this._install_service_button.set_icon_name('emblem-system-symbolic');
}
});
}
});
/**
* Preference windows
*/
function fillPreferencesWindow(window) {
const settings = ExtensionUtils.getSettings();
window.add(new Preferences(settings));
}
/**
* Init
*/
function init() {
ExtensionUtils.initTranslations(Me.metadata.uuid);
}