]> saetta.ns0.it Git - solipa/organigramma/commitdiff
Migrazione a libzakform di ufficio stanza.
authorAndrea Zagli <azagli@libero.it>
Sat, 10 Dec 2016 10:09:58 +0000 (11:09 +0100)
committerAndrea Zagli <azagli@libero.it>
Sat, 10 Dec 2016 10:09:58 +0000 (11:09 +0100)
data/organigramma/form/ufficio_stanza.form
src/ufficiostanza.c

index c968435ccfc4c1f354007d76f7939662fb25018c..60ec420bd6f50fe7f89e78ef64a9e27f5b7d47fe 100644 (file)
@@ -1,40 +1,41 @@
 <?xml version="1.0"?>
-<gtkform>
-
-       <table>ufficio_stanze</table>
-
-       <widget type="label" name="label163">
-               <field type="integer" name="id">
-                       <is-key>t</is-key>
-                       <auto-increment>t</auto-increment>
-               </field>
-       </widget>
-
-       <widget type="label" name="label164">
-               <field type="integer" name="id_uffici">
-               </field>
-       </widget>
-
-       <widget type="entry" name="entry44" label="label165">
-               <field type="text" name="piano">
-                       <obligatory>t</obligatory>
-               </field>
-       </widget>
-
-       <widget type="entry" name="entry43" label="label161">
-               <field type="text" name="da_stanza">
-                       <obligatory>t</obligatory>
-               </field>
-       </widget>
-
-       <widget type="entry" name="entry45" label="label162">
-               <field type="text" name="a_stanza">
-                       <obligatory>t</obligatory>
-               </field>
-       </widget>
-
-       <widget type="textview" name="textview16" label="label160">
-               <field type="text" name="note" />
-       </widget>
-
-</gtkform>
+<zakform>
+  <element type="zak_form_gtk_form_element_label">
+    <name>id</name>
+    <type>integer</type>
+    <is-key>TRUE</is-key>
+    <widget>label163</widget>
+  </element>
+  <element type="zak_form_gtk_form_element_label">
+    <name>id_uffici</name>
+    <type>integer</type>
+    <widget>label164</widget>
+  </element>
+  <element type="zak_form_gtk_form_element_entry">
+    <name>piano</name>
+    <type>string</type>
+    <label>label165</label>
+    <widget>entry44</widget>
+    <validator type="zak_form_element_validator_notempty"/>
+  </element>
+  <element type="zak_form_gtk_form_element_entry">
+    <name>da_stanza</name>
+    <type>string</type>
+    <label>label161</label>
+    <widget>entry43</widget>
+    <validator type="zak_form_element_validator_notempty"/>
+  </element>
+  <element type="zak_form_gtk_form_element_entry">
+    <name>a_stanza</name>
+    <type>string</type>
+    <label>label162</label>
+    <widget>entry45</widget>
+    <validator type="zak_form_element_validator_notempty"/>
+  </element>
+  <element type="zak_form_gtk_form_element_textview">
+    <name>note</name>
+    <type>string</type>
+    <label>label160</label>
+    <widget>textview16</widget>
+  </element>
+</zakform>
index 5f44229db8f9eaf48ef187ce061c44c6645a7a88..bd2ec23d006b36d8493f24c8de9a63c36f66435a 100644 (file)
@@ -24,7 +24,9 @@
 #include <glib/gprintf.h>
 
 #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 "ufficiostanza.h"
@@ -71,7 +73,8 @@ struct _OrganigrammaUfficioStanzaPrivate
        {
                OrganigrammaCommons *commons;
 
-               GtkForm *form;
+               ZakFormGtkForm *form;
+               ZakFormGdaexProvider *form_provider;
 
                GtkWidget *w;
 
@@ -145,13 +148,15 @@ OrganigrammaUfficioStanza
                        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, "ufficio_stanza.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, "ufficio_stanza.form", NULL));
+
+       priv->form_provider = zak_form_gdaex_provider_new (priv->commons->gdaex, "ufficio_stanze");
 
        priv->w = GTK_WIDGET (gtk_builder_get_object (priv->commons->gtkbuilder, "w_ufficio_stanza"));
 
-       priv->objects = gtk_form_get_objects_by_name (priv->form,
+       priv->objects = zak_form_gtk_form_get_gobjects_by_name (priv->form,
                                                      "label163",
                                                      "label164",
                                                      NULL);
@@ -172,7 +177,7 @@ OrganigrammaUfficioStanza
                        gtk_label_set_text (GTK_LABEL (priv->objects[LBL_ID]), "");
                        gtk_label_set_text (GTK_LABEL (priv->objects[LBL_ID_UFFICI]), g_strdup_printf ("%d", id_uffici));
 
-                       gtk_form_set_as_origin (priv->form);
+                       zak_form_form_set_as_original (ZAK_FORM_FORM (priv->form));
                }
        else
                {
@@ -213,7 +218,7 @@ organigramma_ufficio_stanza_carica (OrganigrammaUfficioStanza *organigramma_uffi
 
        OrganigrammaUfficioStanzaPrivate *priv = ORGANIGRAMMA_UFFICIO_STANZA_GET_PRIVATE (organigramma_ufficio_stanza);
 
-       if (gtk_form_fill_from_table (priv->form))
+       if (zak_form_form_load (ZAK_FORM_FORM (priv->form), ZAK_FORM_IPROVIDER (priv->form_provider)))
                {
                }
 }
@@ -221,27 +226,38 @@ organigramma_ufficio_stanza_carica (OrganigrammaUfficioStanza *organigramma_uffi
 static void
 organigramma_ufficio_stanza_salva (OrganigrammaUfficioStanza *organigramma_ufficio_stanza, gboolean chiudi)
 {
-       gchar *sql;
+       gboolean success;
 
        OrganigrammaUfficioStanzaClass *klass = ORGANIGRAMMA_UFFICIO_STANZA_GET_CLASS (organigramma_ufficio_stanza);
 
        OrganigrammaUfficioStanzaPrivate *priv = ORGANIGRAMMA_UFFICIO_STANZA_GET_PRIVATE (organigramma_ufficio_stanza);
 
-       if (!gtk_form_check (priv->form, FALSE, 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,
+                                                                          "ufficio_stanze",
+                                                                          "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 (organigramma_ufficio_stanza, klass->aggiornato_signal_id, 0);
 
@@ -250,7 +266,7 @@ organigramma_ufficio_stanza_salva (OrganigrammaUfficioStanza *organigramma_uffic
                                        priv->id = strtol (gtk_label_get_text (GTK_LABEL (priv->objects[LBL_ID])), NULL, 10);
                                }
 
-                       gtk_form_set_as_origin (priv->form);
+                       zak_form_form_set_as_original (ZAK_FORM_FORM (priv->form));
 
                        solipa_message_dialog (priv->w,
                                               GTK_MESSAGE_INFO,
@@ -309,7 +325,7 @@ organigramma_ufficio_stanza_conferma_chiusura (OrganigrammaUfficioStanza *organi
 
        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,