2023-07-10 09:53:00 +00:00
|
|
|
import Atk from 'gi://Atk';
|
|
|
|
import Clutter from 'gi://Clutter';
|
|
|
|
import GObject from 'gi://GObject';
|
|
|
|
import Pango from 'gi://Pango';
|
|
|
|
import St from 'gi://St';
|
2012-02-13 23:13:57 +00:00
|
|
|
|
2023-07-10 09:53:00 +00:00
|
|
|
export const CheckBox = GObject.registerClass(
|
2019-07-16 09:24:13 +00:00
|
|
|
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
|
|
|
});
|