aboutsummaryrefslogtreecommitdiff
path: root/manual tests
diff options
context:
space:
mode:
authorIgor Gnatenko <i.gnatenko.brain@gmail.com>2015-07-02 12:19:40 +0300
committerIgor Gnatenko <i.gnatenko.brain@gmail.com>2015-07-02 12:19:40 +0300
commit04f165842feb61787c604eebf0bc213811924616 (patch)
tree83ffe7011c52399783917930af4bd2e727ebb4fc /manual tests
parent1476af4ada29a452f128470a50e9e5de2895dfff (diff)
downloadmeson-04f165842feb61787c604eebf0bc213811924616.zip
meson-04f165842feb61787c604eebf0bc213811924616.tar.gz
meson-04f165842feb61787c604eebf0bc213811924616.tar.bz2
manual tests: add example for composite widgets
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
Diffstat (limited to 'manual tests')
-rw-r--r--manual tests/7 vala composite widgets/meson.build20
-rw-r--r--manual tests/7 vala composite widgets/my-resources.xml6
-rw-r--r--manual tests/7 vala composite widgets/mywidget.ui70
-rw-r--r--manual tests/7 vala composite widgets/mywidget.vala41
4 files changed, 137 insertions, 0 deletions
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 0000000..39a6348
--- /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 0000000..b5743c1
--- /dev/null
+++ b/manual tests/7 vala composite widgets/my-resources.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+ <gresource prefix="/org/foo/my">
+ <file compressed="true" preprocess="xml-stripblanks">mywidget.ui</file>
+ </gresource>
+</gresources>
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 0000000..2d6286c
--- /dev/null
+++ b/manual tests/7 vala composite widgets/mywidget.ui
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.8 -->
+ <template class="MyWidget" parent="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">4</property>
+ <child>
+ <object class="GtkLabel" id="label1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">start</property>
+ <property name="valign">start</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">This widget is defined with composite GtkBuilder script</property>
+ <property name="wrap">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">•</property>
+ <signal name="changed" handler="on_entry_changed" object="MyWidget" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">start</property>
+ <property name="valign">start</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Press the button to fetch the internal entry text</property>
+ <property name="wrap">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="button">
+ <property name="label" translatable="yes">The Button</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="halign">end</property>
+ <signal name="clicked" handler="on_button_clicked" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ </template>
+</interface>
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 0000000..09a2064
--- /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 ();
+}