[gnome-shell] js: Use GTypeFlags to define abstract GObject classes



commit 7e70dd8453f964312c451080a6a6b4865253958e
Author: Florian Müllner <fmuellner gnome org>
Date:   Sat Apr 27 20:45:14 2019 +0200

    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

 js/ui/altTab.js        | 8 +++-----
 js/ui/switcherPopup.js | 8 +++-----
 2 files changed, 6 insertions(+), 10 deletions(-)
---
diff --git a/js/ui/altTab.js b/js/ui/altTab.js
index 0212992be..ae9846552 100644
--- a/js/ui/altTab.js
+++ b/js/ui/altTab.js
@@ -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();
diff --git a/js/ui/switcherPopup.js b/js/ui/switcherPopup.js
index cd0125786..d324a90f4 100644
--- a/js/ui/switcherPopup.js
+++ b/js/ui/switcherPopup.js
@@ -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 });


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]