2019-01-31 14:07:06 +00:00
|
|
|
/* exported CheckBox */
|
2019-07-16 09:24:13 +00:00
|
|
|
const { Clutter, GObject, Pango, St } = imports.gi;
|
2012-02-13 23:13:57 +00:00
|
|
|
|
2019-07-16 09:24:13 +00:00
|
|
|
var CheckBox = GObject.registerClass(
|
|
|
|
class CheckBox extends St.Button {
|
|
|
|
_init(label) {
|
2019-12-04 20:37:34 +00:00
|
|
|
let container = new St.BoxLayout({
|
|
|
|
x_expand: true,
|
|
|
|
y_expand: true,
|
|
|
|
});
|
2019-07-16 09:24:13 +00:00
|
|
|
super._init({
|
|
|
|
style_class: 'check-box',
|
|
|
|
child: container,
|
|
|
|
button_mask: St.ButtonMask.ONE,
|
|
|
|
toggle_mode: true,
|
|
|
|
can_focus: true,
|
|
|
|
});
|
2013-07-11 14:09:54 +00:00
|
|
|
|
2019-12-04 20:37:34 +00:00
|
|
|
this._box = new St.Bin({ y_align: Clutter.ActorAlign.START });
|
2013-07-11 14:09:54 +00:00
|
|
|
container.add_actor(this._box);
|
|
|
|
|
|
|
|
this._label = new St.Label();
|
|
|
|
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 23:13:57 +00:00
|
|
|
|
|
|
|
if (label)
|
|
|
|
this.setLabel(label);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-02-13 23:13:57 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
setLabel(label) {
|
2013-07-11 14:09:54 +00:00
|
|
|
this._label.set_text(label);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-02-29 08:50:22 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
getLabelActor() {
|
2013-07-11 14:09:54 +00:00
|
|
|
return this._label;
|
2012-02-13 23:13:57 +00:00
|
|
|
}
|
2019-07-16 09:24:13 +00:00
|
|
|
});
|