]> saetta.ns0.it Git - solipa/territorio/commitdiff
Migrato il form tipo_aggregazione_territoriale a zakform.
authorAndrea Zagli <azagli@libero.it>
Sat, 21 Dec 2019 09:55:01 +0000 (10:55 +0100)
committerAndrea Zagli <azagli@libero.it>
Sat, 21 Dec 2019 09:55:01 +0000 (10:55 +0100)
data/territorio/form/tipo_aggregazione_territoriale.form
data/territorio/gui/territorio.gui
src/tipoaggregazioneterritoriale.c

index 4d08478d30941f148634cda3f9e078c2e3dca798..9b5fe43fbab0613303be6a437f61241c42e739d9 100644 (file)
@@ -1,19 +1,18 @@
 <?xml version="1.0"?>
-<gtkform>
-
-       <table>tipi_aggregazione_territoriale</table>
-
-       <widget type="label" name="label28" label="label27">
-               <field type="integer" name="id">
-                       <is-key>t</is-key>
-                       <auto-increment>t</auto-increment>
-               </field>
-       </widget>
-
-       <widget type="entry" name="entry13" label="label29">
-               <field type="text" name="nome">
-                       <obligatory>t</obligatory>
-               </field>
-       </widget>
-
-</gtkform>
+<zakform>
+  <element type="zak_form_gtk_form_element_label">
+    <name>id</name>
+    <type>integer</type>
+    <label>label27</label>
+    <is-key>TRUE</is-key>
+    <widget>label28</widget>
+    <format thousands_separator="" />
+  </element>
+  <element type="zak_form_gtk_form_element_entry">
+    <name>nome</name>
+    <type>string</type>
+    <label>label29</label>
+    <widget>entry13</widget>
+    <validator type="zak_form_element_validator_notempty"/>
+  </element>
+</zakform>
index df456b324fbb08ec2f97d2ddda59f1003f87eb4a..46b0e00f779b99b59a87a4cdac466945f209d25d 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.20.0 -->
+<!-- Generated with glade 3.22.1 -->
 <interface>
   <requires lib="gtk+" version="3.12"/>
   <requires lib="gtkformui" version="0.0"/>
     <property name="type_hint">normal</property>
     <property name="program_name">Territorio</property>
     <property name="version">0.0.3</property>
-    <property name="copyright" translatable="yes">Andrea Zagli &lt;azagli@libero.it&gt; 2010-2018</property>
+    <property name="copyright" translatable="yes">Andrea Zagli &lt;azagli@libero.it&gt; 2010-2019</property>
     <property name="authors">Andrea Zagli &lt;azagli@libero.it&gt;</property>
     <property name="logo_icon_name">image-missing</property>
+    <child>
+      <placeholder/>
+    </child>
     <child internal-child="vbox">
       <object class="GtkBox" id="dialog-vbox1">
         <property name="visible">True</property>
@@ -40,9 +43,6 @@
         </child>
       </object>
     </child>
-    <child>
-      <placeholder/>
-    </child>
   </object>
   <object class="GtkListStore" id="lstore_aggregazioni_territoriali">
     <columns>
@@ -62,6 +62,9 @@
     <property name="default_width">550</property>
     <property name="default_height">400</property>
     <property name="destroy_with_parent">True</property>
+    <child type="titlebar">
+      <placeholder/>
+    </child>
     <child>
       <object class="GtkBox" id="vbox12">
         <property name="visible">True</property>
         </child>
       </object>
     </child>
-    <child type="titlebar">
-      <placeholder/>
-    </child>
   </object>
   <object class="GtkListStore" id="lstore_province">
     <columns>
     <property name="modal">True</property>
     <property name="window_position">center-on-parent</property>
     <property name="destroy_with_parent">True</property>
+    <child type="titlebar">
+      <placeholder/>
+    </child>
     <child>
       <object class="GtkBox" id="vbox13">
         <property name="visible">True</property>
         </child>
       </object>
     </child>
