]> saetta.ns0.it Git - zakform/tests/commitdiff
Tested filter and validator.
authorAndrea Zagli <azagli@libero.it>
Sat, 5 Dec 2015 10:39:51 +0000 (11:39 +0100)
committerAndrea Zagli <azagli@libero.it>
Sat, 5 Dec 2015 10:39:51 +0000 (11:39 +0100)
data/zakformtests/gui/main.ui
data/zakformtests/xml/main.xml
src/main.c

index d1a60924cd6121a9270ae8bbf36a8a2e8eaff905..b682c31bd0640c1841999f4d0030c4a357d92076 100644 (file)
             <property name="position">1</property>
           </packing>
         </child>
+        <child>
+          <object class="GtkButtonBox" id="buttonbox2">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="spacing">5</property>
+            <property name="layout_style">center</property>
+            <child>
+              <object class="GtkButton" id="button4">
+                <property name="label" translatable="yes">Is valid?</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+              </object>
+              <packing>
+                <property name="expand">True</property>
+                <property name="fill">True</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">2</property>
+          </packing>
+        </child>
         <child>
           <object class="GtkScrolledWindow" id="scrolledwindow1">
             <property name="visible">True</property>
           <packing>
             <property name="expand">True</property>
             <property name="fill">True</property>
-            <property name="position">2</property>
+            <property name="position">3</property>
           </packing>
         </child>
       </object>
index 336425fd9ff9e1737075f50a040c4ff7db558eba..32de09e9f8c4eccc46741310c85d7e47c52582ad 100644 (file)
@@ -25,6 +25,8 @@
        <default-value>John Doe</default-value>
        <widget>txt_name</widget>
        <label>label1</label>
+       <filter type="zak_form_element_filter_trim"></filter>
+       <validator type="zak_form_element_validator_notempty"></validator>
   </element>
 
   <element type="zak_form_gtk_form_element_spin">
index 7d1aaf051e7ae8401a7fe822564f3f2ba3464075..6ee8149603ebea2cf9983cb56fbd232889e74d6c 100644 (file)
@@ -24,6 +24,8 @@
 #include <libzakformgtk/libzakformgtk.h>
 #include <libzakformgdaex/libzakformgdaex.h>
 
+GtkWidget *w;
+
 ZakFormGtkForm *form;
 ZakFormGdaexProvider *provider;
 
@@ -48,11 +50,17 @@ update_clicked (GtkButton *button,
        zak_form_form_update (ZAK_FORM_FORM (form), ZAK_FORM_IPROVIDER (provider));
 }
 
+void
+is_valid_clicked (GtkButton *button,
+                               gpointer   user_data)
+{
+       zak_form_gtk_form_is_valid (form, w);
+}
+
 int
 main (int argc, char *argv[])
 {
        GtkBuilder *builder;
-       GtkWidget *w;
 
        GdaEx *gdaex;
 
@@ -74,6 +82,8 @@ main (int argc, char *argv[])
                                          G_CALLBACK (insert_clicked), NULL);
        g_signal_connect (gtk_builder_get_object (builder, "button3"), "clicked",
                                          G_CALLBACK (update_clicked), NULL);
+       g_signal_connect (gtk_builder_get_object (builder, "button4"), "clicked",
+                                         G_CALLBACK (is_valid_clicked), NULL);
 
        form = zak_form_gtk_form_new ();
        zak_form_gtk_form_set_gtkbuilder (form, builder);