]> saetta.ns0.it Git - solipa/organigramma/commitdiff
Migrazione a libzakform di tipo recapito.
authorAndrea Zagli <azagli@libero.it>
Sat, 2 Dec 2017 10:46:14 +0000 (11:46 +0100)
committerAndrea Zagli <azagli@libero.it>
Sat, 2 Dec 2017 10:46:14 +0000 (11:46 +0100)
data/organigramma/form/tipo_recapito.form
po/Makefile.in.in
src/tiporecapito.c

index 5d743af15e343d6417424caee601ef3458889ce1..f8bd1a450958103993eaf684f46a600ab2c5673b 100644 (file)
@@ -1,19 +1,17 @@
 <?xml version="1.0"?>
-<gtkform>
-
-       <table>tipi_recapito</table>
-
-       <widget type="label" name="label15" label="label16">
-               <field type="integer" name="id">
-                       <is-key>t</is-key>
-                       <auto-increment>t</auto-increment>
-               </field>
-       </widget>
-
-       <widget type="entry" name="entry4" label="label14">
-               <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>label16</label>
+    <is-key>TRUE</is-key>
+    <widget>label15</widget>
+  </element>
+  <element type="zak_form_gtk_form_element_entry">
+    <name>nome</name>
+    <type>string</type>
+    <label>label14</label>
+    <widget>entry4</widget>
+    <validator type="zak_form_element_validator_notempty"/>
+  </element>
+</zakform>
index e6c32cba781cc38f8b19155f2858c70342367a56..027f656e89ca287ae338635c67544b94f9d178f8 100644 (file)
@@ -93,7 +93,7 @@ all-yes: $(CATALOGS)
 all-no:
 
 $(srcdir)/$(GETTEXT_PACKAGE).pot: $(POTFILES)
-       $(XGETTEXT) --default-domain=$(GETTEXT_PACKAGE) \
+       $(XGETTEXT) --default-domain=$(GETTEXT_PACKAGE) --from-code=UTF-8 \
          --msgid-bugs-address='http://bugzilla.gnome.org/enter_bug.cgi?product=glib&keywords=I18N+L10N&component=general' \
          --add-comments --keyword=_ --keyword=N_ \
          --keyword=C_:1c,2 \
index faaec5d7ed9c8f2880261ce2d1003593193dce1b..2b12aa876ddd8c9609bca85d6fd976bc188a7029 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010-2016 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2010-2017 Andrea Zagli <azagli@libero.it>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -24,7 +24,9 @@
 #include <libpq-fe.h>
 
 #include <libzakautho/autho.h>
-#include <libgtkform/form.h>
+#include <libzakform/libzakform.h>
+#include <libzakformgtk/libzakformgtk.h>
+#include <libzakformgdaex/libzakformgdaex.h>
 #include <libsolipa/utils.h>
 
 #include "tiporecapito.h"
@@ -69,7 +71,8 @@ struct _OrganigrammaTipoRecapitoPrivate
        {
                OrganigrammaCommons *commons;
 
-               GtkForm *form;
+               ZakFormGtkForm *form;
+               ZakFormGdaexProvider *form_provider;
 
                GtkWidget *w;
                SolipaAllegato *sallegato;
@@ -142,20 +145,22 @@ OrganigrammaTipoRecapito
                        return NULL;
                }
 
-       priv->form = gtk_form_new_from_file (g_build_filename (priv->commons->formdir, "tipo_recapito.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_recapito.form", NULL));
 
-       g_object_set (priv->form, "gdaex", priv->commons->gdaex, NULL);
+       priv->form_provider = zak_form_gdaex_provider_new (priv->commons->gdaex, "tipi_recapito");
 
        priv->w = GTK_WIDGET (gtk_builder_get_object (priv->commons->gtkbuilder, "w_tipo_recapito"));
 
-       priv->objects = gtk_form_get_objects_by_name (priv->form,
+       priv->objects = zak_form_gtk_form_get_gobjects_by_name (priv->form,
                                                      "label15",
                                                      NULL);
 
        priv->sallegato = solipa_allegato_new (commons->solipa);
        if (priv->sallegato != NULL)
                {
-                       solipa_allegato_add_to_gtkform (priv->sallegato, priv->form,
+                       solipa_allegato_add_to_zakformgtk (priv->sallegato, priv->form,
                                                        "immagine_percorso", "immagine_file_data", "immagine_file_dimensione");
                        solipa_allegato_con_salva_in_db (priv->sallegato, FALSE);
                        gtk_container_add (GTK_CONTAINER (gtk_builder_get_object (priv->commons->gtkbuilder, "alignment1")),
@@ -172,13 +177,14 @@ OrganigrammaTipoRecapito
        g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button145"),
                          "clicked", G_CALLBACK (organigramma_tipo_recapito_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
                {
@@ -215,7 +221,7 @@ organigramma_tipo_recapito_carica (OrganigrammaTipoRecapito *tipo_recapito)
 {
        OrganigrammaTipoRecapitoPrivate *priv = ORGANIGRAMMA_TIPO_RECAPITO_GET_PRIVATE (tipo_recapito);
 
-       if (gtk_form_fill_from_table (priv->form))
+       if (zak_form_form_load (ZAK_FORM_FORM (priv->form), ZAK_FORM_IPROVIDER (priv->form_provider)))
                {
                        solipa_allegato_set_salva_in_db (priv->sallegato, TRUE);
                }
@@ -224,31 +230,44 @@ organigramma_tipo_recapito_carica (OrganigrammaTipoRecapito *tipo_recapito)
 static void
 organigramma_tipo_recapito_salva (OrganigrammaTipoRecapito *tipo_recapito, gboolean chiudi)
 {
+       gboolean success;
+
        gchar *sql;
 
        OrganigrammaTipoRecapitoClass *klass = ORGANIGRAMMA_TIPO_RECAPITO_GET_CLASS (tipo_recapito);
 
        OrganigrammaTipoRecapitoPrivate *priv = ORGANIGRAMMA_TIPO_RECAPITO_GET_PRIVATE (tipo_recapito);
 
-       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_recapito",
+                                                  "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_recapito, 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)
                                {
@@ -384,7 +403,7 @@ organigramma_tipo_recapito_conferma_chiusura (OrganigrammaTipoRecapito *tipo_rec
        OrganigrammaTipoRecapitoPrivate *priv = ORGANIGRAMMA_TIPO_RECAPITO_GET_PRIVATE (tipo_recapito);
 
        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,