forked from gpouilloux/gnome-shell-extension-docker
-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathprefs.js
More file actions
122 lines (110 loc) · 3.06 KB
/
prefs.js
File metadata and controls
122 lines (110 loc) · 3.06 KB
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
import Gio from "gi://Gio";
import Adw from "gi://Adw";
import Gtk from "gi://Gtk";
import {
ExtensionPreferences,
gettext as _,
} from "resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js";
import { makePrefCouterGroup } from "./src/prefPages/dockerPrefCounter.js";
const DOCKER_LOG_COMMAND =
"'docker logs -f --tail 2000 %containerName%; exec $SHELL'";
export const loggingOptions = {
"x-terminal-emulator": `x-terminal-emulator -e sh -c ${DOCKER_LOG_COMMAND}`,
"gnome-terminal": `gnome-terminal -- sh -c ${DOCKER_LOG_COMMAND}`,
kgx: `kgx -e ${DOCKER_LOG_COMMAND}`,
"custom...": DOCKER_LOG_COMMAND,
};
const loggingOptionsKeys = Object.keys(loggingOptions);
export default class DockerContainersPreferences extends ExtensionPreferences {
getIntervalSpinButton = () => {
const settings = this.getSettings();
const spin = new Gtk.SpinButton({
valign: Gtk.Align.CENTER,
climb_rate: 10,
digits: 0,
snap_to_ticks: true,
adjustment: new Gtk.Adjustment({
lower: 1,
upper: 3600,
step_increment: 1,
page_size: 0,
}),
});
settings.bind(
"refresh-delay",
spin,
"value",
Gio.SettingsBindFlags.DEFAULT
);
return spin;
};
getCounterFontSizeButton = () => {
const settings = this.getSettings();
const spin = new Gtk.SpinButton({
valign: Gtk.Align.CENTER,
climb_rate: 10,
digits: 0,
snap_to_ticks: true,
adjustment: new Gtk.Adjustment({
lower: 50,
upper: 100,
step_increment: 1,
page_size: 0,
}),
});
settings.bind(
"counter-font-size",
spin,
"value",
Gio.SettingsBindFlags.DEFAULT
);
return spin;
};
getTextLoggingCommand = () => {
const settings = this.getSettings();
const text = new Gtk.Text();
settings.bind(
"selected-logging-command",
text.buffer,
"text",
Gio.SettingsBindFlags.DEFAULT
);
return text;
};
getDropDownLoggingOptions = (textBox) => {
const settings = this.getSettings();
const dropDown = Gtk.DropDown.new_from_strings(loggingOptionsKeys);
settings.bind(
"selected-logging-option",
dropDown,
"selected",
Gio.SettingsBindFlags.DEFAULT
);
dropDown.connect("notify::selected-item", () => {
const selectedItem = dropDown.selected;
textBox.buffer.text = loggingOptions[loggingOptionsKeys[selectedItem]];
});
return dropDown;
};
getCounterEnableSwitchRow = () => {
const settings = this.getSettings();
const counterEnabled = new Adw.SwitchRow({
title: _("Show containers count..."),
});
settings.bind(
"counter-enabled",
counterEnabled,
"active",
Gio.SettingsBindFlags.DEFAULT
);
return counterEnabled;
};
fillPreferencesWindow(window) {
const settings = this.getSettings();
const page = new Adw.PreferencesPage();
//const group = new Adw.PreferencesGroup();
const counterGroup = makePrefCouterGroup(settings);
page.add(counterGroup);
window.add(page);
}
}