-    <child type="titlebar">
-      <placeholder/>
-    </child>
   </object>
   <object class="GtkListStore" id="lstore_vie">
     <columns>
     <property name="default_width">550</property>
     <property name="default_height">400</property>
     <property name="destroy_with_parent">True</property>
+    <child type="titlebar">
+      <placeholder/>
+    </child>
     <child>
       <object class="GtkBox" id="vbox14">
         <property name="visible">True</property>
         </child>
       </object>
     </child>
-    <child type="titlebar">
-      <placeholder/>
-    </child>
   </object>
   <object class="GtkWindow" id="w_comune">
     <property name="can_focus">False</property>
     <property name="modal">True</property>
     <property name="window_position">center-on-parent</property>
     <property name="destroy_with_parent">True</property>
+    <child type="titlebar">
+      <placeholder/>
+    </child>
     <child>
       <object class="GtkBox" id="vbox9">
         <property name="visible">True</property>
         </child>
       </object>
     </child>
-    <child type="titlebar">
-      <placeholder/>
-    </child>
   </object>
   <object class="GtkWindow" id="w_comuni">
     <property name="can_focus">False</property>
     <property name="default_width">550</property>
     <property name="default_height">400</property>
     <property name="destroy_with_parent">True</property>
+    <child type="titlebar">
+      <placeholder/>
+    </child>
     <child>
       <object class="GtkBox" id="vbox8">
         <property name="visible">True</property>
         </child>
       </object>
     </child>
-    <child type="titlebar">
-      <placeholder/>
-    </child>
   </object>
   <object class="GtkWindow" id="w_main">
     <property name="can_focus">False</property>
     <property name="default_width">600</property>
     <property name="default_height">400</property>
     <signal name="destroy" handler="gtk_main_quit" swapped="no"/>
+    <child type="titlebar">
+      <placeholder/>
+    </child>
     <child>
       <object class="GtkBox" id="vbox1">
         <property name="visible">True</property>
         </child>
       </object>
     </child>
-    <child type="titlebar">
-      <placeholder/>
-    </child>
   </object>
   <object class="GtkWindow" id="w_province">
     <property name="can_focus">False</property>
     <property name="default_width">550</property>
     <property name="default_height">400</property>
     <property name="destroy_with_parent">True</property>
+    <child type="titlebar">
+      <placeholder/>
+    </child>
     <child>
       <object class="GtkBox" id="vbox6">
         <property name="visible">True</property>
         </child>
       </object>
     </child>
-    <child type="titlebar">
-      <placeholder/>
-    </child>
   </object>
   <object class="GtkWindow" id="w_provincia">
     <property name="can_focus">False</property>
     <property name="modal">True</property>
     <property name="window_position">center-on-parent</property>
     <property name="destroy_with_parent">True</property>
+    <child type="titlebar">
+      <placeholder/>
+    </child>
     <child>
       <object class="GtkBox" id="vbox7">
         <property name="visible">True</property>
         </child>
       </object>
     </child>
-    <child type="titlebar">
-      <placeholder/>
-    </child>
   </object>
   <object class="GtkWindow" id="w_regione">
     <property name="can_focus">False</property>
     <property name="modal">True</property>
     <property name="window_position">center-on-parent</property>
     <property name="destroy_with_parent">True</property>
+    <child type="titlebar">
+      <placeholder/>
+    </child>
     <child>
       <object class="GtkBox" id="vbox5">
         <property name="visible">True</property>
         </child>
       </object>
     </child>
-    <child type="titlebar">
-      <placeholder/>
-    </child>
   </object>
   <object class="GtkWindow" id="w_regioni">
     <property name="can_focus">False</property>
     <property name="default_width">550</property>
     <property name="default_height">400</property>
     <property name="destroy_with_parent">True</property>
