aboutsummaryrefslogtreecommitdiff
path: root/manual tests/7 vala composite widgets/mywidget.vala
blob: 09a2064ca6754098c4326ca5e3bf9105c02e13f2 (plain)
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
using Gtk;

[GtkTemplate (ui = "/org/foo/my/mywidget.ui")]
public class MyWidget : Box {
	public string text {
		get { return entry.text; }
		set { entry.text = value; }
	}

	[GtkChild]
	private Entry entry;

	public MyWidget (string text) {
		this.text = text;
	}

	[GtkCallback]
	private void on_button_clicked (Button button) {
		print ("The button was clicked with entry text: %s\n", entry.text);
	}

	[GtkCallback]
	private void on_entry_changed (Editable editable) {
		print ("The entry text changed: %s\n", entry.text);

		notify_property ("text");
	}
}

void main(string[] args) {
	Gtk.init (ref args);
	var win = new Window();
	win.destroy.connect (Gtk.main_quit);

	var widget = new MyWidget ("The entry text!");

	win.add (widget);
	win.show_all ();

	Gtk.main ();
}