2017-06-08 10:49:20 -04:00
|
|
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
|
|
|
|
|
|
|
const Clutter = imports.gi.Clutter;
|
|
|
|
const Lang = imports.lang;
|
|
|
|
const Meta = imports.gi.Meta;
|
|
|
|
const St = imports.gi.St;
|
|
|
|
|
|
|
|
const SwitcherPopup = imports.ui.switcherPopup;
|
|
|
|
|
|
|
|
var APP_ICON_SIZE = 96;
|
|
|
|
|
|
|
|
var SwitchMonitorPopup = new Lang.Class({
|
|
|
|
Name: 'SwitchMonitorPopup',
|
|
|
|
Extends: SwitcherPopup.SwitcherPopup,
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_init() {
|
2017-06-08 10:49:20 -04:00
|
|
|
let items = [{ icon: 'view-mirror-symbolic',
|
|
|
|
/* Translators: this is for display mirroring i.e. cloning.
|
|
|
|
* Try to keep it under around 15 characters.
|
|
|
|
*/
|
|
|
|
label: _('Mirror') },
|
|
|
|
{ icon: 'video-joined-displays-symbolic',
|
|
|
|
/* Translators: this is for the desktop spanning displays.
|
|
|
|
* Try to keep it under around 15 characters.
|
|
|
|
*/
|
|
|
|
label: _('Join Displays') },
|
|
|
|
{ icon: 'video-single-display-symbolic',
|
|
|
|
/* Translators: this is for using only an external display.
|
|
|
|
* Try to keep it under around 15 characters.
|
|
|
|
*/
|
|
|
|
label: _('External Only') },
|
|
|
|
{ icon: 'computer-symbolic',
|
|
|
|
/* Translators: this is for using only the laptop display.
|
|
|
|
* Try to keep it under around 15 characters.
|
|
|
|
*/
|
|
|
|
label: _('Built-in Only') }];
|
|
|
|
|
|
|
|
this.parent(items);
|
|
|
|
|
|
|
|
this._switcherList = new SwitchMonitorSwitcher(items);
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
show(backward, binding, mask) {
|
2017-06-08 10:49:20 -04:00
|
|
|
if (!Meta.MonitorManager.get().can_switch_config())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return this.parent(backward, binding, mask);
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_initialSelection() {
|
2017-06-08 10:49:20 -04:00
|
|
|
let currentConfig = Meta.MonitorManager.get().get_switch_config();
|
|
|
|
currentConfig %= Meta.MonitorSwitchConfigType.UNKNOWN;
|
|
|
|
this._select(currentConfig);
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_keyPressHandler(keysym, action) {
|
2017-06-08 10:49:20 -04:00
|
|
|
if (action == Meta.KeyBindingAction.SWITCH_MONITOR)
|
|
|
|
this._select(this._next());
|
|
|
|
else if (keysym == Clutter.Left)
|
|
|
|
this._select(this._previous());
|
|
|
|
else if (keysym == Clutter.Right)
|
|
|
|
this._select(this._next());
|
|
|
|
else
|
|
|
|
return Clutter.EVENT_PROPAGATE;
|
|
|
|
|
|
|
|
return Clutter.EVENT_STOP;
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_finish() {
|
2017-06-08 10:49:20 -04:00
|
|
|
this.parent();
|
|
|
|
|
|
|
|
Meta.MonitorManager.get().switch_config(this._selectedIndex);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
var SwitchMonitorSwitcher = new Lang.Class({
|
|
|
|
Name: 'SwitchMonitorSwitcher',
|
|
|
|
Extends: SwitcherPopup.SwitcherList,
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_init(items) {
|
2017-06-08 10:49:20 -04:00
|
|
|
this.parent(true);
|
|
|
|
|
|
|
|
for (let i = 0; i < items.length; i++)
|
|
|
|
this._addIcon(items[i]);
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_addIcon(item) {
|
2017-06-08 10:49:20 -04:00
|
|
|
let box = new St.BoxLayout({ style_class: 'alt-tab-app',
|
|
|
|
vertical: true });
|
|
|
|
|
|
|
|
let icon = new St.Icon({ icon_name: item.icon,
|
|
|
|
icon_size: APP_ICON_SIZE });
|
|
|
|
box.add(icon, { x_fill: false, y_fill: false } );
|
|
|
|
|
|
|
|
let text = new St.Label({ text: item.label });
|
|
|
|
box.add(text, { x_fill: false });
|
|
|
|
|
|
|
|
this.addItem(box, text);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|