]> saetta.ns0.it Git - solipa/organigramma/commitdiff
Migrazione a libzakform di struttura collegamento.
authorAndrea Zagli <azagli@libero.it>
Sat, 10 Dec 2016 08:44:38 +0000 (09:44 +0100)
committerAndrea Zagli <azagli@libero.it>
Sat, 10 Dec 2016 08:44:38 +0000 (09:44 +0100)
data/organigramma/form/struttura_collegamento.form
src/strutturacollegamento.c

index a62d45fa9a9c25725c67bbb5bfee3f0309f2f47f..7a34f513d5a82901b6fe224706f376313308600d 100644 (file)
@@ -1,33 +1,34 @@
 <?xml version="1.0"?>
-<gtkform>
-
-       <table>struttura_collegamenti</table>
-
-       <widget type="label" name="label188">
-               <field type="integer" name="id">
-                       <is-key>t</is-key>
-                       <auto-increment>t</auto-increment>
-               </field>
-       </widget>
-
-       <widget type="label" name="label189">
-               <field type="integer" name="id_strutture" />
-       </widget>
-
-       <widget type="entry" name="entry52" label="label43">
-               <field type="text" name="descrizione">
-                       <obligatory>t</obligatory>
-               </field>
-       </widget>
-
-       <widget type="entry" name="entry53" label="label186">
-               <field type="text" name="indirizzo">
-                       <obligatory>t</obligatory>
-               </field>
-       </widget>
-
-       <widget type="textview" name="textview20" label="label187">
-               <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>label188</widget>
+  </element>
+  <element type="zak_form_gtk_form_element_label">
+    <name>id_strutture</name>
+    <type>integer</type>
+    <widget>label189</widget>
+  </element>
+  <element type="zak_form_gtk_form_element_entry">
+    <name>descrizione</name>
+    <type>string</type>
+    <label>label43</label>
+    <widget>entry52</widget>
+    <validator type="zak_form_element_validator_notempty"/>
+  </element>
+  <element type="zak_form_gtk_form_element_entry">
+    <name>indirizzo</name>
+    <type>string</type>
+    <label>label186</label>
+    <widget>entry53</widget>
+    <validator type="zak_form_element_validator_notempty"/>
+  </element>
+  <element type="zak_form_gtk_form_element_textview">
+    <name>note</name>
+    <type>string</type>
+    <label>label187</label>
+    <widget>textview20</widget>
+  </element>
+</zakform>
index 3991811fe53044f4eaee3a5694d3c5edaa924edd..59d48a62f127cdc370de303e4f8148297c549fc4 100644 (file)
@@ -19,7 +19,9 @@
 
 #include <libsolipa/libsolipa.h>
 #include <libzakautho/autoz.h>
-#include <libgtkform/form.h>
+#include <libzakform/libzakform.h>
+#include <libzakformgtk/libzakformgtk.h>
+#include <libzakformgdaex/libzakformgdaex.h>
 
 #include "strutturacollegamento.h"
 
@@ -64,7 +66,8 @@ struct _OrganigrammaStrutturaCollegamentoPrivate
        {
                OrganigrammaCommons *commons;
 
-               GtkForm *form;
+               ZakFormGtkForm *form;
+               ZakFormGdaexProvider *form_provider;
 
                GtkWidget *w;
 
@@ -137,15 +140,15 @@ OrganigrammaStrutturaCollegamento
                        return NULL;
                }
 
-       priv->form = gtk_form_new ();
-       g_object_set (priv->form, "gdaex", priv->commons->gdaex, NULL);
-       gtk_form_load_from_file (priv->form, g_build_filename (priv->commons->formdir, "struttura_collegamento.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, "struttura_collegamento.form", NULL));
 
-       g_object_set (priv->form, "gdaex", priv->commons->gdaex, NULL);
+       priv->form_provider = zak_form_gdaex_provider_new (priv->commons->gdaex, "struttura_collegamenti");
 
        priv->w = GTK_WIDGET (gtk_builder_get_object (priv->commons->gtkbuilder, "w_struttura_collegamento"));
 
-       priv->objects = gtk_form_get_objects_by_name (priv->form,
+       priv->objects = zak_form_gtk_form_get_gobjects_by_name (priv->form,
                                                      "label188",
                                                      "label189",
                                                      NULL);
@@ -160,7 +163,7 @@ OrganigrammaStrutturaCollegamento
        g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button187"),
                          "clicked", G_CALLBACK (organigramma_struttura_collegamento_on_btn_salvachiudi_clicked), (gpointer)a);
 
-       gtk_form_clear (priv->form);
+       zak_form_form_clear (ZAK_FORM_FORM (priv->form));
 
        priv->id = id;
        if (priv->id == 0)
@@ -168,7 +171,7 @@ OrganigrammaStrutturaCollegamento
                        gtk_label_set_text (GTK_LABEL (priv->objects[LBL_ID]), "");
                        gtk_label_set_text (GTK_LABEL (priv->objects[LBL_ID_STRUTTURE]), 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
                {
@@ -205,7 +208,7 @@ organigramma_struttura_collegamento_carica (OrganigrammaStrutturaCollegamento *o
 {
        OrganigrammaStrutturaCollegamentoPrivate *priv = ORGANIGRAMMA_STRUTTURA_COLLEGAMENTO_GET_PRIVATE (organigramma_struttura_collegamento);
 
-       if (gtk_form_fill_from_table (priv->form))
+       if (zak_form_form_load (ZAK_FORM_FORM (priv->form), ZAK_FORM_IPROVIDER (priv->form_provider)))
                {
                }
 }
@@ -213,34 +216,42 @@ organigramma_struttura_collegamento_carica (OrganigrammaStrutturaCollegamento *o
 static void
 organigramma_struttura_collegamento_salva (OrganigrammaStrutturaCollegamento *organigramma_struttura_collegamento, gboolean chiudi)
 {
-       gchar *sql;
-       GtkWidget *dialog;
+       gboolean success;
 
        OrganigrammaStrutturaCollegamentoClass *klass = ORGANIGRAMMA_STRUTTURA_COLLEGAMENTO_GET_CLASS (organigramma_struttura_collegamento);
 
        OrganigrammaStrutturaCollegamentoPrivate *priv = ORGANIGRAMMA_STRUTTURA_COLLEGAMENTO_GET_PRIVATE (organigramma_struttura_collegamento);
 
-       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_free (sql);
-
                        g_signal_emit (organigramma_struttura_collegamento, 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)
                                {
@@ -260,8 +271,6 @@ organigramma_struttura_collegamento_salva (OrganigrammaStrutturaCollegamento *or
                }
        else
                {
-                       g_free (sql);
-
                        if (priv->id == 0)
                                {
                                        gtk_label_set_text (GTK_LABEL (priv->objects[LBL_ID]), "");
@@ -310,7 +319,7 @@ organigramma_struttura_collegamento_conferma_chiusura (OrganigrammaStrutturaColl
        OrganigrammaStrutturaCollegamentoPrivate *priv = ORGANIGRAMMA_STRUTTURA_COLLEGAMENTO_GET_PRIVATE (organigramma_struttura_collegamento);
 
        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,