[gnome-shell-extensions] cleanup: Use static class blocks for gtype registration



commit 9f673f27ef5c652af4773c47580015cc54bfdf11
Author: Florian Müllner <fmuellner gnome org>
Date:   Thu Feb 10 01:49:22 2022 +0100

    cleanup: Use static class blocks for gtype registration
    
    gjs enabled support for static class blocks, which gives us a
    less error-prone and more readable alternative to _classInit(),
    provided we make sure to call registerClass() first.
    
    Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/215>

 extensions/apps-menu/extension.js            | 21 +++++++---
 extensions/auto-move-windows/prefs.js        | 59 +++++++++++++++-------------
 extensions/drive-menu/extension.js           | 14 +++++--
 extensions/places-menu/extension.js          | 14 +++++--
 extensions/user-theme/prefs.js               | 14 +++++--
 extensions/window-list/extension.js          | 54 +++++++++++++++----------
 extensions/window-list/prefs.js              |  7 +++-
 extensions/window-list/windowPicker.js       | 44 ++++++++++++++-------
 extensions/window-list/workspaceIndicator.js | 31 ++++++++++-----
 extensions/windowsNavigator/extension.js     | 14 +++++--
 extensions/workspace-indicator/extension.js  | 28 +++++++++----
 extensions/workspace-indicator/prefs.js      | 29 ++++++++------
 12 files changed, 212 insertions(+), 117 deletions(-)
---
diff --git a/extensions/apps-menu/extension.js b/extensions/apps-menu/extension.js
index ef4741d..cc1d697 100644
--- a/extensions/apps-menu/extension.js
+++ b/extensions/apps-menu/extension.js
@@ -24,8 +24,11 @@ const NAVIGATION_REGION_OVERSHOOT = 50;
 Gio._promisify(Gio._LocalFilePrototype, 'query_info_async', 'query_info_finish');
 Gio._promisify(Gio._LocalFilePrototype, 'set_attributes_async', 'set_attributes_finish');
 
-var ApplicationMenuItem = GObject.registerClass(
 class ApplicationMenuItem extends PopupMenu.PopupBaseMenuItem {
+    static {
+        GObject.registerClass(this);
+    }
+
     constructor(button, app) {
         super();
         this._app = app;
@@ -93,10 +96,13 @@ class ApplicationMenuItem extends PopupMenu.PopupBaseMenuItem {
         icon.style_class = 'icon-dropshadow';
         this._iconBin.set_child(icon);
     }
-});
+}
 
