cleanup: Use inheritance for Actor classes instead of composition

Remove the `this.actor = ...` and `this.actor._delegate = this` patterns in most
of classes, by inheriting all the actor container classes.

Uses interfaces when needed for making sure that multiple classes will implement
some required methods or to avoid redefining the same code multiple times.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/559
This commit is contained in:
Marco Trevisan (Treviño)
2019-07-16 11:24:13 +02:00
committed by Florian Müllner
parent f67b409fc1
commit c4c5c4fd5c
58 changed files with 2000 additions and 1757 deletions

View File

@ -379,10 +379,11 @@ var WorkspaceTracker = class {
}
};
var TilePreview = class {
constructor() {
this.actor = new St.Widget();
global.window_group.add_actor(this.actor);
var TilePreview = GObject.registerClass(
class TilePreview extends St.Widget {
_init() {
super._init();
global.window_group.add_actor(this);
this._reset();
this._showing = false;
@ -393,7 +394,7 @@ var TilePreview = class {
if (!windowActor)
return;
global.window_group.set_child_below_sibling(this.actor, windowActor);
global.window_group.set_child_below_sibling(this, windowActor);
if (this._rect && this._rect.equal(tileRect))
return;
@ -414,14 +415,14 @@ var TilePreview = class {
width: monitor.width,
height: monitor.height });
let [, rect] = window.get_frame_rect().intersect(monitorRect);
this.actor.set_size(rect.width, rect.height);
this.actor.set_position(rect.x, rect.y);
this.actor.opacity = 0;
this.set_size(rect.width, rect.height);
this.set_position(rect.x, rect.y);
this.opacity = 0;
}
this._showing = true;
this.actor.show();
this.actor.ease({
this.show();
this.ease({
x: tileRect.x,
y: tileRect.y,
width: tileRect.width,
@ -437,7 +438,7 @@ var TilePreview = class {
return;
this._showing = false;
this.actor.ease({
this.ease({
opacity: 0,
duration: WINDOW_ANIMATION_TIME,
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
@ -446,7 +447,7 @@ var TilePreview = class {
}
_reset() {
this.actor.hide();
this.hide();
this._rect = null;
this._monitorIndex = -1;
}
@ -460,9 +461,9 @@ var TilePreview = class {
if (this._rect.x + this._rect.width == monitor.x + monitor.width)
styles.push('tile-preview-right');
this.actor.style_class = styles.join(' ');
this.style_class = styles.join(' ');
}
};
});
var TouchpadWorkspaceSwitchAction = class {
constructor(actor, allowedModes) {
@ -669,15 +670,16 @@ var AppSwitchAction = GObject.registerClass({
}
});
var ResizePopup = class {
constructor() {
this._widget = new St.Widget({ layout_manager: new Clutter.BinLayout() });
var ResizePopup = GObject.registerClass(
class ResizePopup extends St.Widget {
_init() {
super._init({ layout_manager: new Clutter.BinLayout() });
this._label = new St.Label({ style_class: 'resize-popup',
x_align: Clutter.ActorAlign.CENTER,
y_align: Clutter.ActorAlign.CENTER,
x_expand: true, y_expand: true });
this._widget.add_child(this._label);
Main.uiGroup.add_actor(this._widget);
this.add_child(this._label);
Main.uiGroup.add_actor(this);
}
set(rect, displayW, displayH) {
@ -686,15 +688,10 @@ var ResizePopup = class {
let text = _("%d × %d").format(displayW, displayH);
this._label.set_text(text);
this._widget.set_position(rect.x, rect.y);
this._widget.set_size(rect.width, rect.height);
this.set_position(rect.x, rect.y);
this.set_size(rect.width, rect.height);
}
destroy() {
this._widget.destroy();
this._widget = null;
}
};
});
var WindowManager = class {
constructor() {
@ -1119,7 +1116,7 @@ var WindowManager = class {
this._currentPadOsd = new PadOsd.PadOsd(device, settings, imagePath, editionMode, monitorIndex);
this._currentPadOsd.connect('closed', () => (this._currentPadOsd = null));
return this._currentPadOsd.actor;
return this._currentPadOsd;
}
_switchWorkspaceMotion(action, xRel, yRel) {