]> saetta.ns0.it Git - zakform/tests/commitdiff
Test for FormGdaExElementExtension.
authorAndrea Zagli <azagli@libero.it>
Mon, 13 Feb 2017 17:20:47 +0000 (18:20 +0100)
committerAndrea Zagli <azagli@libero.it>
Mon, 13 Feb 2017 17:20:47 +0000 (18:20 +0100)
data/zakformtests/gui/main.ui
data/zakformtests/xml/main.xml
src/gtk_gdaex.c

index b41bd8c391c9af351a23b0e063d2842e39684d3f..0afde1cbfa8c4b869843921772249d6881990f0c 100644 (file)
                 <property name="position">2</property>
               </packing>
             </child>
+            <child>
+              <object class="GtkButton" id="button7">
+                <property name="label" translatable="yes">Where</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">3</property>
+              </packing>
+            </child>
           </object>
           <packing>
             <property name="expand">False</property>
index 24360f0f911a16686c568e63e8268b8828d08b89..063566a47a13001c784023695df910b12e560fc6 100644 (file)
@@ -8,6 +8,9 @@
        <to-load>FALSE</to-load>
        <widget>entry1</widget>
        <label>label2</label>
+       <extension type="zak_form_gdaex_element_extension">
+         <where type="e"></where>
+       </extension>
   </element>
 
   <element type="zak_form_gtk_form_element_label">
@@ -29,6 +32,9 @@
        <filter type="zak_form_element_filter_trim"></filter>
        <filter type="zak_form_element_filter_luc">camel</filter>
        <validator type="zak_form_element_validator_notempty"></validator>
+       <extension type="zak_form_gdaex_element_extension">
+         <where type="like"></where>
+       </extension>
   </element>
 
   <element type="zak_form_gtk_form_element_spin">
@@ -68,6 +74,9 @@ and                                    some            tabs
        <widget>txt_birthday</widget>
        <label>label11</label>
        <validator type="zak_form_element_validator_date">%d/%m/%Y</validator>
+       <extension type="zak_form_gdaex_element_extension">
+         <where type="e"></where>
+       </extension>
   </element>
 
   <element type="zak_form_gtk_form_element_radio">
index 3a3fde1b0da420fef89236c70b6383fd66b829e1..0a03dd38c2cc992527673a572a7a6f47206e5361 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2015-2017 Andrea Zagli <azagli@libero.it>
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
 #include <libzakformgdaex/libzakformgdaex.h>
 
 GtkWidget *w;
+GtkWidget *textview;
 
 ZakFormGtkForm *form;
 ZakFormGdaexProvider *provider;
 
 void
 load_clicked (GtkButton *button,
-                         gpointer   user_data)
+              gpointer   user_data)
 {
        zak_form_form_load (ZAK_FORM_FORM (form), ZAK_FORM_IPROVIDER (provider));
 }
 
 void
 insert_clicked (GtkButton *button,
-                               gpointer   user_data)
+                gpointer   user_data)
 {
        zak_form_form_insert (ZAK_FORM_FORM (form), ZAK_FORM_IPROVIDER (provider));
 }
 
 void
 update_clicked (GtkButton *button,
-                               gpointer   user_data)
+                gpointer   user_data)
 {
        zak_form_form_update (ZAK_FORM_FORM (form), ZAK_FORM_IPROVIDER (provider));
 }
 
+void
+where_clicked (GtkButton *button,
+               gpointer   user_data)
+{
+       gchar *where;
+
+       GtkTextBuffer *buf;
+
+       where =  zak_form_gdaex_provider_get_where_str (ZAK_FORM_GDAEX_PROVIDER (provider),
+                                                       zak_form_form_get_elements (ZAK_FORM_FORM (form)));
+
+       buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (textview));
+
+       gtk_text_buffer_set_text (GTK_TEXT_BUFFER (buf), where, -1);
+}
+
 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)
+                    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_DESTROY_WITH_PARENT,
+                                                        GTK_MESSAGE_WARNING,
+                                                        GTK_BUTTONS_OK,
+                                                        "Form is changed.");
                        gtk_dialog_run (GTK_DIALOG (dialog));
                        gtk_widget_destroy (dialog);
                }
@@ -86,24 +103,28 @@ main (int argc, char *argv[])
 
        builder = gtk_builder_new ();
        gtk_builder_add_objects_from_file (builder, GUIDIR "/main.ui",
-                                                                          g_strsplit ("w_main"
-                                                                                                  "|adjustment1", "|", -1), NULL);
+                                          g_strsplit ("w_main"
+                                                      "|adjustment1", "|", -1), NULL);
 
        w = GTK_WIDGET (gtk_builder_get_object (builder, "w_main"));
 
+       textview = GTK_WIDGET (gtk_builder_get_object (builder, "textview1"));
+
        g_signal_connect (w, "delete-event",
-                                         gtk_main_quit, NULL);
+                         gtk_main_quit, NULL);
 
        g_signal_connect (gtk_builder_get_object (builder, "button1"), "clicked",
-                                         G_CALLBACK (load_clicked), NULL);
+                         G_CALLBACK (load_clicked), NULL);
        g_signal_connect (gtk_builder_get_object (builder, "button2"), "clicked",
-                                         G_CALLBACK (insert_clicked), NULL);
+                         G_CALLBACK (insert_clicked), NULL);
        g_signal_connect (gtk_builder_get_object (builder, "button3"), "clicked",
-                                         G_CALLBACK (update_clicked), NULL);
+                         G_CALLBACK (update_clicked), NULL);
+       g_signal_connect (gtk_builder_get_object (builder, "button7"), "clicked",
+                         G_CALLBACK (where_clicked), NULL);
        g_signal_connect (gtk_builder_get_object (builder, "button4"), "clicked",
-                                         G_CALLBACK (is_valid_clicked), NULL);
+                         G_CALLBACK (is_valid_clicked), NULL);
        g_signal_connect (gtk_builder_get_object (builder, "button5"), "clicked",
-                                         G_CALLBACK (is_changed_clicked), NULL);
+                         G_CALLBACK (is_changed_clicked), NULL);
 
        form = zak_form_gtk_form_new ();
        zak_form_gtk_form_set_gtkbuilder (form, builder);