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

index b682c31bd0640c1841999f4d0030c4a357d92076..fff812b9ce2b425e442efa17ff879b0962f22f92 100644 (file)
                 <property name="position">0</property>
               </packing>
             </child>
+            <child>
+              <object class="GtkButton" id="button5">
+                <property name="label" translatable="yes">Is changed?</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">1</property>
+              </packing>
+            </child>
           </object>
           <packing>
             <property name="expand">False</property>
index 6ee8149603ebea2cf9983cb56fbd232889e74d6c..3a3fde1b0da420fef89236c70b6383fd66b829e1 100644 (file)
@@ -52,11 +52,29 @@ update_clicked (GtkButton *button,
 
 void
 is_valid_clicked (GtkButton *button,
-                               gpointer   user_data)
+                                 gpointer   user_data)
 {
        zak_form_gtk_form_is_valid (form, w);
 }
 
+void
+is_changed_clicked (GtkButton *button,
+                                       gpointer   user_data)
+{
+       if (zak_form_form_is_changed (ZAK_FORM_FORM (form)))
+               {
+                       GtkWidget *dialog;
+
+                       dialog = gtk_message_dialog_new (GTK_WINDOW (w),
+                                                                                        GTK_DIALOG_DESTROY_WITH_PARENT,
+                                                                                        GTK_MESSAGE_WARNING,
+                                                                                        GTK_BUTTONS_OK,
+                                                                                        "Form is changed.");
+                       gtk_dialog_run (GTK_DIALOG (dialog));
+                       gtk_widget_destroy (dialog);
+               }
+}
+
 int
 main (int argc, char *argv[])
 {
@@ -84,11 +102,14 @@ main (int argc, char *argv[])
                                          G_CALLBACK (update_clicked), NULL);
        g_signal_connect (gtk_builder_get_object (builder, "button4"), "clicked",
                                          G_CALLBACK (is_valid_clicked), NULL);
+       g_signal_connect (gtk_builder_get_object (builder, "button5"), "clicked",
+                                         G_CALLBACK (is_changed_clicked), NULL);
 
        form = zak_form_gtk_form_new ();
        zak_form_gtk_form_set_gtkbuilder (form, builder);
        zak_form_form_load_from_file (ZAK_FORM_FORM (form), XMLDIR "/main.xml");
        zak_form_form_clear (ZAK_FORM_FORM (form));
+       zak_form_form_set_as_original (ZAK_FORM_FORM (form));
 
        gdaex = gdaex_new_from_string ("SQLite://DB_DIR=" DBDIR ";DB_NAME=main.db;");
        provider = zak_form_gdaex_provider_new (gdaex, "clients");