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
@ -2,7 +2,6 @@
|
||||
/* exported Button, SystemIndicator */
|
||||
|
||||
const { Atk, Clutter, GObject, St } = imports.gi;
|
||||
const Signals = imports.signals;
|
||||
|
||||
const Main = imports.ui.main;
|
||||
const Params = imports.misc.params;
|
||||
@ -200,24 +199,34 @@ var Button = GObject.registerClass({
|
||||
* of an icon and a menu section, which will be composed into the
|
||||
* aggregate menu.
|
||||
*/
|
||||
var SystemIndicator = class {
|
||||
constructor() {
|
||||
this.indicators = new St.BoxLayout({ style_class: 'panel-status-indicators-box',
|
||||
reactive: true });
|
||||
this.indicators.hide();
|
||||
var SystemIndicator = GObject.registerClass({
|
||||
GTypeName: 'PanelMenu_SystemIndicator',
|
||||
}, class SystemIndicator extends St.BoxLayout {
|
||||
_init() {
|
||||
super._init({
|
||||
style_class: 'panel-status-indicators-box',
|
||||
reactive: true,
|
||||
visible: false
|
||||
});
|
||||
this.menu = new PopupMenu.PopupMenuSection();
|
||||
}
|
||||
|
||||
get indicators() {
|
||||
let klass = this.constructor.name;
|
||||
let { stack } = new Error();
|
||||
log(`Usage of indicator.indicators is deprecated for ${klass}\n${stack}`);
|
||||
return this;
|
||||
}
|
||||
|
||||
_syncIndicatorsVisible() {
|
||||
this.indicators.visible = this.indicators.get_children().some(a => a.visible);
|
||||
this.visible = this.get_children().some(a => a.visible);
|
||||
}
|
||||
|
||||
_addIndicator() {
|
||||
let icon = new St.Icon({ style_class: 'system-status-icon' });
|
||||
this.indicators.add_actor(icon);
|
||||
this.add_actor(icon);
|
||||
icon.connect('notify::visible', this._syncIndicatorsVisible.bind(this));
|
||||
this._syncIndicatorsVisible();
|
||||
return icon;
|
||||
}
|
||||
};
|
||||
Signals.addSignalMethods(SystemIndicator.prototype);
|
||||
});
|
||||
|
Reference in New Issue
Block a user