[gnome-shell-extensions] cleanup: Use inheritance for Actor classes instead of composition
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell-extensions] cleanup: Use inheritance for Actor classes instead of composition
- Date: Thu, 21 Nov 2019 21:23:53 +0000 (UTC)
commit 63615cb657f02136cc401a8c07b56d69eba61f83
Author: Marco Trevisan (Treviño) <mail 3v1n0 net>
Date: Mon Aug 12 17:13:43 2019 +0200
cleanup: Use inheritance for Actor classes instead of composition
Use GObject types when inheriting from native actor classes.
Related to https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/559
https://gitlab.gnome.org/GNOME/gnome-shell-extensions/merge_requests/89
extensions/window-list/extension.js | 4 ++--
extensions/window-list/windowPicker.js | 22 +++++++++---------
extensions/windowsNavigator/extension.js | 38 ++++++++++++++++++--------------
3 files changed, 36 insertions(+), 28 deletions(-)
---
diff --git a/extensions/window-list/extension.js b/extensions/window-list/extension.js
index 6521552..7223ef2 100644
--- a/extensions/window-list/extension.js
+++ b/extensions/window-list/extension.js
@@ -923,11 +923,11 @@ const WindowList = GObject.registerClass({
}
_updateKeyboardAnchor() {
- if (!Main.keyboard.actor)
+ if (!Main.keyboard.keyboardActor)
return;
let translationY = Main.overview.visible ? 0 : this.height;
- Main.keyboard.actor.translation_y = -translationY;
+ Main.keyboard.keyboardActor.translation_y = -translationY;
}
_onAppStateChanged(appSys, app) {
diff --git a/extensions/window-list/windowPicker.js b/extensions/window-list/windowPicker.js
index 5a26bd2..0e44fd5 100644
--- a/extensions/window-list/windowPicker.js
+++ b/extensions/window-list/windowPicker.js
@@ -6,18 +6,18 @@ const Main = imports.ui.main;
const Overview = imports.ui.overview;
const { WorkspacesDisplay } = imports.ui.workspacesView;
-let MyWorkspacesDisplay = class extends WorkspacesDisplay {
- constructor() {
- super();
+let MyWorkspacesDisplay = GObject.registerClass({
+ GTypeName: 'WindowList_MyWorkspacesDisplay'
+}, class MyWorkspacesDisplay extends WorkspacesDisplay {
+ _init() {
+ super._init();
- this.actor.add_constraint(
+ this.add_constraint(
new Layout.MonitorConstraint({
primary: true,
work_area: true,
}));
- this.actor.connect('destroy', this._onDestroy.bind(this));
-
this._workareasChangedId = global.display.connect('workareas-changed',
this._onWorkAreasChanged.bind(this));
this._onWorkAreasChanged();
@@ -50,8 +50,8 @@ let MyWorkspacesDisplay = class extends WorkspacesDisplay {
super._updateWorkspacesViews();
this._workspacesViews.forEach(v => {
- Main.layoutManager.overviewGroup.remove_actor(v.actor);
- Main.windowPicker.add_actor(v.actor);
+ Main.layoutManager.overviewGroup.remove_actor(v);
+ Main.windowPicker.add_actor(v);
});
}
@@ -59,8 +59,10 @@ let MyWorkspacesDisplay = class extends WorkspacesDisplay {
if (this._workareasChangedId)
global.display.disconnect(this._workareasChangedId);
this._workareasChangedId = 0;
+
+ super._onDestroy();
}
-};
+});
var WindowPicker = GObject.registerClass({
GTypeName: 'WindowListWindowPicker',
@@ -98,7 +100,7 @@ var WindowPicker = GObject.registerClass({
Main.overview.addAction = a => this._backgroundGroup.add_action(a);
this._workspacesDisplay = new MyWorkspacesDisplay();
- this.add_child(this._workspacesDisplay.actor);
+ this.add_child(this._workspacesDisplay);
Main.overview.addAction = addActionOrig;
diff --git a/extensions/windowsNavigator/extension.js b/extensions/windowsNavigator/extension.js
index 99a2d5d..d927b67 100644
--- a/extensions/windowsNavigator/extension.js
+++ b/extensions/windowsNavigator/extension.js
@@ -6,9 +6,11 @@ const Main = imports.ui.main;
const Workspace = imports.ui.workspace;
const WorkspacesView = imports.ui.workspacesView;
-var MyWindowOverlay = class extends Workspace.WindowOverlay {
- constructor(windowClone, parentActor) {
- super(windowClone, parentActor);
+var MyWindowOverlay = GObject.registerClass({
+ GTypeName: 'WindowsNavigator_MyWindowOverlay'
+}, class MyWindowOverlay extends Workspace.WindowOverlay {
+ _init(windowClone, parentActor) {
+ super._init(windowClone, parentActor);
this._id = null;
this._text = new St.Label({
@@ -39,21 +41,23 @@ var MyWindowOverlay = class extends Workspace.WindowOverlay {
this._text.set_position(Math.floor(textX) + 5, Math.floor(textY) + 5);
this._text.raise_top();
}
-};
+});
-var MyWorkspace = class extends Workspace.Workspace {
- constructor(metaWorkspace, monitorIndex) {
- super(metaWorkspace, monitorIndex);
+var MyWorkspace = GObject.registerClass({
+ GTypeName: 'WindowsNavigator_MyWorkspace'
+}, class MyWorkspace extends Workspace.Workspace {
+ _init(metaWorkspace, monitorIndex) {
+ super._init(metaWorkspace, monitorIndex);
if (metaWorkspace && metaWorkspace.index() < 9) {
this._tip = new St.Label({
style_class: 'extension-windowsNavigator-window-tooltip',
visible: false,
});
- this.actor.add_actor(this._tip);
+ this.add_actor(this._tip);
- this.actor.connect('notify::scale-x', () => {
- this._tip.set_scale(1 / this.actor.scale_x, 1 / this.actor.scale_x);
+ this.connect('notify::scale-x', () => {
+ this._tip.set_scale(1 / this.scale_x, 1 / this.scale_x);
});
} else {
this._tip = null;
@@ -67,7 +71,7 @@ var MyWorkspace = class extends Workspace.Workspace {
// Hand code this instead of using _getSpacingAndPadding
// because that fails on empty workspaces
- let node = this.actor.get_theme_node();
+ let node = this.get_theme_node();
let padding = {
left: node.get_padding(St.Side.LEFT),
top: node.get_padding(St.Side.TOP),
@@ -111,11 +115,13 @@ var MyWorkspace = class extends Workspace.Workspace {
this._windowOverlays[i].hideTooltip();
}
}
-};
+});
-var MyWorkspacesView = class extends WorkspacesView.WorkspacesView {
- constructor(width, height, x, y, workspaces) {
- super(width, height, x, y, workspaces);
+var MyWorkspacesView = GObject.registerClass({
+ GTypeName: 'WindowsNavigator_MyWorkspacesView'
+}, class MyWorkspacesView extends WorkspacesView.WorkspacesView {
+ _init(width, height, x, y, workspaces) {
+ super._init(width, height, x, y, workspaces);
this._pickWorkspace = false;
this._pickWindow = false;
@@ -238,7 +244,7 @@ var MyWorkspacesView = class extends WorkspacesView.WorkspacesView {
}
return false;
}
-};
+});
class Extension {
constructor() {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]