forked from gerito1/vala-gtk-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
switch.vala
42 lines (33 loc) · 901 Bytes
/
switch.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
/*
* A SpinButton provides a way to enter numbers either by textual entry from the
* user, or by changing the value with up/down buttons. Ranges to limit the
* value entered are able to be set.
*/
using Gtk;
public class Example : Window
{
private Switch gtkswitch;
public Example()
{
this.title = "Switch";
this.destroy.connect(Gtk.main_quit);
gtkswitch = new Switch();
gtkswitch.notify["active"].connect(on_switch_toggled);
this.add(gtkswitch);
}
private void on_switch_toggled()
{
if (gtkswitch.get_active())
stdout.printf("Switch toggled on\n");
else
stdout.printf("Switch toggled off\n");
}
public static int main(string[] args)
{
Gtk.init(ref args);
var window = new Example();
window.show_all();
Gtk.main();
return 0;
}
}