<?xml version="1.0"?>
-<gtkform>
-
- <table>persone</table>
-
- <widget type="label" name="label67" label="label68">
- <field type="integer" name="id">
- <is-key>t</is-key>
- <auto-increment>t</auto-increment>
- </field>
- </widget>
-
- <widget type="entry" name="entry14" label="label65">
- <field type="text" name="nome" />
- </widget>
-
- <widget type="entry" name="entry17" label="label72">
- <field type="text" name="cognome">
- <obligatory>t</obligatory>
- </field>
- </widget>
-
- <widget type="decoder" name="gtkformdecoder24" label="label73">
- <decoder>
- <sql>
- SELECT a.descrizione
- FROM titoli AS a
- WHERE a.id = ##key0::gint
- </sql>
- </decoder>
- <field type="integer" name="id_titoli">
- </field>
- </widget>
-
- <widget type="entry" name="entry20" label="label84">
- <field type="datetime" name="data_nascita">
- <datetime-type>date</datetime-type>
- <display-format>%d/%m/%Y</display-format>
- </field>
- </widget>
-
- <widget type="entry" name="entry26" label="label108">
- <field type="text" name="indirizzo"/>
- </widget>
-
-
- <widget type="entry" name="entry27">
- <field type="text" name="citta">
- <to-load>f</to-load>
- <to-save>f</to-save>
- </field>
- </widget>
-
- <widget type="label" name="label110" label="label109">
- <on-change what="update" when="after">
- <widget-name>entry27</widget-name>
- <connection-name>territorio</connection-name>
- <sql>
- SELECT c.nome FROM comuni AS c WHERE c.id = ##label110::gint
- </sql>
- </on-change>
- <field type="integer" name="id_citta">
- </field>
- </widget>
-
- <widget type="entry" name="entry29" label="label112">
- <field type="text" name="cap"/>
- </widget>
-
- <widget type="entry" name="entry28" label="label111">
- <field type="text" name="codice_fiscale"/>
- </widget>
- <widget type="textview" name="textview8" label="label66">
- <field type="text" name="descrizione" />
- </widget>
-
-</gtkform>
+<zakform>
+ <element type="zak_form_gtk_form_element_label">
+ <name>id</name>
+ <type>integer</type>
+ <label>label68</label>
+ <is-key>TRUE</is-key>
+ <widget>label67</widget>
+ </element>
+ <element type="zak_form_gtk_form_element_entry">
+ <name>nome</name>
+ <type>string</type>
+ <label>label65</label>
+ <widget>entry14</widget>
+ </element>
+ <element type="zak_form_gtk_form_element_entry">
+ <name>cognome</name>
+ <type>string</type>
+ <label>label72</label>
+ <widget>entry17</widget>
+ <validator type="zak_form_element_validator_notempty"/>
+ </element>
+ <element type="">
+ <name>id_titoli</name>
+ <type>integer</type>
+ <label>label73</label>
+ <widget>gtkformdecoder24</widget>
+ </element>
+ <element type="zak_form_gtk_form_element_entry">
+ <name>data_nascita</name>
+ <type>datetime</type>
+ <label>label84</label>
+ <widget>entry20</widget>
+ <format>%d/%m/%Y</format>
+ <validator type="zak_form_element_validator_date">%d/%m/%Y</validator>
+ </element>
+ <element type="zak_form_gtk_form_element_entry">
+ <name>indirizzo</name>
+ <type>string</type>
+ <label>label108</label>
+ <widget>entry26</widget>
+ </element>
+ <element type="zak_form_gtk_form_element_entry">
+ <name>citta</name>
+ <type>string</type>
+ <to-load>FALSE</to-load>
+ <to-save>FALSE</to-save>
+ <widget>entry27</widget>
+ </element>
+ <element type="zak_form_gtk_form_element_label">
+ <name>id_citta</name>
+ <type>integer</type>
+ <label>label109</label>
+ <widget>label110</widget>
+ </element>
+ <element type="zak_form_gtk_form_element_entry">
+ <name>cap</name>
+ <type>string</type>
+ <label>label112</label>
+ <widget>entry29</widget>
+ </element>
+ <element type="zak_form_gtk_form_element_entry">
+ <name>codice_fiscale</name>
+ <type>string</type>
+ <label>label111</label>
+ <widget>entry28</widget>
+ <validator type="solipa_zak_form_element_validator_codfisc"/>
+ </element>
+ <element type="zak_form_gtk_form_element_textview">
+ <name>descrizione</name>
+ <type>string</type>
+ <label>label66</label>
+ <widget>textview8</widget>
+ </element>
+</zakform>
/*
- * 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
#endif
#include <libzakautho/autho.h>
-#include <libgtkform/form.h>
-#include <libgtkform/fielddatetime.h>
-#include <libgtkformui/gtkformdecoder.h>
+#include <libzakgtkdecoder/libzakgtkdecoder.h>
+#include <libzakform/libzakform.h>
+#include <libzakformgtk/libzakformgtk.h>
+#include <libzakformgdaex/libzakformgdaex.h>
+#include <libzakformgtkdecoder/libzakformgtkdecoder.h>
#include <libsolipa/utils.h>
#include <libterritorio/comuni.h>
static void organigramma_persona_on_recapito_aggiornato (gpointer instance, gpointer user_data);
static void organigramma_persona_on_titolo_selezionato (gpointer instance, guint id, gpointer user_data);
+static gchar *organigramma_persona_on_titolo_decode (gpointer instance, gchar *key, gpointer user_data);
static void organigramma_persona_on_comune_selezionato (gpointer instance, guint id, gpointer user_data);
static gboolean organigramma_persona_on_w_organigramma_persona_delete_event (GtkWidget *widget,
{
OrganigrammaCommons *commons;
- GtkForm *form;
+ ZakFormGtkForm *form;
+ ZakFormGdaexProvider *form_provider;
GtkWidget *w;
return NULL;
}
- priv->form = gtk_form_new ();
- g_object_set (G_OBJECT (priv->form), "gdaex", priv->commons->gdaex, NULL);
- gtk_form_add_db_connection_gdaex (priv->form, "territorio", commons->territorio_commons->gdaex);
- gtk_form_load_from_file (priv->form, g_build_filename (priv->commons->formdir, "persona.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, "persona.form", NULL));
+
+ priv->form_provider = zak_form_gdaex_provider_new (priv->commons->gdaex, "persone");
priv->w = GTK_WIDGET (gtk_builder_get_object (priv->commons->gtkbuilder, "w_persona"));
- priv->objects = gtk_form_get_objects_by_name (priv->form,
+ priv->objects = zak_form_gtk_form_get_gobjects_by_name (priv->form,
"label67",
"lstore_persona_incarichi",
"lstore_persona_nodi",
g_signal_connect (priv->sel_uffici,
"changed", G_CALLBACK (organigramma_persona_on_uffici_sel_changed), (gpointer)a);
- g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "gtkformdecoder24"),
+ g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "zakgtkdecoder17"),
"btn-browse-clicked", G_CALLBACK (organigramma_persona_on_btn_ricerca_titolo_clicked), (gpointer)a);
+ g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "zakgtkdecoder17"),
+ "decode", G_CALLBACK (organigramma_persona_on_titolo_decode), (gpointer)a);
+
g_signal_connect (G_OBJECT (gtk_builder_get_object (priv->commons->gtkbuilder, "button89")),
"clicked", G_CALLBACK (organigramma_persona_on_btn_ricerca_comune_clicked), (gpointer)a);
g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button153"),
"clicked", G_CALLBACK (organigramma_persona_on_btn_salvaechiudi_clicked), (gpointer)a);
- gtk_form_clear (priv->form);
+ zak_form_form_clear (ZAK_FORM_FORM (priv->form));
priv->id = id;
{
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));
- gtk_form_set_sensitive_by_name (priv->form, FALSE, "notebook1", NULL);
+ gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (commons->gtkbuilder, "notebook1")), FALSE);
}
else
{
{
OrganigrammaPersonaPrivate *priv = ORGANIGRAMMA_PERSONA_GET_PRIVATE (persona);
- if (gtk_form_fill_from_table (priv->form))
+ if (zak_form_form_load (ZAK_FORM_FORM (priv->form), ZAK_FORM_IPROVIDER (priv->form_provider)))
{
organigramma_persona_carica_incarichi (persona);
organigramma_persona_carica_nodi (persona);
static void
organigramma_persona_salva (OrganigrammaPersona *persona, gboolean chiudi)
{
- gchar *sql;
+ gboolean success;
OrganigrammaPersonaClass *klass = ORGANIGRAMMA_PERSONA_GET_CLASS (persona);
OrganigrammaPersonaPrivate *priv = ORGANIGRAMMA_PERSONA_GET_PRIVATE (persona);
- 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;
}
- if (!solipa_chk_codice_fiscale (gtk_entry_get_text (GTK_ENTRY (gtk_builder_get_object (priv->commons->gtkbuilder, "entry28"))), TRUE))
- {
- solipa_message_dialog (priv->w,
- GTK_MESSAGE_WARNING,
- GTK_BUTTONS_OK,
- "Codice fiscale errato.");
- gtk_widget_grab_focus (GTK_WIDGET (gtk_builder_get_object (priv->commons->gtkbuilder, "entry28")));
- 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,
+ "uffici",
+ "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 (persona, 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)
{
priv->id = strtol (gtk_label_get_text (GTK_LABEL (priv->objects[LBL_ID])), NULL, 10);
- gtk_form_set_sensitive_by_name (priv->form, TRUE, "notebook1", NULL);
+ gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (priv->commons->gtkbuilder, "notebook1")), TRUE);
}
solipa_message_dialog (priv->w,
OrganigrammaPersonaPrivate *priv = ORGANIGRAMMA_PERSONA_GET_PRIVATE (persona);
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,
}
/* CALLBACK */
+static void
+organigramma_persona_on_titolo_selezionato (gpointer instance, guint id, gpointer user_data)
+{
+ OrganigrammaPersona *f = (OrganigrammaPersona *)user_data;
+ OrganigrammaPersonaPrivate *priv = ORGANIGRAMMA_PERSONA_GET_PRIVATE (f);
+
+ zak_gtk_decoder_set_key (ZAK_GTK_DECODER (gtk_builder_get_object (priv->commons->gtkbuilder, "zakgtkdecoder17")),
+ g_strdup_printf ("%d", id));
+}
+
+static gchar
+*organigramma_persona_on_titolo_decode (gpointer instance, gchar *key, gpointer user_data)
+{
+ GString *ret;
+ gchar *sql;
+ GdaDataModel *dm;
+
+ OrganigrammaPersona *f = (OrganigrammaPersona *)user_data;
+ OrganigrammaPersonaPrivate *priv = ORGANIGRAMMA_PERSONA_GET_PRIVATE (f);
+
+ ret = g_string_new ("");
+
+ sql = g_strdup_printf ("SELECT descrizione"
+ " FROM titoli"
+ " WHERE id = %d",
+ strtol (key, NULL, 10));
+ dm = gdaex_query (priv->commons->gdaex, sql);
+ g_free (sql);
+ if (!gdaex_data_model_is_empty (dm))
+ {
+ g_string_append (ret, gdaex_data_model_get_value_stringify_at (dm, 0, 0));
+ }
+
+ return ret->str;
+}
+
static void
organigramma_persona_on_incarico_aggiornato (gpointer instance, gpointer user_data)
{
organigramma_persona_carica_recapiti (persona);
}
-static void
-organigramma_persona_on_titolo_selezionato (gpointer instance, guint id, gpointer user_data)
-{
- OrganigrammaPersona *ia = (OrganigrammaPersona *)user_data;
-
- OrganigrammaPersonaPrivate *priv = ORGANIGRAMMA_PERSONA_GET_PRIVATE (ia);
-
- gtk_form_widget_set_value_stringify (gtk_form_get_form_widget_from_name (priv->form, "gtkformdecoder24"),
- g_strdup_printf ("%d", id));
-}
-
static void
organigramma_persona_on_comune_selezionato (gpointer instance, guint id, gpointer user_data)
{