2010-08-09 12:33:34 -04:00
|
|
|
/* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */
|
|
|
|
|
|
|
|
const Lang = imports.lang;
|
|
|
|
const Shell = imports.gi.Shell;
|
|
|
|
const Signals = imports.signals;
|
|
|
|
|
|
|
|
const MessageTray = imports.ui.messageTray;
|
|
|
|
const NotificationDaemon = imports.ui.notificationDaemon;
|
2010-12-17 15:30:12 -05:00
|
|
|
const Util = imports.misc.util;
|
2010-08-09 12:33:34 -04:00
|
|
|
|
|
|
|
const STANDARD_TRAY_ICON_IMPLEMENTATIONS = {
|
|
|
|
'bluetooth-applet': 'bluetooth',
|
2010-11-15 10:29:45 -05:00
|
|
|
'gnome-volume-control-applet': 'volume', // renamed to gnome-sound-applet
|
|
|
|
// when moved to control center
|
|
|
|
'gnome-sound-applet': 'volume',
|
2010-08-09 12:33:34 -04:00
|
|
|
'nm-applet': 'network',
|
2010-09-24 15:53:50 -04:00
|
|
|
'gnome-power-manager': 'battery',
|
2011-01-27 20:25:45 -05:00
|
|
|
'keyboard': 'keyboard',
|
2011-01-27 20:30:45 -05:00
|
|
|
'a11y-keyboard': 'a11y',
|
|
|
|
'kbd-scrolllock': 'keyboard',
|
|
|
|
'kbd-numlock': 'keyboard',
|
|
|
|
'kbd-capslock': 'keyboard'
|
2010-08-09 12:33:34 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
function StatusIconDispatcher() {
|
|
|
|
this._init();
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusIconDispatcher.prototype = {
|
|
|
|
_init: function() {
|
|
|
|
this._traymanager = new Shell.TrayManager();
|
|
|
|
this._traymanager.connect('tray-icon-added', Lang.bind(this, this._onTrayIconAdded));
|
|
|
|
this._traymanager.connect('tray-icon-removed', Lang.bind(this, this._onTrayIconRemoved));
|
|
|
|
this._traymanager.manage_stage(global.stage);
|
|
|
|
|
|
|
|
// Yet-another-Ubuntu-workaround - we have to kill their
|
|
|
|
// app-indicators, so that applications fall back to normal
|
|
|
|
// status icons
|
|
|
|
// http://bugzilla.gnome.org/show_bug.cgi=id=621382
|
2010-12-17 15:30:12 -05:00
|
|
|
Util.killall('indicator-application-service');
|
2010-08-09 12:33:34 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
_onTrayIconAdded: function(o, icon) {
|
2010-10-24 08:31:41 -04:00
|
|
|
let wmClass = (icon.wm_class || 'unknown').toLowerCase();
|
2010-08-09 12:33:34 -04:00
|
|
|
let role = STANDARD_TRAY_ICON_IMPLEMENTATIONS[wmClass];
|
|
|
|
if (role)
|
|
|
|
this.emit('status-icon-added', icon, role);
|
|
|
|
else
|
|
|
|
this.emit('message-icon-added', icon);
|
|
|
|
},
|
|
|
|
|
|
|
|
_onTrayIconRemoved: function(o, icon) {
|
2010-10-24 08:31:41 -04:00
|
|
|
let wmClass = (icon.wm_class || 'unknown').toLowerCase();
|
2010-08-09 12:33:34 -04:00
|
|
|
let role = STANDARD_TRAY_ICON_IMPLEMENTATIONS[wmClass];
|
|
|
|
if (role)
|
|
|
|
this.emit('status-icon-removed', icon);
|
|
|
|
else
|
|
|
|
this.emit('message-icon-removed', icon);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
Signals.addSignalMethods(StatusIconDispatcher.prototype);
|