]> saetta.ns0.it Git - solipa/territorio/commitdiff
Migrato il form stato a zakform.
authorAndrea Zagli <azagli@libero.it>
Sat, 21 Dec 2019 09:02:25 +0000 (10:02 +0100)
committerAndrea Zagli <azagli@libero.it>
Sat, 21 Dec 2019 09:02:25 +0000 (10:02 +0100)
configure.ac
data/territorio/form/stato.form
po/Makefile.in.in
src/stato.c

index a9fc35016bc23b03bed165872b978c02e1dbc01c..e615f5fab174a0ecbfd4d1b719c77dc5bf787503 100644 (file)
@@ -43,6 +43,10 @@ PKG_CHECK_MODULES(TERRITORIO, [gio-2.0 >= 2.36
                                libzakconfi >= 0.10.0
                                libgtkform >= 0.5.0
                                libgtkformui >= 0.5.0
+                               libzakform
+                               libzakformgtk
+                               libzakformgdaex
+                               libzakformgtkdecoder
                                libzakauthe >= 0.2.0
                                libzakautho >= 0.0.5
                                libzakutils
index f9940bd985c028152b75c45602f460562c0ddc34..265bddbe70f948bb126a72f8c3e4280a4927f2d8 100644 (file)
@@ -1,35 +1,42 @@
 <?xml version="1.0"?>
-<gtkform>
-
-       <table>stati</table>
-
-       <widget type="label" name="label3" label="label2">
-               <field type="integer" name="id">
-                       <is-key>t</is-key>
-                       <auto-increment>t</auto-increment>
-               </field>
-       </widget>
-
-       <widget type="entry" name="entry1" label="label4">
-               <field type="text" name="nome">
-                       <obligatory>t</obligatory>
-               </field>
-       </widget>
-
-       <widget type="entry" name="entry2" label="label5">
-               <field type="text" name="nazionalita" />
-       </widget>
-
-       <widget type="entry" name="entry3" label="label6">
-               <field type="text" name="sigla" />
-       </widget>
-
-       <widget type="entry" name="entry4" label="label7">
-               <field type="text" name="cod_istat" />
-       </widget>
-
-       <widget type="checkbox" name="checkbutton1" label="label8">
-               <field type="boolean" name="comunita_europea" />
-       </widget>
-
-</gtkform>
+<zakform>
+  <element type="zak_form_gtk_form_element_label">
+    <name>id</name>
+    <type>integer</type>
+    <label>label2</label>
+    <is-key>TRUE</is-key>
+    <widget>label3</widget>
+    <format thousands_separator="" />
+  </element>
+  <element type="zak_form_gtk_form_element_entry">
+    <name>nome</name>
+    <type>string</type>
+    <label>label4</label>
+    <widget>entry1</widget>
+    <validator type="zak_form_element_validator_notempty"/>
+  </element>
+  <element type="zak_form_gtk_form_element_entry">
+    <name>nazionalita</name>
+    <type>string</type>
+    <label>label5</label>
+    <widget>entry2</widget>
+  </element>
+  <element type="zak_form_gtk_form_element_entry">
+    <name>sigla</name>
+    <type>string</type>
+    <label>label6</label>
+    <widget>entry3</widget>
+  </element>
+  <element type="zak_form_gtk_form_element_entry">
+    <name>cod_istat</name>
+    <type>string</type>
+    <label>label7</label>
+    <widget>entry4</widget>
+  </element>
+  <element type="zak_form_gtk_form_element_check">
+    <name>comunita_europea</name>
+    <type>boolean</type>
+    <label>label8</label>
+    <widget>checkbutton1</widget>
+  </element>
+</zakform>
index 027f656e89ca287ae338635c67544b94f9d178f8..cb89a4ac8467507c12bc491f8d66810737ccc6ea 100644 (file)
@@ -56,7 +56,7 @@ COMPILE = $(CC) -c $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) $(XCFLAGS)
 SOURCES = 
 POFILES = @POFILES@
 GMOFILES = @GMOFILES@
-DISTFILES = LINGUAS ChangeLog Makefile.in.in POTFILES.in $(GETTEXT_PACKAGE).pot \
+DISTFILES = LINGUAS Makefile.in.in POTFILES.in $(GETTEXT_PACKAGE).pot \
 $(POFILES) $(GMOFILES) $(SOURCES)
 
 POTFILES = \
index 44ded1a728da0c432ae4328a19b6820d2424f561..4dc3d5c16ca8f72b838edc78552fd4ea83f067e2 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 _TerritorioStatoPrivate
        {
                TerritorioCommons *commons;
 
-               GtkForm *form;
+               ZakFormGtkForm *form;
+               ZakFormGdaexProvider *form_provider;
 
                GtkWidget *w;
 
@@ -135,13 +138,15 @@ TerritorioStato
                        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, "stato.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, "stato.form", NULL));
+
+       priv->form_provider = zak_form_gdaex_provider_new (priv->commons->gdaex, "stati");
 
        priv->w = GTK_WIDGET (gtk_builder_get_object (priv->commons->gtkbuilder, "w_stato"));
 
-       priv->objects = gtk_form_get_objects_by_name (priv->form,
+       priv->objects = zak_form_gtk_form_get_gobjects_by_name (priv->form,
                                                      "label3",
                                                      NULL);
 
@@ -155,13 +160,14 @@ TerritorioStato
        g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button71"),
                          "clicked", G_CALLBACK (territorio_stato_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
                {
@@ -218,7 +224,7 @@ territorio_stato_carica (TerritorioStato *territorio_stato)
 {
        TerritorioStatoPrivate *priv = TERRITORIO_STATO_GET_PRIVATE (territorio_stato);
 
-       if (gtk_form_fill_from_table (priv->form))
+       if (zak_form_form_load (ZAK_FORM_FORM (priv->form), ZAK_FORM_IPROVIDER (priv->form_provider)))
                {
                }
 }
@@ -226,31 +232,42 @@ territorio_stato_carica (TerritorioStato *territorio_stato)
 static void
 territorio_stato_salva (TerritorioStato *territorio_stato, gboolean chiudi)
 {
-       gchar *sql;
+       gboolean success;
 
        TerritorioStatoClass *klass = TERRITORIO_STATO_GET_CLASS (territorio_stato);
 
        TerritorioStatoPrivate *priv = TERRITORIO_STATO_GET_PRIVATE (territorio_stato);
 
-       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,
+                                                                          "stati",
+                                                                          "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_stato, 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)
                                {
@@ -319,7 +336,7 @@ territorio_stato_conferma_chiusura (TerritorioStato *territorio_stato)
 
        ret = TRUE;
        if (gtk_widget_get_sensitive (GTK_WIDGET (gtk_builder_get_object (priv->commons->gtkbuilder, "button7")))
-           && 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,