+    <child type="titlebar">
+      <placeholder/>
+    </child>
     <child>
       <object class="GtkBox" id="vbox4">
         <property name="visible">True</property>
         </child>
       </object>
     </child>
-    <child type="titlebar">
-      <placeholder/>
-    </child>
   </object>
   <object class="GtkWindow" id="w_ricerca_comuni">
     <property name="can_focus">False</property>
     <property name="modal">True</property>
     <property name="window_position">center-on-parent</property>
     <property name="destroy_with_parent">True</property>
+    <child type="titlebar">
+      <placeholder/>
+    </child>
     <child>
       <object class="GtkBox" id="vbox17">
         <property name="visible">True</property>
         </child>
       </object>
     </child>
-    <child type="titlebar">
-      <placeholder/>
-    </child>
   </object>
   <object class="GtkWindow" id="w_ricerca_province">
     <property name="can_focus">False</property>
     <property name="modal">True</property>
     <property name="window_position">center-on-parent</property>
     <property name="destroy_with_parent">True</property>
+    <child type="titlebar">
+      <placeholder/>
+    </child>
     <child>
       <object class="GtkBox" id="vbox16">
         <property name="visible">True</property>
         </child>
       </object>
     </child>
-    <child type="titlebar">
-      <placeholder/>
-    </child>
   </object>
   <object class="GtkWindow" id="w_ricerca_vie">
     <property name="can_focus">False</property>
     <property name="modal">True</property>
     <property name="window_position">center-on-parent</property>
     <property name="destroy_with_parent">True</property>
+    <child type="titlebar">
+      <placeholder/>
+    </child>
     <child>
       <object class="GtkBox" id="vbox18">
         <property name="visible">True</property>
         </child>
       </object>
     </child>
-    <child type="titlebar">
-      <placeholder/>
-    </child>
   </object>
   <object class="GtkWindow" id="w_stati">
     <property name="can_focus">False</property>
     <property name="default_width">550</property>
     <property name="default_height">400</property>
     <property name="destroy_with_parent">True</property>
+    <child type="titlebar">
+      <placeholder/>
+    </child>
     <child>
       <object class="GtkBox" id="vbox2">
         <property name="visible">True</property>
         </child>
       </object>
     </child>
-    <child type="titlebar">
-      <placeholder/>
-    </child>
   </object>
   <object class="GtkWindow" id="w_stati_qe">
     <property name="can_focus">False</property>
     <property name="window_position">center-on-parent</property>
     <property name="default_width">550</property>
     <property name="destroy_with_parent">True</property>
+    <child type="titlebar">
+      <placeholder/>
+    </child>
     <child>
       <object class="GtkBox" id="vbox19">
         <property name="visible">True</property>
         </child>
       </object>
     </child>
-    <child type="titlebar">
-      <placeholder/>
-    </child>
   </object>
   <object class="GtkWindow" id="w_stato">
     <property name="can_focus">False</property>
     <property name="modal">True</property>
     <property name="window_position">center-on-parent</property>
     <property name="destroy_with_parent">True</property>
+    <child type="titlebar">
+      <placeholder/>
+    </child>
     <child>
       <object class="GtkBox" id="vbox3">
         <property name="visible">True</property>
         </child>
       </object>
     </child>
-    <child type="titlebar">
-      <placeholder/>
-    </child>
   </object>
   <object class="GtkWindow" id="w_tipi_aggregazione_territoriale">
     <property name="can_focus">False</property>
     <property name="default_width">550</property>
     <property name="default_height">400</property>
     <property name="destroy_with_parent">True</property>
+    <child type="titlebar">
+      <placeholder/>
+    </child>
     <child>
       <object class="GtkBox" id="vbox10">
         <property name="visible">True</property>
         </child>
       </object>
     </child>
-    <child type="titlebar">
-      <placeholder/>
-    </child>
   </object>
   <object class="GtkWindow" id="w_tipo_aggregazione_territoriale">
     <property name="can_focus">False</property>
     <property name="modal">True</property>
     <property name="window_position">center-on-parent</property>
     <property name="destroy_with_parent">True</property>