-var CategoryMenuItem = GObject.registerClass(
 class CategoryMenuItem extends PopupMenu.PopupBaseMenuItem {
+    static {
+        GObject.registerClass(this);
+    }
+
     constructor(button, category) {
         super();
         this._category = category;
@@ -214,7 +220,7 @@ class CategoryMenuItem extends PopupMenu.PopupBaseMenuItem {
         this._button.selectCategory(this._category);
         this._button.scrollToCatButton(this);
     }
-});
+}
 
 class ApplicationsMenu extends PopupMenu.PopupMenu {
     constructor(sourceActor, arrowAlignment, arrowSide, button) {
@@ -353,8 +359,11 @@ class DesktopTarget {
 }
 Signals.addSignalMethods(DesktopTarget.prototype);
 
-let ApplicationsButton = GObject.registerClass(
 class ApplicationsButton extends PanelMenu.Button {
+    static {
+        GObject.registerClass(this);
+    }
+
     constructor() {
         super(1.0, null, false);
 
@@ -665,7 +674,7 @@ class ApplicationsButton extends PanelMenu.Button {
 
         return applist;
     }
-});
+}
 
 let appsMenuButton;
 
diff --git a/extensions/auto-move-windows/prefs.js b/extensions/auto-move-windows/prefs.js
index 908d328..793db06 100644
--- a/extensions/auto-move-windows/prefs.js
+++ b/extensions/auto-move-windows/prefs.js
@@ -12,17 +12,14 @@ const SETTINGS_KEY = 'application-list';
 
 const WORKSPACE_MAX = 36; // compiled in limit of mutter
 
-const AutoMoveSettingsWidget = GObject.registerClass(
 class AutoMoveSettingsWidget extends Adw.PreferencesGroup {
-    static _classInit(klass) {
-        klass = super._classInit(klass);
+    static {
+        GObject.registerClass(this);
 
-        klass.install_action('rules.add', null, self => self._addNewRule());
-        klass.install_action('rules.remove', 's',
+        this.install_action('rules.add', null, self => self._addNewRule());
+        this.install_action('rules.remove', 's',
             (self, name, param) => self._removeRule(param.unpack()));
-        klass.install_action('rules.update', null, self => self._saveRules());
-
-        return klass;
+        this.install_action('rules.update', null, self => self._saveRules());
     }
 
     constructor() {
@@ -107,22 +104,20 @@ class AutoMoveSettingsWidget extends Adw.PreferencesGroup {
         this._settings.unblock_signal_handler(this._changedId);
         this.action_set_enabled('rules.update', true);
     }
-});
+}
 
-const WorkspaceSelector = GObject.registerClass({
-    Properties: {
+class WorkspaceSelector extends Gtk.Widget {
+    static [GObject.properties] = {
         'number': GObject.ParamSpec.uint(
             'number', 'number', 'number',
             GObject.ParamFlags.READWRITE,
             1, WORKSPACE_MAX, 1),
-    },
-}, class WorkspaceSelector extends Gtk.Widget {
-    static _classInit(klass) {
-        super._classInit(klass);
+    };
 
-        klass.set_layout_manager_type(Gtk.BoxLayout);
+    static {
+        GObject.registerClass(this);
 
-        return klass;
+        this.set_layout_manager_type(Gtk.BoxLayout);
     }
 
     constructor() {
@@ -166,10 +161,10 @@ const WorkspaceSelector = GObject.registerClass({
         this._decButton.sensitive = this.number > 1;
         this._incButton.sensitive = this.number < WORKSPACE_MAX;
     }
-});
+}
 
-const RuleRow = GObject.registerClass({
-    Properties: {
+class RuleRow extends Adw.ActionRow {
+    static [GObject.properties] = {
         'id': GObject.ParamSpec.string(
             'id', 'id', 'id',
             GObject.ParamFlags.READABLE,
@@ -178,8 +173,12 @@ const RuleRow = GObject.registerClass({
             'value', 'value', 'value',
             GObject.ParamFlags.READWRITE,
             1, WORKSPACE_MAX, 1),
-    },
-}, class RuleRow extends Adw.ActionRow {
+    };
+
+    static {
+        GObject.registerClass(this);
+    }
+
     constructor(appInfo, value) {
         super({
             activatable: false,
@@ -217,10 +216,13 @@ const RuleRow = GObject.registerClass({
     get id() {
         return this._appInfo.get_id();
     }
-});
+}
 
-const NewRuleRow = GObject.registerClass(
 class NewRuleRow extends Gtk.ListBoxRow {
+    static {
+        GObject.registerClass(this);
+    }
+
     constructor() {
         super({
             action_name: 'rules.add',
@@ -236,10 +238,13 @@ class NewRuleRow extends Gtk.ListBoxRow {
         this.update_property(
             [Gtk.AccessibleProperty.LABEL], [_('Add Rule')]);
     }
-});
+}
 
-const NewRuleDialog = GObject.registerClass(
 class NewRuleDialog extends Gtk.AppChooserDialog {
+    static {
+        GObject.registerClass(this);
+    }
+
     constructor(parent) {
         super({
             transient_for: parent,
@@ -264,7 +269,7 @@ class NewRuleDialog extends Gtk.AppChooserDialog {
         this.set_response_sensitive(Gtk.ResponseType.OK,
             appInfo && !rules.some(i => i.startsWith(appInfo.get_id())));
     }
-});
+}
 
 /** */
 function init() {
diff --git a/extensions/drive-menu/extension.js b/extensions/drive-menu/extension.js
index 7c74b4c..d054f87 100644
--- a/extensions/drive-menu/extension.js
+++ b/extensions/drive-menu/extension.js
@@ -12,8 +12,11 @@ const _ = ExtensionUtils.gettext;
 
 Gio._promisify(Gio.File.prototype, 'query_filesystem_info_async');
 
-var MountMenuItem = GObject.registerClass(
 class MountMenuItem extends PopupMenu.PopupBaseMenuItem {
+    static {
+        GObject.registerClass(this);
+    }
+
     constructor(mount) {
         super({
             style_class: 'drive-menu-item',
@@ -131,10 +134,13 @@ class MountMenuItem extends PopupMenu.PopupBaseMenuItem {
 
         super.activate(event);
     }
-});
+}
 
-let DriveMenu = GObject.registerClass(
 class DriveMenu extends PanelMenu.Button {
+    static {
+        GObject.registerClass(this);
+    }
+
     constructor() {
         super(0.0, _('Removable devices'));
 
@@ -204,7 +210,7 @@ class DriveMenu extends PanelMenu.Button {
 
         super._onDestroy();
     }
-});
+}
 
 /** */
 function init() {
diff --git a/extensions/places-menu/extension.js b/extensions/places-menu/extension.js
index d263686..7c51220 100644
--- a/extensions/places-menu/extension.js
+++ b/extensions/places-menu/extension.js
@@ -16,8 +16,11 @@ const N_ = x => x;
 
 const PLACE_ICON_SIZE = 16;
 
-var PlaceMenuItem = GObject.registerClass(
 class PlaceMenuItem extends PopupMenu.PopupBaseMenuItem {
+    static {
+        GObject.registerClass(this);
+    }
+
     constructor(info) {
         super({
             style_class: 'place-menu-item',
@@ -73,7 +76,7 @@ class PlaceMenuItem extends PopupMenu.PopupBaseMenuItem {
         this._icon.gicon = info.icon;
         this._label.text = info.name;
     }
-});
+}
 
 const SECTIONS = [
     'special',
@@ -82,8 +85,11 @@ const SECTIONS = [
     'network',
 ];
 
-let PlacesMenu = GObject.registerClass(
 class PlacesMenu extends PanelMenu.Button {
+    static {
+        GObject.registerClass(this);
+    }
+
     constructor() {
         super(0.0, _('Places'));
 
@@ -130,7 +136,7 @@ class PlacesMenu extends PanelMenu.Button {
 
         this._sections[id].actor.visible = places.length > 0;
     }
-});
+}
 
 /** */
 function init() {
diff --git a/extensions/user-theme/prefs.js b/extensions/user-theme/prefs.js
index 94e2d3e..3876c5a 100644
--- a/extensions/user-theme/prefs.js
+++ b/extensions/user-theme/prefs.js
@@ -15,8 +15,11 @@ Gio._promisify(Gio.File.prototype, 'enumerate_children_async');
 Gio._promisify(Gio.File.prototype, 'query_info_async');
 Gio._promisify(Gio.FileEnumerator.prototype, 'next_files_async');
 
-const UserThemePrefsWidget = GObject.registerClass(
 class UserThemePrefsWidget extends Adw.PreferencesGroup {
+    static {
+        GObject.registerClass(this);
+    }
+
     constructor() {
         super({ title: 'Themes' });
 
@@ -101,10 +104,13 @@ class UserThemePrefsWidget extends Adw.PreferencesGroup {
 
         return fileInfos.map(info => info.get_name());
     }
-});
+}
 
-const ThemeRow = GObject.registerClass(
 class ThemeRow extends Adw.ActionRow {
+    static {
+        GObject.registerClass(this);
+    }
+
     constructor(name) {
         const check = new Gtk.CheckButton({
             action_name: 'theme.name',
@@ -117,7 +123,7 @@ class ThemeRow extends Adw.ActionRow {
         });
         this.add_prefix(check);
     }
-});
+}
 
 /** */
 function init() {
diff --git a/extensions/window-list/extension.js b/extensions/window-list/extension.js
index 7b83313..f7e0a41 100644
--- a/extensions/window-list/extension.js
+++ b/extensions/window-list/extension.js
@@ -106,8 +106,11 @@ class WindowContextMenu extends PopupMenu.PopupMenu {
     }
 }
 
-const WindowTitle = GObject.registerClass(
 class WindowTitle extends St.BoxLayout {
+    static {
+        GObject.registerClass(this);
+    }
+
     constructor(metaWindow) {
         super({
             style_class: 'window-button-box',
@@ -175,18 +178,21 @@ class WindowTitle extends St.BoxLayout {
         this._metaWindow.disconnect(this._notifyWmClass);
         this._metaWindow.disconnect(this._notifyAppId);
     }
-});
+}
 
+class BaseButton extends St.Button {
+    static {
+        GObject.registerClass({
+            GTypeFlags: GObject.TypeFlags.ABSTRACT,
+            Properties: {
+                'ignore-workspace': GObject.ParamSpec.boolean(
+                    'ignore-workspace', 'ignore-workspace', 'ignore-workspace',
+                    GObject.ParamFlags.READWRITE,
+                    false),
+            },
+        }, this);
+    }
 
-const BaseButton = GObject.registerClass({
-    GTypeFlags: GObject.TypeFlags.ABSTRACT,
-    Properties: {
-        'ignore-workspace': GObject.ParamSpec.boolean(
-            'ignore-workspace', 'ignore-workspace', 'ignore-workspace',
-            GObject.ParamFlags.READWRITE,
-            false),
-    },
-}, class BaseButton extends St.Button {
     constructor(perMonitor, monitorIndex) {
         super({
             style_class: 'window-button',
@@ -344,11 +350,13 @@ const BaseButton = GObject.registerClass({
             global.display.disconnect(this._windowLeftMonitorId);
         this._windowLeftMonitorId = 0;
     }
-});
-
+}
 
-const WindowButton = GObject.registerClass(
 class WindowButton extends BaseButton {
+    static {
+        GObject.registerClass(this);
+    }
+
     constructor(metaWindow, perMonitor, monitorIndex) {
         super(perMonitor, monitorIndex);
 
@@ -422,8 +430,7 @@ class WindowButton extends BaseButton {
         global.display.disconnect(this._notifyFocusId);
         this._contextMenu.destroy();
     }
-});
-
+}
 
 class AppContextMenu extends PopupMenu.PopupMenu {
     constructor(source) {
@@ -483,8 +490,11 @@ class AppContextMenu extends PopupMenu.PopupMenu {
     }
 }
 
-const AppButton = GObject.registerClass(
 class AppButton extends BaseButton {
+    static {
+        GObject.registerClass(this);
+    }
+
     constructor(app, perMonitor, monitorIndex) {
         super(perMonitor, monitorIndex);
 
@@ -670,11 +680,13 @@ class AppButton extends BaseButton {
         this.app.disconnect(this._windowsChangedId);
         this._menu.destroy();
     }
-});
-
+}
 
-const WindowList = GObject.registerClass(
 class WindowList extends St.Widget {
+    static {
+        GObject.registerClass(this);
+    }
+
     constructor(perMonitor, monitor) {
         super({
             name: 'panel',
@@ -1082,7 +1094,7 @@ class WindowList extends St.Widget {
         for (let i = 0; i < windows.length; i++)
             windows[i].metaWindow.set_icon_geometry(null);
     }
-});
+}
 
 class Extension {
     constructor() {
diff --git a/extensions/window-list/prefs.js b/extensions/window-list/prefs.js
index e6c8750..02b5234 100644
--- a/extensions/window-list/prefs.js
+++ b/extensions/window-list/prefs.js
@@ -12,8 +12,11 @@ function init() {
     ExtensionUtils.initTranslations();
 }
 
-const WindowListPrefsWidget = GObject.registerClass(
 class WindowListPrefsWidget extends Adw.PreferencesPage {
+    static {
+        GObject.registerClass(this);
+    }
+
     constructor() {
         super();
 
@@ -79,7 +82,7 @@ class WindowListPrefsWidget extends Adw.PreferencesPage {
         row.add_suffix(toggle);
         miscGroup.add(row);
     }
-});
+}
 
 /**
  * @returns {Gtk.Widget} - the prefs widget
diff --git a/extensions/window-list/windowPicker.js b/extensions/window-list/windowPicker.js
index e4c2c98..db33156 100644
--- a/extensions/window-list/windowPicker.js
+++ b/extensions/window-list/windowPicker.js
@@ -13,8 +13,11 @@ const {
     ControlsState,
 } = imports.ui.overviewControls;
 
-let MyWorkspacesDisplay = GObject.registerClass(
 class MyWorkspacesDisplay extends WorkspacesDisplay {
+    static {
+        GObject.registerClass(this);
+    }
+
     constructor(controls, overviewAdjustment) {
         let workspaceManager = global.workspace_manager;
 
@@ -75,10 +78,13 @@ class MyWorkspacesDisplay extends WorkspacesDisplay {
 
         super._onDestroy();
     }
-});
+}
 
-const MyWorkspace = GObject.registerClass(
 class MyWorkspace extends Workspace.Workspace {
+    static {
+        GObject.registerClass(this);
+    }
+
     constructor(...args) {
         super(...args);
 
@@ -102,10 +108,13 @@ class MyWorkspace extends Workspace.Workspace {
             this._overviewAdjustment.disconnect(this._adjChangedId);
         this._adjChangedId = 0;
     }
-});
+}
 
-const MyWorkspaceBackground = GObject.registerClass(
 class MyWorkspaceBackground extends Workspace.WorkspaceBackground {
+    static {
+        GObject.registerClass(this);
+    }
+
     _updateBorderRadius() {
     }
 
@@ -138,13 +147,17 @@ class MyWorkspaceBackground extends Workspace.WorkspaceBackground {
             offsets.top + contentHeight + offsets.bottom);
         this._backgroundGroup.allocate(contentBox);
     }
-});
+}
 
-var WindowPicker = GObject.registerClass({
-    Signals: {
+var WindowPicker = class WindowPicker extends Clutter.Actor {
+    static [GObject.signals] = {
         'open-state-changed': { param_types: [GObject.TYPE_BOOLEAN] },
-    },
-}, class extends Clutter.Actor {
+    };
+
+    static {
+        GObject.registerClass(this);
+    }
+
     constructor() {
         super({ reactive: true });
 
@@ -311,10 +324,13 @@ var WindowPicker = GObject.registerClass({
             global.stage.disconnect(this._stageKeyPressId);
         this._stageKeyPressId = 0;
     }
-});
+};
+
+var WindowPickerToggle = class WindowPickerToggle extends St.Button {
+    static {
+        GObject.registerClass(this);
+    }
 
-var WindowPickerToggle = GObject.registerClass(
-class WindowPickerToggle extends St.Button {
     constructor() {
         let iconBin = new St.Widget({
             layout_manager: new Clutter.BinLayout(),
@@ -345,4 +361,4 @@ class WindowPickerToggle extends St.Button {
             this.checked = Main.windowPicker.visible;
         });
     }
-});
+};
diff --git a/extensions/window-list/workspaceIndicator.js b/extensions/window-list/workspaceIndicator.js
index 610c3aa..36d66bb 100644
--- a/extensions/window-list/workspaceIndicator.js
+++ b/extensions/window-list/workspaceIndicator.js
@@ -14,8 +14,11 @@ const TOOLTIP_ANIMATION_TIME = 150;
 
 const MAX_THUMBNAILS = 6;
 
-let WindowPreview = GObject.registerClass(
 class WindowPreview extends St.Button {
+    static {
+        GObject.registerClass(this);
+    }
+
     constructor(window) {
         super({
             style_class: 'window-list-window-preview',
@@ -69,10 +72,13 @@ class WindowPreview extends St.Button {
             this._window.window_type !== Meta.WindowType.DESKTOP &&
             this._window.showing_on_its_workspace();
     }
-});
+}
 
-let WorkspaceLayout = GObject.registerClass(
 class WorkspaceLayout extends Clutter.LayoutManager {
+    static {
+        GObject.registerClass(this);
+    }
+
     vfunc_get_preferred_width() {
         return [0, 0];
     }
@@ -99,10 +105,13 @@ class WorkspaceLayout extends Clutter.LayoutManager {
             child.allocate(childBox);
         }
     }
-});
+}
 
-let WorkspaceThumbnail = GObject.registerClass(
 class WorkspaceThumbnail extends St.Button {
+    static {
+        GObject.registerClass(this);
+    }
+
     constructor(index) {
         super({
             style_class: 'workspace',
@@ -241,10 +250,13 @@ class WorkspaceThumbnail extends St.Button {
         this._workspace.disconnect(this._windowRemovedId);
         global.display.disconnect(this._restackedId);
     }
-});
+}
+
+var WorkspaceIndicator = class WorkspaceIndicator extends PanelMenu.Button {
+    static {
+        GObject.registerClass(this);
+    }
 
-var WorkspaceIndicator = GObject.registerClass(
-class WorkspaceIndicator extends PanelMenu.Button {
     constructor() {
         super(0.0, _('Workspace Indicator'), true);
         this.setMenu(new PopupMenu.PopupMenu(this, 0.0, St.Side.BOTTOM));
@@ -435,5 +447,4 @@ class WorkspaceIndicator extends PanelMenu.Button {
         let newIndex = this._currentWorkspace + diff;
         this._activate(newIndex);
     }
-});
-
+};
diff --git a/extensions/windowsNavigator/extension.js b/extensions/windowsNavigator/extension.js
index c3c0faf..f279430 100644
--- a/extensions/windowsNavigator/extension.js
+++ b/extensions/windowsNavigator/extension.js
@@ -9,8 +9,11 @@ const WorkspacesView = imports.ui.workspacesView;
 
 const WINDOW_SLOT = 4;
 
-var MyWorkspace = GObject.registerClass(
 class MyWorkspace extends Workspace.Workspace {
+    static {
+        GObject.registerClass(this);
+    }
+
     constructor(...args) {
         super(...args);
 
@@ -115,10 +118,13 @@ class MyWorkspace extends Workspace.Workspace {
 
         return clone;
     }
-});
+}
 
-var MyWorkspacesView = GObject.registerClass(
 class MyWorkspacesView extends WorkspacesView.WorkspacesView {
+    static {
+        GObject.registerClass(this);
+    }
+
     constructor(...args) {
         super(...args);
 
@@ -243,7 +249,7 @@ class MyWorkspacesView extends WorkspacesView.WorkspacesView {
         }
         return false;
     }
-});
+}
 
 class Extension {
     constructor() {
diff --git a/extensions/workspace-indicator/extension.js b/extensions/workspace-indicator/extension.js
index 07d01a4..e424a69 100644
--- a/extensions/workspace-indicator/extension.js
+++ b/extensions/workspace-indicator/extension.js
@@ -19,8 +19,11 @@ const TOOLTIP_ANIMATION_TIME = 150;
 
 const MAX_THUMBNAILS = 6;
 
-let WindowPreview = GObject.registerClass(
 class WindowPreview extends St.Button {
+    static {
+        GObject.registerClass(this);
+    }
+
     constructor(window) {
         super({
             style_class: 'workspace-indicator-window-preview',
@@ -74,10 +77,13 @@ class WindowPreview extends St.Button {
             this._window.window_type !== Meta.WindowType.DESKTOP &&
             this._window.showing_on_its_workspace();
     }
-});
+}
 
-let WorkspaceLayout = GObject.registerClass(
 class WorkspaceLayout extends Clutter.LayoutManager {
+    static {
+        GObject.registerClass(this);
+    }
+
     vfunc_get_preferred_width() {
         return [0, 0];
     }
@@ -104,10 +110,13 @@ class WorkspaceLayout extends Clutter.LayoutManager {
             child.allocate(childBox);
         }
     }
-});
+}
 
-let WorkspaceThumbnail = GObject.registerClass(
 class WorkspaceThumbnail extends St.Button {
+    static {
+        GObject.registerClass(this);
+    }
+
     constructor(index) {
         super({
             style_class: 'workspace',
@@ -246,10 +255,13 @@ class WorkspaceThumbnail extends St.Button {
         this._workspace.disconnect(this._windowRemovedId);
         global.display.disconnect(this._restackedId);
     }
-});
+}
 
-let WorkspaceIndicator = GObject.registerClass(
 class WorkspaceIndicator extends PanelMenu.Button {
+    static {
+        GObject.registerClass(this);
+    }
+
     constructor() {
         super(0.0, _('Workspace Indicator'));
 
@@ -440,7 +452,7 @@ class WorkspaceIndicator extends PanelMenu.Button {
         let newIndex = global.workspace_manager.get_active_workspace_index() + diff;
         this._activate(newIndex);
     }
-});
+}
 
 /** */
 function init() {
diff --git a/extensions/workspace-indicator/prefs.js b/extensions/workspace-indicator/prefs.js
index dcc3848..bf64fed 100644
--- a/extensions/workspace-indicator/prefs.js
+++ b/extensions/workspace-indicator/prefs.js
@@ -11,19 +11,16 @@ const N_ = e => e;
 const WORKSPACE_SCHEMA = 'org.gnome.desktop.wm.preferences';
 const WORKSPACE_KEY = 'workspace-names';
 
-const WorkspaceSettingsWidget = GObject.registerClass(
 class WorkspaceSettingsWidget extends Adw.PreferencesGroup {
-    static _classInit(klass) {
-        klass = super._classInit(klass);
+    static {
+        GObject.registerClass(this);
 
-        klass.install_action('workspaces.add', null,
+        this.install_action('workspaces.add', null,
             self => self._addNewName());
-        klass.install_action('workspaces.remove', 's',
+        this.install_action('workspaces.remove', 's',
             (self, name, param) => self._removeName(param.unpack()));
-        klass.install_action('workspaces.update', null,
+        this.install_action('workspaces.update', null,
             self => self._saveNames());
-
-        return klass;
     }
 
     constructor() {
@@ -85,10 +82,13 @@ class WorkspaceSettingsWidget extends Adw.PreferencesGroup {
             this._list.insert(new WorkspaceRow(n), newNames.indexOf(n));
         });
     }
-});
+}
 
-const WorkspaceRow = GObject.registerClass(
 class WorkspaceRow extends Adw.PreferencesRow {
+    static {
+        GObject.registerClass(this);
+    }
+
     constructor(name) {
         super({ name });
 
@@ -163,10 +163,13 @@ class WorkspaceRow extends Adw.PreferencesRow {
         this.grab_focus();
         this._stack.visible_child_name = 'display';
     }
-});
+}
 
-const NewWorkspaceRow = GObject.registerClass(
 class NewWorkspaceRow extends Adw.PreferencesRow {
+    static {
+        GObject.registerClass(this);
+    }
+
     constructor() {
         super({
             action_name: 'workspaces.add',
@@ -182,7 +185,7 @@ class NewWorkspaceRow extends Adw.PreferencesRow {
         this.update_property(
             [Gtk.AccessibleProperty.LABEL], [_('Add Workspace')]);
     }
-});
+}
 
 /** */
 function init() {


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