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
@ -1,16 +1,19 @@
|
||||
/* exported CheckBox */
|
||||
const { Clutter, Pango, St } = imports.gi;
|
||||
const { Clutter, GObject, Pango, St } = imports.gi;
|
||||
|
||||
var CheckBox = class CheckBox {
|
||||
constructor(label) {
|
||||
var CheckBox = GObject.registerClass(
|
||||
class CheckBox extends St.Button {
|
||||
_init(label) {
|
||||
let container = new St.BoxLayout();
|
||||
this.actor = new St.Button({ style_class: 'check-box',
|
||||
child: container,
|
||||
button_mask: St.ButtonMask.ONE,
|
||||
toggle_mode: true,
|
||||
can_focus: true,
|
||||
x_fill: true,
|
||||
y_fill: true });
|
||||
super._init({
|
||||
style_class: 'check-box',
|
||||
child: container,
|
||||
button_mask: St.ButtonMask.ONE,
|
||||
toggle_mode: true,
|
||||
can_focus: true,
|
||||
x_fill: true,
|
||||
y_fill: true
|
||||
});
|
||||
|
||||
this._box = new St.Bin();
|
||||
this._box.set_y_align(Clutter.ActorAlign.START);
|
||||
@ -32,4 +35,4 @@ var CheckBox = class CheckBox {
|
||||
getLabelActor() {
|
||||
return this._label;
|
||||
}
|
||||
};
|
||||
});
|
||||
|
Reference in New Issue
Block a user