+    <child type="titlebar">
+      <placeholder/>
+    </child>
     <child>
       <object class="GtkBox" id="vbox11">
         <property name="visible">True</property>
         </child>
       </object>
     </child>
-    <child type="titlebar">
-      <placeholder/>
-    </child>
   </object>
   <object class="GtkWindow" id="w_via">
     <property name="can_focus">False</property>
     <property name="modal">True</property>
     <property name="window_position">center-on-parent</property>
     <property name="destroy_with_parent">True</property>
+    <child type="titlebar">
+      <placeholder/>
+    </child>
     <child>
       <object class="GtkBox" id="vbox15">
         <property name="visible">True</property>
         </child>
       </object>
     </child>
-    <child type="titlebar">
-      <placeholder/>
-    </child>
   </object>
   <object class="GtkWindow" id="w_widget">
     <property name="can_focus">False</property>
+    <child type="titlebar">
+      <placeholder/>
+    </child>
     <child>
       <object class="GtkGrid" id="table11">
         <property name="visible">True</property>
         </child>
       </object>
     </child>
-    <child type="titlebar">
-      <placeholder/>
-    </child>
   </object>
 </interface>
index ee525b61d81e8581e0e9efb0ad08177fe1523d3a..f42e2bf3795b85e3c64cc49b6d07ffe629565d8f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010-2018 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2010-2019 Andrea Zagli <azagli@libero.it>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -17,7 +17,9 @@
  *
  */
 
-#include <libgtkform/form.h>
+#include <libzakform/libzakform.h>
+#include <libzakformgtk/libzakformgtk.h>
+#include <libzakformgdaex/libzakformgdaex.h>
 #include <libzakautho/autho.h>
 #include <libsolipa/libsolipa.h>
 
@@ -63,7 +65,8 @@ struct _TerritorioTipoAggregazioneTerritorialePrivate
        {
                TerritorioCommons *commons;
 
-               GtkForm *form;
+               ZakFormGtkForm *form;
+               ZakFormGdaexProvider *form_provider;
 
                GtkWidget *w;
 
@@ -135,13 +138,15 @@ TerritorioTipoAggregazioneTerritoriale
                        return NULL;
                }
 
-       priv->form = gtk_form_new ();
-       g_object_set (G_OBJECT (priv->form), "gdaex", priv->commons->gdaex, NULL);
-       gtk_form_load_from_file (priv->form, g_build_filename (priv->commons->formdir, "tipo_aggregazione_territoriale.form", NULL), priv->commons->gtkbuilder);
+       priv->form = zak_form_gtk_form_new ();
+       zak_form_gtk_form_set_gtkbuilder (priv->form, priv->commons->gtkbuilder);
+       zak_form_form_load_from_file (ZAK_FORM_FORM (priv->form), g_build_filename (priv->commons->formdir, "tipo_aggregazione_territoriale.form", NULL));
+
+       priv->form_provider = zak_form_gdaex_provider_new (priv->commons->gdaex, "tipi_aggregazione_territoriale");
 
        priv->w = GTK_WIDGET (gtk_builder_get_object (priv->commons->gtkbuilder, "w_tipo_aggregazione_territoriale"));
 
-       priv->objects = gtk_form_get_objects_by_name (priv->form,
+       priv->objects = zak_form_gtk_form_get_gobjects_by_name (priv->form,
                                                      "label28",
                                                      NULL);
 
@@ -155,13 +160,14 @@ TerritorioTipoAggregazioneTerritoriale
        g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button77"),
                          "clicked", G_CALLBACK (territorio_tipo_aggregazione_territoriale_on_btn_salva_chiudi_clicked), (gpointer)a);
 
-       priv->id = id;
+       zak_form_form_clear (ZAK_FORM_FORM (priv->form));
 
