Debian Codegraph @

test cases/vala/27 file as command line argument/mywidget.vala

raw
1 using Gtk;
2
3 [GtkTemplate (ui = "/org/foo/my/mywidget.ui")]
4 public class MyWidget : Box {
5 public string text {
6 get { return entry.text; }
7 set { entry.text = value; }
8 }
9
10 [GtkChild]
11 private Entry entry;
12
13 public MyWidget (string text) {
14 this.text = text;
15 }
16
17 [GtkCallback]
18 private void on_button_clicked (Button button) {
19 print ("The button was clicked with entry text: %s\n", entry.text);
20 }
21
22 [GtkCallback]
23 private void on_entry_changed (Editable editable) {
24 print ("The entry text changed: %s\n", entry.text);
25
26 notify_property ("text");
27 }
28 }
29
30 void main(string[] args) {
31 Gtk.init (ref args);
32 var win = new Window();
33 win.destroy.connect (Gtk.main_quit);
34
35 var widget = new MyWidget ("The entry text!");
36
37 win.add (widget);
38 win.show_all ();
39
40 Gtk.main ();
41 }