2019-01-31 15:07:06 +01:00
|
|
|
/* exported CheckBox */
|
2020-03-29 12:42:44 +11:00
|
|
|
const { Atk, Clutter, GObject, Pango, St } = imports.gi;
|
2012-02-14 00:13:57 +01:00
|
|
|
|
2019-07-16 11:24:13 +02:00
|
|
|
var CheckBox = GObject.registerClass(
|
|
|
|
class CheckBox extends St.Button {
|
|
|
|
_init(label) {
|
2019-12-04 21:37:34 +01:00
|
|
|
let container = new St.BoxLayout({
|
|
|
|
x_expand: true,
|
|
|
|
y_expand: true,
|
|
|
|
});
|
2019-07-16 11:24:13 +02:00
|
|
|
super._init({
|
|
|
|
style_class: 'check-box',
|
|
|
|
child: container,
|
|
|
|
button_mask: St.ButtonMask.ONE,
|
|
|
|
toggle_mode: true,
|
|
|
|
can_focus: true,
|
|
|
|
});
|
2020-03-29 12:42:44 +11:00
|
|
|
this.set_accessible_role(Atk.Role.CHECK_BOX);
|
2013-07-11 16:09:54 +02:00
|
|
|
|
2019-12-04 21:37:34 +01:00
|
|
|
this._box = new St.Bin({ y_align: Clutter.ActorAlign.START });
|
2013-07-11 16:09:54 +02:00
|
|
|
container.add_actor(this._box);
|
|
|
|
|
2020-01-30 15:26:32 +01:00
|
|
|
this._label = new St.Label({ y_align: Clutter.ActorAlign.CENTER });
|
2013-07-11 16:09:54 +02:00
|
|
|
this._label.clutter_text.set_line_wrap(true);
|
|
|
|
this._label.clutter_text.set_ellipsize(Pango.EllipsizeMode.NONE);
|
2020-03-29 12:42:44 +11:00
|
|
|
this.set_label_actor(this._label);
|
2013-07-11 16:09:54 +02:00
|
|
|
container.add_actor(this._label);
|
2012-02-14 00:13:57 +01:00
|
|
|
|
|
|
|
if (label)
|
|
|
|
this.setLabel(label);
|
2017-10-31 02:19:44 +01:00
|
|
|
}
|
2012-02-14 00:13:57 +01:00
|
|
|
|
2017-10-31 01:03:21 +01:00
|
|
|
setLabel(label) {
|
2013-07-11 16:09:54 +02:00
|
|
|
this._label.set_text(label);
|
2017-10-31 02:19:44 +01:00
|
|
|
}
|
2012-02-29 09:50:22 +01:00
|
|
|
|
2017-10-31 01:03:21 +01:00
|
|
|
getLabelActor() {
|
2013-07-11 16:09:54 +02:00
|
|
|
return this._label;
|
2012-02-14 00:13:57 +01:00
|
|
|
}
|
2019-07-16 11:24:13 +02:00
|
|
|
});
|