forked from gerito1/vala-gtk-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
checkbutton.vala
44 lines (34 loc) · 979 Bytes
/
checkbutton.vala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
* Similar to the RadioButton, the CheckButton combines a label and box to
* indicate the current state. When the CheckButton is toggled, a tick is either
* shown or hidden.
*/
using Gtk;
public class Example : Window
{
private CheckButton checkbutton;
public Example()
{
this.title = "CheckButton";
this.destroy.connect(Gtk.main_quit);
checkbutton = new CheckButton.with_label("CheckButton");
checkbutton.toggled.connect(on_checkbutton_toggle);
this.add(checkbutton);
}
private void on_checkbutton_toggle()
{
var active = checkbutton.get_active();
if (active == true)
stdout.printf("CheckButton toggled on\n");
else
stdout.printf("CheckButton toggled off\n");
}
public static int main(string[] args)
{
Gtk.init(ref args);
var window = new Example();
window.show_all();
Gtk.main();
return 0;
}
}