+       priv->id = id;
        if (priv->id == 0)
                {
                        gtk_label_set_text (GTK_LABEL (priv->objects[LBL_ID]), "");
 
-                       gtk_form_set_as_origin (priv->form);
+                       zak_form_form_set_as_original (ZAK_FORM_FORM (priv->form));
                }
        else
                {
@@ -197,7 +203,7 @@ territorio_tipo_aggregazione_territoriale_carica (TerritorioTipoAggregazioneTerr
 {
        TerritorioTipoAggregazioneTerritorialePrivate *priv = TERRITORIO_TIPO_AGGREGAZIONE_TERRITORIALE_GET_PRIVATE (territorio_tipo_aggregazione_territoriale);
 
-       if (gtk_form_fill_from_table (priv->form))
+       if (zak_form_form_load (ZAK_FORM_FORM (priv->form), ZAK_FORM_IPROVIDER (priv->form_provider)))
                {
                }
 }
@@ -205,31 +211,42 @@ territorio_tipo_aggregazione_territoriale_carica (TerritorioTipoAggregazioneTerr
 static void
 territorio_tipo_aggregazione_territoriale_salva (TerritorioTipoAggregazioneTerritoriale *territorio_tipo_aggregazione_territoriale, gboolean chiudi)
 {
-       gchar *sql;
+       gboolean success;
 
        TerritorioTipoAggregazioneTerritorialeClass *klass = TERRITORIO_TIPO_AGGREGAZIONE_TERRITORIALE_GET_CLASS (territorio_tipo_aggregazione_territoriale);
 
        TerritorioTipoAggregazioneTerritorialePrivate *priv = TERRITORIO_TIPO_AGGREGAZIONE_TERRITORIALE_GET_PRIVATE (territorio_tipo_aggregazione_territoriale);
 
-       if (!gtk_form_check (priv->form, (priv->id != 0), NULL, TRUE, priv->w, TRUE))
+       if (!zak_form_gtk_form_is_valid (priv->form, priv->w))
                {
                        return;
                }
 
+       success = FALSE;
+
        if (priv->id == 0)
                {
-                       sql = gtk_form_get_sql (priv->form, GTK_FORM_SQL_INSERT);
+                       guint new_id;
+
+                       new_id = gdaex_get_new_id (priv->commons->gdaex,
+                                                  "tipi_aggregazione_territoriale",
+                                                  "id",
+                                                  NULL);
+
+                       gtk_label_set_text (GTK_LABEL (priv->objects[LBL_ID]), g_strdup_printf ("%d", new_id));
+
+                       success = zak_form_form_insert (ZAK_FORM_FORM (priv->form), ZAK_FORM_IPROVIDER (priv->form_provider));
                }
        else
                {
-                       sql = gtk_form_get_sql (priv->form, GTK_FORM_SQL_UPDATE);
+                       success = zak_form_form_update (ZAK_FORM_FORM (priv->form), ZAK_FORM_IPROVIDER (priv->form_provider));
                }
 
-       if (gdaex_execute (priv->commons->gdaex, sql) == 1)
+       if (success)
                {
                        g_signal_emit (territorio_tipo_aggregazione_territoriale, klass->aggiornato_signal_id, 0);
 
-                       gtk_form_set_as_origin (priv->form);
+                       zak_form_form_set_as_original (ZAK_FORM_FORM (priv->form));
 
                        if (priv->id == 0)
                                {
@@ -298,7 +315,7 @@ territorio_tipo_aggregazione_territoriale_conferma_chiusura (TerritorioTipoAggre
 
        ret = TRUE;
        if (gtk_widget_get_sensitive (GTK_WIDGET (gtk_builder_get_object (priv->commons->gtkbuilder, "button35")))
-           && gtk_form_is_changed (priv->form))
+           && zak_form_form_is_changed (ZAK_FORM_FORM (priv->form)))
                {
                        if (solipa_message_dialog (priv->w,
                                                   GTK_MESSAGE_QUESTION,