-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindicator.js
More file actions
75 lines (66 loc) · 2.15 KB
/
indicator.js
File metadata and controls
75 lines (66 loc) · 2.15 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
import GObject from "gi://GObject";
import St from "gi://St";
import * as PanelMenu from "resource:///org/gnome/shell/ui/panelMenu.js";
import { Status } from "./status.js";
/**
* A GNOME panel indicator with an icon showing worst status of all server statuses.
* Upon clicking, a series of `ServerStatusPanel`s displays individual server statuses.
*/
export const Indicator = GObject.registerClass(
{
GTypeName: "ServerStatusIndicator",
},
class Indicator extends PanelMenu.Button {
_init(extensionName, iconProvider) {
super._init(0.0, extensionName);
this.iconProvider = iconProvider;
this.panelIcon = new St.Icon({
gicon: iconProvider?.getIcon(Status.Init),
style_class: "system-status-icon",
});
this.add_child(this.panelIcon);
this.statusPanels = [];
}
/**
* Gets the panel's leading icon widget.
* @returns {St.Icon}
*/
getPanelIcon() {
return this.panelIcon;
}
/**
* Gets the set of `ServerStatusPanel`s, one per server setting.
* @returns {ServerStatusPanel} array
*/
getStatusPanels() {
return this.statusPanels;
}
/**
* Add a `ServerStatusPanel` to the set of #statusPanels.
* @param {ServerStatusPanel} panel
*/
addStatusPanel(panel) {
this.statusPanels.push(panel);
}
/**
* Remove all `ServerStatusPanel`s from the indicator menu.
*/
clearStatusPanels() {
if (this.statusPanels) {
this.statusPanels.forEach((panel) => {
panel.destroy();
});
this.statusPanels = [];
}
}
/**
* Replace the current icon with the one appropriate for the provided status.
* @param {Status} status
*/
updatePanelIcon(status) {
if (this.panelIcon && this.iconProvider) {
this.panelIcon.gicon = this.iconProvider.getIcon(status);
}
}
},
);