2011-09-28 09:16:26 -04:00
|
|
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
2010-08-09 12:33:34 -04:00
|
|
|
|
|
|
|
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',
|
2011-03-25 02:16:57 -04:00
|
|
|
'kbd-capslock': 'keyboard',
|
2011-03-25 21:24:11 -04:00
|
|
|
'ibus-ui-gtk': 'input-method'
|
2010-08-09 12:33:34 -04:00
|
|
|
};
|
|
|
|
|
2011-11-20 12:56:27 -05:00
|
|
|
const StatusIconDispatcher = new Lang.Class({
|
|
|
|
Name: 'StatusIconDispatcher',
|
2010-08-09 12:33:34 -04:00
|
|
|
|
|
|
|
_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));
|
|
|
|
|
|
|
|
// 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
|
|
|
},
|
|
|
|
|
2011-01-31 12:48:18 -05:00
|
|
|
start: function(themeWidget) {
|
|
|
|
this._traymanager.manage_stage(global.stage, themeWidget);
|
|
|
|
},
|
|
|
|
|
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);
|
|
|
|
}
|
2011-11-20 12:56:27 -05:00
|
|
|
});
|
2010-08-09 12:33:34 -04:00
|
|
|
Signals.addSignalMethods(StatusIconDispatcher.prototype);
|