forked from polof/traytop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextension.js
50 lines (41 loc) · 1.53 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
/*
traytop - GNOME Shell 3.4 extension that puts tray icons in the top panel.
Copyright 2013 Per Olofsson <[email protected]>
This work is free. You can redistribute it and/or modify it under the
terms of the Do What The Fuck You Want To Public License, Version 2,
as published by Sam Hocevar. See the COPYING file for more details.
*/
const Lang = imports.lang;
const Main = imports.ui.main;
function _onTrayIconAdded(o, icon) {
this.emit('status-icon-added', icon, 'tray');
}
function _onTrayIconRemoved(o, icon) {
this.emit('status-icon-removed', icon);
}
function _connectStatusIconSignals(sid) {
let panel = Main.panel;
sid.connect('status-icon-added',
Lang.bind(panel, panel._onTrayIconAdded));
sid.connect('status-icon-removed',
Lang.bind(panel, panel._onTrayIconRemoved));
}
function init() {
}
function enable() {
let sid = Main.statusIconDispatcher;
// GNOME Shell 3.4 doesn't save the handler ID's so we can't
// disconnect the individual handlers.
sid.disconnectAll();
_connectStatusIconSignals(sid);
sid.connect('message-icon-added', Lang.bind(sid, _onTrayIconAdded));
sid.connect('message-icon-removed', Lang.bind(sid, _onTrayIconRemoved));
}
function disable() {
let sid = Main.statusIconDispatcher;
let nd = Main.notificationDaemon;
sid.disconnectAll();
_connectStatusIconSignals(sid);
sid.connect('message-icon-added', Lang.bind(nd, nd._onTrayIconAdded));
sid.connect('message-icon-removed', Lang.bind(nd, nd._onTrayIconRemoved));
}