js: Use GTypeFlags to define abstract GObject classes

gjs now supports an optional GTypeFlags value for GObject subclasses
defined with GObject.registerClass(), so it is not possible to define
abstract classes on the gobject-level, just like from C.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/517
This commit is contained in:
Florian Müllner 2019-04-27 20:45:14 +02:00 committed by Florian Müllner
parent 2e209a82f9
commit 7e70dd8453
2 changed files with 6 additions and 10 deletions

View File

@ -474,12 +474,10 @@ var CyclerList = GObject.registerClass({
}
});
var CyclerPopup = GObject.registerClass(
class CyclerPopup extends SwitcherPopup.SwitcherPopup {
var CyclerPopup = GObject.registerClass({
GTypeFlags: GObject.TypeFlags.ABSTRACT
}, class CyclerPopup extends SwitcherPopup.SwitcherPopup {
_init() {
if (this.constructor.name === CyclerPopup.prototype.constructor.name)
throw new TypeError(`Cannot instantiate abstract class ${this.constructor.name}`);
super._init();
this._items = this._getWindows();

View File

@ -30,12 +30,10 @@ function primaryModifier(mask) {
return primary;
}
var SwitcherPopup = GObject.registerClass(
class SwitcherPopup extends St.Widget {
var SwitcherPopup = GObject.registerClass({
GTypeFlags: GObject.TypeFlags.ABSTRACT
}, class SwitcherPopup extends St.Widget {
_init(items) {
if (this.constructor.name === SwitcherPopup.prototype.constructor.name)
throw new TypeError(`Cannot instantiate abstract class ${this.constructor.name}`);
super._init({ style_class: 'switcher-popup',
reactive: true,
visible: false });