cleanup: Port GObject classes to JS6 classes

GJS added API for defining GObject classes with ES6 class syntax
last cycle, use it to port the remaining Lang.Class classes to
the new syntax.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/361
This commit is contained in:
Florian Müllner
2017-10-31 02:23:39 +01:00
committed by Georges Basile Stavracas Neto
parent bacfdbbb03
commit e68dfed1f7
43 changed files with 1036 additions and 1235 deletions

View File

@ -1,7 +1,7 @@
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
const Clutter = imports.gi.Clutter;
const Lang = imports.lang;
const GObject = imports.gi.GObject;
const Meta = imports.gi.Meta;
const St = imports.gi.St;
@ -9,10 +9,8 @@ const SwitcherPopup = imports.ui.switcherPopup;
var APP_ICON_SIZE = 96;
var SwitchMonitorPopup = new Lang.Class({
Name: 'SwitchMonitorPopup',
Extends: SwitcherPopup.SwitcherPopup,
var SwitchMonitorPopup = GObject.registerClass(
class SwitchMonitorPopup extends SwitcherPopup.SwitcherPopup {
_init() {
let items = [{ icon: 'view-mirror-symbolic',
/* Translators: this is for display mirroring i.e. cloning.
@ -35,23 +33,23 @@ var SwitchMonitorPopup = new Lang.Class({
*/
label: _('Built-in Only') }];
this.parent(items);
super._init(items);
this._switcherList = new SwitchMonitorSwitcher(items);
},
}
show(backward, binding, mask) {
if (!Meta.MonitorManager.get().can_switch_config())
return false;
return this.parent(backward, binding, mask);
},
return super.show(backward, binding, mask);
}
_initialSelection() {
let currentConfig = Meta.MonitorManager.get().get_switch_config();
let selectConfig = (currentConfig + 1) % Meta.MonitorSwitchConfigType.UNKNOWN;
this._select(selectConfig);
},
}
_keyPressHandler(keysym, action) {
if (action == Meta.KeyBindingAction.SWITCH_MONITOR)
@ -64,25 +62,23 @@ var SwitchMonitorPopup = new Lang.Class({
return Clutter.EVENT_PROPAGATE;
return Clutter.EVENT_STOP;
},
}
_finish() {
this.parent();
super._finish();
Meta.MonitorManager.get().switch_config(this._selectedIndex);
},
}
});
var SwitchMonitorSwitcher = new Lang.Class({
Name: 'SwitchMonitorSwitcher',
Extends: SwitcherPopup.SwitcherList,
var SwitchMonitorSwitcher = GObject.registerClass(
class SwitchMonitorSwitcher extends SwitcherPopup.SwitcherList {
_init(items) {
this.parent(true);
super._init(true);
for (let i = 0; i < items.length; i++)
this._addIcon(items[i]);
},
}
_addIcon(item) {
let box = new St.BoxLayout({ style_class: 'alt-tab-app',
@ -98,4 +94,3 @@ var SwitchMonitorSwitcher = new Lang.Class({
this.addItem(box, text);
}
});