test.vala 650 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. using Gtk;
  2. using GLib;
  3. [GtkTemplate (ui = "/org/Meson/test.ui")]
  4. public class TestWidget : Box {
  5. public string text {
  6. get { return entry.text; }
  7. set { entry.text = value; }
  8. }
  9. [GtkChild]
  10. private Entry entry;
  11. public TestWidget (string text) {
  12. this.text = text;
  13. }
  14. }
  15. void main(string[] args) {
  16. Gtk.init (ref args);
  17. var win = new Window();
  18. win.destroy.connect (Gtk.main_quit);
  19. var widget = new TestWidget ("SOME TEXT HERE");
  20. win.add (widget);
  21. win.show_all ();
  22. /* Exit immediately */
  23. Timeout.add_full (Priority.DEFAULT_IDLE, 1, () =>
  24. {
  25. Gtk.main_quit();
  26. return false;
  27. });
  28. Gtk.main ();
  29. }