<?xml version="1.0"?>
-<gtkform>
-
- <table>ufficio_orari</table>
-
- <widget type="label" name="label52">
- <field type="integer" name="id">
- <is-key>t</is-key>
- <auto-increment>t</auto-increment>
- </field>
- </widget>
-
- <widget type="label" name="label53">
- <field type="integer" name="id_uffici">
- </field>
- </widget>
-
- <widget type="textview" name="textview7" label="label50">
- <field type="text" name="descrizione">
- <obligatory>t</obligatory>
- </field>
- </widget>
-
- <widget type="entry" name="entry15" label="label79">
- <field type="datetime" name="da_data">
- <datetime-type>date</datetime-type>
- <display-format>%d/%m/%Y</display-format>
- </field>
- </widget>
-
- <widget type="entry" name="entry16" label="label80">
- <field type="datetime" name="a_data">
- <datetime-type>date</datetime-type>
- <display-format>%d/%m/%Y</display-format>
- </field>
- </widget>
-
- <widget type="checkbox" name="checkbutton1" label="label51">
- <field type="boolean" name="lunedi" />
- </widget>
-
- <widget type="checkbox" name="checkbutton2" label="label51">
- <field type="boolean" name="martedi" />
- </widget>
-
- <widget type="checkbox" name="checkbutton3" label="label51">
- <field type="boolean" name="mercoledi" />
- </widget>
-
- <widget type="checkbox" name="checkbutton4" label="label51">
- <field type="boolean" name="giovedi" />
- </widget>
-
- <widget type="checkbox" name="checkbutton5" label="label51">
- <field type="boolean" name="venerdi" />
- </widget>
-
- <widget type="checkbox" name="checkbutton6" label="label51">
- <field type="boolean" name="sabato" />
- </widget>
-
- <widget type="checkbox" name="checkbutton7" label="label51">
- <field type="boolean" name="domenica" />
- </widget>
-
- <widget type="spin" name="spinbutton1" label="label54">
- <field type="integer" name="settimana" />
- </widget>
-
- <widget type="spin" name="spinbutton2" label="label55">
- <field type="integer" name="giorno_mese" />
- </widget>
-
- <widget type="combobox" name="combobox3" label="label56">
- <column-field>0</column-field>
- <field type="integer" name="mese"/>
- </widget>
-
- <widget type="entry" name="entry18" label="label81">
- <field type="datetime" name="da_ora">
- <datetime-type>time</datetime-type>
- <display-format>%H.%M</display-format>
- </field>
- </widget>
-
- <widget type="entry" name="entry19" label="label82">
- <field type="datetime" name="a_ora">
- <datetime-type>time</datetime-type>
- <display-format>%H.%M</display-format>
- </field>
- </widget>
-
-</gtkform>
+<zakform>
+ <element type="zak_form_gtk_form_element_label">
+ <name>id</name>
+ <type>integer</type>
+ <is-key>TRUE</is-key>
+ <widget>label52</widget>
+ </element>
+ <element type="zak_form_gtk_form_element_label">
+ <name>id_uffici</name>
+ <type>integer</type>
+ <widget>label53</widget>
+ </element>
+ <element type="zak_form_gtk_form_element_textview">
+ <name>descrizione</name>
+ <type>string</type>
+ <label>label50</label>
+ <widget>textview7</widget>
+ <validator type="zak_form_element_validator_notempty"/>
+ </element>
+ <element type="zak_form_gtk_form_element_entry">
+ <name>da_data</name>
+ <type>date</type>
+ <label>label79</label>
+ <widget>entry15</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>a_data</name>
+ <type>date</type>
+ <label>label80</label>
+ <widget>entry16</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_check">
+ <name>lunedi</name>
+ <type>boolean</type>
+ <label>label51</label>
+ <widget>checkbutton1</widget>
+ </element>
+ <element type="zak_form_gtk_form_element_check">
+ <name>martedi</name>
+ <type>boolean</type>
+ <label>label51</label>
+ <widget>checkbutton2</widget>
+ </element>
+ <element type="zak_form_gtk_form_element_check">
+ <name>mercoledi</name>
+ <type>boolean</type>
+ <label>label51</label>
+ <widget>checkbutton3</widget>
+ </element>
+ <element type="zak_form_gtk_form_element_check">
+ <name>giovedi</name>
+ <type>boolean</type>
+ <label>label51</label>
+ <widget>checkbutton4</widget>
+ </element>
+ <element type="zak_form_gtk_form_element_check">
+ <name>venerdi</name>
+ <type>boolean</type>
+ <label>label51</label>
+ <widget>checkbutton5</widget>
+ </element>
+ <element type="zak_form_gtk_form_element_check">
+ <name>sabato</name>
+ <type>boolean</type>
+ <label>label51</label>
+ <widget>checkbutton6</widget>
+ </element>
+ <element type="zak_form_gtk_form_element_check">
+ <name>domenica</name>
+ <type>boolean</type>
+ <label>label51</label>
+ <widget>checkbutton7</widget>
+ </element>
+ <element type="zak_form_gtk_form_element_spin">
+ <name>settimana</name>
+ <type>integer</type>
+ <label>label54</label>
+ <widget>spinbutton1</widget>
+ </element>
+ <element type="zak_form_gtk_form_element_spin">
+ <name>giorno_mese</name>
+ <type>integer</type>
+ <label>label55</label>
+ <widget>spinbutton2</widget>
+ </element>
+ <element type="zak_form_gtk_form_element_combo">
+ <name>mese</name>
+ <type>integer</type>
+ <label>label56</label>
+ <widget>combobox3</widget>
+ <column-field>0</column-field>
+ </element>
+ <element type="zak_form_gtk_form_element_entry">
+ <name>da_ora</name>
+ <type>time</type>
+ <label>label81</label>
+ <widget>entry18</widget>
+ <format>%H.%M</format>
+ <validator type="zak_form_element_validator_date">%H.%M</validator>
+ </element>
+ <element type="zak_form_gtk_form_element_entry">
+ <name>a_ora</name>
+ <type>time</type>
+ <label>label82</label>
+ <widget>entry19</widget>
+ <format>%H.%M</format>
+ <validator type="zak_form_element_validator_date">%H.%M</validator>
+ </element>
+
+ <validator type="zak_form_validator_compare_date" type_comp="lt" element1="da_data" format1="%d/%m/%Y" element2="a_data" format2="%d/%m/%Y"></validator>
+ <validator type="zak_form_validator_compare_date" type_comp="lt" element1="da_ora" format1="%H.%M" element2="a_ora" format2="%H.%M"></validator>
+</zakform>
#include <glib/gprintf.h>
#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 "ufficioorario.h"
{
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_load_from_file (priv->form, g_build_filename (priv->commons->formdir, "ufficio_orario.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, "ufficio_orario.form", NULL));
+
+ priv->form_provider = zak_form_gdaex_provider_new (priv->commons->gdaex, "ufficio_orari");
priv->w = GTK_WIDGET (gtk_builder_get_object (priv->commons->gtkbuilder, "w_ufficio_orario"));
- priv->objects = gtk_form_get_objects_by_name (priv->form,
+ priv->objects = zak_form_gtk_form_get_gobjects_by_name (priv->form,
"label52",
"label53",
NULL);
g_signal_connect (G_OBJECT (gtk_builder_get_object (priv->commons->gtkbuilder, "button155")),
"clicked", G_CALLBACK (organigramma_ufficio_orario_on_btn_salvaechiudi_clicked), (gpointer)a);
+ 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_label_set_text (GTK_LABEL (priv->objects[LBL_ID_UFFICI]), 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
{
static void
organigramma_ufficio_orario_carica (OrganigrammaUfficioOrario *organigramma_ufficio_orario)
{
- gchar *sql;
- GdaDataModel *dm;
-
OrganigrammaUfficioOrarioPrivate *priv = ORGANIGRAMMA_UFFICIO_ORARIO_GET_PRIVATE (organigramma_ufficio_orario);
- if (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_ufficio_orario_salva (OrganigrammaUfficioOrario *organigramma_ufficio_orario, gboolean chiudi)
{
- gchar *sql;
+ gboolean success;
OrganigrammaUfficioOrarioClass *klass = ORGANIGRAMMA_UFFICIO_ORARIO_GET_CLASS (organigramma_ufficio_orario);
OrganigrammaUfficioOrarioPrivate *priv = ORGANIGRAMMA_UFFICIO_ORARIO_GET_PRIVATE (organigramma_ufficio_orario);
- if (!gtk_form_check (priv->form, FALSE, 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,
+ "ufficio_orari",
+ "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_ufficio_orario, klass->aggiornato_signal_id, 0);
priv->id = strtol (gtk_label_get_text (GTK_LABEL (priv->objects[LBL_ID])), NULL, 10);
}
- gtk_form_set_as_origin (priv->form);
+ zak_form_form_set_as_original (ZAK_FORM_FORM (priv->form));
solipa_message_dialog (priv->w,
GTK_MESSAGE_INFO,
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,