nodo.form \
persona.form \
persona_nodo.form \
+ persona_nodo_recapito.form \
persona_recapito.form \
persona_ufficio.form \
persona_ufficio_recapito.form \
--- /dev/null
+<?xml version="1.0"?>
+<gtkform>
+
+ <table>persona_nodo_recapiti</table>
+
+ <widget type="label" name="label122">
+ <field type="integer" name="id">
+ <is-key>t</is-key>
+ <auto-increment>t</auto-increment>
+ </field>
+ </widget>
+
+ <widget type="label" name="label126">
+ <field type="integer" name="id_persone">
+ </field>
+ </widget>
+
+ <widget type="label" name="label123">
+ <field type="integer" name="id_nodi">
+ </field>
+ </widget>
+
+ <widget type="combobox" name="combobox7" label="label121">
+ <column-field>0</column-field>
+ <sql with-empty-entry="t">
+ SELECT id, nome FROM tipi_recapito WHERE status <> 'E' ORDER BY nome
+ </sql>
+ <field type="integer" name="id_tipi_recapito">
+ </field>
+ </widget>
+
+ <widget type="entry" name="entry33" label="label124">
+ <field type="text" name="recapito">
+ </field>
+ </widget>
+
+ <widget type="textview" name="textview13" label="label120">
+ <field type="text" name="note" />
+ </widget>
+
+ <widget type="checkbox" name="checkbutton11" label="label125">
+ <field type="boolean" name="privato">
+ </field>
+ </widget>
+
+</gtkform>
-- Dumped from database version 8.4.4
-- Dumped by pg_dump version 9.0.0
--- Started on 2010-10-14 11:26:02
+-- Started on 2010-10-14 12:00:45
SET statement_timeout = 0;
SET client_encoding = 'UTF8';
SET escape_string_warning = off;
--
--- TOC entry 347 (class 2612 OID 16386)
+-- TOC entry 350 (class 2612 OID 16386)
-- Name: plpgsql; Type: PROCEDURAL LANGUAGE; Schema: -; Owner: -
--
SET default_with_oids = false;
--
--- TOC entry 1534 (class 1259 OID 59279)
--- Dependencies: 1828 1829 1830 3
+-- TOC entry 1537 (class 1259 OID 59279)
+-- Dependencies: 1832 1833 1834 3
-- Name: nodi; Type: TABLE; Schema: public; Owner: -
--
--
--- TOC entry 1550 (class 1259 OID 61295)
--- Dependencies: 1878 1879 1880 1881 3
+-- TOC entry 1553 (class 1259 OID 61295)
+-- Dependencies: 1882 1883 1884 1885 3
-- Name: persona_nodi; Type: TABLE; Schema: public; Owner: -
--
--
--- TOC entry 1548 (class 1259 OID 61266)
--- Dependencies: 1865 1866 1867 1868 1869 1870 3
+-- TOC entry 1554 (class 1259 OID 61307)
+-- Dependencies: 1886 1887 1888 1889 1890 1891 1892 3
+-- Name: persona_nodo_recapiti; Type: TABLE; Schema: public; Owner: -
+--
+
+CREATE TABLE persona_nodo_recapiti (
+ id integer NOT NULL,
+ id_persone integer DEFAULT 0,
+ id_nodi integer DEFAULT 0,
+ id_tipi_recapito integer DEFAULT 0,
+ recapito character varying(100) DEFAULT ''::character varying,
+ note text DEFAULT ''::text,
+ privato boolean DEFAULT false,
+ status character varying(1) DEFAULT ''::character varying
+);
+
+
+--
+-- TOC entry 1551 (class 1259 OID 61266)
+-- Dependencies: 1869 1870 1871 1872 1873 1874 3
-- Name: persona_recapiti; Type: TABLE; Schema: public; Owner: -
--
--
--- TOC entry 1547 (class 1259 OID 61243)
--- Dependencies: 1863 1864 3
+-- TOC entry 1550 (class 1259 OID 61243)
+-- Dependencies: 1867 1868 3
-- Name: persona_uffici; Type: TABLE; Schema: public; Owner: -
--
--
--- TOC entry 1549 (class 1259 OID 61280)
--- Dependencies: 1871 1872 1873 1874 1875 1876 1877 3
+-- TOC entry 1552 (class 1259 OID 61280)
+-- Dependencies: 1875 1876 1877 1878 1879 1880 1881 3
-- Name: persona_ufficio_recapiti; Type: TABLE; Schema: public; Owner: -
--
--
--- TOC entry 1545 (class 1259 OID 61227)
--- Dependencies: 1857 1858 1859 1860 3
+-- TOC entry 1548 (class 1259 OID 61227)
+-- Dependencies: 1861 1862 1863 1864 3
-- Name: persone; Type: TABLE; Schema: public; Owner: -
--
--
--- TOC entry 1540 (class 1259 OID 59346)
--- Dependencies: 1844 1845 1846 3
+-- TOC entry 1543 (class 1259 OID 59346)
+-- Dependencies: 1848 1849 1850 3
-- Name: struttura_indirizzi; Type: TABLE; Schema: public; Owner: -
--
--
--- TOC entry 1538 (class 1259 OID 59327)
--- Dependencies: 1838 1839 1840 1841 1842 3
+-- TOC entry 1541 (class 1259 OID 59327)
+-- Dependencies: 1842 1843 1844 1845 1846 3
-- Name: strutture; Type: TABLE; Schema: public; Owner: -
--
--
--- TOC entry 1535 (class 1259 OID 59290)
--- Dependencies: 1831 1832 3
+-- TOC entry 1538 (class 1259 OID 59290)
+-- Dependencies: 1835 1836 3
-- Name: tipi_nodo; Type: TABLE; Schema: public; Owner: -
--
--
--- TOC entry 1546 (class 1259 OID 61236)
--- Dependencies: 1861 1862 3
+-- TOC entry 1549 (class 1259 OID 61236)
+-- Dependencies: 1865 1866 3
-- Name: tipi_rapporto_lavoro; Type: TABLE; Schema: public; Owner: -
--
--
--- TOC entry 1536 (class 1259 OID 59297)
--- Dependencies: 1833 1834 3
+-- TOC entry 1539 (class 1259 OID 59297)
+-- Dependencies: 1837 1838 3
-- Name: tipi_recapito; Type: TABLE; Schema: public; Owner: -
--
--
--- TOC entry 1544 (class 1259 OID 61219)
--- Dependencies: 1854 1855 1856 3
+-- TOC entry 1547 (class 1259 OID 61219)
+-- Dependencies: 1858 1859 1860 3
-- Name: titoli; Type: TABLE; Schema: public; Owner: -
--
--
--- TOC entry 1537 (class 1259 OID 59311)
--- Dependencies: 1835 1836 1837 3
+-- TOC entry 1540 (class 1259 OID 59311)
+-- Dependencies: 1839 1840 1841 3
-- Name: uffici; Type: TABLE; Schema: public; Owner: -
--
--
--- TOC entry 1541 (class 1259 OID 59357)
--- Dependencies: 1847 1848 3
+-- TOC entry 1544 (class 1259 OID 59357)
+-- Dependencies: 1851 1852 3
-- Name: ufficio_nodi; Type: TABLE; Schema: public; Owner: -
--
--
--- TOC entry 1542 (class 1259 OID 59399)
--- Dependencies: 1849 1850 3
+-- TOC entry 1545 (class 1259 OID 59399)
+-- Dependencies: 1853 1854 3
-- Name: ufficio_orari; Type: TABLE; Schema: public; Owner: -
--
--
--- TOC entry 1543 (class 1259 OID 59409)
--- Dependencies: 1851 1852 1853 3
+-- TOC entry 1546 (class 1259 OID 59409)
+-- Dependencies: 1855 1856 1857 3
-- Name: ufficio_recapiti; Type: TABLE; Schema: public; Owner: -
--
--
--- TOC entry 1539 (class 1259 OID 59340)
--- Dependencies: 1843 3
+-- TOC entry 1542 (class 1259 OID 59340)
+-- Dependencies: 1847 3
-- Name: vie; Type: TABLE; Schema: public; Owner: -
--
--
--- TOC entry 1883 (class 2606 OID 59289)
--- Dependencies: 1534 1534
+-- TOC entry 1894 (class 2606 OID 59289)
+-- Dependencies: 1537 1537
-- Name: nodi_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
--
--- TOC entry 1915 (class 2606 OID 61305)
--- Dependencies: 1550 1550
+-- TOC entry 1926 (class 2606 OID 61305)
+-- Dependencies: 1553 1553
-- Name: persona_nodi_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
--
--- TOC entry 1911 (class 2606 OID 61279)
--- Dependencies: 1548 1548
+-- TOC entry 1928 (class 2606 OID 61321)
+-- Dependencies: 1554 1554
+-- Name: persona_nodo_recapiti_pkey; Type: CONSTRAINT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY persona_nodo_recapiti
+ ADD CONSTRAINT persona_nodo_recapiti_pkey PRIMARY KEY (id);
+
+
+--
+-- TOC entry 1922 (class 2606 OID 61279)
+-- Dependencies: 1551 1551
-- Name: persona_recapiti_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
--
--- TOC entry 1909 (class 2606 OID 61252)
--- Dependencies: 1547 1547
+-- TOC entry 1920 (class 2606 OID 61252)
+-- Dependencies: 1550 1550
-- Name: persona_uffici_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
--
--- TOC entry 1913 (class 2606 OID 61294)
--- Dependencies: 1549 1549
+-- TOC entry 1924 (class 2606 OID 61294)
+-- Dependencies: 1552 1552
-- Name: persona_ufficio_recapiti_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
--
--- TOC entry 1905 (class 2606 OID 61235)
--- Dependencies: 1545 1545
+-- TOC entry 1916 (class 2606 OID 61235)
+-- Dependencies: 1548 1548
-- Name: persone_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
--
--- TOC entry 1895 (class 2606 OID 59356)
--- Dependencies: 1540 1540
+-- TOC entry 1906 (class 2606 OID 59356)
+-- Dependencies: 1543 1543
-- Name: struttura_indirizzi_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
--
--- TOC entry 1891 (class 2606 OID 59339)
--- Dependencies: 1538 1538
+-- TOC entry 1902 (class 2606 OID 59339)
+-- Dependencies: 1541 1541
-- Name: strutture_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
--
--- TOC entry 1885 (class 2606 OID 59296)
--- Dependencies: 1535 1535
+-- TOC entry 1896 (class 2606 OID 59296)
+-- Dependencies: 1538 1538
-- Name: tipi_nodo_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
--
--- TOC entry 1907 (class 2606 OID 61242)
--- Dependencies: 1546 1546
+-- TOC entry 1918 (class 2606 OID 61242)
+-- Dependencies: 1549 1549
-- Name: tipi_rapporto_lavoro_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
--
--- TOC entry 1887 (class 2606 OID 59303)
--- Dependencies: 1536 1536
+-- TOC entry 1898 (class 2606 OID 59303)
+-- Dependencies: 1539 1539
-- Name: tipi_recapito_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
--
--- TOC entry 1903 (class 2606 OID 61226)
--- Dependencies: 1544 1544
+-- TOC entry 1914 (class 2606 OID 61226)
+-- Dependencies: 1547 1547
-- Name: titoli_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
--
--- TOC entry 1889 (class 2606 OID 59321)
--- Dependencies: 1537 1537
+-- TOC entry 1900 (class 2606 OID 59321)
+-- Dependencies: 1540 1540
-- Name: uffici_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
--
--- TOC entry 1897 (class 2606 OID 59366)
--- Dependencies: 1541 1541
+-- TOC entry 1908 (class 2606 OID 59366)
+-- Dependencies: 1544 1544
-- Name: ufficio_nodi_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
--
--- TOC entry 1899 (class 2606 OID 59408)
--- Dependencies: 1542 1542
+-- TOC entry 1910 (class 2606 OID 59408)
+-- Dependencies: 1545 1545
-- Name: ufficio_orari_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
--
--- TOC entry 1901 (class 2606 OID 59419)
--- Dependencies: 1543 1543
+-- TOC entry 1912 (class 2606 OID 59419)
+-- Dependencies: 1546 1546
-- Name: ufficio_recapiti_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
--
--- TOC entry 1893 (class 2606 OID 59345)
--- Dependencies: 1539 1539
+-- TOC entry 1904 (class 2606 OID 59345)
+-- Dependencies: 1542 1542
-- Name: vie_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ADD CONSTRAINT vie_pkey PRIMARY KEY (id);
--- Completed on 2010-10-14 11:26:03
+-- Completed on 2010-10-14 12:00:46
--
-- PostgreSQL database dump complete
persone.h \
personanodo.c \
personanodo.h \
+ personanodorecapito.c \
+ personanodorecapito.h \
personarecapito.c \
personarecapito.h \
personaufficio.c \
#include "persona.h"
#include "personanodo.h"
+#include "personanodorecapito.h"
#include "personaufficio.h"
#include "personaufficiorecapito.h"
#include "personarecapito.h"
static void persona_salva (Persona *persona);
static void persona_carica_nodi (Persona *persona);
+static void persona_carica_nodo_recapiti (Persona *persona);
static void persona_carica_uffici (Persona *persona);
static void persona_carica_ufficio_recapiti (Persona *persona);
static void persona_carica_recapiti (Persona *persona);
-static void persona_ufficio_nodo (Persona *persona);
+static void persona_ufficio_nodo_modifica (Persona *persona);
static void persona_ufficio_modifica (Persona *persona);
static void persona_ufficio_recapito_modifica (Persona *persona);
static void persona_recapito_modifica (Persona *persona);
GParamSpec *pspec);
static void persona_on_nodo_aggiornato (gpointer instance, gpointer user_data);
+static void persona_on_nodo_recapito_aggiornato (gpointer instance, gpointer user_data);
static void persona_on_ufficio_aggiornato (gpointer instance, gpointer user_data);
static void persona_on_ufficio_recapito_aggiornato (gpointer instance, gpointer user_data);
static void persona_on_recapito_aggiornato (gpointer instance, gpointer user_data);
static void persona_on_nodi_sel_changed (GtkTreeSelection *selection,
gpointer user_data);
+static void persona_on_btn_nodo_recapito_nuovo_clicked (GtkButton *button,
+ gpointer user_data);
+static void persona_on_btn_nodo_recapito_modifica_clicked (GtkButton *button,
+ gpointer user_data);
+static void persona_on_btn_nodo_recapito_elimina_clicked (GtkButton *button,
+ gpointer user_data);
+static void persona_on_trv_nodo_recapiti_row_activated (GtkTreeView *tree_view,
+ GtkTreePath *tree_path,
+ GtkTreeViewColumn *column,
+ gpointer user_data);
+
static void persona_on_btn_ufficio_nuovo_clicked (GtkButton *button,
gpointer user_data);
static void persona_on_btn_ufficio_modifica_clicked (GtkButton *button,
{
LBL_ID,
LSTORE_NODI,
+ LSTORE_NODO_RECAPITI,
LSTORE_UFFICI,
LSTORE_UFFICIO_RECAPITI,
LSTORE_RECAPITI
NODI_COL_A_DATA
};
+enum
+{
+ NODO_RECAPITI_COL_ID,
+ NODO_RECAPITI_COL_TIPO,
+ NODO_RECAPITI_COL_RECAPITO
+};
+
enum
{
UFFICI_COL_ID,
GObject **objects;
GtkTreeSelection *sel_nodi;
+ GtkTreeSelection *sel_nodo_recapiti;
GtkTreeSelection *sel_uffici;
GtkTreeSelection *sel_ufficio_recapiti;
GtkTreeSelection *sel_recapiti;
g_strsplit (g_strconcat (
"lstore_titoli"
"|lstore_persona_nodi"
+ "|lstore_persona_nodo_recapiti"
"|lstore_persona_uffici"
"|lstore_persona_ufficio_recapiti"
"|lstore_persona_recapiti"
priv->objects = gtk_form_get_objects_by_name (priv->form,
"label67",
"lstore_persona_nodi",
+ "lstore_persona_nodo_recapiti",
"lstore_persona_uffici",
"lstore_persona_ufficio_recapiti",
"lstore_persona_recapiti",
"delete-event", G_CALLBACK (persona_on_w_persona_delete_event), (gpointer *)a);
priv->sel_nodi = gtk_tree_view_get_selection (GTK_TREE_VIEW (gtk_builder_get_object (priv->commons->gtkbuilder, "treeview13")));
+ priv->sel_nodo_recapiti = gtk_tree_view_get_selection (GTK_TREE_VIEW (gtk_builder_get_object (priv->commons->gtkbuilder, "treeview14")));
priv->sel_uffici = gtk_tree_view_get_selection (GTK_TREE_VIEW (gtk_builder_get_object (priv->commons->gtkbuilder, "treeview11")));
priv->sel_ufficio_recapiti = gtk_tree_view_get_selection (GTK_TREE_VIEW (gtk_builder_get_object (priv->commons->gtkbuilder, "treeview12")));
priv->sel_recapiti = gtk_tree_view_get_selection (GTK_TREE_VIEW (gtk_builder_get_object (priv->commons->gtkbuilder, "treeview15")));
+ g_signal_connect (priv->sel_nodi,
+ "changed", G_CALLBACK (persona_on_nodi_sel_changed), (gpointer)a);
g_signal_connect (priv->sel_uffici,
"changed", G_CALLBACK (persona_on_uffici_sel_changed), (gpointer)a);
g_signal_connect (G_OBJECT (gtk_builder_get_object (priv->commons->gtkbuilder, "treeview13")),
"row-activated", G_CALLBACK (persona_on_trv_nodi_row_activated), (gpointer *)a);
+ g_signal_connect (G_OBJECT (gtk_builder_get_object (priv->commons->gtkbuilder, "button73")),
+ "clicked", G_CALLBACK (persona_on_btn_nodo_recapito_nuovo_clicked), (gpointer *)a);
+ g_signal_connect (G_OBJECT (gtk_builder_get_object (priv->commons->gtkbuilder, "button74")),
+ "clicked", G_CALLBACK (persona_on_btn_nodo_recapito_modifica_clicked), (gpointer *)a);
+ g_signal_connect (G_OBJECT (gtk_builder_get_object (priv->commons->gtkbuilder, "button75")),
+ "clicked", G_CALLBACK (persona_on_btn_nodo_recapito_elimina_clicked), (gpointer *)a);
+ g_signal_connect (G_OBJECT (gtk_builder_get_object (priv->commons->gtkbuilder, "treeview14")),
+ "row-activated", G_CALLBACK (persona_on_trv_nodo_recapiti_row_activated), (gpointer *)a);
+
g_signal_connect (G_OBJECT (gtk_builder_get_object (priv->commons->gtkbuilder, "button62")),
"clicked", G_CALLBACK (persona_on_btn_ufficio_nuovo_clicked), (gpointer *)a);
g_signal_connect (G_OBJECT (gtk_builder_get_object (priv->commons->gtkbuilder, "button63")),
if (gtk_form_fill_from_table (priv->form))
{
persona_carica_nodi (persona);
+ persona_carica_nodo_recapiti (persona);
persona_carica_uffici (persona);
persona_carica_ufficio_recapiti (persona);
persona_carica_recapiti (persona);
g_free (sql);
}
+static void
+persona_carica_nodo_recapiti (Persona *persona)
+{
+ gchar *sql;
+ GdaDataModel *dm;
+ guint row;
+ guint rows;
+
+ GtkTreeIter iter;
+ guint id_nodi;
+
+ PersonaPrivate *priv = PERSONA_GET_PRIVATE (persona);
+
+ gtk_list_store_clear (GTK_LIST_STORE (priv->objects[LSTORE_NODO_RECAPITI]));
+
+ if (gtk_tree_selection_get_selected (priv->sel_nodi, NULL, &iter))
+ {
+ gtk_tree_model_get (GTK_TREE_MODEL (priv->objects[LSTORE_NODI]), &iter,
+ NODI_COL_ID, &id_nodi,
+ -1);
+ }
+
+ sql = g_strdup_printf ("SELECT pur.id, tr.nome, pur.recapito"
+ " FROM persona_nodo_recapiti AS pur INNER JOIN tipi_recapito AS tr ON"
+ " pur.id_tipi_recapito = tr.id"
+ " WHERE pur.id_persone = %d"
+ " AND pur.id_nodi = %d"
+ " AND pur.status <> 'E'"
+ " ORDER BY tr.nome, pur.recapito",
+ priv->id,
+ id_nodi);
+ dm = gdaex_query (priv->commons->gdaex, sql);
+ if (dm != NULL)
+ {
+ GtkTreeIter iter;
+
+ rows = gda_data_model_get_n_rows (dm);
+ for (row = 0; row < rows; row++)
+ {
+ gtk_list_store_append (GTK_LIST_STORE (priv->objects[LSTORE_NODO_RECAPITI]), &iter);
+ gtk_list_store_set (GTK_LIST_STORE (priv->objects[LSTORE_NODO_RECAPITI]), &iter,
+ NODO_RECAPITI_COL_ID, gdaex_data_model_get_field_value_integer_at (dm, row, "id"),
+ NODO_RECAPITI_COL_TIPO, gdaex_data_model_get_field_value_stringify_at (dm, row, "nome"),
+ NODO_RECAPITI_COL_RECAPITO, gdaex_data_model_get_field_value_stringify_at (dm, row, "recapito"),
+ -1);
+ }
+
+ g_object_unref (dm);
+ }
+ g_free (sql);
+}
+
static void
persona_carica_uffici (Persona *persona)
{
}
}
+static void
+persona_nodo_recapito_modifica (Persona *persona)
+{
+ GtkTreeIter iter;
+ GtkWidget *dialog;
+
+ PersonaPrivate *priv = PERSONA_GET_PRIVATE (persona);
+
+ guint id_nodi;
+ if (gtk_tree_selection_get_selected (priv->sel_nodi, NULL, &iter))
+ {
+ gtk_tree_model_get (GTK_TREE_MODEL (priv->objects[LSTORE_NODI]), &iter,
+ NODI_COL_ID, &id_nodi,
+ -1);
+ }
+
+ if (id_nodi == 0)
+ {
+ GtkWidget *dialog = gtk_message_dialog_new (GTK_WINDOW (priv->w),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_WARNING,
+ GTK_BUTTONS_OK,
+ "Occorre prima selezionare un nodo.");
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+ return;
+ }
+
+ if (gtk_tree_selection_get_selected (priv->sel_nodo_recapiti, NULL, &iter))
+ {
+ guint id;
+ GtkWidget *w;
+
+ gtk_tree_model_get (GTK_TREE_MODEL (priv->objects[LSTORE_NODO_RECAPITI]), &iter,
+ NODO_RECAPITI_COL_ID, &id,
+ -1);
+
+ PersonaNodoRecapito *a = persona_nodo_recapito_new (priv->commons, id, 0, 0);
+
+ g_signal_connect (G_OBJECT (a), "aggiornato",
+ G_CALLBACK (persona_on_nodo_recapito_aggiornato), (gpointer)persona);
+
+ w = persona_nodo_recapito_get_widget (a);
+ gtk_window_set_transient_for (GTK_WINDOW (w), GTK_WINDOW (priv->w));
+ gtk_widget_show (w);
+ }
+ else
+ {
+ dialog = gtk_message_dialog_new (GTK_WINDOW (priv->w),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_WARNING,
+ GTK_BUTTONS_OK,
+ "Occorre prima selezionare un nodo.");
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+ }
+}
+
static void
persona_ufficio_modifica (Persona *persona)
{
persona_carica_nodi (persona);
}
+static void
+persona_on_nodo_recapito_aggiornato (gpointer instance, gpointer user_data)
+{
+ Persona *persona = (Persona *)user_data;
+ PersonaClass *klass = PERSONA_GET_CLASS (persona);
+
+ persona_carica_nodo_recapiti (persona);
+}
+
static void
persona_on_ufficio_aggiornato (gpointer instance, gpointer user_data)
{
persona_nodo_modifica ((Persona *)user_data);
}
+static void
+persona_on_nodi_sel_changed (GtkTreeSelection *selection,
+ gpointer user_data)
+{
+ persona_carica_nodo_recapiti ((Persona *)user_data);
+}
+
+static void
+persona_on_btn_nodo_recapito_nuovo_clicked (GtkButton *button,
+ gpointer user_data)
+{
+ GtkWidget *w;
+ GtkTreeIter iter;
+
+ Persona *persona = (Persona *)user_data;
+
+ PersonaPrivate *priv = PERSONA_GET_PRIVATE (persona);
+
+ guint id_nodi;
+ if (gtk_tree_selection_get_selected (priv->sel_nodi, NULL, &iter))
+ {
+ gtk_tree_model_get (GTK_TREE_MODEL (priv->objects[LSTORE_NODI]), &iter,
+ NODI_COL_ID, &id_nodi,
+ -1);
+ }
+
+ if (id_nodi == 0)
+ {
+ GtkWidget *dialog = gtk_message_dialog_new (GTK_WINDOW (priv->w),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_WARNING,
+ GTK_BUTTONS_OK,
+ "Occorre prima selezionare un nodo.");
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+ return;
+ }
+
+ PersonaNodoRecapito *a = persona_nodo_recapito_new (priv->commons, 0, priv->id, id_nodi);
+
+ g_signal_connect (G_OBJECT (a), "aggiornato",
+ G_CALLBACK (persona_on_nodo_recapito_aggiornato), (gpointer)persona);
+
+ w = persona_nodo_recapito_get_widget (a);
+ gtk_window_set_transient_for (GTK_WINDOW (w), GTK_WINDOW (priv->w));
+ gtk_widget_show (w);
+}
+
+static void
+persona_on_btn_nodo_recapito_modifica_clicked (GtkButton *button,
+ gpointer user_data)
+{
+ persona_nodo_recapito_modifica ((Persona *)user_data);
+}
+
+static void
+persona_on_btn_nodo_recapito_elimina_clicked (GtkButton *button,
+ gpointer user_data)
+{
+ GtkTreeIter iter;
+ GtkWidget *dialog;
+ guint risp;
+ guint id_nodi;
+
+ Persona *persona = (Persona *)user_data;
+
+ PersonaClass *klass = PERSONA_GET_CLASS (persona);
+ PersonaPrivate *priv = PERSONA_GET_PRIVATE (persona);
+
+ if (gtk_tree_selection_get_selected (priv->sel_nodi, NULL, &iter))
+ {
+ gtk_tree_model_get (GTK_TREE_MODEL (priv->objects[LSTORE_NODI]), &iter,
+ NODI_COL_ID, &id_nodi,
+ -1);
+ }
+
+ if (id_nodi == 0)
+ {
+ dialog = gtk_message_dialog_new (GTK_WINDOW (priv->w),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_WARNING,
+ GTK_BUTTONS_OK,
+ "Occorre prima selezionare un nodo.");
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+ return;
+ }
+
+ if (gtk_tree_selection_get_selected (priv->sel_nodo_recapiti, NULL, &iter))
+ {
+ dialog = gtk_message_dialog_new (GTK_WINDOW (priv->w),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_QUESTION,
+ GTK_BUTTONS_YES_NO,
+ "Sicuro di voler eliminare il recapito selezionato?");
+ risp = gtk_dialog_run (GTK_DIALOG (dialog));
+ if (risp == GTK_RESPONSE_YES)
+ {
+ guint id;
+
+ gtk_tree_model_get (GTK_TREE_MODEL (priv->objects[LSTORE_NODO_RECAPITI]), &iter,
+ NODO_RECAPITI_COL_ID, &id,
+ -1);
+
+ gdaex_execute (priv->commons->gdaex,
+ g_strdup_printf ("UPDATE persona_nodo_recapiti"
+ " SET status = 'E'"
+ " WHERE id = %d",
+ id));
+
+ persona_carica_nodo_recapiti (persona);
+ }
+ gtk_widget_destroy (dialog);
+ }
+ else
+ {
+ dialog = gtk_message_dialog_new (GTK_WINDOW (priv->w),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_WARNING,
+ GTK_BUTTONS_OK,
+ "Occorre prima selezionare un recapito.");
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+ }
+}
+
+static void
+persona_on_trv_nodo_recapiti_row_activated (GtkTreeView *tree_view,
+ GtkTreePath *tree_path,
+ GtkTreeViewColumn *column,
+ gpointer user_data)
+{
+ persona_nodo_recapito_modifica ((Persona *)user_data);
+}
+
static void
persona_on_btn_ufficio_nuovo_clicked (GtkButton *button,
gpointer user_data)
--- /dev/null
+/*
+ * Copyright (C) 2009 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
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+ #include <config.h>
+#endif
+
+#include <libgtkform/form.h>
+
+#include "personanodorecapito.h"
+
+static void persona_nodo_recapito_class_init (PersonaNodoRecapitoClass *klass);
+static void persona_nodo_recapito_init (PersonaNodoRecapito *persona_nodo_recapito);
+
+static void persona_nodo_recapito_carica (PersonaNodoRecapito *persona_nodo_recapito);
+static void persona_nodo_recapito_salva (PersonaNodoRecapito *persona_nodo_recapito);
+
+static gboolean persona_nodo_recapito_conferma_chiusura (PersonaNodoRecapito *persona_nodo_recapito);
+
+static void persona_nodo_recapito_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void persona_nodo_recapito_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
+
+static gboolean persona_nodo_recapito_on_w_persona_nodo_recapito_delete_event (GtkWidget *widget,
+ GdkEvent *event,
+ gpointer user_data);
+
+static void persona_nodo_recapito_on_btn_annulla_clicked (GtkButton *button,
+ gpointer user_data);
+static void persona_nodo_recapito_on_btn_salva_clicked (GtkButton *button,
+ gpointer user_data);
+
+
+#define PERSONA_NODO_RECAPITO_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_PERSONA_NODO_RECAPITO, PersonaNodoRecapitoPrivate))
+
+enum
+{
+ LBL_ID,
+ LBL_ID_PERSONE,
+ LBL_ID_NODI
+};
+
+typedef struct _PersonaNodoRecapitoPrivate PersonaNodoRecapitoPrivate;
+struct _PersonaNodoRecapitoPrivate
+ {
+ Commons *commons;
+
+ GtkForm *form;
+
+ GtkWidget *w;
+
+ GObject **objects;
+
+ guint id;
+ };
+
+G_DEFINE_TYPE (PersonaNodoRecapito, persona_nodo_recapito, G_TYPE_OBJECT)
+
+static void
+persona_nodo_recapito_class_init (PersonaNodoRecapitoClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ g_type_class_add_private (object_class, sizeof (PersonaNodoRecapitoPrivate));
+
+ object_class->set_property = persona_nodo_recapito_set_property;
+ object_class->get_property = persona_nodo_recapito_get_property;
+
+ /**
+ * PersonaNodoRecapito::aggiornato:
+ * @persona_nodo_recapito:
+ *
+ */
+ klass->aggiornato_signal_id = g_signal_new ("aggiornato",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
+}
+
+static void
+persona_nodo_recapito_init (PersonaNodoRecapito *persona_nodo_recapito)
+{
+ PersonaNodoRecapitoPrivate *priv = PERSONA_NODO_RECAPITO_GET_PRIVATE (persona_nodo_recapito);
+}
+
+/**
+ * persona_nodo_recapito_new:
+ * @commons:
+ * @id:
+ * @id_persone:
+ * @id_nodi:
+ *
+ * Returns: the newly created #PersonaNodoRecapito object.
+ */
+PersonaNodoRecapito
+*persona_nodo_recapito_new (Commons *commons, guint id, guint id_persone, guint id_nodi)
+{
+ GError *error;
+
+ PersonaNodoRecapito *a = PERSONA_NODO_RECAPITO (g_object_new (persona_nodo_recapito_get_type (), NULL));
+
+ PersonaNodoRecapitoPrivate *priv = PERSONA_NODO_RECAPITO_GET_PRIVATE (a);
+
+ priv->commons = commons;
+
+ error = NULL;
+
+ gtk_builder_add_objects_from_file (priv->commons->gtkbuilder, priv->commons->guifile,
+ g_strsplit ("lstore_tipi_recapito|w_persona_nodo_recapito", "|", -1),
+ &error);
+ if (error != NULL)
+ {
+ g_fprintf (stderr, "Errore: %s\n", error->message);
+ 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, "persona_nodo_recapito.form", NULL), priv->commons->gtkbuilder);
+
+ priv->w = GTK_WIDGET (gtk_builder_get_object (priv->commons->gtkbuilder, "w_persona_nodo_recapito"));
+
+ priv->objects = gtk_form_get_objects_by_name (priv->form,
+ "label122",
+ "label126",
+ "label123",
+ NULL);
+
+ g_signal_connect (priv->w,
+ "delete-event", G_CALLBACK (persona_nodo_recapito_on_w_persona_nodo_recapito_delete_event), (gpointer *)a);
+
+ g_signal_connect (G_OBJECT (gtk_builder_get_object (priv->commons->gtkbuilder, "button93")),
+ "clicked", G_CALLBACK (persona_nodo_recapito_on_btn_annulla_clicked), (gpointer *)a);
+ g_signal_connect (G_OBJECT (gtk_builder_get_object (priv->commons->gtkbuilder, "button94")),
+ "clicked", G_CALLBACK (persona_nodo_recapito_on_btn_salva_clicked), (gpointer *)a);
+
+ 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_PERSONE]), g_strdup_printf ("%d", id_persone));
+ gtk_label_set_text (GTK_LABEL (priv->objects[LBL_ID_NODI]), g_strdup_printf ("%d", id_nodi));
+
+ gtk_form_set_as_origin (priv->form);
+ }
+ else
+ {
+ gtk_label_set_text (GTK_LABEL (priv->objects[LBL_ID]), g_strdup_printf ("%d", priv->id));
+
+ persona_nodo_recapito_carica (a);
+ }
+
+ return a;
+}
+
+/**
+ * persona_nodo_recapito_get_widget:
+ * @persona_nodo_recapito:
+ *
+ */
+GtkWidget
+*persona_nodo_recapito_get_widget (PersonaNodoRecapito *persona_nodo_recapito)
+{
+ PersonaNodoRecapitoPrivate *priv = PERSONA_NODO_RECAPITO_GET_PRIVATE (persona_nodo_recapito);
+
+ return priv->w;
+}
+
+/* PRIVATE */
+static void
+persona_nodo_recapito_carica (PersonaNodoRecapito *persona_nodo_recapito)
+{
+ gchar *sql;
+ GdaDataModel *dm;
+
+ PersonaNodoRecapitoPrivate *priv = PERSONA_NODO_RECAPITO_GET_PRIVATE (persona_nodo_recapito);
+
+ if (gtk_form_fill_from_table (priv->form))
+ {
+ }
+}
+
+static void
+persona_nodo_recapito_salva (PersonaNodoRecapito *persona_nodo_recapito)
+{
+ gchar *sql;
+ GtkWidget *dialog;
+
+ PersonaNodoRecapitoClass *klass = PERSONA_NODO_RECAPITO_GET_CLASS (persona_nodo_recapito);
+
+ PersonaNodoRecapitoPrivate *priv = PERSONA_NODO_RECAPITO_GET_PRIVATE (persona_nodo_recapito);
+
+ if (!gtk_form_check (priv->form, FALSE, NULL, TRUE, priv->w, TRUE))
+ {
+ return;
+ }
+
+ if (priv->id == 0)
+ {
+ sql = gtk_form_get_sql (priv->form, GTK_FORM_SQL_INSERT);
+ }
+ else
+ {
+ sql = gtk_form_get_sql (priv->form, GTK_FORM_SQL_UPDATE);
+ }
+
+ if (gdaex_execute (priv->commons->gdaex, sql) == 1)
+ {
+ g_signal_emit (persona_nodo_recapito, klass->aggiornato_signal_id, 0);
+
+ if (priv->id == 0)
+ {
+ priv->id = strtol (gtk_label_get_text (GTK_LABEL (priv->objects[LBL_ID])), NULL, 10);
+ }
+
+ gtk_form_set_as_origin (priv->form);
+
+ dialog = gtk_message_dialog_new (GTK_WINDOW (priv->w),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_INFO,
+ GTK_BUTTONS_OK,
+ "Salvataggio eseguito con successo.");
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+ }
+ else
+ {
+ dialog = gtk_message_dialog_new (GTK_WINDOW (priv->w),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_WARNING,
+ GTK_BUTTONS_OK,
+ "Errore durante il salvataggio.");
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+ }
+}
+
+static void
+persona_nodo_recapito_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
+{
+ PersonaNodoRecapito *persona_nodo_recapito = PERSONA_NODO_RECAPITO (object);
+
+ PersonaNodoRecapitoPrivate *priv = PERSONA_NODO_RECAPITO_GET_PRIVATE (persona_nodo_recapito);
+
+ switch (property_id)
+ {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+persona_nodo_recapito_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
+{
+ PersonaNodoRecapito *persona_nodo_recapito = PERSONA_NODO_RECAPITO (object);
+
+ PersonaNodoRecapitoPrivate *priv = PERSONA_NODO_RECAPITO_GET_PRIVATE (persona_nodo_recapito);
+
+ switch (property_id)
+ {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static gboolean
+persona_nodo_recapito_conferma_chiusura (PersonaNodoRecapito *persona_nodo_recapito)
+{
+ GtkWidget *dialog;
+
+ gboolean ret;
+
+ PersonaNodoRecapitoPrivate *priv = PERSONA_NODO_RECAPITO_GET_PRIVATE (persona_nodo_recapito);
+
+ ret = TRUE;
+
+ if (gtk_form_is_changed (priv->form))
+ {
+ dialog = gtk_message_dialog_new (GTK_WINDOW (priv->w),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_QUESTION,
+ GTK_BUTTONS_YES_NO,
+ "Sicuro di voler chiudere senza salvare?");
+ if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_NO)
+ {
+ ret = FALSE;
+ }
+ gtk_widget_destroy (dialog);
+ }
+
+ return ret;
+}
+
+/* CALLBACK */
+static gboolean
+persona_nodo_recapito_on_w_persona_nodo_recapito_delete_event (GtkWidget *widget,
+ GdkEvent *event,
+ gpointer user_data)
+{
+ return !persona_nodo_recapito_conferma_chiusura ((PersonaNodoRecapito *)user_data);
+}
+
+static void
+persona_nodo_recapito_on_btn_annulla_clicked (GtkButton *button,
+ gpointer user_data)
+{
+ PersonaNodoRecapito *persona_nodo_recapito = (PersonaNodoRecapito *)user_data;
+
+ PersonaNodoRecapitoPrivate *priv = PERSONA_NODO_RECAPITO_GET_PRIVATE (persona_nodo_recapito);
+
+ if (persona_nodo_recapito_conferma_chiusura (persona_nodo_recapito)) gtk_widget_destroy (priv->w);
+}
+
+static void
+persona_nodo_recapito_on_btn_salva_clicked (GtkButton *button,
+ gpointer user_data)
+{
+ persona_nodo_recapito_salva ((PersonaNodoRecapito *)user_data);
+}
--- /dev/null
+/*
+ * Copyright (C) 2009 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
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#ifndef __PERSONA_NODO_RECAPITO_H__
+#define __PERSONA_NODO_RECAPITO_H__
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include <gtk/gtk.h>
+
+#include "commons.h"
+
+G_BEGIN_DECLS
+
+
+#define TYPE_PERSONA_NODO_RECAPITO (persona_nodo_recapito_get_type ())
+#define PERSONA_NODO_RECAPITO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PERSONA_NODO_RECAPITO, PersonaNodoRecapito))
+#define PERSONA_NODO_RECAPITO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_PERSONA_NODO_RECAPITO, PersonaNodoRecapitoClass))
+#define IS_PERSONA_NODO_RECAPITO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_PERSONA_NODO_RECAPITO))
+#define IS_PERSONA_NODO_RECAPITO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_PERSONA_NODO_RECAPITO))
+#define PERSONA_NODO_RECAPITO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_PERSONA_NODO_RECAPITO, PersonaNodoRecapitoClass))
+
+
+typedef struct _PersonaNodoRecapito PersonaNodoRecapito;
+typedef struct _PersonaNodoRecapitoClass PersonaNodoRecapitoClass;
+
+struct _PersonaNodoRecapito
+ {
+ GObject parent;
+ };
+
+struct _PersonaNodoRecapitoClass
+ {
+ GObjectClass parent_class;
+
+ guint aggiornato_signal_id;
+ };
+
+GType persona_nodo_recapito_get_type (void) G_GNUC_CONST;
+
+PersonaNodoRecapito *persona_nodo_recapito_new (Commons *commons, guint id, guint id_persone, guint id_nodi);
+
+GtkWidget *persona_nodo_recapito_get_widget (PersonaNodoRecapito *persona_nodo_recapito);
+
+
+G_END_DECLS
+
+#endif /* __PERSONA_NODO_RECAPITO_H__ */