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:

committed by
Florian Müllner

parent
f67b409fc1
commit
c4c5c4fd5c
@ -3,7 +3,6 @@
|
||||
|
||||
const { Clutter, GLib, GObject,
|
||||
Graphene, Meta, Shell, St } = imports.gi;
|
||||
const Signals = imports.signals;
|
||||
|
||||
const AppDisplay = imports.ui.appDisplay;
|
||||
const AppFavorites = imports.ui.appFavorites;
|
||||
@ -24,9 +23,10 @@ function getAppFromSource(source) {
|
||||
}
|
||||
}
|
||||
|
||||
var DashIcon = class DashIcon extends AppDisplay.AppIcon {
|
||||
constructor(app) {
|
||||
super(app, {
|
||||
var DashIcon = GObject.registerClass(
|
||||
class DashIcon extends AppDisplay.AppIcon {
|
||||
_init(app) {
|
||||
super._init(app, {
|
||||
setSizeManually: true,
|
||||
showLabel: false
|
||||
});
|
||||
@ -46,7 +46,7 @@ var DashIcon = class DashIcon extends AppDisplay.AppIcon {
|
||||
acceptDrop() {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
// A container like StBin, but taking the child's scale into account
|
||||
// when requesting a size
|
||||
@ -331,8 +331,10 @@ class DashActor extends St.Widget {
|
||||
|
||||
const baseIconSizes = [16, 22, 24, 32, 48, 64];
|
||||
|
||||
var Dash = class Dash {
|
||||
constructor() {
|
||||
var Dash = GObject.registerClass({
|
||||
Signals: { 'icon-size-changed': {} }
|
||||
}, class Dash extends St.Bin {
|
||||
_init() {
|
||||
this._maxHeight = -1;
|
||||
this.iconSize = 64;
|
||||
this._shownInitially = false;
|
||||
@ -360,11 +362,11 @@ var Dash = class Dash {
|
||||
|
||||
this._container.add_actor(this._showAppsIcon);
|
||||
|
||||
this.actor = new St.Bin({ child: this._container });
|
||||
this.actor.connect('notify::height', () => {
|
||||
if (this._maxHeight != this.actor.height)
|
||||
super._init({ child: this._container });
|
||||
this.connect('notify::height', () => {
|
||||
if (this._maxHeight != this.height)
|
||||
this._queueRedisplay();
|
||||
this._maxHeight = this.actor.height;
|
||||
this._maxHeight = this.height;
|
||||
});
|
||||
|
||||
this._workId = Main.initializeDeferredWork(this._box, this._redisplay.bind(this));
|
||||
@ -387,7 +389,7 @@ var Dash = class Dash {
|
||||
|
||||
// Translators: this is the name of the dock/favorites area on
|
||||
// the left of the overview
|
||||
Main.ctrlAltTabManager.addGroup(this.actor, _("Dash"), 'user-bookmarks-symbolic');
|
||||
Main.ctrlAltTabManager.addGroup(this, _("Dash"), 'user-bookmarks-symbolic');
|
||||
}
|
||||
|
||||
_onDragBegin() {
|
||||
@ -482,11 +484,11 @@ var Dash = class Dash {
|
||||
});
|
||||
|
||||
let item = new DashItemContainer();
|
||||
item.setChild(appIcon.actor);
|
||||
item.setChild(appIcon);
|
||||
|
||||
// Override default AppIcon label_actor, now the
|
||||
// accessible_name is set at DashItemContainer.setLabelText
|
||||
appIcon.actor.label_actor = null;
|
||||
appIcon.label_actor = null;
|
||||
item.setLabelText(app.get_name());
|
||||
|
||||
appIcon.icon.setIconSize(this.iconSize);
|
||||
@ -903,5 +905,4 @@ var Dash = class Dash {
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
Signals.addSignalMethods(Dash.prototype);
|
||||
});
|
||||
|
Reference in New Issue
Block a user