2011-09-28 13:16:26 +00:00
|
|
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
2010-08-09 16:33:34 +00: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 20:30:12 +00:00
|
|
|
const Util = imports.misc.util;
|
2010-08-09 16:33:34 +00:00
|
|
|
|
|
|
|
const STANDARD_TRAY_ICON_IMPLEMENTATIONS = {
|
|
|
|
'bluetooth-applet': 'bluetooth',
|
2010-11-15 15:29:45 +00:00
|
|
|
'gnome-volume-control-applet': 'volume', // renamed to gnome-sound-applet
|
|
|
|
// when moved to control center
|
|
|
|
'gnome-sound-applet': 'volume',
|
2010-08-09 16:33:34 +00:00
|
|
|
'nm-applet': 'network',
|
2010-09-24 19:53:50 +00:00
|
|
|
'gnome-power-manager': 'battery',
|
2011-01-28 01:25:45 +00:00
|
|
|
'keyboard': 'keyboard',
|
2011-01-28 01:30:45 +00:00
|
|
|
'a11y-keyboard': 'a11y',
|
|
|
|
'kbd-scrolllock': 'keyboard',
|
|
|
|
'kbd-numlock': 'keyboard',
|
2011-03-25 06:16:57 +00:00
|
|
|
'kbd-capslock': 'keyboard',
|
2011-03-26 01:24:11 +00:00
|
|
|
'ibus-ui-gtk': 'input-method'
|
2010-08-09 16:33:34 +00: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));
|
|
|
|
|
|
|
|
// 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 20:30:12 +00:00
|
|
|
Util.killall('indicator-application-service');
|
2010-08-09 16:33:34 +00:00
|
|
|
},
|
|
|
|
|
2011-01-31 17:48:18 +00:00
|
|
|
start: function(themeWidget) {
|
|
|
|
this._traymanager.manage_stage(global.stage, themeWidget);
|
|
|
|
},
|
|
|
|
|
2010-08-09 16:33:34 +00:00
|
|
|
_onTrayIconAdded: function(o, icon) {
|
2010-10-24 12:31:41 +00:00
|
|
|
let wmClass = (icon.wm_class || 'unknown').toLowerCase();
|
2010-08-09 16:33:34 +00: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 12:31:41 +00:00
|
|
|
let wmClass = (icon.wm_class || 'unknown').toLowerCase();
|
2010-08-09 16:33:34 +00: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);
|