777189d7bd
The only point of using a custom container here was to prevent StBoxLayout from enforcing the wrong request mode based on the orientation. With that issue fixed, we can simplify the checkbox widget significantly. https://bugzilla.gnome.org/show_bug.cgi?id=703811
41 lines
1.2 KiB
JavaScript
41 lines
1.2 KiB
JavaScript
const Clutter = imports.gi.Clutter;
|
|
const Pango = imports.gi.Pango;
|
|
const St = imports.gi.St;
|
|
|
|
const Lang = imports.lang;
|
|
|
|
const CheckBox = new Lang.Class({
|
|
Name: 'CheckBox',
|
|
|
|
_init: function(label) {
|
|
let container = new St.BoxLayout();
|
|
this.actor = new St.Button({ style_class: 'check-box',
|
|
child: container,
|
|
button_mask: St.ButtonMask.ONE,
|
|
toggle_mode: true,
|
|
can_focus: true,
|
|
x_fill: true,
|
|
y_fill: true });
|
|
|
|
this._box = new St.Bin();
|
|
this._box.set_y_align(Clutter.ActorAlign.START);
|
|
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);
|
|
|
|
if (label)
|
|
this.setLabel(label);
|
|
},
|
|
|
|
setLabel: function(label) {
|
|
this._label.set_text(label);
|
|
},
|
|
|
|
getLabelActor: function() {
|
|
return this._label;
|
|
}
|
|
});
|