KeyboardStatus: handle modifier key indicators

Introduce a generic framework for on/off indicators that are shown
in the panel, next to the system status area, and use it for
showing the status of modifier keys.

https://bugzilla.gnome.org/show_bug.cgi?id=600771
This commit is contained in:
Giovanni Campagna
2011-01-12 16:00:54 +01:00
parent d6a6e6220a
commit 20f49e8c89
2 changed files with 72 additions and 11 deletions

View File

@ -43,6 +43,10 @@ const STANDARD_TRAY_ICON_SHELL_IMPLEMENTATION = {
if (Config.HAVE_BLUETOOTH)
STANDARD_TRAY_ICON_SHELL_IMPLEMENTATION['bluetooth'] = imports.ui.status.bluetooth.Indicator;
const STANDARD_TRAY_INDICATOR_FACTORIES = [
imports.ui.status.keyboard.ModifierIndicatorFactory
];
// in org.gnome.desktop.interface
const CLOCK_FORMAT_KEY = 'clock-format';
@ -809,17 +813,18 @@ Panel.prototype = {
/* right */
// System status applets live in statusBox, while legacy tray icons
// On-off indicators (for keyboard leds and accessx) are in indicatorBox
// System status applets live in statusBox, and legacy tray icons
// live in trayBox
// The trayBox is hidden when there are no tray icons.
let statusBox = new St.BoxLayout({ name: 'statusTray' });
let trayBox = new St.BoxLayout({ name: 'legacyTray' });
this._trayBox = trayBox;
this._statusBox = statusBox;
this._indicatorBox = new St.BoxLayout({ name: 'indicatorBox' });
this._trayBox = new St.BoxLayout({ name: 'legacyTray' });
this._statusBox = new St.BoxLayout({ name: 'statusTray' });
trayBox.hide();
this._rightBox.add(trayBox);
this._rightBox.add(statusBox);
this._trayBox.hide();
this._rightBox.add(this._indicatorBox);
this._rightBox.add(this._trayBox);
this._rightBox.add(this._statusBox);
Main.statusIconDispatcher.connect('status-icon-added', Lang.bind(this, this._onTrayIconAdded));
Main.statusIconDispatcher.connect('status-icon-removed', Lang.bind(this, this._onTrayIconRemoved));
@ -869,6 +874,13 @@ Panel.prototype = {
},
startStatusArea: function() {
for (let i = 0; i < STANDARD_TRAY_INDICATOR_FACTORIES.length; i++) {
let factory = new STANDARD_TRAY_INDICATOR_FACTORIES[i];
let indicators = factory.getIndicators();
for (let j = 0; j < indicators.length; j++)
this._indicatorBox.add(indicators[j]);
}
for (let i = 0; i < STANDARD_TRAY_ICON_ORDER.length; i++) {
let role = STANDARD_TRAY_ICON_ORDER[i];
let constructor = STANDARD_TRAY_ICON_SHELL_IMPLEMENTATION[role];