1public class MyWindow : Gtk.ApplicationWindow {
2	internal MyWindow (MyApplication app) {
3		Object (application: app, title: "RadioButton Example");
4
5		this.border_width = 20;
6		this.set_default_size (250, 100);
7
8		/* We demonstrate 3 different RadioButton creation methods */
9
10		//Create a Radio Button
11		var button1 = new Gtk.RadioButton (null);
12		button1.set_label ("Button 1");
13
14		//Create a RadioButton with a label, and add it to the same group as button1.
15		var button2 = new Gtk.RadioButton.with_label (button1.get_group(),"Button 2");
16
17		//Create a RadioButton with a label, adding it to button1's group.
18		var button3 = new Gtk.RadioButton.with_label_from_widget (button1, "Button 3");
19
20		//Attach the buttons to a grid.
21		var grid = new Gtk.Grid ();
22		grid.attach (button1, 0, 0, 1, 1);
23		grid.attach (button2, 0, 1, 1, 1);
24		grid.attach (button3, 0, 2, 1, 1);
25
26		//Add the button to the window.
27		this.add (grid);
28
29		//Connect the signal handlers (aka. callback functions) to the buttons.
30		button1.toggled.connect (button_toggled_cb);
31		button2.toggled.connect (button_toggled_cb);
32		button3.toggled.connect (button_toggled_cb);
33	}
34
35	void button_toggled_cb (Gtk.ToggleButton button)
36	{
37		var state = "unknown";
38
39		if (button.get_active ())
40			state = "on";
41		else {
42			state = "off";
43			print ("\n");
44		}
45		print (button.get_label() + " was turned " + state + "\n");
46	}
47}
48
49public class MyApplication : Gtk.Application {
50	protected override void activate () {
51
52		//Show all of the things.
53		new MyWindow (this).show_all ();
54	}
55
56	internal MyApplication () {
57		Object (application_id: "org.example.MyApplication");
58	}
59}
60
61public int main (string[] args) {
62	return new MyApplication ().run (args);
63}
64