]> saetta.ns0.it Git - solipa/organigramma/commitdiff
Migrazione a libzakform di tipo rapporto lavoro.
authorAndrea Zagli <azagli@libero.it>
Sat, 10 Dec 2016 09:18:31 +0000 (10:18 +0100)
committerAndrea Zagli <azagli@libero.it>
Sat, 10 Dec 2016 09:18:31 +0000 (10:18 +0100)
data/organigramma/form/tipo_rapporto_lavoro.form
src/tiporapportolavoro.c

index ceb42dfd75621fc97eaf13e561b3979f019636b3..5d1dfacd0a0e13b2bc67d3cb47c80040d22affbe 100644 (file)
@@ -1,19 +1,17 @@
 <?xml version="1.0"?>
-<gtkform>
-
-       <table>tipi_rapporto_lavoro</table>
-
-       <widget type="label" name="label145" label="label146">
-               <field type="integer" name="id">
-                       <is-key>t</is-key>
-                       <auto-increment>t</auto-increment>
-               </field>
-       </widget>
-
-       <widget type="entry" name="entry40" label="label147">
-               <field type="text" name="nome">
-                       <obligatory>t</obligatory>
-               </field>
-       </widget>
-
-</gtkform>
+<zakform>
+  <element type="zak_form_gtk_form_element_label">
+    <name>id</name>
+    <type>integer</type>
+    <label>label146</label>
+    <is-key>TRUE</is-key>
+    <widget>label145</widget>
+  </element>
+  <element type="zak_form_gtk_form_element_entry">
+    <name>nome</name>
+    <type>string</type>
+    <label>label147</label>
+    <widget>entry40</widget>
+    <validator type="zak_form_element_validator_notempty"/>
+  </element>
+</zakform>
index b21f39867ea70b887226c932f00cd1cd0dd9a764..0d12721fde49e896270853dc3c15a4ac6e074d1a 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 "tiporapportolavoro.h"
@@ -67,7 +69,8 @@ struct _OrganigrammaTipoRapportoLavoroPrivate
        {
                OrganigrammaCommons *commons;
 
-               GtkForm *form;
+               ZakFormGtkForm *form;
+               ZakFormGdaexProvider *form_provider;
 
                GtkWidget *w;
 
@@ -139,13 +142,15 @@ OrganigrammaTipoRapportoLavoro
                        return NULL;
                }
 
-       priv->form = gtk_form_new_from_file (g_build_filename (priv->commons->formdir, "tipo_rapporto_lavoro.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_rapporto_lavoro.form", NULL));
 
-       g_object_set (priv->form, "gdaex", priv->commons->gdaex, NULL);
+       priv->form_provider = zak_form_gdaex_provider_new (priv->commons->gdaex, "tipi_rapporto_lavoro");
 
        priv->w = GTK_WIDGET (gtk_builder_get_object (priv->commons->gtkbuilder, "w_tipo_rapporto_lavoro"));
 
-       priv->objects = gtk_form_get_objects_by_name (priv->form,
+       priv->objects = zak_form_gtk_form_get_gobjects_by_name (priv->form,
                                                      "label145",
                                                      NULL);
 
@@ -159,13 +164,14 @@ OrganigrammaTipoRapportoLavoro
        g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button144"),
                          "clicked", G_CALLBACK (organigramma_tipo_rapporto_lavoro_on_btn_salvaechiudi_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
                {
@@ -202,37 +208,50 @@ organigramma_tipo_rapporto_lavoro_carica (OrganigrammaTipoRapportoLavoro *tipo_r
 {
        OrganigrammaTipoRapportoLavoroPrivate *priv = ORGANIGRAMMA_TIPO_RAPPORTO_LAVORO_GET_PRIVATE (tipo_rapporto_lavoro);
 
-       gtk_form_fill_from_table (priv->form);
+       if (zak_form_form_load (ZAK_FORM_FORM (priv->form), ZAK_FORM_IPROVIDER (priv->form_provider)))
+               {
+               }
 }
 
 static void
 organigramma_tipo_rapporto_lavoro_salva (OrganigrammaTipoRapportoLavoro *tipo_rapporto_lavoro, gboolean chiudi)
 {
-       gchar *sql;
+       gboolean success;
 
        OrganigrammaTipoRapportoLavoroClass *klass = ORGANIGRAMMA_TIPO_RAPPORTO_LAVORO_GET_CLASS (tipo_rapporto_lavoro);
 
        OrganigrammaTipoRapportoLavoroPrivate *priv = ORGANIGRAMMA_TIPO_RAPPORTO_LAVORO_GET_PRIVATE (tipo_rapporto_lavoro);
 
-       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_rapporto_lavoro",
+                                                                          "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 (tipo_rapporto_lavoro, 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)
                                {
@@ -300,7 +319,7 @@ organigramma_tipo_rapporto_lavoro_conferma_chiusura (OrganigrammaTipoRapportoLav
        OrganigrammaTipoRapportoLavoroPrivate *priv = ORGANIGRAMMA_TIPO_RAPPORTO_LAVORO_GET_PRIVATE (tipo_rapporto_lavoro);
 
        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,