2023-07-10 02:53:00 -07: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-14 00:13:57 +01:00
|
|
|
|
2023-07-10 02:53:00 -07:00
|
|
|
export const CheckBox = GObject.registerClass(
|
2019-07-16 11:24:13 +02:00
|
|
|
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
|
|
|
|
2023-08-07 00:40:20 +02:00
|
|
|
this._box = new St.Bin({y_align: Clutter.ActorAlign.START});
|
2013-07-11 16:09:54 +02:00
|
|
|
container.add_actor(this._box);
|
|
|
|
|
2023-08-07 00:40:20 +02: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
|
|
|
});
|