-
Notifications
You must be signed in to change notification settings - Fork 0
/
extension.js
52 lines (40 loc) · 1.09 KB
/
extension.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
const GETTEXT_DOMAIN = 'my-indicator-extension';
const { GObject, St } = imports.gi;
const ExtensionUtils = imports.misc.extensionUtils;
const Main = imports.ui.main;
const PanelMenu = imports.ui.panelMenu;
const _ = ExtensionUtils.gettext;
const Indicator = GObject.registerClass(
class Indicator extends PanelMenu.Button {
_init() {
super._init(0.0, _('BarDuck'));
let icon = new St.Icon({
style_class: 'duck_close',
width: 20
});
this.add_child(icon);
this.connect('button-press-event', () => {
icon.style_class = 'duck_open';
});
this.connect('button-release-event', () => {
icon.style_class = 'duck_close';
});
}
});
class Extension {
constructor(uuid) {
this._uuid = uuid;
ExtensionUtils.initTranslations(GETTEXT_DOMAIN);
}
enable() {
this._indicator = new Indicator();
Main.panel.addToStatusArea(this._uuid, this._indicator, 1, "center");
}
disable() {
this._indicator.destroy();
this._indicator = null;
}
}
function init(meta) {
return new Extension(meta.uuid);
}