form_DATA = \
nodo.form \
persona.form \
+ persona_recapito.form \
persona_ufficio.form \
struttura.form \
struttura_indirizzo.form \
--- /dev/null
+<?xml version="1.0"?>
+<gtkform>
+
+ <table>persona_recapiti</table>
+
+ <widget type="label" name="label103">
+ <field type="integer" name="id">
+ <is-key>t</is-key>
+ <auto-increment>t</auto-increment>
+ </field>
+ </widget>
+
+ <widget type="label" name="label107">
+ <field type="integer" name="id_persone">
+ </field>
+ </widget>
+
+ <widget type="combobox" name="combobox6" label="label102">
+ <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="entry25" label="label105">
+ <field type="text" name="recapito">
+ </field>
+ </widget>
+
+ <widget type="textview" name="textview11" label="label101">
+ <field type="text" name="note" />
+ </widget>
+
+ <widget type="checkbox" name="checkbutton10" label="label106">
+ <field type="boolean" name="privato">
+ </field>
+ </widget>
+
+</gtkform>
<column type="gchararray"/>
</columns>
</object>
- <object class="GtkListStore" id="lstore_persona_incarichi">
- <columns>
- <!-- column-name id -->
- <column type="guint"/>
- <!-- column-name da_data -->
- <column type="gchararray"/>
- <!-- column-name a_data -->
- <column type="gchararray"/>
- </columns>
- </object>
<object class="GtkListStore" id="lstore_tipi_rapporto_lavoro">
<columns>
<!-- column-name id -->
<column type="gchararray"/>
</columns>
</object>
+ <object class="GtkListStore" id="lstore_persona_incarichi">
+ <columns>
+ <!-- column-name id -->
+ <column type="guint"/>
+ <!-- column-name da_data -->
+ <column type="gchararray"/>
+ <!-- column-name a_data -->
+ <column type="gchararray"/>
+ <!-- column-name descrizione -->
+ <column type="gchararray"/>
+ </columns>
+ </object>
<object class="GtkWindow" id="w_nodi">
<property name="modal">True</property>
<property name="window_position">center-on-parent</property>
</child>
</object>
</child>
+ <child>
+ <object class="GtkTreeViewColumn" id="treeviewcolumn32">
+ <property name="title">Descrizione</property>
+ <child>
+ <object class="GtkCellRendererText" id="cellrenderertext43"/>
+ <attributes>
+ <attribute name="text">3</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
</object>
</child>
</object>
</child>
</object>
</child>
+ <child>
+ <object class="GtkTreeViewColumn" id="treeviewcolumn30">
+ <property name="title">Da data</property>
+ <child>
+ <object class="GtkCellRendererText" id="cellrenderertext41"/>
+ <attributes>
+ <attribute name="text">3</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn" id="treeviewcolumn31">
+ <property name="title">A data</property>
+ <child>
+ <object class="GtkCellRendererText" id="cellrenderertext42"/>
+ <attributes>
+ <attribute name="text">4</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkLabel" id="label107">
- <property name="label" translatable="yes">lbl_id_persona</property>
+ <property name="label" translatable="yes">lbl_id_persone</property>
</object>
<packing>
<property name="left_attach">1</property>
<child>
<object class="GtkTable" id="table17">
<property name="visible">True</property>
- <property name="n_rows">9</property>
+ <property name="n_rows">10</property>
<property name="n_columns">2</property>
<property name="column_spacing">5</property>
<property name="row_spacing">5</property>
<property name="label" translatable="yes">Note</property>
</object>
<packing>
- <property name="top_attach">7</property>
- <property name="bottom_attach">8</property>
+ <property name="top_attach">8</property>
+ <property name="bottom_attach">9</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
- <property name="top_attach">7</property>
- <property name="bottom_attach">8</property>
+ <property name="top_attach">8</property>
+ <property name="bottom_attach">9</property>
</packing>
</child>
<child>
<property name="label" translatable="yes">lbl_id</property>
</object>
<packing>
- <property name="top_attach">8</property>
- <property name="bottom_attach">9</property>
+ <property name="top_attach">9</property>
+ <property name="bottom_attach">10</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
- <property name="top_attach">8</property>
- <property name="bottom_attach">9</property>
+ <property name="top_attach">9</property>
+ <property name="bottom_attach">10</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
+ <child>
+ <object class="GtkLabel" id="label144">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0</property>
+ <property name="label" translatable="yes">Descrizione</property>
+ </object>
+ <packing>
+ <property name="top_attach">7</property>
+ <property name="bottom_attach">8</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkScrolledWindow" id="scrolledwindow34">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hscrollbar_policy">automatic</property>
+ <property name="vscrollbar_policy">automatic</property>
+ <property name="shadow_type">etched-in</property>
+ <child>
+ <object class="GtkTextView" id="textview15">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">7</property>
+ <property name="bottom_attach">8</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="position">0</property>
-- Dumped from database version 8.4.4
-- Dumped by pg_dump version 9.0.0
--- Started on 2010-10-13 10:20:10
+-- Started on 2010-10-13 12:04:21
SET statement_timeout = 0;
SET client_encoding = 'UTF8';
SET escape_string_warning = off;
--
--- TOC entry 338 (class 2612 OID 16386)
+-- TOC entry 341 (class 2612 OID 16386)
-- Name: plpgsql; Type: PROCEDURAL LANGUAGE; Schema: -; Owner: -
--
SET default_with_oids = false;
--
--- TOC entry 1525 (class 1259 OID 59279)
--- Dependencies: 1816 1817 1818 3
+-- TOC entry 1528 (class 1259 OID 59279)
+-- Dependencies: 1820 1821 1822 3
-- Name: nodi; Type: TABLE; Schema: public; Owner: -
--
--
--- TOC entry 1538 (class 1259 OID 61243)
--- Dependencies: 1851 1852 3
+-- TOC entry 1542 (class 1259 OID 61266)
+-- Dependencies: 1857 1858 1859 1860 1861 1862 3
+-- Name: persona_recapiti; Type: TABLE; Schema: public; Owner: -
+--
+
+CREATE TABLE persona_recapiti (
+ id integer NOT NULL,
+ id_persone 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 1541 (class 1259 OID 61243)
+-- Dependencies: 1855 1856 3
-- Name: persona_uffici; Type: TABLE; Schema: public; Owner: -
--
--
--- TOC entry 1536 (class 1259 OID 61227)
--- Dependencies: 1845 1846 1847 1848 3
+-- TOC entry 1539 (class 1259 OID 61227)
+-- Dependencies: 1849 1850 1851 1852 3
-- Name: persone; Type: TABLE; Schema: public; Owner: -
--
--
--- TOC entry 1531 (class 1259 OID 59346)
--- Dependencies: 1832 1833 1834 3
+-- TOC entry 1534 (class 1259 OID 59346)
+-- Dependencies: 1836 1837 1838 3
-- Name: struttura_indirizzi; Type: TABLE; Schema: public; Owner: -
--
--
--- TOC entry 1529 (class 1259 OID 59327)
--- Dependencies: 1826 1827 1828 1829 1830 3
+-- TOC entry 1532 (class 1259 OID 59327)
+-- Dependencies: 1830 1831 1832 1833 1834 3
-- Name: strutture; Type: TABLE; Schema: public; Owner: -
--
--
--- TOC entry 1526 (class 1259 OID 59290)
--- Dependencies: 1819 1820 3
+-- TOC entry 1529 (class 1259 OID 59290)
+-- Dependencies: 1823 1824 3
-- Name: tipi_nodo; Type: TABLE; Schema: public; Owner: -
--
--
--- TOC entry 1537 (class 1259 OID 61236)
--- Dependencies: 1849 1850 3
+-- TOC entry 1540 (class 1259 OID 61236)
+-- Dependencies: 1853 1854 3
-- Name: tipi_rapporto_lavoro; Type: TABLE; Schema: public; Owner: -
--
--
--- TOC entry 1527 (class 1259 OID 59297)
--- Dependencies: 1821 1822 3
+-- TOC entry 1530 (class 1259 OID 59297)
+-- Dependencies: 1825 1826 3
-- Name: tipi_recapito; Type: TABLE; Schema: public; Owner: -
--
--
--- TOC entry 1535 (class 1259 OID 61219)
--- Dependencies: 1842 1843 1844 3
+-- TOC entry 1538 (class 1259 OID 61219)
+-- Dependencies: 1846 1847 1848 3
-- Name: titoli; Type: TABLE; Schema: public; Owner: -
--
--
--- TOC entry 1528 (class 1259 OID 59311)
--- Dependencies: 1823 1824 1825 3
+-- TOC entry 1531 (class 1259 OID 59311)
+-- Dependencies: 1827 1828 1829 3
-- Name: uffici; Type: TABLE; Schema: public; Owner: -
--
--
--- TOC entry 1532 (class 1259 OID 59357)
--- Dependencies: 1835 1836 3
+-- TOC entry 1535 (class 1259 OID 59357)
+-- Dependencies: 1839 1840 3
-- Name: ufficio_nodi; Type: TABLE; Schema: public; Owner: -
--
--
--- TOC entry 1533 (class 1259 OID 59399)
--- Dependencies: 1837 1838 3
+-- TOC entry 1536 (class 1259 OID 59399)
+-- Dependencies: 1841 1842 3
-- Name: ufficio_orari; Type: TABLE; Schema: public; Owner: -
--
--
--- TOC entry 1534 (class 1259 OID 59409)
--- Dependencies: 1839 1840 1841 3
+-- TOC entry 1537 (class 1259 OID 59409)
+-- Dependencies: 1843 1844 1845 3
-- Name: ufficio_recapiti; Type: TABLE; Schema: public; Owner: -
--
--
--- TOC entry 1530 (class 1259 OID 59340)
--- Dependencies: 1831 3
+-- TOC entry 1533 (class 1259 OID 59340)
+-- Dependencies: 1835 3
-- Name: vie; Type: TABLE; Schema: public; Owner: -
--
--
--- TOC entry 1854 (class 2606 OID 59289)
--- Dependencies: 1525 1525
+-- TOC entry 1864 (class 2606 OID 59289)
+-- Dependencies: 1528 1528
-- Name: nodi_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
--
--- TOC entry 1880 (class 2606 OID 61252)
--- Dependencies: 1538 1538
+-- TOC entry 1892 (class 2606 OID 61279)
+-- Dependencies: 1542 1542
+-- Name: persona_recapiti_pkey; Type: CONSTRAINT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY persona_recapiti
+ ADD CONSTRAINT persona_recapiti_pkey PRIMARY KEY (id);
+
+
+--
+-- TOC entry 1890 (class 2606 OID 61252)
+-- Dependencies: 1541 1541
-- Name: persona_uffici_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
--
--- TOC entry 1876 (class 2606 OID 61235)
--- Dependencies: 1536 1536
+-- TOC entry 1886 (class 2606 OID 61235)
+-- Dependencies: 1539 1539
-- Name: persone_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
--
--- TOC entry 1866 (class 2606 OID 59356)
--- Dependencies: 1531 1531
+-- TOC entry 1876 (class 2606 OID 59356)
+-- Dependencies: 1534 1534
-- Name: struttura_indirizzi_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
--
--- TOC entry 1862 (class 2606 OID 59339)
--- Dependencies: 1529 1529
+-- TOC entry 1872 (class 2606 OID 59339)
+-- Dependencies: 1532 1532
-- Name: strutture_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
--
--- TOC entry 1856 (class 2606 OID 59296)
--- Dependencies: 1526 1526
+-- TOC entry 1866 (class 2606 OID 59296)
+-- Dependencies: 1529 1529
-- Name: tipi_nodo_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
--
--- TOC entry 1878 (class 2606 OID 61242)
--- Dependencies: 1537 1537
+-- TOC entry 1888 (class 2606 OID 61242)
+-- Dependencies: 1540 1540
-- Name: tipi_rapporto_lavoro_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
--
--- TOC entry 1858 (class 2606 OID 59303)
--- Dependencies: 1527 1527
+-- TOC entry 1868 (class 2606 OID 59303)
+-- Dependencies: 1530 1530
-- Name: tipi_recapito_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
--
--- TOC entry 1874 (class 2606 OID 61226)
--- Dependencies: 1535 1535
+-- TOC entry 1884 (class 2606 OID 61226)
+-- Dependencies: 1538 1538
-- Name: titoli_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
--
--- TOC entry 1860 (class 2606 OID 59321)
--- Dependencies: 1528 1528
+-- TOC entry 1870 (class 2606 OID 59321)
+-- Dependencies: 1531 1531
-- Name: uffici_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
--
--- TOC entry 1868 (class 2606 OID 59366)
--- Dependencies: 1532 1532
+-- TOC entry 1878 (class 2606 OID 59366)
+-- Dependencies: 1535 1535
-- Name: ufficio_nodi_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
--
--- TOC entry 1870 (class 2606 OID 59408)
--- Dependencies: 1533 1533
+-- TOC entry 1880 (class 2606 OID 59408)
+-- Dependencies: 1536 1536
-- Name: ufficio_orari_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
--
--- TOC entry 1872 (class 2606 OID 59419)
--- Dependencies: 1534 1534
+-- TOC entry 1882 (class 2606 OID 59419)
+-- Dependencies: 1537 1537
-- Name: ufficio_recapiti_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
--
--- TOC entry 1864 (class 2606 OID 59345)
--- Dependencies: 1530 1530
+-- TOC entry 1874 (class 2606 OID 59345)
+-- Dependencies: 1533 1533
-- Name: vie_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ADD CONSTRAINT vie_pkey PRIMARY KEY (id);
--- Completed on 2010-10-13 10:20:10
+-- Completed on 2010-10-13 12:04:21
--
-- PostgreSQL database dump complete
persona.h \
persone.c \
persone.h \
+ personarecapito.c \
+ personarecapito.h \
personaufficio.c \
personaufficio.h \
struttura.c \
#include "persona.h"
#include "personaufficio.h"
+#include "personarecapito.h"
static void persona_class_init (PersonaClass *klass);
static void persona_init (Persona *persona);
static void persona_salva (Persona *persona);
static void persona_carica_uffici (Persona *persona);
+static void persona_carica_recapiti (Persona *persona);
static void persona_ufficio_modifica (Persona *persona);
+static void persona_recapito_modifica (Persona *persona);
static gboolean persona_conferma_chiusura (Persona *persona);
GParamSpec *pspec);
static void persona_on_ufficio_aggiornato (gpointer instance, gpointer user_data);
+static void persona_on_recapito_aggiornato (gpointer instance, gpointer user_data);
static gboolean persona_on_w_persona_delete_event (GtkWidget *widget,
GdkEvent *event,
GtkTreeViewColumn *column,
gpointer user_data);
+static void persona_on_btn_recapito_nuovo_clicked (GtkButton *button,
+ gpointer user_data);
+static void persona_on_btn_recapito_modifica_clicked (GtkButton *button,
+ gpointer user_data);
+static void persona_on_btn_recapito_elimina_clicked (GtkButton *button,
+ gpointer user_data);
+static void persona_on_trv_recapiti_row_activated (GtkTreeView *tree_view,
+ GtkTreePath *tree_path,
+ GtkTreeViewColumn *column,
+ gpointer user_data);
+
static void persona_on_btn_annulla_clicked (GtkButton *button,
gpointer user_data);
static void persona_on_btn_salva_clicked (GtkButton *button,
enum
{
LBL_ID,
- LSTORE_UFFICI
+ LSTORE_UFFICI,
+ LSTORE_RECAPITI
};
enum
UFFICI_COL_UFFICIO
};
+enum
+{
+ RECAPITI_COL_ID,
+ RECAPITI_COL_TIPO,
+ RECAPITI_COL_RECAPITO
+};
+
typedef struct _PersonaPrivate PersonaPrivate;
struct _PersonaPrivate
{
GObject **objects;
GtkTreeSelection *sel_uffici;
+ GtkTreeSelection *sel_recapiti;
gint id;
};
g_strsplit (g_strconcat (
"lstore_titoli"
"|lstore_persona_uffici"
+ "|lstore_persona_recapiti"
"|w_persona", NULL), "|", -1),
&error);
if (error != NULL)
priv->objects = gtk_form_get_objects_by_name (priv->form,
"label67",
"lstore_persona_uffici",
+ "lstore_persona_recapiti",
NULL);
g_signal_connect (priv->w,
"delete-event", G_CALLBACK (persona_on_w_persona_delete_event), (gpointer *)a);
priv->sel_uffici = gtk_tree_view_get_selection (GTK_TREE_VIEW (gtk_builder_get_object (priv->commons->gtkbuilder, "treeview11")));
+ priv->sel_recapiti = gtk_tree_view_get_selection (GTK_TREE_VIEW (gtk_builder_get_object (priv->commons->gtkbuilder, "treeview15")));
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, "treeview11")),
"row-activated", G_CALLBACK (persona_on_trv_uffici_row_activated), (gpointer *)a);
+ g_signal_connect (G_OBJECT (gtk_builder_get_object (priv->commons->gtkbuilder, "button76")),
+ "clicked", G_CALLBACK (persona_on_btn_recapito_nuovo_clicked), (gpointer *)a);
+ g_signal_connect (G_OBJECT (gtk_builder_get_object (priv->commons->gtkbuilder, "button77")),
+ "clicked", G_CALLBACK (persona_on_btn_recapito_modifica_clicked), (gpointer *)a);
+ g_signal_connect (G_OBJECT (gtk_builder_get_object (priv->commons->gtkbuilder, "button78")),
+ "clicked", G_CALLBACK (persona_on_btn_recapito_elimina_clicked), (gpointer *)a);
+ g_signal_connect (G_OBJECT (gtk_builder_get_object (priv->commons->gtkbuilder, "treeview15")),
+ "row-activated", G_CALLBACK (persona_on_trv_recapiti_row_activated), (gpointer *)a);
+
g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button65"),
"clicked", G_CALLBACK (persona_on_btn_annulla_clicked), (gpointer *)a);
g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button66"),
if (gtk_form_fill_from_table (priv->form))
{
persona_carica_uffici (persona);
+ persona_carica_recapiti (persona);
}
}
g_free (sql);
}
+static void
+persona_carica_recapiti (Persona *persona)
+{
+ gchar *sql;
+ GdaDataModel *dm;
+ guint row;
+ guint rows;
+
+ PersonaPrivate *priv = PERSONA_GET_PRIVATE (persona);
+
+ gtk_list_store_clear (GTK_LIST_STORE (priv->objects[LSTORE_RECAPITI]));
+
+ sql = g_strdup_printf ("SELECT pr.id, tr.nome, pr.recapito"
+ " FROM persona_recapiti AS pr INNER JOIN tipi_recapito AS tr ON"
+ " pr.id_tipi_recapito = tr.id"
+ " WHERE pr.id_persone = %d"
+ " AND pr.status <> 'E'"
+ " ORDER BY tr.nome, pr.recapito",
+ priv->id);
+ 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_RECAPITI]), &iter);
+ gtk_list_store_set (GTK_LIST_STORE (priv->objects[LSTORE_RECAPITI]), &iter,
+ RECAPITI_COL_ID, gdaex_data_model_get_field_value_integer_at (dm, row, "id"),
+ RECAPITI_COL_TIPO, gdaex_data_model_get_field_value_stringify_at (dm, row, "nome"),
+ 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_ufficio_modifica (Persona *persona)
{
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_WARNING,
GTK_BUTTONS_OK,
- "Occorre prima selezionare un ufficio");
+ "Occorre prima selezionare un ufficio.");
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+ }
+}
+
+static void
+persona_recapito_modifica (Persona *persona)
+{
+ GtkTreeIter iter;
+ GtkWidget *dialog;
+
+ PersonaPrivate *priv = PERSONA_GET_PRIVATE (persona);
+
+ if (gtk_tree_selection_get_selected (priv->sel_recapiti, NULL, &iter))
+ {
+ guint id;
+ GtkWidget *w;
+
+ gtk_tree_model_get (GTK_TREE_MODEL (priv->objects[LSTORE_RECAPITI]), &iter,
+ RECAPITI_COL_ID, &id,
+ -1);
+
+ PersonaRecapito *a = persona_recapito_new (priv->commons, id, 0);
+
+ g_signal_connect (G_OBJECT (a), "aggiornato",
+ G_CALLBACK (persona_on_recapito_aggiornato), (gpointer)persona);
+
+ w = persona_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 recapito.");
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
}
persona_carica_uffici (persona);
}
+static void
+persona_on_recapito_aggiornato (gpointer instance, gpointer user_data)
+{
+ Persona *persona = (Persona *)user_data;
+ PersonaClass *klass = PERSONA_GET_CLASS (persona);
+
+ persona_carica_recapiti (persona);
+}
+
static gboolean
persona_on_w_persona_delete_event (GtkWidget *widget,
GdkEvent *event,
persona_ufficio_modifica ((Persona *)user_data);
}
+static void
+persona_on_btn_recapito_nuovo_clicked (GtkButton *button,
+ gpointer user_data)
+{
+ GtkWidget *w;
+
+ Persona *persona = (Persona *)user_data;
+
+ PersonaPrivate *priv = PERSONA_GET_PRIVATE (persona);
+
+ PersonaRecapito *a = persona_recapito_new (priv->commons, 0, priv->id);
+
+ g_signal_connect (G_OBJECT (a), "aggiornato",
+ G_CALLBACK (persona_on_recapito_aggiornato), (gpointer)persona);
+
+ w = persona_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_recapito_modifica_clicked (GtkButton *button,
+ gpointer user_data)
+{
+ persona_recapito_modifica ((Persona *)user_data);
+}
+
+static void
+persona_on_btn_recapito_elimina_clicked (GtkButton *button,
+ gpointer user_data)
+{
+ GtkTreeIter iter;
+ GtkWidget *dialog;
+ guint risp;
+
+ 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_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_RECAPITI]), &iter,
+ RECAPITI_COL_ID, &id,
+ -1);
+
+ gdaex_execute (priv->commons->gdaex,
+ g_strdup_printf ("UPDATE persona_recapiti"
+ " SET status = 'E'"
+ " WHERE id = %d",
+ id));
+
+ persona_carica_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_recapiti_row_activated (GtkTreeView *tree_view,
+ GtkTreePath *tree_path,
+ GtkTreeViewColumn *column,
+ gpointer user_data)
+{
+ persona_recapito_modifica ((Persona *)user_data);
+}
+
static void
persona_on_btn_annulla_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 "personarecapito.h"
+
+static void persona_recapito_class_init (PersonaRecapitoClass *klass);
+static void persona_recapito_init (PersonaRecapito *persona_recapito);
+
+static void persona_recapito_carica (PersonaRecapito *persona_recapito);
+static void persona_recapito_salva (PersonaRecapito *persona_recapito);
+
+static gboolean persona_recapito_conferma_chiusura (PersonaRecapito *persona_recapito);
+
+static void persona_recapito_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void persona_recapito_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
+
+static gboolean persona_recapito_on_w_persona_recapito_delete_event (GtkWidget *widget,
+ GdkEvent *event,
+ gpointer user_data);
+
+static void persona_recapito_on_btn_annulla_clicked (GtkButton *button,
+ gpointer user_data);
+static void persona_recapito_on_btn_salva_clicked (GtkButton *button,
+ gpointer user_data);
+
+
+#define PERSONA_RECAPITO_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_PERSONA_RECAPITO, PersonaRecapitoPrivate))
+
+enum
+{
+ LBL_ID,
+ LBL_ID_PERSONE
+};
+
+typedef struct _PersonaRecapitoPrivate PersonaRecapitoPrivate;
+struct _PersonaRecapitoPrivate
+ {
+ Commons *commons;
+
+ GtkForm *form;
+
+ GtkWidget *w;
+
+ GObject **objects;
+
+ guint id;
+ };
+
+G_DEFINE_TYPE (PersonaRecapito, persona_recapito, G_TYPE_OBJECT)
+
+static void
+persona_recapito_class_init (PersonaRecapitoClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ g_type_class_add_private (object_class, sizeof (PersonaRecapitoPrivate));
+
+ object_class->set_property = persona_recapito_set_property;
+ object_class->get_property = persona_recapito_get_property;
+
+ /**
+ * PersonaRecapito::aggiornato:
+ * @persona_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_recapito_init (PersonaRecapito *persona_recapito)
+{
+ PersonaRecapitoPrivate *priv = PERSONA_RECAPITO_GET_PRIVATE (persona_recapito);
+}
+
+/**
+ * persona_recapito_new:
+ * @commons:
+ * @id:
+ * @id_persone:
+ *
+ * Returns: the newly created #PersonaRecapito object.
+ */
+PersonaRecapito
+*persona_recapito_new (Commons *commons, guint id, guint id_persone)
+{
+ GError *error;
+
+ PersonaRecapito *a = PERSONA_RECAPITO (g_object_new (persona_recapito_get_type (), NULL));
+
+ PersonaRecapitoPrivate *priv = PERSONA_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_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_recapito.form", NULL), priv->commons->gtkbuilder);
+
+ priv->w = GTK_WIDGET (gtk_builder_get_object (priv->commons->gtkbuilder, "w_persona_recapito"));
+
+ priv->objects = gtk_form_get_objects_by_name (priv->form,
+ "label103",
+ "label107",
+ NULL);
+
+ g_signal_connect (priv->w,
+ "delete-event", G_CALLBACK (persona_recapito_on_w_persona_recapito_delete_event), (gpointer *)a);
+
+ g_signal_connect (G_OBJECT (gtk_builder_get_object (priv->commons->gtkbuilder, "button87")),
+ "clicked", G_CALLBACK (persona_recapito_on_btn_annulla_clicked), (gpointer *)a);
+ g_signal_connect (G_OBJECT (gtk_builder_get_object (priv->commons->gtkbuilder, "button88")),
+ "clicked", G_CALLBACK (persona_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_form_set_as_origin (priv->form);
+ }
+ else
+ {
+ gtk_label_set_text (GTK_LABEL (priv->objects[LBL_ID]), g_strdup_printf ("%d", priv->id));
+
+ persona_recapito_carica (a);
+ }
+
+ return a;
+}
+
+/**
+ * persona_recapito_get_widget:
+ * @persona_recapito:
+ *
+ */
+GtkWidget
+*persona_recapito_get_widget (PersonaRecapito *persona_recapito)
+{
+ PersonaRecapitoPrivate *priv = PERSONA_RECAPITO_GET_PRIVATE (persona_recapito);
+
+ return priv->w;
+}
+
+/* PRIVATE */
+static void
+persona_recapito_carica (PersonaRecapito *persona_recapito)
+{
+ gchar *sql;
+ GdaDataModel *dm;
+
+ PersonaRecapitoPrivate *priv = PERSONA_RECAPITO_GET_PRIVATE (persona_recapito);
+
+ if (gtk_form_fill_from_table (priv->form))
+ {
+ }
+}
+
+static void
+persona_recapito_salva (PersonaRecapito *persona_recapito)
+{
+ gchar *sql;
+ GtkWidget *dialog;
+
+ PersonaRecapitoClass *klass = PERSONA_RECAPITO_GET_CLASS (persona_recapito);
+
+ PersonaRecapitoPrivate *priv = PERSONA_RECAPITO_GET_PRIVATE (persona_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_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_recapito_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
+{
+ PersonaRecapito *persona_recapito = PERSONA_RECAPITO (object);
+
+ PersonaRecapitoPrivate *priv = PERSONA_RECAPITO_GET_PRIVATE (persona_recapito);
+
+ switch (property_id)
+ {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+persona_recapito_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
+{
+ PersonaRecapito *persona_recapito = PERSONA_RECAPITO (object);
+
+ PersonaRecapitoPrivate *priv = PERSONA_RECAPITO_GET_PRIVATE (persona_recapito);
+
+ switch (property_id)
+ {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static gboolean
+persona_recapito_conferma_chiusura (PersonaRecapito *persona_recapito)
+{
+ GtkWidget *dialog;
+
+ gboolean ret;
+
+ PersonaRecapitoPrivate *priv = PERSONA_RECAPITO_GET_PRIVATE (persona_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_recapito_on_w_persona_recapito_delete_event (GtkWidget *widget,
+ GdkEvent *event,
+ gpointer user_data)
+{
+ return !persona_recapito_conferma_chiusura ((PersonaRecapito *)user_data);
+}
+
+static void
+persona_recapito_on_btn_annulla_clicked (GtkButton *button,
+ gpointer user_data)
+{
+ PersonaRecapito *persona_recapito = (PersonaRecapito *)user_data;
+
+ PersonaRecapitoPrivate *priv = PERSONA_RECAPITO_GET_PRIVATE (persona_recapito);
+
+ if (persona_recapito_conferma_chiusura (persona_recapito)) gtk_widget_destroy (priv->w);
+}
+
+static void
+persona_recapito_on_btn_salva_clicked (GtkButton *button,
+ gpointer user_data)
+{
+ persona_recapito_salva ((PersonaRecapito *)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_RECAPITO_H__
+#define __PERSONA_RECAPITO_H__
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include <gtk/gtk.h>
+
+#include "commons.h"
+
+G_BEGIN_DECLS
+
+
+#define TYPE_PERSONA_RECAPITO (persona_recapito_get_type ())
+#define PERSONA_RECAPITO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PERSONA_RECAPITO, PersonaRecapito))
+#define PERSONA_RECAPITO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_PERSONA_RECAPITO, PersonaRecapitoClass))
+#define IS_PERSONA_RECAPITO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_PERSONA_RECAPITO))
+#define IS_PERSONA_RECAPITO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_PERSONA_RECAPITO))
+#define PERSONA_RECAPITO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_PERSONA_RECAPITO, PersonaRecapitoClass))
+
+
+typedef struct _PersonaRecapito PersonaRecapito;
+typedef struct _PersonaRecapitoClass PersonaRecapitoClass;
+
+struct _PersonaRecapito
+ {
+ GObject parent;
+ };
+
+struct _PersonaRecapitoClass
+ {
+ GObjectClass parent_class;
+
+ guint aggiornato_signal_id;
+ };
+
+GType persona_recapito_get_type (void) G_GNUC_CONST;
+
+PersonaRecapito *persona_recapito_new (Commons *commons, guint id, guint id_persone);
+
+GtkWidget *persona_recapito_get_widget (PersonaRecapito *persona_recapito);
+
+
+G_END_DECLS
+
+#endif /* __PERSONA_RECAPITO_H__ */