-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathtopbar.js
63 lines (57 loc) · 1.64 KB
/
topbar.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
import St from 'gi://St';
import Clutter from 'gi://Clutter';
import * as Icons from './icons.js';
export function empty() {
return {
box: new St.Label({text: "", y_align: Clutter.ActorAlign.CENTER}),
update: function() { },
interval: function() { }
};
}
export function text_only() {
let rotation = 0,
online = [];
return {
box: new St.Label({text: "", y_align: Clutter.ActorAlign.CENTER}),
update: function(_online) { online = _online; },
interval: function() { this.box.set_text(online[rotation++ % online.length].streamer); }
};
}
export function icon_only() {
let rotation = 0,
icon,
online = [];
return {
box: new St.BoxLayout(),
update: function(_online) { online = _online; },
interval: function() {
if (icon) {
icon.destroy();
icon = undefined;
}
if (online.length > 0) {
icon = Icons.get_streamericon(online[rotation++ % online.length].login, "streamer-icon system-status-icon"),
this.box.add_child(icon);
}
}
};
}
export function count_only() {
return {
box: new St.Label({text: "", y_align: Clutter.ActorAlign.CENTER}),
update: function(online) { this.box.set_text(online.length.toString()); },
interval: function() { }
};
}
export function all_icons() {
let actors = [];
return {
box: new St.BoxLayout(),
update: function(online) {
actors.forEach((actor) => actor.destroy());
actors = online.map((streamer) => Icons.get_streamericon(streamer.login, "streamer-icon system-status-icon"));
actors.forEach((icon) => this.box.add_child(icon));
},
interval: function() { }
}
}