5 public class Stuffkeeper
.DataBooleanConfig
: Gtk
.HBox
{
6 private string field
= null;
7 private DataSchema schema
= null;
8 private Gtk
.CheckButton checkbox
= null;
9 /* hack to fix vala bug */
12 * Listen to changes to this field
14 private void field_changed(DataSchema schema
, string id
, int field
)
19 if(schema
.get_custom_field_integer(id
, 0, out value
))
21 if(checkbox
.active
!= (bool)value
)
23 this
.checkbox
.toggled
.disconnect(toggled
);
24 checkbox
.active
= (bool)value
;
25 this
.checkbox
.toggled
.connect(toggled
);
34 private void toggled(Gtk
.ToggleButton toggle
)
38 schema
.set_custom_field_integer(field
,0,1);
40 schema
.set_custom_field_integer(field
,0,0);
47 ~DataBooleanConfig() {
48 stdout
.printf("Dispose data boolean config\n");
49 schema
.schema_custom_field_changed
.disconnect(field_changed
);
55 var label
= new Gtk
.Label("Default value");
56 this
.checkbox
= new Gtk
.CheckButton();
58 this
.pack_start(label
, false, false,0);
59 this
.pack_start(checkbox
, true, true,0);
66 public void setup (Stuffkeeper
.DataSchema schema
, string fid
) {
71 if(schema
.get_custom_field_integer(field
, 0, out value
))
73 this
.checkbox
.active
= (bool)value
;
76 this
.checkbox
.toggled
.connect(toggled
);
77 schema
.schema_custom_field_changed
.connect(field_changed
);