forked from maweki/twitchlive-extension
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtopbar.js
64 lines (58 loc) · 1.67 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
64
const St = imports.gi.St;
const Clutter = imports.gi.Clutter;
const Extension = imports.misc.extensionUtils.getCurrentExtension();
const Icons = Extension.imports.icons;
function empty() {
return {
box: new St.Label({text: "", y_align: Clutter.ActorAlign.CENTER}),
update: function() { },
interval: function() { }
};
}
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); }
};
}
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_actor(icon);
}
}
};
}
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() { }
};
}
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_actor(icon));
},
interval: function() { }
}
}