From 04f165842feb61787c604eebf0bc213811924616 Mon Sep 17 00:00:00 2001 From: Igor Gnatenko Date: Thu, 2 Jul 2015 12:19:40 +0300 Subject: [PATCH] manual tests: add example for composite widgets Signed-off-by: Igor Gnatenko --- .../7 vala composite widgets/meson.build | 20 ++++++ .../7 vala composite widgets/my-resources.xml | 6 ++ .../7 vala composite widgets/mywidget.ui | 70 +++++++++++++++++++ .../7 vala composite widgets/mywidget.vala | 41 +++++++++++ 4 files changed, 137 insertions(+) create mode 100644 manual tests/7 vala composite widgets/meson.build create mode 100644 manual tests/7 vala composite widgets/my-resources.xml create mode 100644 manual tests/7 vala composite widgets/mywidget.ui create mode 100644 manual tests/7 vala composite widgets/mywidget.vala diff --git a/manual tests/7 vala composite widgets/meson.build b/manual tests/7 vala composite widgets/meson.build new file mode 100644 index 000000000..39a6348f6 --- /dev/null +++ b/manual tests/7 vala composite widgets/meson.build @@ -0,0 +1,20 @@ +project('composite', 'vala', 'c') +gnome = import('gnome') +deps = [ + dependency('glib-2.0', version : '>=2.38'), + dependency('gobject-2.0'), + dependency('gtk+-3.0'), +] +res = gnome.compile_resources( + 'my', 'my-resources.xml', + source_dir : '.', +) +executable( + 'demo', + sources : [ + 'mywidget.vala', + res, + ], + dependencies : deps, + vala_args : '--gresources=@0@/my-resources.xml'.format(meson.current_source_dir()), +) diff --git a/manual tests/7 vala composite widgets/my-resources.xml b/manual tests/7 vala composite widgets/my-resources.xml new file mode 100644 index 000000000..b5743c193 --- /dev/null +++ b/manual tests/7 vala composite widgets/my-resources.xml @@ -0,0 +1,6 @@ + + + + mywidget.ui + + diff --git a/manual tests/7 vala composite widgets/mywidget.ui b/manual tests/7 vala composite widgets/mywidget.ui new file mode 100644 index 000000000..2d6286ca2 --- /dev/null +++ b/manual tests/7 vala composite widgets/mywidget.ui @@ -0,0 +1,70 @@ + + + + + diff --git a/manual tests/7 vala composite widgets/mywidget.vala b/manual tests/7 vala composite widgets/mywidget.vala new file mode 100644 index 000000000..09a2064ca --- /dev/null +++ b/manual tests/7 vala composite widgets/mywidget.vala @@ -0,0 +1,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 (); +}