]> saetta.ns0.it Git - solipa/organigramma/commitdiff
Migrazione a libzakform di tipo nodo.
authorAndrea Zagli <azagli@libero.it>
Fri, 9 Dec 2016 11:01:33 +0000 (12:01 +0100)
committerAndrea Zagli <azagli@libero.it>
Fri, 9 Dec 2016 11:01:33 +0000 (12:01 +0100)
data/organigramma/form/tipo_nodo.form
src/tiponodo.c

index 01776b9f79511761e36d2f84231c7af8461d6377..3e5976350b8647347a91ca07a22bc9b98fb1d76c 100644 (file)
@@ -1,27 +1,29 @@
 <?xml version="1.0"?>
-<gtkform>
-
-       <table>tipi_nodo</table>
-
-       <widget type="label" name="label12" label="label9">
-               <field type="integer" name="id">
-                       <is-key>t</is-key>
-                       <auto-increment>t</auto-increment>
-               </field>
-       </widget>
-
-       <widget type="entry" name="entry3" label="label8">
-               <field type="text" name="nome">
-                       <obligatory>t</obligatory>
-               </field>
-       </widget>
-
-       <widget type="textview" name="textview17" label="label29">
-               <field type="text" name="graphviz" />
-       </widget>
-
-       <widget type="textview" name="textview18" label="label64">
-               <field type="text" name="graphviz_connessione" />
-       </widget>
-
-</gtkform>
+<zakform>
+  <element type="zak_form_gtk_form_element_label">
+    <name>id</name>
+    <type>integer</type>
+    <label>label9</label>
+    <is-key>TRUE</is-key>
+    <widget>label12</widget>
+  </element>
+  <element type="zak_form_gtk_form_element_entry">
+    <name>nome</name>
+    <type>string</type>
+    <label>label8</label>
+    <widget>entry3</widget>
+    <validator type="zak_form_element_validator_notempty"/>
+  </element>
+  <element type="zak_form_gtk_form_element_textview">
+    <name>graphviz</name>
+    <type>string</type>
+    <label>label29</label>
+    <widget>textview17</widget>
+  </element>
+  <element type="zak_form_gtk_form_element_textview">
+    <name>graphviz_connessione</name>
+    <type>string</type>
+    <label>label64</label>
+    <widget>textview18</widget>
+  </element>
+</zakform>
index 18edaea9417629ff095b6357dadab35d03375037..7d301e03a09e5b0395fd56b00825f1806cf05c62 100644 (file)
@@ -22,8 +22,9 @@
 #endif
 
 #include <libzakautho/autoz.h>
-#include <libgtkform/form.h>
-#include <libgtkform/fielddatetime.h>
+#include <libzakform/libzakform.h>
+#include <libzakformgtk/libzakformgtk.h>
+#include <libzakformgdaex/libzakformgdaex.h>
 #include <libsolipa/utils.h>
 
 #include "tiponodo.h"
@@ -68,7 +69,8 @@ struct _OrganigrammaTipoNodoPrivate
        {
                OrganigrammaCommons *commons;
 
-               GtkForm *form;
+               ZakFormGtkForm *form;
+               ZakFormGdaexProvider *form_provider;
 
                GtkWidget *w;
 
@@ -140,13 +142,15 @@ OrganigrammaTipoNodo
                        return NULL;
                }
 
-       priv->form = gtk_form_new_from_file (g_build_filename (priv->commons->formdir, "tipo_nodo.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_nodo.form", NULL));
 
-       g_object_set (priv->form, "gdaex", priv->commons->gdaex, NULL);
+       priv->form_provider = zak_form_gdaex_provider_new (priv->commons->gdaex, "tipi_nodo");
 
        priv->w = GTK_WIDGET (gtk_builder_get_object (priv->commons->gtkbuilder, "w_tipo_nodo"));
 
-       priv->objects = gtk_form_get_objects_by_name (priv->form,
+       priv->objects = zak_form_gtk_form_get_gobjects_by_name (priv->form,
                                                      "label12",
                                                      NULL);
 
@@ -166,7 +170,7 @@ OrganigrammaTipoNodo
                {
                        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
                {
@@ -203,7 +207,7 @@ organigramma_tipo_nodo_carica (OrganigrammaTipoNodo *organigramma_tipo_nodo)
 {
        OrganigrammaTipoNodoPrivate *priv = ORGANIGRAMMA_TIPO_NODO_GET_PRIVATE (organigramma_tipo_nodo);
 
-       if (gtk_form_fill_from_table (priv->form))
+       if (zak_form_form_load (ZAK_FORM_FORM (priv->form), ZAK_FORM_IPROVIDER (priv->form_provider)))
                {
                }
 }
@@ -211,31 +215,42 @@ organigramma_tipo_nodo_carica (OrganigrammaTipoNodo *organigramma_tipo_nodo)
 static void
 organigramma_tipo_nodo_salva (OrganigrammaTipoNodo *organigramma_tipo_nodo, gboolean chiudi)
 {
-       gchar *sql;
+       gboolean success;
 
        OrganigrammaTipoNodoClass *klass = ORGANIGRAMMA_TIPO_NODO_GET_CLASS (organigramma_tipo_nodo);
 
        OrganigrammaTipoNodoPrivate *priv = ORGANIGRAMMA_TIPO_NODO_GET_PRIVATE (organigramma_tipo_nodo);
 
-       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_nodo",
+                                                                          "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_tipo_nodo, 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)
                                {
@@ -303,7 +318,7 @@ organigramma_tipo_nodo_conferma_chiusura (OrganigrammaTipoNodo *organigramma_tip
        OrganigrammaTipoNodoPrivate *priv = ORGANIGRAMMA_TIPO_NODO_GET_PRIVATE (organigramma_tipo_nodo);
 
        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,