From 149b81df78e2e9c7590c991078074c27b2d3c767 Mon Sep 17 00:00:00 2001 From: Andrea Zagli Date: Sat, 5 Dec 2015 11:57:23 +0100 Subject: [PATCH] Tested ZakFormForm::is_changed. --- data/zakformtests/gui/main.ui | 13 +++++++++++++ src/main.c | 23 ++++++++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/data/zakformtests/gui/main.ui b/data/zakformtests/gui/main.ui index b682c31..fff812b 100644 --- a/data/zakformtests/gui/main.ui +++ b/data/zakformtests/gui/main.ui @@ -380,6 +380,19 @@ 0 + + + Is changed? + True + True + True + + + True + True + 1 + + False diff --git a/src/main.c b/src/main.c index 6ee8149..3a3fde1 100644 --- a/src/main.c +++ b/src/main.c @@ -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"); -- 2.49.0