forked from maniacx/Battery-Health-Charging
-
Notifications
You must be signed in to change notification settings - Fork 0
/
prefs.js
37 lines (34 loc) · 1.7 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
'use strict';
import {ExtensionPreferences} from 'resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js';
import * as DeviceList from './lib/deviceList.js';
import {General} from './preferences/general.js';
import {Apple} from './preferences/apple.js';
import {Dell} from './preferences/dell.js';
import {ThresholdPrimary} from './preferences/thresholdPrimary.js';
import {ThresholdSecondary} from './preferences/thresholdSecondary.js';
import {About} from './preferences/about.js';
export default class BatteryHealthChargingPrefs extends ExtensionPreferences {
fillPreferencesWindow(window) {
let currentDevice = null;
const settings = this.getSettings();
const type = settings.get_int('device-type');
if (type !== 0) {
const device = new DeviceList.deviceArray[type - 1](settings);
if (device.type === type)
currentDevice = device;
}
window.set_default_size(650, 700);
window.add(new General(settings, currentDevice));
if (currentDevice !== null) {
if (currentDevice.type === 16) // device.type 16 is AppleIntel
window.add(new Apple(settings));
if ((currentDevice.type === 22) && settings.get_boolean('detected-cctk')) // device.type 22 is Dell
window.add(new Dell(settings));
if (currentDevice.deviceHaveVariableThreshold) // Laptop has customizable threshold
window.add(new ThresholdPrimary(settings, currentDevice));
if (currentDevice.deviceHaveDualBattery) // Laptop has dual battery
window.add(new ThresholdSecondary(settings, currentDevice));
}
window.add(new About(window, this));
}
}