1public class MyWindow : Gtk.ApplicationWindow {
2
3	Gtk.Statusbar statusbar;
4	uint context_id;
5
6	internal MyWindow (MyApplication app) {
7		Object (application: app, title: "Statusbar Example");
8
9		statusbar = new Gtk.Statusbar ();
10		context_id = statusbar.get_context_id ("example");
11		statusbar.push (context_id, "Waiting for you to do something...");
12
13		//set the default size of the window
14		this.set_default_size (200, 100);
15		var grid = new Gtk.Grid ();
16		var label = new Gtk.Label ("Press any key or ");
17
18		grid.attach (label, 0, 0, 1, 1);
19		label.show ();
20
21		var button = new Gtk.Button.with_label ("click me.");
22		grid.attach_next_to (button, label, Gtk.PositionType.RIGHT, 1, 1);
23		button.show ();
24
25		grid.attach (statusbar, 0, 1, 2, 1);
26		statusbar.show ();
27
28		grid.set_column_spacing (5);
29		grid.set_column_homogeneous (true);
30		grid.set_row_homogeneous (true);
31
32		this.add (grid);
33		grid.show ();
34
35		button.clicked.connect(button_clicked_cb);
36	}
37
38	/* Since the key-press-event is a signal received by the window, we don't need to connect
39	the window to a callback function.  We can just override key_press_event. */
40	protected override bool key_press_event (Gdk.EventKey event) {
41		statusbar.push (context_id, Gdk.keyval_name(event.keyval) + " key was pressed.");
42		return true;
43	}
44
45	void button_clicked_cb (Gtk.Button button) {
46		statusbar.push (context_id, "You clicked the button.");
47	}
48}
49
50public class MyApplication : Gtk.Application {
51	protected override void activate () {
52		new MyWindow (this).show ();
53	}
54
55	internal MyApplication () {
56		Object (application_id: "org.example.status");
57	}
58}
59
60public int main (string[] args) {
61	return new MyApplication ().run (args);
62}
63