2011-09-28 09:16:26 -04:00
|
|
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
2011-01-04 17:04:56 -05:00
|
|
|
|
2012-12-10 14:35:29 -05:00
|
|
|
const Clutter = imports.gi.Clutter;
|
2011-01-04 17:04:56 -05:00
|
|
|
const Gio = imports.gi.Gio;
|
|
|
|
const GLib = imports.gi.GLib;
|
2012-04-18 22:01:29 -04:00
|
|
|
const GnomeDesktop = imports.gi.GnomeDesktop;
|
2011-01-04 17:04:56 -05:00
|
|
|
const Lang = imports.lang;
|
2012-12-10 14:35:29 -05:00
|
|
|
const Meta = imports.gi.Meta;
|
2011-01-04 17:04:56 -05:00
|
|
|
const Shell = imports.gi.Shell;
|
2012-09-01 17:57:53 -04:00
|
|
|
const Signals = imports.signals;
|
2011-01-04 17:04:56 -05:00
|
|
|
const St = imports.gi.St;
|
|
|
|
|
2012-05-29 13:30:14 -04:00
|
|
|
try {
|
|
|
|
var IBus = imports.gi.IBus;
|
|
|
|
if (!('new_async' in IBus.Bus))
|
|
|
|
throw "IBus version is too old";
|
2012-05-29 13:30:46 -04:00
|
|
|
const IBusCandidatePopup = imports.ui.ibusCandidatePopup;
|
2012-05-29 13:30:14 -04:00
|
|
|
} catch (e) {
|
|
|
|
var IBus = null;
|
|
|
|
log(e);
|
|
|
|
}
|
|
|
|
|
2011-06-21 18:26:57 -04:00
|
|
|
const Main = imports.ui.main;
|
2011-01-04 17:04:56 -05:00
|
|
|
const PopupMenu = imports.ui.popupMenu;
|
|
|
|
const PanelMenu = imports.ui.panelMenu;
|
2012-12-10 14:35:29 -05:00
|
|
|
const SwitcherPopup = imports.ui.switcherPopup;
|
2011-02-05 13:30:16 -05:00
|
|
|
const Util = imports.misc.util;
|
2011-01-04 17:04:56 -05:00
|
|
|
|
2012-04-18 22:01:29 -04:00
|
|
|
const DESKTOP_INPUT_SOURCES_SCHEMA = 'org.gnome.desktop.input-sources';
|
|
|
|
const KEY_CURRENT_INPUT_SOURCE = 'current';
|
|
|
|
const KEY_INPUT_SOURCES = 'sources';
|
|
|
|
|
|
|
|
const INPUT_SOURCE_TYPE_XKB = 'xkb';
|
2012-05-29 13:30:14 -04:00
|
|
|
const INPUT_SOURCE_TYPE_IBUS = 'ibus';
|
|
|
|
|
|
|
|
const IBusManager = new Lang.Class({
|
|
|
|
Name: 'IBusManager',
|
|
|
|
|
|
|
|
_init: function(readyCallback) {
|
|
|
|
if (!IBus)
|
|
|
|
return;
|
|
|
|
|
|
|
|
IBus.init();
|
|
|
|
|
|
|
|
this._readyCallback = readyCallback;
|
2012-05-29 13:30:46 -04:00
|
|
|
this._candidatePopup = new IBusCandidatePopup.CandidatePopup();
|
2012-05-29 13:30:14 -04:00
|
|
|
|
|
|
|
this._ibus = null;
|
2012-05-29 13:30:46 -04:00
|
|
|
this._panelService = null;
|
2012-05-29 13:30:14 -04:00
|
|
|
this._engines = {};
|
|
|
|
this._ready = false;
|
2012-09-01 17:57:53 -04:00
|
|
|
this._registerPropertiesId = 0;
|
2012-12-13 14:48:13 -05:00
|
|
|
this._currentEngineName = null;
|
2012-05-29 13:30:14 -04:00
|
|
|
|
|
|
|
this._nameWatcherId = Gio.DBus.session.watch_name(IBus.SERVICE_IBUS,
|
|
|
|
Gio.BusNameWatcherFlags.NONE,
|
|
|
|
Lang.bind(this, this._onNameAppeared),
|
|
|
|
Lang.bind(this, this._clear));
|
|
|
|
},
|
|
|
|
|
|
|
|
_clear: function() {
|
2012-05-29 13:30:46 -04:00
|
|
|
if (this._panelService)
|
|
|
|
this._panelService.destroy();
|
2012-05-29 13:30:14 -04:00
|
|
|
if (this._ibus)
|
|
|
|
this._ibus.destroy();
|
|
|
|
|
|
|
|
this._ibus = null;
|
2012-05-29 13:30:46 -04:00
|
|
|
this._panelService = null;
|
|
|
|
this._candidatePopup.setPanelService(null);
|
2012-05-29 13:30:14 -04:00
|
|
|
this._engines = {};
|
|
|
|
this._ready = false;
|
2012-09-01 17:57:53 -04:00
|
|
|
this._registerPropertiesId = 0;
|
2012-12-13 14:48:13 -05:00
|
|
|
this._currentEngineName = null;
|
2012-12-10 14:34:43 -05:00
|
|
|
|
|
|
|
if (this._readyCallback)
|
|
|
|
this._readyCallback(false);
|
2012-05-29 13:30:14 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
_onNameAppeared: function() {
|
|
|
|
this._ibus = IBus.Bus.new_async();
|
|
|
|
this._ibus.connect('connected', Lang.bind(this, this._onConnected));
|
|
|
|
},
|
|
|
|
|
|
|
|
_onConnected: function() {
|
|
|
|
this._ibus.list_engines_async(-1, null, Lang.bind(this, this._initEngines));
|
2012-05-29 13:30:46 -04:00
|
|
|
this._ibus.request_name_async(IBus.SERVICE_PANEL,
|
|
|
|
IBus.BusNameFlag.REPLACE_EXISTING,
|
|
|
|
-1, null,
|
|
|
|
Lang.bind(this, this._initPanelService));
|
2012-05-29 13:30:14 -04:00
|
|
|
this._ibus.connect('disconnected', Lang.bind(this, this._clear));
|
|
|
|
},
|
|
|
|
|
|
|
|
_initEngines: function(ibus, result) {
|
|
|
|
let enginesList = this._ibus.list_engines_async_finish(result);
|
|
|
|
if (enginesList) {
|
|
|
|
for (let i = 0; i < enginesList.length; ++i) {
|
|
|
|
let name = enginesList[i].get_name();
|
|
|
|
this._engines[name] = enginesList[i];
|
|
|
|
}
|
2012-12-10 14:34:43 -05:00
|
|
|
this._updateReadiness();
|
2012-05-29 13:30:14 -04:00
|
|
|
} else {
|
|
|
|
this._clear();
|
2012-05-29 13:30:46 -04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
_initPanelService: function(ibus, result) {
|
|
|
|
let success = this._ibus.request_name_async_finish(result);
|
|
|
|
if (success) {
|
|
|
|
this._panelService = new IBus.PanelService({ connection: this._ibus.get_connection(),
|
|
|
|
object_path: IBus.PATH_PANEL });
|
|
|
|
this._candidatePopup.setPanelService(this._panelService);
|
2012-09-01 17:57:53 -04:00
|
|
|
// Need to set this to get 'global-engine-changed' emitions
|
|
|
|
this._ibus.set_watch_ibus_signal(true);
|
2012-12-13 14:48:13 -05:00
|
|
|
this._ibus.connect('global-engine-changed', Lang.bind(this, this._engineChanged));
|
2012-09-01 17:57:53 -04:00
|
|
|
this._panelService.connect('update-property', Lang.bind(this, this._updateProperty));
|
2012-12-13 14:48:13 -05:00
|
|
|
// If an engine is already active we need to get its properties
|
|
|
|
this._ibus.get_global_engine_async(-1, null, Lang.bind(this, function(i, result) {
|
|
|
|
let engine = this._ibus.get_global_engine_async_finish(result);
|
|
|
|
if (!engine)
|
|
|
|
return;
|
|
|
|
this._engineChanged(this._ibus, engine.get_name());
|
|
|
|
}));
|
2012-12-10 14:34:43 -05:00
|
|
|
this._updateReadiness();
|
2012-05-29 13:30:46 -04:00
|
|
|
} else {
|
|
|
|
this._clear();
|
2012-05-29 13:30:14 -04:00
|
|
|
}
|
2012-05-29 13:30:46 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
_updateReadiness: function() {
|
|
|
|
this._ready = (Object.keys(this._engines).length > 0 &&
|
|
|
|
this._panelService != null);
|
|
|
|
|
2012-12-10 14:34:43 -05:00
|
|
|
if (this._readyCallback)
|
|
|
|
this._readyCallback(this._ready);
|
2012-05-29 13:30:14 -04:00
|
|
|
},
|
|
|
|
|
2012-12-13 14:48:13 -05:00
|
|
|
_engineChanged: function(bus, engineName) {
|
|
|
|
this._currentEngineName = engineName;
|
2012-09-01 17:57:53 -04:00
|
|
|
|
|
|
|
if (this._registerPropertiesId != 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this._registerPropertiesId =
|
|
|
|
this._panelService.connect('register-properties', Lang.bind(this, function(p, props) {
|
|
|
|
if (!props.get(0))
|
|
|
|
return;
|
|
|
|
|
|
|
|
this._panelService.disconnect(this._registerPropertiesId);
|
|
|
|
this._registerPropertiesId = 0;
|
|
|
|
|
2012-12-13 14:48:13 -05:00
|
|
|
this.emit('properties-registered', this._currentEngineName, props);
|
2012-09-01 17:57:53 -04:00
|
|
|
}));
|
|
|
|
},
|
|
|
|
|
|
|
|
_updateProperty: function(panel, prop) {
|
2012-12-13 14:48:13 -05:00
|
|
|
this.emit('property-updated', this._currentEngineName, prop);
|
2012-09-01 17:57:53 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
activateProperty: function(key, state) {
|
|
|
|
this._panelService.property_activate(key, state);
|
|
|
|
},
|
|
|
|
|
2012-05-29 13:30:14 -04:00
|
|
|
getEngineDesc: function(id) {
|
|
|
|
if (!IBus || !this._ready)
|
|
|
|
return null;
|
|
|
|
|
|
|
|
return this._engines[id];
|
|
|
|
}
|
|
|
|
});
|
2012-09-01 17:57:53 -04:00
|
|
|
Signals.addSignalMethods(IBusManager.prototype);
|
2012-04-18 22:01:29 -04:00
|
|
|
|
2011-11-20 08:10:48 -05:00
|
|
|
const LayoutMenuItem = new Lang.Class({
|
|
|
|
Name: 'LayoutMenuItem',
|
|
|
|
Extends: PopupMenu.PopupBaseMenuItem,
|
2011-01-04 17:04:56 -05:00
|
|
|
|
2012-04-18 22:01:29 -04:00
|
|
|
_init: function(displayName, shortName) {
|
2011-11-20 08:10:48 -05:00
|
|
|
this.parent();
|
2011-01-04 17:04:56 -05:00
|
|
|
|
2012-04-18 22:01:29 -04:00
|
|
|
this.label = new St.Label({ text: displayName });
|
|
|
|
this.indicator = new St.Label({ text: shortName });
|
2011-01-04 17:04:56 -05:00
|
|
|
this.addActor(this.label);
|
|
|
|
this.addActor(this.indicator);
|
2012-09-20 09:02:49 -04:00
|
|
|
this.actor.label_actor = this.label;
|
2011-01-04 17:04:56 -05:00
|
|
|
}
|
2011-11-20 08:10:48 -05:00
|
|
|
});
|
2011-01-04 17:04:56 -05:00
|
|
|
|
2012-12-13 10:31:03 -05:00
|
|
|
const InputSource = new Lang.Class({
|
|
|
|
Name: 'InputSource',
|
|
|
|
|
|
|
|
_init: function(type, id, displayName, shortName, index) {
|
|
|
|
this.type = type;
|
|
|
|
this.id = id;
|
|
|
|
this.displayName = displayName;
|
|
|
|
this._shortName = shortName;
|
|
|
|
this.index = index;
|
|
|
|
|
|
|
|
this._menuItem = new LayoutMenuItem(this.displayName, this._shortName);
|
|
|
|
this._menuItem.connect('activate', Lang.bind(this, this.activate));
|
|
|
|
this._indicatorLabel = new St.Label({ text: this._shortName });
|
2012-12-13 14:48:13 -05:00
|
|
|
|
|
|
|
this.properties = null;
|
2012-12-13 10:31:03 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
destroy: function() {
|
|
|
|
this._menuItem.destroy();
|
|
|
|
this._indicatorLabel.destroy();
|
|
|
|
},
|
|
|
|
|
|
|
|
get shortName() {
|
|
|
|
return this._shortName;
|
|
|
|
},
|
|
|
|
|
|
|
|
set shortName(v) {
|
|
|
|
this._shortName = v;
|
|
|
|
this._menuItem.indicator.set_text(v);
|
|
|
|
this._indicatorLabel.set_text(v);
|
|
|
|
},
|
|
|
|
|
|
|
|
get menuItem() {
|
|
|
|
return this._menuItem;
|
|
|
|
},
|
|
|
|
|
|
|
|
get indicatorLabel() {
|
|
|
|
return this._indicatorLabel;
|
|
|
|
},
|
|
|
|
|
|
|
|
activate: function() {
|
|
|
|
this.emit('activate');
|
|
|
|
},
|
|
|
|
});
|
|
|
|
Signals.addSignalMethods(InputSource.prototype);
|
|
|
|
|
2012-12-10 14:35:29 -05:00
|
|
|
const InputSourcePopup = new Lang.Class({
|
|
|
|
Name: 'InputSourcePopup',
|
|
|
|
Extends: SwitcherPopup.SwitcherPopup,
|
|
|
|
|
|
|
|
_init: function(items, action, actionBackward) {
|
|
|
|
this.parent(items);
|
|
|
|
|
|
|
|
this._action = action;
|
|
|
|
this._actionBackward = actionBackward;
|
|
|
|
},
|
|
|
|
|
|
|
|
_createSwitcher: function() {
|
|
|
|
this._switcherList = new InputSourceSwitcher(this._items);
|
|
|
|
return true;
|
|
|
|
},
|
|
|
|
|
|
|
|
_initialSelection: function(backward, binding) {
|
|
|
|
if (binding == 'switch-input-source') {
|
|
|
|
if (backward)
|
|
|
|
this._selectedIndex = this._items.length - 1;
|
|
|
|
} else if (binding == 'switch-input-source-backward') {
|
|
|
|
if (!backward)
|
|
|
|
this._selectedIndex = this._items.length - 1;
|
|
|
|
}
|
|
|
|
this._select(this._selectedIndex);
|
|
|
|
},
|
|
|
|
|
|
|
|
_keyPressHandler: function(keysym, backwards, action) {
|
|
|
|
if (action == this._action)
|
|
|
|
this._select(backwards ? this._previous() : this._next());
|
|
|
|
else if (action == this._actionBackward)
|
|
|
|
this._select(backwards ? this._next() : this._previous());
|
|
|
|
else if (keysym == Clutter.Left)
|
|
|
|
this._select(this._previous());
|
|
|
|
else if (keysym == Clutter.Right)
|
|
|
|
this._select(this._next());
|
|
|
|
},
|
|
|
|
|
|
|
|
_finish : function() {
|
|
|
|
this.parent();
|
|
|
|
|
|
|
|
this._items[this._selectedIndex].activate();
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
const InputSourceSwitcher = new Lang.Class({
|
|
|
|
Name: 'InputSourceSwitcher',
|
|
|
|
Extends: SwitcherPopup.SwitcherList,
|
|
|
|
|
|
|
|
_init: function(items) {
|
|
|
|
this.parent(true);
|
|
|
|
|
|
|
|
for (let i = 0; i < items.length; i++)
|
|
|
|
this._addIcon(items[i]);
|
|
|
|
},
|
|
|
|
|
|
|
|
_addIcon: function(item) {
|
|
|
|
let box = new St.BoxLayout({ vertical: true });
|
|
|
|
|
|
|
|
let bin = new St.Bin({ style_class: 'input-source-switcher-symbol' });
|
|
|
|
let symbol = new St.Label({ text: item.shortName });
|
|
|
|
bin.set_child(symbol);
|
|
|
|
box.add(bin, { x_fill: false, y_fill: false } );
|
|
|
|
|
|
|
|
let text = new St.Label({ text: item.displayName });
|
|
|
|
box.add(text, { x_fill: false });
|
|
|
|
|
|
|
|
this.addItem(box, text);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2012-04-18 22:01:29 -04:00
|
|
|
const InputSourceIndicator = new Lang.Class({
|
|
|
|
Name: 'InputSourceIndicator',
|
2011-11-20 09:38:48 -05:00
|
|
|
Extends: PanelMenu.Button,
|
2011-01-04 17:04:56 -05:00
|
|
|
|
|
|
|
_init: function() {
|
2012-03-23 16:12:51 -04:00
|
|
|
this.parent(0.0, _("Keyboard"));
|
2011-01-04 17:04:56 -05:00
|
|
|
|
|
|
|
this._container = new Shell.GenericContainer();
|
2011-09-19 08:07:40 -04:00
|
|
|
this._container.connect('get-preferred-width', Lang.bind(this, this._containerGetPreferredWidth));
|
|
|
|
this._container.connect('get-preferred-height', Lang.bind(this, this._containerGetPreferredHeight));
|
|
|
|
this._container.connect('allocate', Lang.bind(this, this._containerAllocate));
|
2011-06-09 11:50:24 -04:00
|
|
|
this.actor.add_actor(this._container);
|
2011-09-19 08:21:43 -04:00
|
|
|
this.actor.add_style_class_name('panel-status-button');
|
2011-01-04 17:04:56 -05:00
|
|
|
|
2012-12-13 10:31:03 -05:00
|
|
|
// All valid input sources currently in the gsettings
|
|
|
|
// KEY_INPUT_SOURCES list indexed by their index there
|
|
|
|
this._inputSources = {};
|
2012-12-13 14:48:13 -05:00
|
|
|
// All valid input sources currently in the gsettings
|
|
|
|
// KEY_INPUT_SOURCES list of type INPUT_SOURCE_TYPE_IBUS
|
|
|
|
// indexed by the IBus ID
|
|
|
|
this._ibusSources = {};
|
2012-12-13 10:31:03 -05:00
|
|
|
|
|
|
|
this._currentSource = null;
|
2011-01-04 17:04:56 -05:00
|
|
|
|
2012-12-10 14:34:43 -05:00
|
|
|
// All valid input sources currently in the gsettings
|
|
|
|
// KEY_INPUT_SOURCES list ordered by most recently used
|
|
|
|
this._mruSources = [];
|
2012-12-10 14:35:29 -05:00
|
|
|
this._keybindingAction =
|
|
|
|
Main.wm.addKeybinding('switch-input-source',
|
2012-12-18 10:04:14 -05:00
|
|
|
new Gio.Settings({ schema: "org.gnome.desktop.wm.keybindings" }),
|
2012-12-10 14:35:29 -05:00
|
|
|
Meta.KeyBindingFlags.REVERSES,
|
|
|
|
Main.KeybindingMode.ALL,
|
|
|
|
Lang.bind(this, this._switchInputSource));
|
|
|
|
this._keybindingActionBackward =
|
|
|
|
Main.wm.addKeybinding('switch-input-source-backward',
|
2012-12-18 10:04:14 -05:00
|
|
|
new Gio.Settings({ schema: "org.gnome.desktop.wm.keybindings" }),
|
2012-12-10 14:35:29 -05:00
|
|
|
Meta.KeyBindingFlags.REVERSES |
|
|
|
|
Meta.KeyBindingFlags.REVERSED,
|
|
|
|
Main.KeybindingMode.ALL,
|
|
|
|
Lang.bind(this, this._switchInputSource));
|
2012-04-18 22:01:29 -04:00
|
|
|
this._settings = new Gio.Settings({ schema: DESKTOP_INPUT_SOURCES_SCHEMA });
|
|
|
|
this._settings.connect('changed::' + KEY_CURRENT_INPUT_SOURCE, Lang.bind(this, this._currentInputSourceChanged));
|
|
|
|
this._settings.connect('changed::' + KEY_INPUT_SOURCES, Lang.bind(this, this._inputSourcesChanged));
|
2011-01-04 17:04:56 -05:00
|
|
|
|
2012-04-18 22:01:29 -04:00
|
|
|
this._xkbInfo = new GnomeDesktop.XkbInfo();
|
|
|
|
|
2012-09-18 06:17:58 -04:00
|
|
|
this._propSeparator = new PopupMenu.PopupSeparatorMenuItem();
|
|
|
|
this.menu.addMenuItem(this._propSeparator);
|
2012-09-01 17:57:53 -04:00
|
|
|
this._propSection = new PopupMenu.PopupMenuSection();
|
|
|
|
this.menu.addMenuItem(this._propSection);
|
|
|
|
this._propSection.actor.hide();
|
2012-05-29 13:30:14 -04:00
|
|
|
|
2012-12-10 14:34:43 -05:00
|
|
|
this._ibusReady = false;
|
|
|
|
this._ibusManager = new IBusManager(Lang.bind(this, this._ibusReadyCallback));
|
2012-09-01 17:57:53 -04:00
|
|
|
this._ibusManager.connect('properties-registered', Lang.bind(this, this._ibusPropertiesRegistered));
|
|
|
|
this._ibusManager.connect('property-updated', Lang.bind(this, this._ibusPropertyUpdated));
|
2012-04-18 22:01:29 -04:00
|
|
|
this._inputSourcesChanged();
|
2011-01-04 17:04:56 -05:00
|
|
|
|
2012-09-01 08:42:53 -04:00
|
|
|
this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
|
|
|
|
this._showLayoutItem = this.menu.addAction(_("Show Keyboard Layout"), Lang.bind(this, this._showLayout));
|
|
|
|
|
|
|
|
Main.sessionMode.connect('updated', Lang.bind(this, this._sessionUpdated));
|
|
|
|
this._sessionUpdated();
|
|
|
|
|
|
|
|
this.menu.addSettingsAction(_("Region and Language Settings"), 'gnome-region-panel.desktop');
|
2013-01-08 20:01:33 -05:00
|
|
|
|
|
|
|
this._sourcesPerWindow = false;
|
|
|
|
this._focusWindowNotifyId = 0;
|
|
|
|
this._overviewShowingId = 0;
|
|
|
|
this._overviewHiddenId = 0;
|
|
|
|
this._settings.connect('changed::per-window', Lang.bind(this, this._sourcesPerWindowChanged));
|
|
|
|
this._sourcesPerWindowChanged();
|
2012-09-01 08:42:53 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
_sessionUpdated: function() {
|
2012-05-16 19:43:59 -04:00
|
|
|
// re-using "allowSettings" for the keyboard layout is a bit shady,
|
|
|
|
// but at least for now it is used as "allow popping up windows
|
|
|
|
// from shell menus"; we can always add a separate sessionMode
|
|
|
|
// option if need arises.
|
2012-10-01 22:29:21 -04:00
|
|
|
this._showLayoutItem.actor.visible = Main.sessionMode.allowSettings;
|
2012-05-22 18:27:06 -04:00
|
|
|
},
|
|
|
|
|
2012-12-10 14:34:43 -05:00
|
|
|
_ibusReadyCallback: function(ready) {
|
|
|
|
if (this._ibusReady == ready)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this._ibusReady = ready;
|
|
|
|
this._mruSources = [];
|
|
|
|
this._inputSourcesChanged();
|
|
|
|
},
|
|
|
|
|
2012-12-10 14:35:29 -05:00
|
|
|
_switchInputSource: function(display, screen, window, binding) {
|
|
|
|
let popup = new InputSourcePopup(this._mruSources, this._keybindingAction, this._keybindingActionBackward);
|
|
|
|
let modifiers = binding.get_modifiers();
|
|
|
|
let backwards = modifiers & Meta.VirtualModifier.SHIFT_MASK;
|
|
|
|
if (!popup.show(backwards, binding.get_name(), binding.get_mask()))
|
|
|
|
popup.destroy();
|
|
|
|
},
|
|
|
|
|
2012-04-18 22:01:29 -04:00
|
|
|
_currentInputSourceChanged: function() {
|
2012-12-13 10:31:03 -05:00
|
|
|
let nVisibleSources = Object.keys(this._inputSources).length;
|
|
|
|
let newSourceIndex = this._settings.get_uint(KEY_CURRENT_INPUT_SOURCE);
|
|
|
|
let newSource = this._inputSources[newSourceIndex];
|
2012-09-01 17:57:53 -04:00
|
|
|
|
2012-12-13 14:48:13 -05:00
|
|
|
if (!newSource || (nVisibleSources < 2 && !newSource.properties)) {
|
2012-09-01 17:57:53 -04:00
|
|
|
// This source index might be invalid if we weren't able
|
|
|
|
// to build a menu item for it, so we hide ourselves since
|
|
|
|
// we can't fix it here. *shrug*
|
|
|
|
|
|
|
|
// We also hide if we have only one visible source unless
|
|
|
|
// it's an IBus source with properties.
|
2012-04-18 22:01:29 -04:00
|
|
|
this.menu.close();
|
|
|
|
this.actor.hide();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-09-01 17:57:53 -04:00
|
|
|
this.actor.show();
|
|
|
|
|
2012-12-13 10:31:03 -05:00
|
|
|
let oldSource;
|
|
|
|
[oldSource, this._currentSource] = [this._currentSource, newSource];
|
2012-09-01 17:57:53 -04:00
|
|
|
|
2012-12-13 10:31:03 -05:00
|
|
|
if (oldSource) {
|
|
|
|
oldSource.menuItem.setShowDot(false);
|
|
|
|
this._container.set_skip_paint(oldSource.indicatorLabel, true);
|
|
|
|
}
|
2012-09-01 17:57:53 -04:00
|
|
|
|
2012-12-13 10:31:03 -05:00
|
|
|
newSource.menuItem.setShowDot(true);
|
|
|
|
this._container.set_skip_paint(newSource.indicatorLabel, false);
|
2012-12-13 14:48:13 -05:00
|
|
|
|
|
|
|
this._buildPropSection(newSource.properties);
|
2012-12-10 14:34:43 -05:00
|
|
|
|
|
|
|
for (let i = 1; i < this._mruSources.length; ++i)
|
|
|
|
if (this._mruSources[i] == newSource) {
|
|
|
|
let currentSource = this._mruSources.splice(i, 1);
|
|
|
|
this._mruSources = currentSource.concat(this._mruSources);
|
|
|
|
break;
|
|
|
|
}
|
2013-01-08 20:01:33 -05:00
|
|
|
|
|
|
|
this._changePerWindowSource();
|
2011-05-15 13:31:02 -04:00
|
|
|
},
|
|
|
|
|
2012-04-18 22:01:29 -04:00
|
|
|
_inputSourcesChanged: function() {
|
|
|
|
let sources = this._settings.get_value(KEY_INPUT_SOURCES);
|
|
|
|
let nSources = sources.n_children();
|
|
|
|
|
2012-12-13 10:31:03 -05:00
|
|
|
for (let i in this._inputSources)
|
|
|
|
this._inputSources[i].destroy();
|
2012-04-18 22:01:29 -04:00
|
|
|
|
2012-12-13 10:31:03 -05:00
|
|
|
this._inputSources = {};
|
2012-12-13 14:48:13 -05:00
|
|
|
this._ibusSources = {};
|
2012-04-18 22:01:29 -04:00
|
|
|
|
2012-12-13 10:31:03 -05:00
|
|
|
let inputSourcesByShortName = {};
|
2012-04-18 22:01:29 -04:00
|
|
|
|
|
|
|
for (let i = 0; i < nSources; i++) {
|
2012-12-13 10:31:03 -05:00
|
|
|
let displayName;
|
|
|
|
let shortName;
|
2012-04-18 22:01:29 -04:00
|
|
|
let [type, id] = sources.get_child_value(i).deep_unpack();
|
2012-12-13 10:31:03 -05:00
|
|
|
let exists = false;
|
2012-04-18 22:01:29 -04:00
|
|
|
|
2012-05-29 13:30:14 -04:00
|
|
|
if (type == INPUT_SOURCE_TYPE_XKB) {
|
2012-12-13 10:31:03 -05:00
|
|
|
[exists, displayName, shortName, , ] =
|
2012-05-29 13:30:14 -04:00
|
|
|
this._xkbInfo.get_layout_info(id);
|
|
|
|
} else if (type == INPUT_SOURCE_TYPE_IBUS) {
|
|
|
|
let engineDesc = this._ibusManager.getEngineDesc(id);
|
|
|
|
if (engineDesc) {
|
2012-08-31 12:14:48 -04:00
|
|
|
let language = IBus.get_language_name(engineDesc.get_language());
|
2012-12-13 10:31:03 -05:00
|
|
|
exists = true;
|
|
|
|
displayName = language + ' (' + engineDesc.get_longname() + ')';
|
|
|
|
shortName = this._makeEngineShortName(engineDesc);
|
2012-05-29 13:30:14 -04:00
|
|
|
}
|
|
|
|
}
|
2012-04-18 22:01:29 -04:00
|
|
|
|
2012-12-13 10:31:03 -05:00
|
|
|
if (!exists)
|
2012-04-18 22:01:29 -04:00
|
|
|
continue;
|
|
|
|
|
2012-12-13 10:31:03 -05:00
|
|
|
let is = new InputSource(type, id, displayName, shortName, i);
|
2012-04-18 22:01:29 -04:00
|
|
|
|
2012-12-13 10:31:03 -05:00
|
|
|
is.connect('activate', Lang.bind(this, function() {
|
2013-01-08 20:01:59 -05:00
|
|
|
if (this._currentSource.index == is.index)
|
|
|
|
return;
|
2012-12-13 10:31:03 -05:00
|
|
|
this._settings.set_value(KEY_CURRENT_INPUT_SOURCE,
|
|
|
|
GLib.Variant.new_uint32(is.index));
|
|
|
|
}));
|
|
|
|
|
|
|
|
if (!(is.shortName in inputSourcesByShortName))
|
|
|
|
inputSourcesByShortName[is.shortName] = [];
|
|
|
|
inputSourcesByShortName[is.shortName].push(is);
|
|
|
|
|
|
|
|
this._inputSources[is.index] = is;
|
2012-12-13 14:48:13 -05:00
|
|
|
|
|
|
|
if (is.type == INPUT_SOURCE_TYPE_IBUS)
|
|
|
|
this._ibusSources[is.id] = is;
|
2011-01-04 17:04:56 -05:00
|
|
|
}
|
|
|
|
|
2012-12-13 10:31:03 -05:00
|
|
|
let menuIndex = 0;
|
|
|
|
for (let i in this._inputSources) {
|
|
|
|
let is = this._inputSources[i];
|
|
|
|
if (inputSourcesByShortName[is.shortName].length > 1) {
|
|
|
|
let sub = inputSourcesByShortName[is.shortName].indexOf(is) + 1;
|
|
|
|
is.shortName += String.fromCharCode(0x2080 + sub);
|
2012-04-18 22:01:29 -04:00
|
|
|
}
|
2011-01-04 17:04:56 -05:00
|
|
|
|
2012-12-13 10:31:03 -05:00
|
|
|
this.menu.addMenuItem(is.menuItem, menuIndex++);
|
2011-01-04 17:04:56 -05:00
|
|
|
|
2012-12-13 10:31:03 -05:00
|
|
|
this._container.add_actor(is.indicatorLabel);
|
|
|
|
this._container.set_skip_paint(is.indicatorLabel, true);
|
2011-01-04 17:04:56 -05:00
|
|
|
}
|
|
|
|
|
2012-12-10 14:34:43 -05:00
|
|
|
let sourcesList = [];
|
|
|
|
for (let i in this._inputSources)
|
|
|
|
sourcesList.push(this._inputSources[i]);
|
|
|
|
|
|
|
|
let mruSources = [];
|
|
|
|
for (let i = 0; i < this._mruSources.length; i++) {
|
|
|
|
for (let j = 0; j < sourcesList.length; j++)
|
|
|
|
if (this._mruSources[i].type == sourcesList[j].type &&
|
|
|
|
this._mruSources[i].id == sourcesList[j].id) {
|
|
|
|
mruSources = mruSources.concat(sourcesList.splice(j, 1));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this._mruSources = mruSources.concat(sourcesList);
|
|
|
|
|
2012-04-18 22:01:29 -04:00
|
|
|
this._currentInputSourceChanged();
|
2011-01-04 17:04:56 -05:00
|
|
|
},
|
|
|
|
|
2012-04-18 22:01:29 -04:00
|
|
|
_showLayout: function() {
|
|
|
|
Main.overview.hide();
|
2011-01-04 17:04:56 -05:00
|
|
|
|
2012-12-13 10:31:03 -05:00
|
|
|
let source = this._currentSource;
|
2012-05-29 13:30:14 -04:00
|
|
|
let xkbLayout = '';
|
|
|
|
let xkbVariant = '';
|
|
|
|
|
2012-12-13 10:31:03 -05:00
|
|
|
if (source.type == INPUT_SOURCE_TYPE_XKB) {
|
|
|
|
[, , , xkbLayout, xkbVariant] = this._xkbInfo.get_layout_info(source.id);
|
|
|
|
} else if (source.type == INPUT_SOURCE_TYPE_IBUS) {
|
|
|
|
let engineDesc = this._ibusManager.getEngineDesc(source.id);
|
2012-05-29 13:30:14 -04:00
|
|
|
if (engineDesc) {
|
|
|
|
xkbLayout = engineDesc.get_layout();
|
|
|
|
xkbVariant = '';
|
|
|
|
}
|
|
|
|
}
|
2011-01-04 17:04:56 -05:00
|
|
|
|
2012-04-18 22:01:29 -04:00
|
|
|
if (!xkbLayout || xkbLayout.length == 0)
|
|
|
|
return;
|
2011-01-04 17:04:56 -05:00
|
|
|
|
2012-04-18 22:01:29 -04:00
|
|
|
let description = xkbLayout;
|
|
|
|
if (xkbVariant.length > 0)
|
|
|
|
description = description + '\t' + xkbVariant;
|
2011-01-04 17:04:56 -05:00
|
|
|
|
2012-04-18 22:01:29 -04:00
|
|
|
Util.spawn(['gkbd-keyboard-display', '-l', description]);
|
2011-01-04 17:04:56 -05:00
|
|
|
},
|
|
|
|
|
2012-09-09 16:44:25 -04:00
|
|
|
_makeEngineShortName: function(engineDesc) {
|
|
|
|
let symbol = engineDesc.get_symbol();
|
|
|
|
if (symbol && symbol[0])
|
|
|
|
return symbol;
|
|
|
|
|
|
|
|
let langCode = engineDesc.get_language().split('_', 1)[0];
|
|
|
|
if (langCode.length == 2 || langCode.length == 3)
|
|
|
|
return langCode.toLowerCase();
|
|
|
|
|
|
|
|
return String.fromCharCode(0x2328); // keyboard glyph
|
|
|
|
},
|
|
|
|
|
2012-12-13 14:48:13 -05:00
|
|
|
_ibusPropertiesRegistered: function(im, engineName, props) {
|
|
|
|
let source = this._ibusSources[engineName];
|
|
|
|
if (!source)
|
|
|
|
return;
|
|
|
|
|
|
|
|
source.properties = props;
|
|
|
|
|
|
|
|
if (source == this._currentSource)
|
|
|
|
this._currentInputSourceChanged();
|
2012-09-01 17:57:53 -04:00
|
|
|
},
|
|
|
|
|
2012-12-13 14:48:13 -05:00
|
|
|
_ibusPropertyUpdated: function(im, engineName, prop) {
|
|
|
|
let source = this._ibusSources[engineName];
|
|
|
|
if (!source)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (this._updateSubProperty(source.properties, prop) &&
|
|
|
|
source == this._currentSource)
|
|
|
|
this._currentInputSourceChanged();
|
2012-09-01 17:57:53 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
_updateSubProperty: function(props, prop) {
|
|
|
|
if (!props)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
let p;
|
|
|
|
for (let i = 0; (p = props.get(i)) != null; ++i) {
|
|
|
|
if (p.get_key() == prop.get_key() && p.get_prop_type() == prop.get_prop_type()) {
|
|
|
|
p.update(prop);
|
|
|
|
return true;
|
|
|
|
} else if (p.get_prop_type() == IBus.PropType.MENU) {
|
|
|
|
if (this._updateSubProperty(p.get_sub_props(), prop))
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
},
|
|
|
|
|
2012-12-13 14:48:13 -05:00
|
|
|
_buildPropSection: function(properties) {
|
2012-09-18 06:17:58 -04:00
|
|
|
this._propSeparator.actor.hide();
|
2012-09-01 17:57:53 -04:00
|
|
|
this._propSection.actor.hide();
|
|
|
|
this._propSection.removeAll();
|
|
|
|
|
2012-12-13 14:48:13 -05:00
|
|
|
this._buildPropSubMenu(this._propSection, properties);
|
2012-09-01 17:57:53 -04:00
|
|
|
|
2012-09-18 06:17:58 -04:00
|
|
|
if (!this._propSection.isEmpty()) {
|
2012-09-01 17:57:53 -04:00
|
|
|
this._propSection.actor.show();
|
2012-09-18 06:17:58 -04:00
|
|
|
this._propSeparator.actor.show();
|
|
|
|
}
|
2012-09-01 17:57:53 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
_buildPropSubMenu: function(menu, props) {
|
|
|
|
if (!props)
|
|
|
|
return;
|
|
|
|
|
|
|
|
let radioGroup = [];
|
|
|
|
let p;
|
|
|
|
for (let i = 0; (p = props.get(i)) != null; ++i) {
|
|
|
|
let prop = p;
|
|
|
|
|
2012-11-24 10:38:21 -05:00
|
|
|
if (!prop.get_visible())
|
2012-09-01 17:57:53 -04:00
|
|
|
continue;
|
|
|
|
|
|
|
|
if (prop.get_key() == 'InputMode') {
|
|
|
|
let text;
|
|
|
|
if (prop.get_symbol)
|
|
|
|
text = prop.get_symbol().get_text();
|
|
|
|
else
|
|
|
|
text = prop.get_label().get_text();
|
|
|
|
|
|
|
|
if (text && text.length > 0 && text.length < 3)
|
2012-12-13 14:48:13 -05:00
|
|
|
this._currentSource.indicatorLabel.set_text(text);
|
2012-09-01 17:57:53 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
let item;
|
2012-11-24 09:56:06 -05:00
|
|
|
switch (prop.get_prop_type()) {
|
|
|
|
case IBus.PropType.MENU:
|
2012-09-01 17:57:53 -04:00
|
|
|
item = new PopupMenu.PopupSubMenuMenuItem(prop.get_label().get_text());
|
|
|
|
this._buildPropSubMenu(item.menu, prop.get_sub_props());
|
2012-11-24 09:56:06 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
case IBus.PropType.RADIO:
|
2012-09-01 17:57:53 -04:00
|
|
|
item = new PopupMenu.PopupMenuItem(prop.get_label().get_text());
|
|
|
|
item.prop = prop;
|
|
|
|
radioGroup.push(item);
|
|
|
|
item.radioGroup = radioGroup;
|
|
|
|
item.setShowDot(prop.get_state() == IBus.PropState.CHECKED);
|
|
|
|
item.connect('activate', Lang.bind(this, function() {
|
|
|
|
if (item.prop.get_state() == IBus.PropState.CHECKED)
|
|
|
|
return;
|
|
|
|
|
|
|
|
let group = item.radioGroup;
|
|
|
|
for (let i = 0; i < group.length; ++i) {
|
|
|
|
if (group[i] == item) {
|
|
|
|
item.setShowDot(true);
|
|
|
|
item.prop.set_state(IBus.PropState.CHECKED);
|
|
|
|
this._ibusManager.activateProperty(item.prop.get_key(),
|
|
|
|
IBus.PropState.CHECKED);
|
|
|
|
} else {
|
|
|
|
group[i].setShowDot(false);
|
|
|
|
group[i].prop.set_state(IBus.PropState.UNCHECKED);
|
|
|
|
this._ibusManager.activateProperty(group[i].prop.get_key(),
|
|
|
|
IBus.PropState.UNCHECKED);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}));
|
2012-11-24 09:56:06 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
case IBus.PropType.TOGGLE:
|
|
|
|
item = new PopupMenu.PopupSwitchMenuItem(prop.get_label().get_text(), prop.get_state() == IBus.PropState.CHECKED);
|
|
|
|
item.prop = prop;
|
|
|
|
item.connect('toggled', Lang.bind(this, function() {
|
|
|
|
if (item.state) {
|
|
|
|
item.prop.set_state(IBus.PropState.CHECKED);
|
|
|
|
this._ibusManager.activateProperty(item.prop.get_key(),
|
|
|
|
IBus.PropState.CHECKED);
|
|
|
|
} else {
|
|
|
|
item.prop.set_state(IBus.PropState.UNCHECKED);
|
|
|
|
this._ibusManager.activateProperty(item.prop.get_key(),
|
|
|
|
IBus.PropState.UNCHECKED);
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IBus.PropType.NORMAL:
|
|
|
|
item = new PopupMenu.PopupMenuItem(prop.get_label().get_text());
|
|
|
|
item.prop = prop;
|
|
|
|
item.connect('activate', Lang.bind(this, function() {
|
|
|
|
this._ibusManager.activateProperty(item.prop.get_key(),
|
|
|
|
IBus.PropState.CHECKED);
|
|
|
|
}));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IBus.PropType.SEPARATOR:
|
|
|
|
item = new PopupMenu.PopupSeparatorMenuItem();
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
log ('IBus property %s has invalid type %d'.format(prop.get_key(), type));
|
2012-09-01 17:57:53 -04:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
item.setSensitive(prop.get_sensitive());
|
|
|
|
menu.addMenuItem(item);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2013-01-08 20:01:33 -05:00
|
|
|
_getNewInputSource: function(current) {
|
|
|
|
for (let i in this._inputSources) {
|
|
|
|
let is = this._inputSources[i];
|
|
|
|
if (is.type == current.type &&
|
|
|
|
is.id == current.id)
|
|
|
|
return is;
|
|
|
|
}
|
|
|
|
return this._currentSource;
|
|
|
|
},
|
|
|
|
|
|
|
|
_getCurrentWindow: function() {
|
|
|
|
if (Main.overview.visible)
|
|
|
|
return Main.overview;
|
|
|
|
else
|
|
|
|
return global.display.focus_window;
|
|
|
|
},
|
|
|
|
|
|
|
|
_setPerWindowInputSource: function() {
|
|
|
|
let window = this._getCurrentWindow();
|
|
|
|
if (!window)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!window._inputSources) {
|
|
|
|
window._inputSources = this._inputSources;
|
|
|
|
window._currentSource = this._currentSource;
|
|
|
|
} else if (window._inputSources == this._inputSources) {
|
|
|
|
window._currentSource.activate();
|
|
|
|
} else {
|
|
|
|
window._inputSources = this._inputSources;
|
|
|
|
window._currentSource = this._getNewInputSource(window._currentSource);
|
|
|
|
window._currentSource.activate();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
_sourcesPerWindowChanged: function() {
|
|
|
|
this._sourcesPerWindow = this._settings.get_boolean('per-window');
|
|
|
|
|
|
|
|
if (this._sourcesPerWindow && this._focusWindowNotifyId == 0) {
|
|
|
|
this._focusWindowNotifyId = global.display.connect('notify::focus-window',
|
|
|
|
Lang.bind(this, this._setPerWindowInputSource));
|
|
|
|
this._overviewShowingId = Main.overview.connect('showing',
|
|
|
|
Lang.bind(this, this._setPerWindowInputSource));
|
|
|
|
this._overviewHiddenId = Main.overview.connect('hidden',
|
|
|
|
Lang.bind(this, this._setPerWindowInputSource));
|
|
|
|
} else if (!this._sourcesPerWindow && this._focusWindowNotifyId != 0) {
|
|
|
|
global.display.disconnect(this._focusWindowNotifyId);
|
|
|
|
this._focusWindowNotifyId = 0;
|
|
|
|
Main.overview.disconnect(this._overviewShowingId);
|
|
|
|
this._overviewShowingId = 0;
|
|
|
|
Main.overview.disconnect(this._overviewHiddenId);
|
|
|
|
this._overviewHiddenId = 0;
|
|
|
|
|
|
|
|
let windows = global.get_window_actors().map(function(w) {
|
|
|
|
return w.meta_window;
|
|
|
|
});
|
|
|
|
for (let i = 0; i < windows.length; ++i) {
|
|
|
|
delete windows[i]._inputSources;
|
|
|
|
delete windows[i]._currentSource;
|
|
|
|
}
|
|
|
|
delete Main.overview._inputSources;
|
|
|
|
delete Main.overview._currentSource;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
_changePerWindowSource: function() {
|
|
|
|
if (!this._sourcesPerWindow)
|
|
|
|
return;
|
|
|
|
|
|
|
|
let window = this._getCurrentWindow();
|
|
|
|
if (!window)
|
|
|
|
return;
|
|
|
|
|
|
|
|
window._inputSources = this._inputSources;
|
|
|
|
window._currentSource = this._currentSource;
|
|
|
|
},
|
|
|
|
|
2011-09-19 08:07:40 -04:00
|
|
|
_containerGetPreferredWidth: function(container, for_height, alloc) {
|
|
|
|
// Here, and in _containerGetPreferredHeight, we need to query
|
|
|
|
// for the height of all children, but we ignore the results
|
|
|
|
// for those we don't actually display.
|
2011-01-04 17:04:56 -05:00
|
|
|
let max_min_width = 0, max_natural_width = 0;
|
|
|
|
|
2012-12-13 10:31:03 -05:00
|
|
|
for (let i in this._inputSources) {
|
|
|
|
let is = this._inputSources[i];
|
|
|
|
let [min_width, natural_width] = is.indicatorLabel.get_preferred_width(for_height);
|
2012-04-18 22:01:29 -04:00
|
|
|
max_min_width = Math.max(max_min_width, min_width);
|
|
|
|
max_natural_width = Math.max(max_natural_width, natural_width);
|
2011-01-04 17:04:56 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
alloc.min_size = max_min_width;
|
|
|
|
alloc.natural_size = max_natural_width;
|
|
|
|
},
|
|
|
|
|
2011-09-19 08:07:40 -04:00
|
|
|
_containerGetPreferredHeight: function(container, for_width, alloc) {
|
2011-01-04 17:04:56 -05:00
|
|
|
let max_min_height = 0, max_natural_height = 0;
|
2012-04-18 22:01:29 -04:00
|
|
|
|
2012-12-13 10:31:03 -05:00
|
|
|
for (let i in this._inputSources) {
|
|
|
|
let is = this._inputSources[i];
|
|
|
|
let [min_height, natural_height] = is.indicatorLabel.get_preferred_height(for_width);
|
2012-04-18 22:01:29 -04:00
|
|
|
max_min_height = Math.max(max_min_height, min_height);
|
|
|
|
max_natural_height = Math.max(max_natural_height, natural_height);
|
2011-01-04 17:04:56 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
alloc.min_size = max_min_height;
|
|
|
|
alloc.natural_size = max_natural_height;
|
|
|
|
},
|
|
|
|
|
2011-09-19 08:07:40 -04:00
|
|
|
_containerAllocate: function(container, box, flags) {
|
2011-01-04 17:04:56 -05:00
|
|
|
// translate box to (0, 0)
|
|
|
|
box.x2 -= box.x1;
|
|
|
|
box.x1 = 0;
|
|
|
|
box.y2 -= box.y1;
|
|
|
|
box.y1 = 0;
|
|
|
|
|
2012-12-13 10:31:03 -05:00
|
|
|
for (let i in this._inputSources) {
|
|
|
|
let is = this._inputSources[i];
|
|
|
|
is.indicatorLabel.allocate_align_fill(box, 0.5, 0, false, false, flags);
|
|
|
|
}
|
2011-01-04 17:04:56 -05:00
|
|
|
}
|
2011-11-20 09:38:48 -05:00
|
|
|
});
|