forked from PhoenicisOrg/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
47 lines (42 loc) · 1.47 KB
/
script.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
const Wine = include("engines.wine.engine.object");
include("engines.wine.plugins.regedit");
include("engines.wine.plugins.usetakefocus");
/**
* Setting to enable/disable UseTakeFocus
*/
// eslint-disable-next-line no-unused-vars
module.default = class UseTakeFocusSetting {
constructor() {
this.options = [tr("Default"), tr("Disabled"), tr("Enabled")];
// values which are written into the registry, do not translate!
// `Y` is blind code since it's enabled by default on wine-staging it seems
this.registryValues = ["", "N", "Y"];
}
getText() {
return tr("UseTakeFocus");
}
getOptions() {
return this.options;
}
getCurrentOption(container) {
var currentValue = new Wine()
.prefix(container)
.regedit()
.fetchValue(["HKEY_CURRENT_USER", "Software", "Wine", "X11 Driver", "UseTakeFocus"]);
// find matching option (use default if not found)
var index = Math.max(this.registryValues.indexOf(currentValue), 0);
return this.options[index];
}
setOption(container, optionIndex) {
if (0 == optionIndex) {
new Wine()
.prefix(container)
.regedit()
.deleteValue("HKEY_CURRENT_USER\\Software\\Wine\\X11 Driver", "UseTakeFocus");
} else {
new Wine()
.prefix(container)
.UseTakeFocus(this.registryValues[optionIndex]);
}
}
}