2019-01-31 14:07:06 +00:00
|
|
|
/* exported CheckBox */
|
2023-06-08 04:52:46 +00:00
|
|
|
const Atk = imports.gi.Atk;
|
|
|
|
const Clutter = imports.gi.Clutter;
|
|
|
|
const GObject = imports.gi.GObject;
|
|
|
|
const Pango = imports.gi.Pango;
|
|
|
|
const St = imports.gi.St;
|
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,
|
|
|
|
});
|
2020-03-29 01:42:44 +00:00
|
|
|
this.set_accessible_role(Atk.Role.CHECK_BOX);
|
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);
|
|
|
|
|
2020-01-30 14:26:32 +00:00
|
|
|
this._label = new St.Label({ y_align: Clutter.ActorAlign.CENTER });
|
2013-07-11 14:09:54 +00:00
|
|
|
this._label.clutter_text.set_line_wrap(true);
|
|
|
|
this._label.clutter_text.set_ellipsize(Pango.EllipsizeMode.NONE);
|
2020-03-29 01:42:44 +00:00
|
|
|
this.set_label_actor(this._label);
|
2013-07-11 14:09:54 +00:00
|
|
|
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
|
|
|
});
|