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