-
Notifications
You must be signed in to change notification settings - Fork 1
/
extension.js
64 lines (50 loc) · 1.71 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
53
54
55
56
57
58
59
60
61
62
63
64
/* exported init */
const GETTEXT_DOMAIN = 'geary-tray-icon';
const { GObject, St } = imports.gi;
const Gettext = imports.gettext.domain(GETTEXT_DOMAIN);
const _ = Gettext.gettext;
const GLib = imports.gi.GLib;
const ExtensionUtils = imports.misc.extensionUtils;
const Main = imports.ui.main;
const PanelMenu = imports.ui.panelMenu;
const PopupMenu = imports.ui.popupMenu;
const Indicator = GObject.registerClass(
class Indicator extends PanelMenu.Button {
_init() {
super._init(0.0, _('Geary Tray Icon'));
let box = new St.BoxLayout({ style_class: 'panel-status-menu-box' });
box.add_child(new St.Icon({
icon_name: 'mail-mark-unread-symbolic',
style_class: 'system-status-icon',
}));
box.add_child(PopupMenu.arrowIcon(St.Side.BOTTOM));
this.add_child(box);
let open_mail_item = new PopupMenu.PopupMenuItem(_('Open Mailbox'));
open_mail_item.connect('activate', () => {
GLib.spawn_command_line_async("geary");
});
this.menu.addMenuItem(open_mail_item);
let new_mail_item = new PopupMenu.PopupMenuItem(_('New Mail'));
new_mail_item.connect('activate', () => {
GLib.spawn_command_line_async("geary mailto:");
});
this.menu.addMenuItem(new_mail_item);
}
});
class Extension {
constructor(uuid) {
this._uuid = uuid;
ExtensionUtils.initTranslations(GETTEXT_DOMAIN);
}
enable() {
this._indicator = new Indicator();
Main.panel.addToStatusArea(this._uuid, this._indicator);
}
disable() {
this._indicator.destroy();
this._indicator = null;
}
}
function init(meta) {
return new Extension(meta.uuid);
}