From ae6c3057c365e94213236cbf737a4f04b7b6d45a Mon Sep 17 00:00:00 2001 From: Andrea Zagli Date: Thu, 14 Oct 2010 16:41:39 +0200 Subject: [PATCH] Gestione tabella profili professionali. --- data/organigramma/form/Makefile.am | 1 + .../form/profilo_professionale.form | 17 + data/organigramma/gui/organigramma.gui | 264 ++++++++++ docs/organigramma.sql | 189 ++++--- src/Makefile.am | 4 + src/main.c | 14 + src/profiliprofessionali.c | 495 ++++++++++++++++++ src/profiliprofessionali.h | 66 +++ src/profiloprofessionale.c | 339 ++++++++++++ src/profiloprofessionale.h | 66 +++ 10 files changed, 1372 insertions(+), 83 deletions(-) create mode 100644 data/organigramma/form/profilo_professionale.form create mode 100644 src/profiliprofessionali.c create mode 100644 src/profiliprofessionali.h create mode 100644 src/profiloprofessionale.c create mode 100644 src/profiloprofessionale.h diff --git a/data/organigramma/form/Makefile.am b/data/organigramma/form/Makefile.am index 51707fc..6256aef 100644 --- a/data/organigramma/form/Makefile.am +++ b/data/organigramma/form/Makefile.am @@ -9,6 +9,7 @@ form_DATA = \ persona_ufficio.form \ persona_ufficio_recapito.form \ posizione_economica.form \ + profilo_professionale.form \ struttura.form \ struttura_indirizzo.form \ tipo_nodo.form \ diff --git a/data/organigramma/form/profilo_professionale.form b/data/organigramma/form/profilo_professionale.form new file mode 100644 index 0000000..ece4467 --- /dev/null +++ b/data/organigramma/form/profilo_professionale.form @@ -0,0 +1,17 @@ + + + + profili_professionali
+ + + + t + t + + + + + + + +
diff --git a/data/organigramma/gui/organigramma.gui b/data/organigramma/gui/organigramma.gui index bc07c87..f2d7bf2 100644 --- a/data/organigramma/gui/organigramma.gui +++ b/data/organigramma/gui/organigramma.gui @@ -136,6 +136,14 @@ + + + True + Pro_fili professionali + True + + + @@ -7710,4 +7718,260 @@ + + Profili professionali - Gestione organigramma + True + center-on-parent + 500 + 400 + True + + + True + 5 + vertical + 5 + + + True + <b>Profili professionali</b> + True + + + False + 0 + + + + + True + True + automatic + automatic + etched-in + + + True + True + lstore_profili_professionali + False + 0 + + + Nome + + + + 1 + + + + + + + + + 1 + + + + + True + 5 + end + + + gtk-new + True + True + True + True + + + False + False + 0 + + + + + gtk-edit + True + True + True + True + + + False + False + 1 + + + + + gtk-delete + True + True + True + True + + + False + False + 2 + + + + + gtk-cancel + True + True + True + True + + + False + False + 3 + + + + + gtk-ok + True + True + True + True + + + False + False + 4 + + + + + False + 2 + + + + + + + Profilo professionale - Gestione organigramma + True + center-on-parent + True + + + True + 5 + vertical + 5 + + + True + 2 + 2 + 5 + 5 + + + True + 0 + lbl_id + + + 1 + 2 + GTK_FILL + + + + + True + 0 + ID + + + GTK_FILL + GTK_FILL + + + + + True + 0 + Nome + + + 1 + 2 + GTK_FILL + GTK_FILL + + + + + True + True + 50 + + + + 1 + 2 + 1 + 2 + GTK_FILL + + + + + 0 + + + + + True + 5 + end + + + gtk-cancel + True + True + True + True + + + False + False + 0 + + + + + gtk-save + True + True + True + True + + + False + False + 1 + + + + + False + 1 + + + + + diff --git a/docs/organigramma.sql b/docs/organigramma.sql index ae8bcbe..6a2405f 100644 --- a/docs/organigramma.sql +++ b/docs/organigramma.sql @@ -4,7 +4,7 @@ -- Dumped from database version 8.4.4 -- Dumped by pg_dump version 9.0.0 --- Started on 2010-10-14 15:50:19 +-- Started on 2010-10-14 16:40:21 SET statement_timeout = 0; SET client_encoding = 'UTF8'; @@ -14,7 +14,7 @@ SET client_min_messages = warning; SET escape_string_warning = off; -- --- TOC entry 354 (class 2612 OID 16386) +-- TOC entry 356 (class 2612 OID 16386) -- Name: plpgsql; Type: PROCEDURAL LANGUAGE; Schema: -; Owner: - -- @@ -26,8 +26,8 @@ SET search_path = public, pg_catalog; SET default_with_oids = false; -- --- TOC entry 1541 (class 1259 OID 59279) --- Dependencies: 1838 1839 1840 3 +-- TOC entry 1543 (class 1259 OID 59279) +-- Dependencies: 1841 1842 1843 3 -- Name: nodi; Type: TABLE; Schema: public; Owner: - -- @@ -42,8 +42,8 @@ CREATE TABLE nodi ( -- --- TOC entry 1557 (class 1259 OID 61295) --- Dependencies: 1888 1889 1890 1891 3 +-- TOC entry 1559 (class 1259 OID 61295) +-- Dependencies: 1891 1892 1893 1894 3 -- Name: persona_nodi; Type: TABLE; Schema: public; Owner: - -- @@ -59,8 +59,8 @@ CREATE TABLE persona_nodi ( -- --- TOC entry 1558 (class 1259 OID 61307) --- Dependencies: 1892 1893 1894 1895 1896 1897 1898 3 +-- TOC entry 1560 (class 1259 OID 61307) +-- Dependencies: 1895 1896 1897 1898 1899 1900 1901 3 -- Name: persona_nodo_recapiti; Type: TABLE; Schema: public; Owner: - -- @@ -77,8 +77,8 @@ CREATE TABLE persona_nodo_recapiti ( -- --- TOC entry 1555 (class 1259 OID 61266) --- Dependencies: 1875 1876 1877 1878 1879 1880 3 +-- TOC entry 1557 (class 1259 OID 61266) +-- Dependencies: 1878 1879 1880 1881 1882 1883 3 -- Name: persona_recapiti; Type: TABLE; Schema: public; Owner: - -- @@ -94,8 +94,8 @@ CREATE TABLE persona_recapiti ( -- --- TOC entry 1554 (class 1259 OID 61243) --- Dependencies: 1873 1874 3 +-- TOC entry 1556 (class 1259 OID 61243) +-- Dependencies: 1876 1877 3 -- Name: persona_uffici; Type: TABLE; Schema: public; Owner: - -- @@ -111,8 +111,8 @@ CREATE TABLE persona_uffici ( -- --- TOC entry 1556 (class 1259 OID 61280) --- Dependencies: 1881 1882 1883 1884 1885 1886 1887 3 +-- TOC entry 1558 (class 1259 OID 61280) +-- Dependencies: 1884 1885 1886 1887 1888 1889 1890 3 -- Name: persona_ufficio_recapiti; Type: TABLE; Schema: public; Owner: - -- @@ -129,8 +129,8 @@ CREATE TABLE persona_ufficio_recapiti ( -- --- TOC entry 1552 (class 1259 OID 61227) --- Dependencies: 1867 1868 1869 1870 3 +-- TOC entry 1554 (class 1259 OID 61227) +-- Dependencies: 1870 1871 1872 1873 3 -- Name: persone; Type: TABLE; Schema: public; Owner: - -- @@ -145,8 +145,8 @@ CREATE TABLE persone ( -- --- TOC entry 1559 (class 1259 OID 61322) --- Dependencies: 1899 1900 3 +-- TOC entry 1561 (class 1259 OID 61322) +-- Dependencies: 1902 1903 3 -- Name: posizioni_economiche; Type: TABLE; Schema: public; Owner: - -- @@ -158,8 +158,21 @@ CREATE TABLE posizioni_economiche ( -- --- TOC entry 1547 (class 1259 OID 59346) --- Dependencies: 1854 1855 1856 3 +-- TOC entry 1563 (class 1259 OID 61336) +-- Dependencies: 1906 1907 3 +-- Name: profili_professionali; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE profili_professionali ( + id integer NOT NULL, + nome character varying(255) DEFAULT ''::character varying, + status character varying(1) DEFAULT ''::character varying +); + + +-- +-- TOC entry 1549 (class 1259 OID 59346) +-- Dependencies: 1857 1858 1859 3 -- Name: struttura_indirizzi; Type: TABLE; Schema: public; Owner: - -- @@ -174,8 +187,8 @@ CREATE TABLE struttura_indirizzi ( -- --- TOC entry 1545 (class 1259 OID 59327) --- Dependencies: 1848 1849 1850 1851 1852 3 +-- TOC entry 1547 (class 1259 OID 59327) +-- Dependencies: 1851 1852 1853 1854 1855 3 -- Name: strutture; Type: TABLE; Schema: public; Owner: - -- @@ -190,8 +203,8 @@ CREATE TABLE strutture ( -- --- TOC entry 1542 (class 1259 OID 59290) --- Dependencies: 1841 1842 3 +-- TOC entry 1544 (class 1259 OID 59290) +-- Dependencies: 1844 1845 3 -- Name: tipi_nodo; Type: TABLE; Schema: public; Owner: - -- @@ -203,8 +216,8 @@ CREATE TABLE tipi_nodo ( -- --- TOC entry 1560 (class 1259 OID 61329) --- Dependencies: 1901 1902 3 +-- TOC entry 1562 (class 1259 OID 61329) +-- Dependencies: 1904 1905 3 -- Name: tipi_prestazione; Type: TABLE; Schema: public; Owner: - -- @@ -216,8 +229,8 @@ CREATE TABLE tipi_prestazione ( -- --- TOC entry 1553 (class 1259 OID 61236) --- Dependencies: 1871 1872 3 +-- TOC entry 1555 (class 1259 OID 61236) +-- Dependencies: 1874 1875 3 -- Name: tipi_rapporto_lavoro; Type: TABLE; Schema: public; Owner: - -- @@ -229,8 +242,8 @@ CREATE TABLE tipi_rapporto_lavoro ( -- --- TOC entry 1543 (class 1259 OID 59297) --- Dependencies: 1843 1844 3 +-- TOC entry 1545 (class 1259 OID 59297) +-- Dependencies: 1846 1847 3 -- Name: tipi_recapito; Type: TABLE; Schema: public; Owner: - -- @@ -242,8 +255,8 @@ CREATE TABLE tipi_recapito ( -- --- TOC entry 1551 (class 1259 OID 61219) --- Dependencies: 1864 1865 1866 3 +-- TOC entry 1553 (class 1259 OID 61219) +-- Dependencies: 1867 1868 1869 3 -- Name: titoli; Type: TABLE; Schema: public; Owner: - -- @@ -256,8 +269,8 @@ CREATE TABLE titoli ( -- --- TOC entry 1544 (class 1259 OID 59311) --- Dependencies: 1845 1846 1847 3 +-- TOC entry 1546 (class 1259 OID 59311) +-- Dependencies: 1848 1849 1850 3 -- Name: uffici; Type: TABLE; Schema: public; Owner: - -- @@ -271,8 +284,8 @@ CREATE TABLE uffici ( -- --- TOC entry 1548 (class 1259 OID 59357) --- Dependencies: 1857 1858 3 +-- TOC entry 1550 (class 1259 OID 59357) +-- Dependencies: 1860 1861 3 -- Name: ufficio_nodi; Type: TABLE; Schema: public; Owner: - -- @@ -286,8 +299,8 @@ CREATE TABLE ufficio_nodi ( -- --- TOC entry 1549 (class 1259 OID 59399) --- Dependencies: 1859 1860 3 +-- TOC entry 1551 (class 1259 OID 59399) +-- Dependencies: 1862 1863 3 -- Name: ufficio_orari; Type: TABLE; Schema: public; Owner: - -- @@ -314,8 +327,8 @@ CREATE TABLE ufficio_orari ( -- --- TOC entry 1550 (class 1259 OID 59409) --- Dependencies: 1861 1862 1863 3 +-- TOC entry 1552 (class 1259 OID 59409) +-- Dependencies: 1864 1865 1866 3 -- Name: ufficio_recapiti; Type: TABLE; Schema: public; Owner: - -- @@ -331,8 +344,8 @@ CREATE TABLE ufficio_recapiti ( -- --- TOC entry 1546 (class 1259 OID 59340) --- Dependencies: 1853 3 +-- TOC entry 1548 (class 1259 OID 59340) +-- Dependencies: 1856 3 -- Name: vie; Type: TABLE; Schema: public; Owner: - -- @@ -343,8 +356,8 @@ CREATE TABLE vie ( -- --- TOC entry 1904 (class 2606 OID 59289) --- Dependencies: 1541 1541 +-- TOC entry 1909 (class 2606 OID 59289) +-- Dependencies: 1543 1543 -- Name: nodi_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -353,8 +366,8 @@ ALTER TABLE ONLY nodi -- --- TOC entry 1936 (class 2606 OID 61305) --- Dependencies: 1557 1557 +-- TOC entry 1941 (class 2606 OID 61305) +-- Dependencies: 1559 1559 -- Name: persona_nodi_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -363,8 +376,8 @@ ALTER TABLE ONLY persona_nodi -- --- TOC entry 1938 (class 2606 OID 61321) --- Dependencies: 1558 1558 +-- TOC entry 1943 (class 2606 OID 61321) +-- Dependencies: 1560 1560 -- Name: persona_nodo_recapiti_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -373,8 +386,8 @@ ALTER TABLE ONLY persona_nodo_recapiti -- --- TOC entry 1932 (class 2606 OID 61279) --- Dependencies: 1555 1555 +-- TOC entry 1937 (class 2606 OID 61279) +-- Dependencies: 1557 1557 -- Name: persona_recapiti_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -383,8 +396,8 @@ ALTER TABLE ONLY persona_recapiti -- --- TOC entry 1930 (class 2606 OID 61252) --- Dependencies: 1554 1554 +-- TOC entry 1935 (class 2606 OID 61252) +-- Dependencies: 1556 1556 -- Name: persona_uffici_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -393,8 +406,8 @@ ALTER TABLE ONLY persona_uffici -- --- TOC entry 1934 (class 2606 OID 61294) --- Dependencies: 1556 1556 +-- TOC entry 1939 (class 2606 OID 61294) +-- Dependencies: 1558 1558 -- Name: persona_ufficio_recapiti_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -403,8 +416,8 @@ ALTER TABLE ONLY persona_ufficio_recapiti -- --- TOC entry 1926 (class 2606 OID 61235) --- Dependencies: 1552 1552 +-- TOC entry 1931 (class 2606 OID 61235) +-- Dependencies: 1554 1554 -- Name: persone_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -413,8 +426,8 @@ ALTER TABLE ONLY persone -- --- TOC entry 1940 (class 2606 OID 61328) --- Dependencies: 1559 1559 +-- TOC entry 1945 (class 2606 OID 61328) +-- Dependencies: 1561 1561 -- Name: posizioni_economiche_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -423,8 +436,18 @@ ALTER TABLE ONLY posizioni_economiche -- --- TOC entry 1916 (class 2606 OID 59356) --- Dependencies: 1547 1547 +-- TOC entry 1949 (class 2606 OID 61342) +-- Dependencies: 1563 1563 +-- Name: profili_professionali_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY profili_professionali + ADD CONSTRAINT profili_professionali_pkey PRIMARY KEY (id); + + +-- +-- TOC entry 1921 (class 2606 OID 59356) +-- Dependencies: 1549 1549 -- Name: struttura_indirizzi_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -433,8 +456,8 @@ ALTER TABLE ONLY struttura_indirizzi -- --- TOC entry 1912 (class 2606 OID 59339) --- Dependencies: 1545 1545 +-- TOC entry 1917 (class 2606 OID 59339) +-- Dependencies: 1547 1547 -- Name: strutture_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -443,8 +466,8 @@ ALTER TABLE ONLY strutture -- --- TOC entry 1906 (class 2606 OID 59296) --- Dependencies: 1542 1542 +-- TOC entry 1911 (class 2606 OID 59296) +-- Dependencies: 1544 1544 -- Name: tipi_nodo_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -453,8 +476,8 @@ ALTER TABLE ONLY tipi_nodo -- --- TOC entry 1942 (class 2606 OID 61335) --- Dependencies: 1560 1560 +-- TOC entry 1947 (class 2606 OID 61335) +-- Dependencies: 1562 1562 -- Name: tipi_prestazione_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -463,8 +486,8 @@ ALTER TABLE ONLY tipi_prestazione -- --- TOC entry 1928 (class 2606 OID 61242) --- Dependencies: 1553 1553 +-- TOC entry 1933 (class 2606 OID 61242) +-- Dependencies: 1555 1555 -- Name: tipi_rapporto_lavoro_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -473,8 +496,8 @@ ALTER TABLE ONLY tipi_rapporto_lavoro -- --- TOC entry 1908 (class 2606 OID 59303) --- Dependencies: 1543 1543 +-- TOC entry 1913 (class 2606 OID 59303) +-- Dependencies: 1545 1545 -- Name: tipi_recapito_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -483,8 +506,8 @@ ALTER TABLE ONLY tipi_recapito -- --- TOC entry 1924 (class 2606 OID 61226) --- Dependencies: 1551 1551 +-- TOC entry 1929 (class 2606 OID 61226) +-- Dependencies: 1553 1553 -- Name: titoli_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -493,8 +516,8 @@ ALTER TABLE ONLY titoli -- --- TOC entry 1910 (class 2606 OID 59321) --- Dependencies: 1544 1544 +-- TOC entry 1915 (class 2606 OID 59321) +-- Dependencies: 1546 1546 -- Name: uffici_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -503,8 +526,8 @@ ALTER TABLE ONLY uffici -- --- TOC entry 1918 (class 2606 OID 59366) --- Dependencies: 1548 1548 +-- TOC entry 1923 (class 2606 OID 59366) +-- Dependencies: 1550 1550 -- Name: ufficio_nodi_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -513,8 +536,8 @@ ALTER TABLE ONLY ufficio_nodi -- --- TOC entry 1920 (class 2606 OID 59408) --- Dependencies: 1549 1549 +-- TOC entry 1925 (class 2606 OID 59408) +-- Dependencies: 1551 1551 -- Name: ufficio_orari_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -523,8 +546,8 @@ ALTER TABLE ONLY ufficio_orari -- --- TOC entry 1922 (class 2606 OID 59419) --- Dependencies: 1550 1550 +-- TOC entry 1927 (class 2606 OID 59419) +-- Dependencies: 1552 1552 -- Name: ufficio_recapiti_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -533,8 +556,8 @@ ALTER TABLE ONLY ufficio_recapiti -- --- TOC entry 1914 (class 2606 OID 59345) --- Dependencies: 1546 1546 +-- TOC entry 1919 (class 2606 OID 59345) +-- Dependencies: 1548 1548 -- Name: vie_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -542,7 +565,7 @@ ALTER TABLE ONLY vie ADD CONSTRAINT vie_pkey PRIMARY KEY (id); --- Completed on 2010-10-14 15:50:19 +-- Completed on 2010-10-14 16:40:22 -- -- PostgreSQL database dump complete diff --git a/src/Makefile.am b/src/Makefile.am index 48ddae2..e3939e9 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -35,6 +35,10 @@ organigramma_SOURCES = \ posizioneeconomica.h \ posizionieconomiche.c \ posizionieconomiche.h \ + profiliprofessionali.c \ + profiliprofessionali.h \ + profiloprofessionale.c \ + profiloprofessionale.h \ struttura.c \ struttura.h \ strutturaindirizzo.c \ diff --git a/src/main.c b/src/main.c index 6ec4def..68a9b99 100644 --- a/src/main.c +++ b/src/main.c @@ -31,6 +31,7 @@ #include "nodi.h" #include "persone.h" #include "posizionieconomiche.h" +#include "profiliprofessionali.h" #include "strutture.h" #include "tipinodo.h" #include "tipiprestazione.h" @@ -190,6 +191,19 @@ on_mnu_tabelle_tipi_prestazione_activate (GtkMenuItem *menuitem, main_set_vbx_body_child (vbx); } +G_MODULE_EXPORT void +on_mnu_tabelle_profili_professionali_activate (GtkMenuItem *menuitem, + gpointer user_data) +{ + GtkWidget *vbx; + + ProfiliProfessionali *m = profili_professionali_new (commons, FALSE); + + vbx = profili_professionali_get_widget (m); + + main_set_vbx_body_child (vbx); +} + G_MODULE_EXPORT void on_mnu_help_about_activate (GtkMenuItem *menuitem, gpointer user_data) diff --git a/src/profiliprofessionali.c b/src/profiliprofessionali.c new file mode 100644 index 0000000..bf95286 --- /dev/null +++ b/src/profiliprofessionali.c @@ -0,0 +1,495 @@ +/* + * Copyright (C) 2010 Andrea Zagli + * + * 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 + * + */ + +#include "profiliprofessionali.h" +#include "profiloprofessionale.h" + +static void profili_professionali_class_init (ProfiliProfessionaliClass *klass); +static void profili_professionali_init (ProfiliProfessionali *profili_professionali); + +static void profili_professionali_carica (ProfiliProfessionali *profili_professionali); +static void profili_professionali_modifica (ProfiliProfessionali *profili_professionali); + +static void profili_professionali_selezionato (ProfiliProfessionali *profili_professionali); +static void profili_professionali_on_profilo_aggiornato (gpointer instance, gpointer user_data); + +static void profili_professionali_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec); +static void profili_professionali_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec); + +static void profili_professionali_on_btn_nuovo_clicked (GtkButton *button, + gpointer user_data); +static void profili_professionali_on_btn_modifica_clicked (GtkButton *button, + gpointer user_data); +static void profili_professionali_on_btn_elimina_clicked (GtkButton *button, + gpointer user_data); +static void profili_professionali_on_trv_profili_professionali_row_activated (GtkTreeView *tree_view, + GtkTreePath *tree_path, + GtkTreeViewColumn *column, + gpointer user_data); + +static void profili_professionali_on_btn_ricerca_clicked (GtkButton *button, + gpointer user_data); + +static void profili_professionali_on_btn_annulla_clicked (GtkButton *button, + gpointer user_data); +static void profili_professionali_on_btn_seleziona_clicked (GtkButton *button, + gpointer user_data); + +#define PROFILI_PROFESSIONALI_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_PROFILI_PROFESSIONALI, ProfiliProfessionaliPrivate)) + +enum +{ + COL_ID, + COL_NOME +}; + +typedef struct _ProfiliProfessionaliPrivate ProfiliProfessionaliPrivate; +struct _ProfiliProfessionaliPrivate + { + Commons *commons; + + GtkWidget *widget; + GtkTreeSelection *selection; + GtkListStore *lstore_profili_professionali; + + gboolean selezione; + }; + +G_DEFINE_TYPE (ProfiliProfessionali, profili_professionali, G_TYPE_OBJECT) + +static void +profili_professionali_class_init (ProfiliProfessionaliClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + g_type_class_add_private (object_class, sizeof (ProfiliProfessionaliPrivate)); + + object_class->set_property = profili_professionali_set_property; + object_class->get_property = profili_professionali_get_property; + + /** + * ProfiliProfessionali::selezionato: + * @profili_professionali: + * + */ + klass->selezionato_signal_id = g_signal_new ("selezionato", + G_TYPE_FROM_CLASS (object_class), + G_SIGNAL_RUN_LAST, + 0, + NULL, + NULL, + g_cclosure_marshal_VOID__UINT, + G_TYPE_NONE, + 1, G_TYPE_UINT); +} + +static void +profili_professionali_init (ProfiliProfessionali *profili_professionali) +{ + ProfiliProfessionaliPrivate *priv = PROFILI_PROFESSIONALI_GET_PRIVATE (profili_professionali); +} + +/** + * profili_professionali_new: + * @commons: + * @selezione: + * + * Returns: the newly created #ProfiliProfessionali object. + */ +ProfiliProfessionali +*profili_professionali_new (Commons *commons, gboolean selezione) +{ + GError *error; + + ProfiliProfessionali *a = PROFILI_PROFESSIONALI (g_object_new (profili_professionali_get_type (), NULL)); + + ProfiliProfessionaliPrivate *priv = PROFILI_PROFESSIONALI_GET_PRIVATE (a); + + priv->commons = commons; + priv->selezione = selezione; + + error = NULL; + gtk_builder_add_objects_from_file (priv->commons->gtkbuilder, priv->commons->guifile, + g_strsplit (g_strconcat ("lstore_profili_professionali|", + (selezione ? "w_profili_professionali" : "vbx_profili_professionali"), + NULL), "|", -1), + &error); + if (error != NULL) + { + g_warning ("Errore: %s.", error->message); + return NULL; + } + + priv->widget = GTK_WIDGET (gtk_builder_get_object (priv->commons->gtkbuilder, (selezione ? "w_profili_professionali" : "vbx_profili_professionali"))); + priv->selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (gtk_builder_get_object (priv->commons->gtkbuilder, "treeview22"))); + priv->lstore_profili_professionali = GTK_LIST_STORE (gtk_builder_get_object (priv->commons->gtkbuilder, "lstore_profili_professionali")); + + g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button130"), + "clicked", G_CALLBACK (profili_professionali_on_btn_nuovo_clicked), (gpointer)a); + g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button131"), + "clicked", G_CALLBACK (profili_professionali_on_btn_modifica_clicked), (gpointer)a); + g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button132"), + "clicked", G_CALLBACK (profili_professionali_on_btn_elimina_clicked), (gpointer)a); + g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "treeview22"), + "row-activated", G_CALLBACK (profili_professionali_on_trv_profili_professionali_row_activated), (gpointer)a); + + if (priv->selezione) + { + gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (priv->commons->gtkbuilder, "label156"))); + g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button133"), + "clicked", G_CALLBACK (profili_professionali_on_btn_annulla_clicked), (gpointer)a); + g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button134"), + "clicked", G_CALLBACK (profili_professionali_on_btn_seleziona_clicked), (gpointer)a); + } + else + { + gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (priv->commons->gtkbuilder, "button133"))); + gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (priv->commons->gtkbuilder, "button134"))); + } + + profili_professionali_carica (a); + + return a; +} + +/** + * profili_professionali_get_widget: + * @profili_professionali: + * + */ +GtkWidget +*profili_professionali_get_widget (ProfiliProfessionali *profili_professionali) +{ + ProfiliProfessionaliPrivate *priv = PROFILI_PROFESSIONALI_GET_PRIVATE (profili_professionali); + + return priv->widget; +} + +/* PRIVATE */ +static void +profili_professionali_carica (ProfiliProfessionali *profili_professionali) +{ + GtkTreeIter iter; + GdaDataModel *dm; + + gchar *sql_where; + gchar *sql; + + gchar *gcval; + gint ival; + + gint rows; + gint row; + + ProfiliProfessionaliPrivate *priv = PROFILI_PROFESSIONALI_GET_PRIVATE (profili_professionali); + + gtk_list_store_clear (priv->lstore_profili_professionali); + + sql_where = g_strdup (""); + + /*if (priv->parametri_ricerca != NULL) + { + gcval = (gchar *)g_value_get_string ((GValue *)g_hash_table_lookup (priv->parametri_ricerca, "ragione_sociale")); + if (gcval != NULL && g_strcmp0 (g_strstrip (gcval), "") != 0) + { + sql_where = g_strconcat (sql_where, " AND ragione_sociale ILIKE '%%", + gdaex_strescape (gcval, NULL), + "%%'", + NULL); + } + gcval = (gchar *)g_value_get_string ((GValue *)g_hash_table_lookup (priv->parametri_ricerca, "codice_fiscale")); + if (gcval != NULL && g_strcmp0 (g_strstrip (gcval), "") != 0) + { + sql_where = g_strconcat (sql_where, " AND codice_fiscale = '", + gdaex_strescape (gcval, NULL), + "'", + NULL); + } + gcval = (gchar *)g_value_get_string ((GValue *)g_hash_table_lookup (priv->parametri_ricerca, "partita_iva")); + if (gcval != NULL && g_strcmp0 (g_strstrip (gcval), "") != 0) + { + sql_where = g_strconcat (sql_where, " AND partita_iva = '", + gdaex_strescape (gcval, NULL), + "'", + NULL); + } + ival = g_value_get_int ((GValue *)g_hash_table_lookup (priv->parametri_ricerca, "id_citta")); + if (ival != 0) + { + sql_where = g_strconcat (sql_where, " AND id_citta = ", + g_strdup_printf ("%d", ival), + NULL); + } + }*/ + + sql = g_strdup_printf ("SELECT c.id, c.nome" + " FROM profili_professionali c" + " WHERE c.status <> 'E'" + "%s" + " ORDER BY c.nome", sql_where); + dm = gdaex_query (priv->commons->gdaex, sql); + if (dm != NULL) + { + rows = gda_data_model_get_n_rows (dm); + for (row = 0; row < rows; row++) + { + gtk_list_store_append (priv->lstore_profili_professionali, &iter); + + gtk_list_store_set (priv->lstore_profili_professionali, &iter, + COL_ID, gdaex_data_model_get_field_value_stringify_at (dm, row, "id"), + COL_NOME, gdaex_data_model_get_field_value_stringify_at (dm, row, "nome"), + -1); + } + + g_object_unref (dm); + } +} + +static void +profili_professionali_modifica (ProfiliProfessionali *profili_professionali) +{ + GtkTreeIter iter; + gchar *id; + + ProfiliProfessionaliPrivate *priv = PROFILI_PROFESSIONALI_GET_PRIVATE (profili_professionali); + + if (gtk_tree_selection_get_selected (priv->selection, NULL, &iter)) + { + GtkWidget *w; + + gtk_tree_model_get (GTK_TREE_MODEL (priv->lstore_profili_professionali), &iter, + COL_ID, &id, + -1); + + ProfiloProfessionale *c = profilo_professionale_new (priv->commons, strtol (id, NULL, 10)); + + g_signal_connect (G_OBJECT (c), "aggiornato", + G_CALLBACK (profili_professionali_on_profilo_aggiornato), (gpointer)profili_professionali); + + w = profilo_professionale_get_widget (c); + if (priv->selezione) + { + gtk_window_set_transient_for (GTK_WINDOW (w), GTK_WINDOW (priv->widget)); + } + else + { + gtk_window_set_transient_for (GTK_WINDOW (w), GTK_WINDOW (gtk_builder_get_object (priv->commons->gtkbuilder, "w_main"))); + } + gtk_widget_show (w); + } + else + { + GtkWidget *dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_builder_get_object (priv->commons->gtkbuilder, "w_main")), + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_WARNING, + GTK_BUTTONS_OK, + "Occorre prima selezionare un profilo professionale."); + gtk_dialog_run (GTK_DIALOG (dialog)); + gtk_widget_destroy (dialog); + } +} + +static void +profili_professionali_selezionato (ProfiliProfessionali *profili_professionali) +{ + GtkTreeIter iter; + guint id; + + ProfiliProfessionaliClass *klass = PROFILI_PROFESSIONALI_GET_CLASS (profili_professionali); + ProfiliProfessionaliPrivate *priv = PROFILI_PROFESSIONALI_GET_PRIVATE (profili_professionali); + + if (gtk_tree_selection_get_selected (priv->selection, NULL, &iter)) + { + gtk_tree_model_get (GTK_TREE_MODEL (priv->lstore_profili_professionali), &iter, + COL_ID, &id, + -1); + + g_signal_emit (G_OBJECT (profili_professionali), klass->selezionato_signal_id, 0, id); + + gtk_widget_destroy (priv->widget); + g_object_unref (G_OBJECT (profili_professionali)); + } + else + { + GtkWidget *dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_builder_get_object (priv->commons->gtkbuilder, "w_main")), + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_WARNING, + GTK_BUTTONS_OK, + "Occorre prima selezionare un profilo professionale."); + gtk_dialog_run (GTK_DIALOG (dialog)); + gtk_widget_destroy (dialog); + } +} + +static void +profili_professionali_on_profilo_aggiornato (gpointer instance, gpointer user_data) +{ + profili_professionali_carica ((ProfiliProfessionali *)user_data); +} + +static void +profili_professionali_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) +{ + ProfiliProfessionali *profili_professionali = PROFILI_PROFESSIONALI (object); + + ProfiliProfessionaliPrivate *priv = PROFILI_PROFESSIONALI_GET_PRIVATE (profili_professionali); + + switch (property_id) + { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + +static void +profili_professionali_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) +{ + ProfiliProfessionali *profili_professionali = PROFILI_PROFESSIONALI (object); + + ProfiliProfessionaliPrivate *priv = PROFILI_PROFESSIONALI_GET_PRIVATE (profili_professionali); + + switch (property_id) + { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + +/* CALLBACK */ +static void +profili_professionali_on_btn_nuovo_clicked (GtkButton *button, + gpointer user_data) +{ + GtkWidget *w; + + ProfiliProfessionali *profili_professionali = (ProfiliProfessionali *)user_data; + ProfiliProfessionaliPrivate *priv = PROFILI_PROFESSIONALI_GET_PRIVATE (profili_professionali); + + ProfiloProfessionale *c = profilo_professionale_new (priv->commons, 0); + + g_signal_connect (G_OBJECT (c), "aggiornato", + G_CALLBACK (profili_professionali_on_profilo_aggiornato), (gpointer)profili_professionali); + + w = profilo_professionale_get_widget (c); + if (priv->selezione) + { + gtk_window_set_transient_for (GTK_WINDOW (w), GTK_WINDOW (priv->widget)); + } + else + { + gtk_window_set_transient_for (GTK_WINDOW (w), GTK_WINDOW (gtk_builder_get_object (priv->commons->gtkbuilder, "w_main"))); + } + gtk_widget_show (w); +} + +static void +profili_professionali_on_btn_modifica_clicked (GtkButton *button, + gpointer user_data) +{ + profili_professionali_modifica ((ProfiliProfessionali *)user_data); +} + +static void +profili_professionali_on_btn_elimina_clicked (GtkButton *button, + gpointer user_data) +{ + GtkWidget *dialog; + gboolean risp; + + GtkTreeIter iter; + gchar *id; + + ProfiliProfessionali *profili_professionali = (ProfiliProfessionali *)user_data; + ProfiliProfessionaliPrivate *priv = PROFILI_PROFESSIONALI_GET_PRIVATE (profili_professionali); + + if (gtk_tree_selection_get_selected (priv->selection, NULL, &iter)) + { + dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_builder_get_object (priv->commons->gtkbuilder, "w_main")), + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_QUESTION, + GTK_BUTTONS_YES_NO, + "Sicuro di voler eliminare il profilo professionale selezionato?"); + risp = gtk_dialog_run (GTK_DIALOG (dialog)); + if (risp == GTK_RESPONSE_YES) + { + gtk_tree_model_get (GTK_TREE_MODEL (priv->lstore_profili_professionali), &iter, + COL_ID, &id, + -1); + + gdaex_execute (priv->commons->gdaex, + g_strdup_printf ("UPDATE profili_professionali SET status = 'E' WHERE id = %d", strtol (id, NULL, 10))); + + profili_professionali_carica (profili_professionali); + } + gtk_widget_destroy (dialog); + } + else + { + dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_builder_get_object (priv->commons->gtkbuilder, "w_main")), + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_WARNING, + GTK_BUTTONS_OK, + "Occorre prima selezionare un profilo professionale."); + gtk_dialog_run (GTK_DIALOG (dialog)); + gtk_widget_destroy (dialog); + } +} + +static void +profili_professionali_on_trv_profili_professionali_row_activated (GtkTreeView *tree_view, + GtkTreePath *tree_path, + GtkTreeViewColumn *column, + gpointer user_data) +{ + ProfiliProfessionaliPrivate *priv = PROFILI_PROFESSIONALI_GET_PRIVATE ((ProfiliProfessionali *)user_data); + + if (priv->selezione) + { + profili_professionali_selezionato ((ProfiliProfessionali *)user_data); + } + else + { + profili_professionali_modifica ((ProfiliProfessionali *)user_data); + } +} + +static void +profili_professionali_on_btn_annulla_clicked (GtkButton *button, + gpointer user_data) +{ + ProfiliProfessionaliPrivate *priv = PROFILI_PROFESSIONALI_GET_PRIVATE ((ProfiliProfessionali *)user_data); + + gtk_widget_destroy (priv->widget); + g_object_unref (G_OBJECT (user_data)); +} + +static void +profili_professionali_on_btn_seleziona_clicked (GtkButton *button, + gpointer user_data) +{ + profili_professionali_selezionato ((ProfiliProfessionali *)user_data); +} diff --git a/src/profiliprofessionali.h b/src/profiliprofessionali.h new file mode 100644 index 0000000..ba82451 --- /dev/null +++ b/src/profiliprofessionali.h @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2010 Andrea Zagli + * + * 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 __PROFILI_PROFESSIONALI_H__ +#define __PROFILI_PROFESSIONALI_H__ + +#include +#include + +#include +#include + +#include "commons.h" + +G_BEGIN_DECLS + + +#define TYPE_PROFILI_PROFESSIONALI (profili_professionali_get_type ()) +#define PROFILI_PROFESSIONALI(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PROFILI_PROFESSIONALI, ProfiliProfessionali)) +#define PROFILI_PROFESSIONALI_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_PROFILI_PROFESSIONALI, ProfiliProfessionaliClass)) +#define IS_PROFILI_PROFESSIONALI(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_PROFILI_PROFESSIONALI)) +#define IS_PROFILI_PROFESSIONALI_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_PROFILI_PROFESSIONALI)) +#define PROFILI_PROFESSIONALI_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_PROFILI_PROFESSIONALI, ProfiliProfessionaliClass)) + + +typedef struct _ProfiliProfessionali ProfiliProfessionali; +typedef struct _ProfiliProfessionaliClass ProfiliProfessionaliClass; + +struct _ProfiliProfessionali + { + GObject parent; + }; + +struct _ProfiliProfessionaliClass + { + GObjectClass parent_class; + + guint selezionato_signal_id; + }; + +GType profili_professionali_get_type (void) G_GNUC_CONST; + +ProfiliProfessionali *profili_professionali_new (Commons *commons, gboolean selezione); + +GtkWidget *profili_professionali_get_widget (ProfiliProfessionali *profili_professionali); + + +G_END_DECLS + +#endif /* __PROFILI_PROFESSIONALI_H__ */ diff --git a/src/profiloprofessionale.c b/src/profiloprofessionale.c new file mode 100644 index 0000000..74da9f9 --- /dev/null +++ b/src/profiloprofessionale.c @@ -0,0 +1,339 @@ +/* + * Copyright (C) 2010 Andrea Zagli + * + * 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 + * + */ + +#include +#include + +#include "profiloprofessionale.h" + +static void profilo_professionale_class_init (ProfiloProfessionaleClass *klass); +static void profilo_professionale_init (ProfiloProfessionale *profilo_professionale); + +static void profilo_professionale_carica (ProfiloProfessionale *profilo_professionale); +static void profilo_professionale_salva (ProfiloProfessionale *profilo_professionale); + +static gboolean profilo_professionale_conferma_chiusura (ProfiloProfessionale *profilo_professionale); + +static void profilo_professionale_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec); +static void profilo_professionale_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec); + +static gboolean profilo_professionale_on_w_profilo_professionale_delete_event (GtkWidget *widget, + GdkEvent *event, + gpointer user_data); + +static void profilo_professionale_on_btn_annulla_clicked (GtkButton *button, + gpointer user_data); +static void profilo_professionale_on_btn_salva_clicked (GtkButton *button, + gpointer user_data); + +#define PROFILO_PROFESSIONALE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_PROFILO_PROFESSIONALE, ProfiloProfessionalePrivate)) + +enum +{ + LBL_ID +}; + +typedef struct _ProfiloProfessionalePrivate ProfiloProfessionalePrivate; +struct _ProfiloProfessionalePrivate + { + Commons *commons; + + GtkForm *form; + + GtkWidget *w; + + GObject **objects; + + gint id; + }; + +G_DEFINE_TYPE (ProfiloProfessionale, profilo_professionale, G_TYPE_OBJECT) + +static void +profilo_professionale_class_init (ProfiloProfessionaleClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + g_type_class_add_private (object_class, sizeof (ProfiloProfessionalePrivate)); + + object_class->set_property = profilo_professionale_set_property; + object_class->get_property = profilo_professionale_get_property; + + /** + * ProfiloProfessionale::aggiornato: + * @profilo_professionale: + * + */ + 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 +profilo_professionale_init (ProfiloProfessionale *profilo_professionale) +{ + ProfiloProfessionalePrivate *priv = PROFILO_PROFESSIONALE_GET_PRIVATE (profilo_professionale); +} + +/** + * profilo_professionale_new: + * @commons: + * @id: + * + * Returns: the newly created #ProfiloProfessionale object. + */ +ProfiloProfessionale +*profilo_professionale_new (Commons *commons, gint id) +{ + GError *error; + + ProfiloProfessionale *a = PROFILO_PROFESSIONALE (g_object_new (profilo_professionale_get_type (), NULL)); + + ProfiloProfessionalePrivate *priv = PROFILO_PROFESSIONALE_GET_PRIVATE (a); + + priv->commons = commons; + + error = NULL; + gtk_builder_add_objects_from_file (priv->commons->gtkbuilder, priv->commons->guifile, + g_strsplit ("w_profilo_professionale", "|", -1), + &error); + if (error != NULL) + { + g_warning ("Errore: %s.", error->message); + return NULL; + } + + priv->form = gtk_form_new_from_file (g_build_filename (priv->commons->formdir, "profilo_professionale.form", NULL), priv->commons->gtkbuilder); + + g_object_set (priv->form, "gdaex", priv->commons->gdaex, NULL); + + priv->w = GTK_WIDGET (gtk_builder_get_object (priv->commons->gtkbuilder, "w_profilo_professionale")); + + priv->objects = gtk_form_get_objects_by_name (priv->form, + "label157", + NULL); + + g_signal_connect (priv->w, + "delete-event", G_CALLBACK (profilo_professionale_on_w_profilo_professionale_delete_event), (gpointer *)a); + + g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button135"), + "clicked", G_CALLBACK (profilo_professionale_on_btn_annulla_clicked), (gpointer *)a); + g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button136"), + "clicked", G_CALLBACK (profilo_professionale_on_btn_salva_clicked), (gpointer *)a); + + priv->id = id; + + if (priv->id == 0) + { + gtk_label_set_text (GTK_LABEL (priv->objects[LBL_ID]), ""); + + gtk_form_set_as_origin (priv->form); + } + else + { + gtk_label_set_text (GTK_LABEL (priv->objects[LBL_ID]), g_strdup_printf ("%d", priv->id)); + profilo_professionale_carica (a); + } + + return a; +} + +/** + * profilo_professionale_get_widget: + * @profilo_professionale: + * + */ +GtkWidget +*profilo_professionale_get_widget (ProfiloProfessionale *profilo_professionale) +{ + ProfiloProfessionalePrivate *priv = PROFILO_PROFESSIONALE_GET_PRIVATE (profilo_professionale); + + return priv->w; +} + +/* PRIVATE */ +static void +profilo_professionale_carica (ProfiloProfessionale *profilo_professionale) +{ + ProfiloProfessionalePrivate *priv = PROFILO_PROFESSIONALE_GET_PRIVATE (profilo_professionale); + + if (gtk_form_fill_from_table (priv->form)) + { + } +} + +static void +profilo_professionale_salva (ProfiloProfessionale *profilo_professionale) +{ + GError *error = NULL; + gchar *sql; + GtkWidget *dialog; + + GDate *da; + GDate *a; + + ProfiloProfessionaleClass *klass = PROFILO_PROFESSIONALE_GET_CLASS (profilo_professionale); + + ProfiloProfessionalePrivate *priv = PROFILO_PROFESSIONALE_GET_PRIVATE (profilo_professionale); + + if (!gtk_form_check (priv->form, (priv->id != 0), 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 (profilo_professionale, klass->aggiornato_signal_id, 0); + + gtk_form_set_as_origin (priv->form); + + if (priv->id == 0) + { + priv->id = strtol (gtk_label_get_text (GTK_LABEL (priv->objects[LBL_ID])), NULL, 10); + } + + 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 + { + if (priv->id == 0) + { + gtk_label_set_text (GTK_LABEL (priv->objects[LBL_ID]), ""); + } + + 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 +profilo_professionale_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) +{ + ProfiloProfessionale *profilo_professionale = PROFILO_PROFESSIONALE (object); + + ProfiloProfessionalePrivate *priv = PROFILO_PROFESSIONALE_GET_PRIVATE (profilo_professionale); + + switch (property_id) + { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + +static void +profilo_professionale_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) +{ + ProfiloProfessionale *profilo_professionale = PROFILO_PROFESSIONALE (object); + + ProfiloProfessionalePrivate *priv = PROFILO_PROFESSIONALE_GET_PRIVATE (profilo_professionale); + + switch (property_id) + { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + +static gboolean +profilo_professionale_conferma_chiusura (ProfiloProfessionale *profilo_professionale) +{ + GtkWidget *dialog; + + gboolean ret; + + ProfiloProfessionalePrivate *priv = PROFILO_PROFESSIONALE_GET_PRIVATE (profilo_professionale); + + 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 +profilo_professionale_on_w_profilo_professionale_delete_event (GtkWidget *widget, + GdkEvent *event, + gpointer user_data) +{ + return !profilo_professionale_conferma_chiusura ((ProfiloProfessionale *)user_data); +} + +static void +profilo_professionale_on_btn_annulla_clicked (GtkButton *button, + gpointer user_data) +{ + ProfiloProfessionale *profilo_professionale = (ProfiloProfessionale *)user_data; + + ProfiloProfessionalePrivate *priv = PROFILO_PROFESSIONALE_GET_PRIVATE (profilo_professionale); + + if (profilo_professionale_conferma_chiusura (profilo_professionale)) gtk_widget_destroy (priv->w); +} + +static void +profilo_professionale_on_btn_salva_clicked (GtkButton *button, + gpointer user_data) +{ + profilo_professionale_salva ((ProfiloProfessionale *)user_data); +} diff --git a/src/profiloprofessionale.h b/src/profiloprofessionale.h new file mode 100644 index 0000000..38ca3f4 --- /dev/null +++ b/src/profiloprofessionale.h @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2010 Andrea Zagli + * + * 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 __PROFILO_PROFESSIONALE_H__ +#define __PROFILO_PROFESSIONALE_H__ + +#include +#include + +#include +#include + +#include "commons.h" + +G_BEGIN_DECLS + + +#define TYPE_PROFILO_PROFESSIONALE (profilo_professionale_get_type ()) +#define PROFILO_PROFESSIONALE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PROFILO_PROFESSIONALE, ProfiloProfessionale)) +#define PROFILO_PROFESSIONALE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_PROFILO_PROFESSIONALE, ProfiloProfessionaleClass)) +#define IS_PROFILO_PROFESSIONALE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_PROFILO_PROFESSIONALE)) +#define IS_PROFILO_PROFESSIONALE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_PROFILO_PROFESSIONALE)) +#define PROFILO_PROFESSIONALE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_PROFILO_PROFESSIONALE, ProfiloProfessionaleClass)) + + +typedef struct _ProfiloProfessionale ProfiloProfessionale; +typedef struct _ProfiloProfessionaleClass ProfiloProfessionaleClass; + +struct _ProfiloProfessionale + { + GObject parent; + }; + +struct _ProfiloProfessionaleClass + { + GObjectClass parent_class; + + guint aggiornato_signal_id; + }; + +GType profilo_professionale_get_type (void) G_GNUC_CONST; + +ProfiloProfessionale *profilo_professionale_new (Commons *commons, gint id); + +GtkWidget *profilo_professionale_get_widget (ProfiloProfessionale *profilo_professionale); + + +G_END_DECLS + +#endif /* __PROFILO_PROFESSIONALE_H__ */ -- 2.49.0