]> saetta.ns0.it Git - solipa/organigramma/commitdiff
Migrazione a libzakform di titolo.
authorAndrea Zagli <azagli@libero.it>
Fri, 9 Dec 2016 09:13:05 +0000 (10:13 +0100)
committerAndrea Zagli <azagli@libero.it>
Fri, 9 Dec 2016 09:13:05 +0000 (10:13 +0100)
configure.ac
data/organigramma/form/titolo.form
src/titolo.c

index 6300c9175258da2b7f42d0373a59d85a25f8b26f..2176fc0dd346c9d4abeb491adb8fc86720edd017 100644 (file)
@@ -48,6 +48,9 @@ PKG_CHECK_MODULES(ORGANIGRAMMA, [gio-2.0 >= 2.36
                                  libgdaexgrid
                                  libgtkform >= 0.5.0
                                  libgtkformui >= 0.5.0
+                                 libzakform
+                                 libzakformgtk
+                                 libzakformgdaex
                                  libzakconfi >= 0.10.0
                                  libzakauthe >= 0.5.99
                                  libzakautho >= 0.0.5
index fea144b309eb82cefc5a3e3eacf3bfb143ae8849..87a02ace1ff19780ded35619698b5c0f9ba72792 100644 (file)
@@ -1,25 +1,24 @@
 <?xml version="1.0"?>
-<gtkform>
-
-       <table>titoli</table>
-
-       <widget type="label" name="label140" label="label141">
-               <field type="integer" name="id">
-                       <is-key>t</is-key>
-                       <auto-increment>t</auto-increment>
-               </field>
-       </widget>
-
-       <widget type="entry" name="entry37" label="label138">
-               <field type="text" name="sigla">
-                       <obligatory>t</obligatory>
-               </field>
-       </widget>
-
-       <widget type="entry" name="entry38" label="label142">
-               <field type="text" name="descrizione">
-                       <obligatory>t</obligatory>
-               </field>
-       </widget>
-
-</gtkform>
+<zakform>
+  <element type="zak_form_gtk_form_element_label">
+    <name>id</name>
+    <type>integer</type>
+    <label>label141</label>
+    <is-key>TRUE</is-key>
+    <widget>label140</widget>
+  </element>
+  <element type="zak_form_gtk_form_element_entry">
+    <name>sigla</name>
+    <type>string</type>
+    <label>label138</label>
+    <widget>entry37</widget>
+    <validator type="zak_form_element_validator_notempty"/>
+  </element>
+  <element type="zak_form_gtk_form_element_entry">
+    <name>descrizione</name>
+    <type>string</type>
+    <label>label142</label>
+    <widget>entry38</widget>
+    <validator type="zak_form_element_validator_notempty"/>
+  </element>
+</zakform>
index 6b35918969795f4baae54b232a9bdde9428c3224..7d41b542a61dc72e9ac6f573a8502e494cc9d672 100644 (file)
@@ -22,7 +22,9 @@
 #endif
 
 #include <libzakautho/autoz.h>
-#include <libgtkform/form.h>
+#include <libzakform/libzakform.h>
+#include <libzakformgtk/libzakformgtk.h>
+#include <libzakformgdaex/libzakformgdaex.h>
 #include <libsolipa/utils.h>
 
 #include "titolo.h"
@@ -67,7 +69,8 @@ struct _OrganigrammaTitoloPrivate
        {
                OrganigrammaCommons *commons;
 
-               GtkForm *form;
+               ZakFormGtkForm *form;
+               ZakFormGdaexProvider *form_provider;
 
                GtkWidget *w;
 
@@ -139,13 +142,15 @@ OrganigrammaTitolo
                        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, "titolo.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, "titolo.form", NULL));
+
+       priv->form_provider = zak_form_gdaex_provider_new (priv->commons->gdaex, "titoli");
 
        priv->w = GTK_WIDGET (gtk_builder_get_object (priv->commons->gtkbuilder, "w_titolo"));
 
-       priv->objects = gtk_form_get_objects_by_name (priv->form,
+       priv->objects = zak_form_gtk_form_get_gobjects_by_name (priv->form,
                                                      "label140",
                                                      NULL);
 
@@ -165,7 +170,7 @@ OrganigrammaTitolo
                {
                        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
                {
@@ -202,7 +207,7 @@ organigramma_titolo_carica (OrganigrammaTitolo *titolo)
 {
        OrganigrammaTitoloPrivate *priv = ORGANIGRAMMA_TITOLO_GET_PRIVATE (titolo);
 
-       if (gtk_form_fill_from_table (priv->form))
+       if (zak_form_form_load (ZAK_FORM_FORM (priv->form), ZAK_FORM_IPROVIDER (priv->form_provider)))
                {
                }
 }
@@ -210,31 +215,42 @@ organigramma_titolo_carica (OrganigrammaTitolo *titolo)
 static void
 organigramma_titolo_salva (OrganigrammaTitolo *titolo, gboolean chiudi)
 {
-       gchar *sql;
+       gboolean success;
 
        OrganigrammaTitoloClass *klass = ORGANIGRAMMA_TITOLO_GET_CLASS (titolo);
 
        OrganigrammaTitoloPrivate *priv = ORGANIGRAMMA_TITOLO_GET_PRIVATE (titolo);
 
-       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,
+                                                                          "titoli",
+                                                                          "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 (titolo, 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)
                                {
@@ -302,7 +318,7 @@ organigramma_titolo_conferma_chiusura (OrganigrammaTitolo *titolo)
        OrganigrammaTitoloPrivate *priv = ORGANIGRAMMA_TITOLO_GET_PRIVATE (titolo);
 
        ret = TRUE;
-       if (gtk_form_is_changed (priv->form))
+       if (zak_form_form_is_changed (ZAK_FORM_FORM (priv->form)))
                {
                        if (solipa_message_dialog (priv->w,
                                                   GTK_MESSAGE_QUESTION,