]> saetta.ns0.it Git - solipa/organigramma/commitdiff
Aggiunta e gestita la tabella ruoli (refs #595).
authorAndrea Zagli <a.zagli@comune.scandicci.fi.it>
Wed, 29 May 2013 08:55:20 +0000 (10:55 +0200)
committerAndrea Zagli <a.zagli@comune.scandicci.fi.it>
Wed, 29 May 2013 08:55:20 +0000 (10:55 +0200)
data/organigramma/form/Makefile.am
data/organigramma/form/ruolo.form [new file with mode: 0644]
data/organigramma/gui/organigramma.gui
docs/DBChangelog
docs/organigramma.sql
src/Makefile.am
src/main.c
src/ruoli.c [new file with mode: 0644]
src/ruoli.h [new file with mode: 0644]
src/ruolo.c [new file with mode: 0644]
src/ruolo.h [new file with mode: 0644]

index 72cf39c2ca27a48bec5fa3141ea040c8ab13c9fb..793f5e29f57d19d127f087ff197cabef33296c8e 100644 (file)
@@ -11,6 +11,7 @@ form_DATA = \
             persona_ufficio_recapito.form \
             posizione_economica.form \
             profilo_professionale.form \
+            ruolo.form \
             struttura.form \
             struttura_indirizzo.form \
             tipo_nodo.form \
diff --git a/data/organigramma/form/ruolo.form b/data/organigramma/form/ruolo.form
new file mode 100644 (file)
index 0000000..864936c
--- /dev/null
@@ -0,0 +1,19 @@
+<?xml version="1.0"?>
+<gtkform>
+
+       <table>ruoli</table>
+
+       <widget type="label" name="label175" label="label176">
+               <field type="integer" name="id">
+                       <is-key>t</is-key>
+                       <auto-increment>t</auto-increment>
+               </field>
+       </widget>
+
+       <widget type="entry" name="entry49" label="label174">
+               <field type="text" name="nome">
+                       <obligatory>t</obligatory>
+               </field>
+       </widget>
+
+</gtkform>
index 07280953bbf47b3ca0c5e240f5d8234b57666edf..829b297efd75ff42af6852733b335d55ea81a7ce 100644 (file)
       <column type="gchararray"/>
     </columns>
   </object>
+  <object class="GtkListStore" id="lstore_ruoli">
+    <columns>
+      <!-- column-name id -->
+      <column type="guint"/>
+      <!-- column-name nome -->
+      <column type="gchararray"/>
+    </columns>
+  </object>
   <object class="GtkListStore" id="lstore_struttura_indirizzi">
     <columns>
       <!-- column-name id -->
       <column type="guint"/>
       <!-- column-name nome -->
       <column type="gchararray"/>
+      <!-- column-name da_data -->
+      <column type="gchararray"/>
+      <!-- column-name a_data -->
+      <column type="gchararray"/>
     </columns>
   </object>
   <object class="GtkListStore" id="lstore_ufficio_recapiti">
                         <signal name="activate" handler="on_mnu_tabelle_titoli_activate" swapped="no"/>
                       </object>
                     </child>
+                    <child>
+                      <object class="GtkMenuItem" id="menuitem16">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="label" translatable="yes">Ru_oli</property>
+                        <property name="use_underline">True</property>
+                        <signal name="activate" handler="on_mnu_tabelle_ruoli_activate" swapped="no"/>
+                      </object>
+                    </child>
                     <child>
                       <object class="GtkMenuItem" id="menuitem12">
                         <property name="visible">True</property>
       </object>
     </child>
   </object>
+  <object class="GtkWindow" id="w_ruoli">
+    <property name="can_focus">False</property>
+    <property name="title" translatable="yes">Ruoli - Gestione organigramma</property>
+    <property name="modal">True</property>
+    <property name="window_position">center-on-parent</property>
+    <property name="default_width">500</property>
+    <property name="default_height">400</property>
+    <property name="destroy_with_parent">True</property>
+    <child>
+      <object class="GtkVBox" id="vbx_ruoli">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="border_width">5</property>
+        <property name="spacing">5</property>
+        <child>
+          <object class="GtkLabel" id="label86">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes">&lt;b&gt;Ruoli&lt;/b&gt;</property>
+            <property name="use_markup">True</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkScrolledWindow" id="scrolledwindow42">
+            <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="GtkTreeView" id="treeview8">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="model">lstore_ruoli</property>
+                <property name="headers_clickable">False</property>
+                <property name="rules_hint">True</property>
+                <property name="search_column">1</property>
+                <child>
+                  <object class="GtkTreeViewColumn" id="treeviewcolumn41">
+                    <property name="title">Nome</property>
+                    <child>
+                      <object class="GtkCellRendererText" id="cellrenderertext52"/>
+                      <attributes>
+                        <attribute name="text">1</attribute>
+                      </attributes>
+                    </child>
+                  </object>
+                </child>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkHButtonBox" id="hbuttonbox13">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="spacing">5</property>
+            <property name="layout_style">end</property>
+            <child>
+              <object class="GtkButton" id="button52">
+                <property name="label">gtk-new</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_stock">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="button53">
+                <property name="label">gtk-edit</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_stock">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="button168">
+                <property name="label">gtk-delete</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_stock">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">2</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="button169">
+                <property name="label">gtk-cancel</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_stock">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">3</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="button170">
+                <property name="label">gtk-ok</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_stock">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">4</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">2</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+  </object>
+  <object class="GtkWindow" id="w_ruolo">
+    <property name="can_focus">False</property>
+    <property name="title" translatable="yes">Ruolo - Gestione organigramma</property>
+    <property name="modal">True</property>
+    <property name="window_position">center-on-parent</property>
+    <property name="destroy_with_parent">True</property>
+    <child>
+      <object class="GtkVBox" id="vbox26">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="border_width">5</property>
+        <property name="spacing">5</property>
+        <child>
+          <object class="GtkTable" id="table25">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="n_rows">2</property>
+            <property name="n_columns">2</property>
+            <property name="column_spacing">5</property>
+            <property name="row_spacing">5</property>
+            <child>
+              <object class="GtkLabel" id="label174">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="xalign">0</property>
+                <property name="label" translatable="yes">Nome</property>
+              </object>
+              <packing>
+                <property name="top_attach">1</property>
+                <property name="bottom_attach">2</property>
+                <property name="x_options">GTK_FILL</property>
+                <property name="y_options">GTK_FILL</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkEntry" id="entry49">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="max_length">100</property>
+                <property name="invisible_char">●</property>
+                <property name="invisible_char_set">True</property>
+                <property name="primary_icon_activatable">False</property>
+                <property name="secondary_icon_activatable">False</property>
+                <property name="primary_icon_sensitive">True</property>
+                <property name="secondary_icon_sensitive">True</property>
+              </object>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="right_attach">2</property>
+                <property name="top_attach">1</property>
+                <property name="bottom_attach">2</property>
+                <property name="y_options">GTK_FILL</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="label175">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="xalign">0</property>
+                <property name="label" translatable="yes">lbl_id</property>
+              </object>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="right_attach">2</property>
+                <property name="x_options">GTK_FILL</property>
+                <property name="y_options">GTK_FILL</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="label176">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="xalign">0</property>
+                <property name="label" translatable="yes">ID</property>
+              </object>
+              <packing>
+                <property name="x_options">GTK_FILL</property>
+                <property name="y_options">GTK_FILL</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkHButtonBox" id="hbuttonbox35">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="spacing">5</property>
+            <property name="layout_style">end</property>
+            <child>
+              <object class="GtkButton" id="button171">
+                <property name="label">gtk-cancel</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_stock">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="button172">
+                <property name="label">gtk-save</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_stock">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="button173">
+                <property name="label" translatable="yes">Salva e _chiudi</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_underline">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">2</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+  </object>
   <object class="GtkWindow" id="w_struttura">
     <property name="can_focus">False</property>
     <property name="title" translatable="yes">Struttura - Gestione organigramma</property>
                                 </child>
                               </object>
                             </child>
+                            <child>
+                              <object class="GtkTreeViewColumn" id="treeviewcolumn10">
+                                <property name="title" translatable="yes">Da data</property>
+                                <child>
+                                  <object class="GtkCellRendererText" id="cellrenderertext12"/>
+                                  <attributes>
+                                    <attribute name="text">2</attribute>
+                                  </attributes>
+                                </child>
+                              </object>
+                            </child>
+                            <child>
+                              <object class="GtkTreeViewColumn" id="treeviewcolumn39">
+                                <property name="title" translatable="yes">A data</property>
+                                <child>
+                                  <object class="GtkCellRendererText" id="cellrenderertext50"/>
+                                  <attributes>
+                                    <attribute name="text">3</attribute>
+                                  </attributes>
+                                </child>
+                              </object>
+                            </child>
                           </object>
                         </child>
                       </object>
index 56bf0dbcf1df48f991ee57e419f65bf6645b3b77..27da7a1e42631e0dcbca089c78aa41abe9bcd8c8 100644 (file)
@@ -5,3 +5,11 @@ ALTER TABLE uffici ADD COLUMN id_uffici integer DEFAULT 0;
 ALTER TABLE tipi_nodo ADD COLUMN graphviz text DEFAULT '';
 
 ALTER TABLE tipi_nodo ADD COLUMN graphviz_connessione text DEFAULT '';
+
+CREATE TABLE ruoli
+(
+       id integer NOT NULL,
+       nome character varying(255) DEFAULT '',
+       status character varying(1) DEFAULT '',
+       CONSTRAINT ruoli_pkey PRIMARY KEY (id)
+);
\ No newline at end of file
index c635f23534689186237d5719d118207b59fe9165..2fb76b06a351d4e44a9130a476b6043d569772d1 100644 (file)
@@ -4,7 +4,7 @@
 
 -- Dumped from database version 8.4.17
 -- Dumped by pg_dump version 9.2.2
--- Started on 2013-05-29 10:22:36
+-- Started on 2013-05-29 10:39:38
 
 SET statement_timeout = 0;
 SET client_encoding = 'UTF8';
@@ -14,7 +14,7 @@ SET client_min_messages = warning;
 SET escape_string_warning = off;
 
 --
--- TOC entry 539 (class 2612 OID 16386)
+-- TOC entry 543 (class 2612 OID 16386)
 -- Name: plpgsql; Type: PROCEDURAL LANGUAGE; Schema: -; Owner: -
 --
 
@@ -189,6 +189,18 @@ CREATE TABLE profili_professionali (
 );
 
 
+--
+-- TOC entry 162 (class 1259 OID 618182)
+-- Name: ruoli; Type: TABLE; Schema: public; Owner: -
+--
+
+CREATE TABLE ruoli (
+    id integer NOT NULL,
+    nome character varying(255) DEFAULT ''::character varying,
+    status character varying(1) DEFAULT ''::character varying
+);
+
+
 --
 -- TOC entry 145 (class 1259 OID 59346)
 -- Name: struttura_indirizzi; Type: TABLE; Schema: public; Owner: -
@@ -371,7 +383,7 @@ CREATE TABLE ufficio_stanze (
 
 
 --
--- TOC entry 1963 (class 2606 OID 59289)
+-- TOC entry 1969 (class 2606 OID 59289)
 -- Name: nodi_pkey; Type: CONSTRAINT; Schema: public; Owner: -
 --
 
@@ -380,7 +392,7 @@ ALTER TABLE ONLY nodi
 
 
 --
--- TOC entry 2003 (class 2606 OID 61360)
+-- TOC entry 2009 (class 2606 OID 61360)
 -- Name: persona_incarichi_pkey; Type: CONSTRAINT; Schema: public; Owner: -
 --
 
@@ -389,7 +401,7 @@ ALTER TABLE ONLY persona_incarichi
 
 
 --
--- TOC entry 1993 (class 2606 OID 61305)
+-- TOC entry 1999 (class 2606 OID 61305)
 -- Name: persona_nodi_pkey; Type: CONSTRAINT; Schema: public; Owner: -
 --
 
@@ -398,7 +410,7 @@ ALTER TABLE ONLY persona_nodi
 
 
 --
--- TOC entry 1995 (class 2606 OID 61321)
+-- TOC entry 2001 (class 2606 OID 61321)
 -- Name: persona_nodo_recapiti_pkey; Type: CONSTRAINT; Schema: public; Owner: -
 --
 
@@ -407,7 +419,7 @@ ALTER TABLE ONLY persona_nodo_recapiti
 
 
 --
--- TOC entry 1989 (class 2606 OID 61279)
+-- TOC entry 1995 (class 2606 OID 61279)
 -- Name: persona_recapiti_pkey; Type: CONSTRAINT; Schema: public; Owner: -
 --
 
@@ -416,7 +428,7 @@ ALTER TABLE ONLY persona_recapiti
 
 
 --
--- TOC entry 1987 (class 2606 OID 61252)
+-- TOC entry 1993 (class 2606 OID 61252)
 -- Name: persona_uffici_pkey; Type: CONSTRAINT; Schema: public; Owner: -
 --
 
@@ -425,7 +437,7 @@ ALTER TABLE ONLY persona_uffici
 
 
 --
--- TOC entry 1991 (class 2606 OID 61294)
+-- TOC entry 1997 (class 2606 OID 61294)
 -- Name: persona_ufficio_recapiti_pkey; Type: CONSTRAINT; Schema: public; Owner: -
 --
 
@@ -434,7 +446,7 @@ ALTER TABLE ONLY persona_ufficio_recapiti
 
 
 --
--- TOC entry 1983 (class 2606 OID 61235)
+-- TOC entry 1989 (class 2606 OID 61235)
 -- Name: persone_pkey; Type: CONSTRAINT; Schema: public; Owner: -
 --
 
@@ -443,7 +455,7 @@ ALTER TABLE ONLY persone
 
 
 --
--- TOC entry 1997 (class 2606 OID 61328)
+-- TOC entry 2003 (class 2606 OID 61328)
 -- Name: posizioni_economiche_pkey; Type: CONSTRAINT; Schema: public; Owner: -
 --
 
@@ -452,7 +464,7 @@ ALTER TABLE ONLY posizioni_economiche
 
 
 --
--- TOC entry 2001 (class 2606 OID 61342)
+-- TOC entry 2007 (class 2606 OID 61342)
 -- Name: profili_professionali_pkey; Type: CONSTRAINT; Schema: public; Owner: -
 --
 
@@ -461,7 +473,16 @@ ALTER TABLE ONLY profili_professionali
 
 
 --
--- TOC entry 1973 (class 2606 OID 59356)
+-- TOC entry 2013 (class 2606 OID 618188)
+-- Name: ruoli_pkey; Type: CONSTRAINT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY ruoli
+    ADD CONSTRAINT ruoli_pkey PRIMARY KEY (id);
+
+
+--
+-- TOC entry 1979 (class 2606 OID 59356)
 -- Name: struttura_indirizzi_pkey; Type: CONSTRAINT; Schema: public; Owner: -
 --
 
@@ -470,7 +491,7 @@ ALTER TABLE ONLY struttura_indirizzi
 
 
 --
--- TOC entry 1971 (class 2606 OID 59339)
+-- TOC entry 1977 (class 2606 OID 59339)
 -- Name: strutture_pkey; Type: CONSTRAINT; Schema: public; Owner: -
 --
 
@@ -479,7 +500,7 @@ ALTER TABLE ONLY strutture
 
 
 --
--- TOC entry 1965 (class 2606 OID 59296)
+-- TOC entry 1971 (class 2606 OID 59296)
 -- Name: tipi_nodo_pkey; Type: CONSTRAINT; Schema: public; Owner: -
 --
 
@@ -488,7 +509,7 @@ ALTER TABLE ONLY tipi_nodo
 
 
 --
--- TOC entry 1999 (class 2606 OID 61335)
+-- TOC entry 2005 (class 2606 OID 61335)
 -- Name: tipi_prestazione_pkey; Type: CONSTRAINT; Schema: public; Owner: -
 --
 
@@ -497,7 +518,7 @@ ALTER TABLE ONLY tipi_prestazione
 
 
 --
--- TOC entry 1985 (class 2606 OID 61242)
+-- TOC entry 1991 (class 2606 OID 61242)
 -- Name: tipi_rapporto_lavoro_pkey; Type: CONSTRAINT; Schema: public; Owner: -
 --
 
@@ -506,7 +527,7 @@ ALTER TABLE ONLY tipi_rapporto_lavoro
 
 
 --
--- TOC entry 1967 (class 2606 OID 59303)
+-- TOC entry 1973 (class 2606 OID 59303)
 -- Name: tipi_recapito_pkey; Type: CONSTRAINT; Schema: public; Owner: -
 --
 
@@ -515,7 +536,7 @@ ALTER TABLE ONLY tipi_recapito
 
 
 --
--- TOC entry 1981 (class 2606 OID 61226)
+-- TOC entry 1987 (class 2606 OID 61226)
 -- Name: titoli_pkey; Type: CONSTRAINT; Schema: public; Owner: -
 --
 
@@ -524,7 +545,7 @@ ALTER TABLE ONLY titoli
 
 
 --
--- TOC entry 1969 (class 2606 OID 59321)
+-- TOC entry 1975 (class 2606 OID 59321)
 -- Name: uffici_pkey; Type: CONSTRAINT; Schema: public; Owner: -
 --
 
@@ -533,7 +554,7 @@ ALTER TABLE ONLY uffici
 
 
 --
--- TOC entry 1975 (class 2606 OID 59366)
+-- TOC entry 1981 (class 2606 OID 59366)
 -- Name: ufficio_nodi_pkey; Type: CONSTRAINT; Schema: public; Owner: -
 --
 
@@ -542,7 +563,7 @@ ALTER TABLE ONLY ufficio_nodi
 
 
 --
--- TOC entry 1977 (class 2606 OID 59408)
+-- TOC entry 1983 (class 2606 OID 59408)
 -- Name: ufficio_orari_pkey; Type: CONSTRAINT; Schema: public; Owner: -
 --
 
@@ -551,7 +572,7 @@ ALTER TABLE ONLY ufficio_orari
 
 
 --
--- TOC entry 1979 (class 2606 OID 59419)
+-- TOC entry 1985 (class 2606 OID 59419)
 -- Name: ufficio_recapiti_pkey; Type: CONSTRAINT; Schema: public; Owner: -
 --
 
@@ -560,7 +581,7 @@ ALTER TABLE ONLY ufficio_recapiti
 
 
 --
--- TOC entry 2005 (class 2606 OID 61430)
+-- TOC entry 2011 (class 2606 OID 61430)
 -- Name: ufficio_stanze_pkey; Type: CONSTRAINT; Schema: public; Owner: -
 --
 
@@ -568,7 +589,7 @@ ALTER TABLE ONLY ufficio_stanze
     ADD CONSTRAINT ufficio_stanze_pkey PRIMARY KEY (id);
 
 
--- Completed on 2013-05-29 10:22:37
+-- Completed on 2013-05-29 10:39:39
 
 --
 -- PostgreSQL database dump complete
index a0560485c851778ea603dd667c03dd87d8244060..478ecba85964e429ef7b9702638738487086d13a 100644 (file)
@@ -55,6 +55,10 @@ organigramma_SOURCES = \
                 profiliprofessionali.h \
                 profiloprofessionale.c \
                 profiloprofessionale.h \
+                ruoli.c \
+                ruoli.h \
+                ruolo.c \
+                ruolo.h \
                 struttura.c \
                 struttura.h \
                 strutturaindirizzo.c \
index fee24dae54b5c0f66cfc80abc0f53a70446b0f4f..6b7f151b17a8f8d82c53a2e657a1274cb8ddd81c 100644 (file)
@@ -34,6 +34,7 @@
 #include "persone.h"
 #include "posizionieconomiche.h"
 #include "profiliprofessionali.h"
+#include "ruoli.h"
 #include "strutture.h"
 #include "tipinodo.h"
 #include "tipiprestazione.h"
@@ -154,6 +155,19 @@ on_mnu_tabelle_titoli_activate (GtkMenuItem *menuitem,
        main_set_vbx_body_child (vbx);
 }
 
+G_MODULE_EXPORT void
+on_mnu_tabelle_ruoli_activate (GtkMenuItem *menuitem,
+                            gpointer user_data)
+{
+       GtkWidget *vbx;
+
+       OrganigrammaRuoli *m = organigramma_ruoli_new (commons, FALSE);
+
+       vbx = organigramma_ruoli_get_widget (m);
+
+       main_set_vbx_body_child (vbx);
+}
+
 G_MODULE_EXPORT void
 on_mnu_tabelle_tipi_rapporto_lavoro_activate (GtkMenuItem *menuitem,
                             gpointer user_data)
diff --git a/src/ruoli.c b/src/ruoli.c
new file mode 100644 (file)
index 0000000..1be0cf8
--- /dev/null
@@ -0,0 +1,440 @@
+/* 
+ * Copyright (C) 2013 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
+ *
+ */
+
+#include <libautoz/autoz.h>
+#include <libsolipa/utils.h>
+
+#include "ruoli.h"
+#include "ruolo.h"
+
+static void organigramma_ruoli_class_init (OrganigrammaRuoliClass *klass);
+static void organigramma_ruoli_init (OrganigrammaRuoli *ruoli);
+
+static void organigramma_ruoli_carica (OrganigrammaRuoli *ruoli);
+static void organigramma_ruoli_modifica (OrganigrammaRuoli *ruoli);
+
+static void organigramma_ruoli_selezionato (OrganigrammaRuoli *ruoli);
+static void organigramma_ruoli_on_costo_aggiornato (gpointer instance, gpointer user_data);
+
+static void organigramma_ruoli_set_property (GObject *object,
+                                     guint property_id,
+                                     const GValue *value,
+                                     GParamSpec *pspec);
+static void organigramma_ruoli_get_property (GObject *object,
+                                     guint property_id,
+                                     GValue *value,
+                                     GParamSpec *pspec);
+
+static void organigramma_ruoli_on_btn_nuovo_clicked (GtkButton *button,
+                      gpointer user_data);
+static void organigramma_ruoli_on_btn_modifica_clicked (GtkButton *button,
+                      gpointer user_data);
+static void organigramma_ruoli_on_btn_elimina_clicked (GtkButton *button,
+                        gpointer user_data);
+static void organigramma_ruoli_on_trv_organigramma_ruoli_row_activated (GtkTreeView *tree_view,
+                                             GtkTreePath *tree_path,
+                                             GtkTreeViewColumn *column,
+                                             gpointer user_data);
+
+static void organigramma_ruoli_on_btn_annulla_clicked (GtkButton *button,
+                                    gpointer user_data);
+static void organigramma_ruoli_on_btn_seleziona_clicked (GtkButton *button,
+                                  gpointer user_data);
+
+#define ORGANIGRAMMA_RUOLI_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_ORGANIGRAMMA_RUOLI, OrganigrammaRuoliPrivate))
+
+enum
+{
+       COL_ID,
+       COL_NOME
+};
+
+typedef struct _OrganigrammaRuoliPrivate OrganigrammaRuoliPrivate;
+struct _OrganigrammaRuoliPrivate
+       {
+               OrganigrammaCommons *commons;
+
+               GtkWidget *widget;
+               GtkTreeSelection *selection;
+               GtkListStore *lstore_ruoli;
+
+               gboolean selezione;
+               GtkWindow *wtransient;
+       };
+
+G_DEFINE_TYPE (OrganigrammaRuoli, organigramma_ruoli, G_TYPE_OBJECT)
+
+static void
+organigramma_ruoli_class_init (OrganigrammaRuoliClass *klass)
+{
+       GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+       g_type_class_add_private (object_class, sizeof (OrganigrammaRuoliPrivate));
+
+       object_class->set_property = organigramma_ruoli_set_property;
+       object_class->get_property = organigramma_ruoli_get_property;
+
+       /**
+        * OrganigrammaRuoli::selezionato:
+        * @ruoli:
+        *
+        */
+       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
+organigramma_ruoli_init (OrganigrammaRuoli *ruoli)
+{
+       OrganigrammaRuoliPrivate *priv = ORGANIGRAMMA_RUOLI_GET_PRIVATE (ruoli);
+}
+
+/**
+ * organigramma_ruoli_new:
+ * @commons:
+ * @selezione:
+ *
+ * Returns: the newly created #OrganigrammaRuoli object.
+ */
+OrganigrammaRuoli
+*organigramma_ruoli_new (OrganigrammaCommons *commons, gboolean selezione)
+{
+       GError *error;
+       AutozIResource *ires1;
+
+       OrganigrammaRuoli *a = ORGANIGRAMMA_RUOLI (g_object_new (organigramma_ruoli_get_type (), NULL));
+
+       OrganigrammaRuoliPrivate *priv = ORGANIGRAMMA_RUOLI_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_ruoli|",
+                                          (selezione ? "w_ruoli" : "vbx_ruoli"),
+                                          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_ruoli" : "vbx_ruoli")));
+       priv->selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (gtk_builder_get_object (priv->commons->gtkbuilder, "treeview8")));
+       priv->lstore_ruoli = GTK_LIST_STORE (gtk_builder_get_object (priv->commons->gtkbuilder, "lstore_ruoli"));
+
+       if (priv->selezione)
+               {
+                       priv->wtransient = GTK_WINDOW (priv->widget);
+               }
+       else
+               {
+                       priv->wtransient = GTK_WINDOW (gtk_builder_get_object (priv->commons->gtkbuilder, "w_main"));
+               }
+
+       g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button52"),
+                         "clicked", G_CALLBACK (organigramma_ruoli_on_btn_nuovo_clicked), (gpointer)a);
+       g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button53"),
+                         "clicked", G_CALLBACK (organigramma_ruoli_on_btn_modifica_clicked), (gpointer)a);
+       g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button168"),
+                         "clicked", G_CALLBACK (organigramma_ruoli_on_btn_elimina_clicked), (gpointer)a);
+       g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "treeview8"),
+                         "row-activated", G_CALLBACK (organigramma_ruoli_on_trv_organigramma_ruoli_row_activated), (gpointer)a);
+
+       if (priv->selezione)
+               {
+                       gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (priv->commons->gtkbuilder, "label86")));
+                       g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button169"),
+                                         "clicked", G_CALLBACK (organigramma_ruoli_on_btn_annulla_clicked), (gpointer)a);
+                       g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button170"),
+                                         "clicked", G_CALLBACK (organigramma_ruoli_on_btn_seleziona_clicked), (gpointer)a);
+               }
+       else
+               {
+                       gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (priv->commons->gtkbuilder, "button169")));
+                       gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (priv->commons->gtkbuilder, "button170")));
+               }
+
+       organigramma_ruoli_carica (a);
+
+       ires1 = autoz_get_resource_from_id (priv->commons->autoz, "organigramma_rw");
+       if (!autoz_is_allowed (priv->commons->autoz, priv->commons->role_utente, ires1, FALSE))
+               {
+                       gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (commons->gtkbuilder, "button52")), FALSE);
+                       gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (commons->gtkbuilder, "button168")), FALSE);
+               }
+
+       return a;
+}
+
+/**
+ * organigramma_ruoli_get_widget:
+ * @ruoli:
+ *
+ */
+GtkWidget
+*organigramma_ruoli_get_widget (OrganigrammaRuoli *ruoli)
+{
+       OrganigrammaRuoliPrivate *priv = ORGANIGRAMMA_RUOLI_GET_PRIVATE (ruoli);
+
+       return priv->widget;
+}
+
+/* PRIVATE */
+static void
+organigramma_ruoli_carica (OrganigrammaRuoli *ruoli)
+{
+       GtkTreeIter iter;
+
+       gchar *sql;
+       GdaDataModel *dm;
+
+       gint rows;
+       gint row;
+
+       OrganigrammaRuoliPrivate *priv = ORGANIGRAMMA_RUOLI_GET_PRIVATE (ruoli);
+
+       gtk_list_store_clear (priv->lstore_ruoli);
+
+       sql = g_strdup_printf ("SELECT c.id, c.nome"
+                              " FROM ruoli AS c"
+                              " WHERE c.status <> 'E'"
+                              " ORDER BY c.nome");
+       dm = gdaex_query (priv->commons->gdaex, sql);
+       g_free (sql);
+       if (dm != NULL)
+               {
+                       rows = gda_data_model_get_n_rows (dm);
+                       for (row = 0; row < rows; row++)
+                               {
+                                       gtk_list_store_append (priv->lstore_ruoli, &iter);
+                                       gtk_list_store_set (priv->lstore_ruoli, &iter,
+                                                           COL_ID, gdaex_data_model_get_field_value_integer_at (dm, row, "id"),
+                                                           COL_NOME, gdaex_data_model_get_field_value_stringify_at (dm, row, "nome"),
+                                                           -1);
+                               }
+
+                       g_object_unref (dm);
+               }
+}
+
+static void
+organigramma_ruoli_modifica (OrganigrammaRuoli *ruoli)
+{
+       GtkTreeIter iter;
+       guint id;
+
+       OrganigrammaRuoliPrivate *priv = ORGANIGRAMMA_RUOLI_GET_PRIVATE (ruoli);
+
+       if (gtk_tree_selection_get_selected (priv->selection, NULL, &iter))
+               {
+                       GtkWidget *w;
+
+                       gtk_tree_model_get (GTK_TREE_MODEL (priv->lstore_ruoli), &iter,
+                                           COL_ID, &id,
+                                           -1);
+
+                       OrganigrammaRuolo *c = organigramma_ruolo_new (priv->commons, id);
+
+                       g_signal_connect (G_OBJECT (c), "aggiornato",
+                                         G_CALLBACK (organigramma_ruoli_on_costo_aggiornato), (gpointer)ruoli);
+
+                       w = organigramma_ruolo_get_widget (c);
+                       gtk_window_set_transient_for (GTK_WINDOW (w), GTK_WINDOW (priv->wtransient));
+                       gtk_widget_show (w);
+               }
+       else
+               {
+                       solipa_message_dialog (GTK_WIDGET (priv->wtransient),
+                                              GTK_MESSAGE_WARNING,
+                                              GTK_BUTTONS_OK,
+                                              "Occorre prima selezionare un ruolo.");
+               }
+}
+
+static void
+organigramma_ruoli_selezionato (OrganigrammaRuoli *ruoli)
+{
+       GtkTreeIter iter;
+       guint id;
+
+       OrganigrammaRuoliClass *klass = ORGANIGRAMMA_RUOLI_GET_CLASS (ruoli);
+       OrganigrammaRuoliPrivate *priv = ORGANIGRAMMA_RUOLI_GET_PRIVATE (ruoli);
+
+       if (gtk_tree_selection_get_selected (priv->selection, NULL, &iter))
+               {
+                       gtk_tree_model_get (GTK_TREE_MODEL (priv->lstore_ruoli), &iter,
+                                           COL_ID, &id,
+                                           -1);
+
+                       g_signal_emit (G_OBJECT (ruoli), klass->selezionato_signal_id, 0, id);
+
+                       gtk_widget_destroy (priv->widget);
+                       g_object_unref (G_OBJECT (ruoli));
+               }
+       else
+               {
+                       solipa_message_dialog (GTK_WIDGET (priv->wtransient),
+                                              GTK_MESSAGE_WARNING,
+                                              GTK_BUTTONS_OK,
+                                              "Occorre prima selezionare un ruolo.");
+               }
+}
+
+static void
+organigramma_ruoli_on_costo_aggiornato (gpointer instance, gpointer user_data)
+{
+       organigramma_ruoli_carica ((OrganigrammaRuoli *)user_data);
+}
+
+static void
+organigramma_ruoli_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
+{
+       OrganigrammaRuoli *ruoli = ORGANIGRAMMA_RUOLI (object);
+       OrganigrammaRuoliPrivate *priv = ORGANIGRAMMA_RUOLI_GET_PRIVATE (ruoli);
+
+       switch (property_id)
+               {
+                       default:
+                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                               break;
+               }
+}
+
+static void
+organigramma_ruoli_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
+{
+       OrganigrammaRuoli *ruoli = ORGANIGRAMMA_RUOLI (object);
+       OrganigrammaRuoliPrivate *priv = ORGANIGRAMMA_RUOLI_GET_PRIVATE (ruoli);
+
+       switch (property_id)
+               {
+                       default:
+                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                               break;
+               }
+}
+
+/* CALLBACK */
+static void
+organigramma_ruoli_on_btn_nuovo_clicked (GtkButton *button,
+                      gpointer user_data)
+{
+       GtkWidget *w;
+
+       OrganigrammaRuoli *ruoli = (OrganigrammaRuoli *)user_data;
+       OrganigrammaRuoliPrivate *priv = ORGANIGRAMMA_RUOLI_GET_PRIVATE (ruoli);
+
+       OrganigrammaRuolo *c = organigramma_ruolo_new (priv->commons, 0);
+
+       g_signal_connect (G_OBJECT (c), "aggiornato",
+                         G_CALLBACK (organigramma_ruoli_on_costo_aggiornato), (gpointer)ruoli);
+
+       w = organigramma_ruolo_get_widget (c);
+       gtk_window_set_transient_for (GTK_WINDOW (w), priv->wtransient);
+       gtk_widget_show (w);
+}
+
+static void
+organigramma_ruoli_on_btn_modifica_clicked (GtkButton *button,
+                      gpointer user_data)
+{
+       organigramma_ruoli_modifica ((OrganigrammaRuoli *)user_data);
+}
+
+static void
+organigramma_ruoli_on_btn_elimina_clicked (GtkButton *button,
+                        gpointer user_data)
+{
+       GtkTreeIter iter;
+       guint id;
+
+       OrganigrammaRuoli *ruoli = (OrganigrammaRuoli *)user_data;
+       OrganigrammaRuoliPrivate *priv = ORGANIGRAMMA_RUOLI_GET_PRIVATE (ruoli);
+
+       if (gtk_tree_selection_get_selected (priv->selection, NULL, &iter))
+               {
+                       if (solipa_message_dialog (GTK_WIDGET (priv->wtransient),
+                                                  GTK_MESSAGE_QUESTION,
+                                                  GTK_BUTTONS_YES_NO,
+                                                  "Sicuro di voler eliminare il ruolo selezionato?") == GTK_RESPONSE_YES)
+                               {
+                                       gtk_tree_model_get (GTK_TREE_MODEL (priv->lstore_ruoli), &iter,
+                                                           COL_ID, &id,
+                                                           -1);
+
+                                       gdaex_execute (priv->commons->gdaex,
+                                                      g_strdup_printf ("UPDATE ruoli SET status = 'E' WHERE id = %d", id));
+
+                                       organigramma_ruoli_carica (ruoli);
+                               }
+               }
+       else
+               {
+                       solipa_message_dialog (GTK_WIDGET (priv->wtransient),
+                                              GTK_MESSAGE_WARNING,
+                                              GTK_BUTTONS_OK,
+                                              "Occorre prima selezionare un ruolo.");
+               }
+}
+
+static void
+organigramma_ruoli_on_trv_organigramma_ruoli_row_activated (GtkTreeView *tree_view,
+                                             GtkTreePath *tree_path,
+                                             GtkTreeViewColumn *column,
+                                             gpointer user_data)
+{
+       OrganigrammaRuoliPrivate *priv = ORGANIGRAMMA_RUOLI_GET_PRIVATE ((OrganigrammaRuoli *)user_data);
+
+       if (priv->selezione)
+               {
+                       organigramma_ruoli_selezionato ((OrganigrammaRuoli *)user_data);
+               }
+       else
+               {
+                       organigramma_ruoli_modifica ((OrganigrammaRuoli *)user_data);
+               }
+}
+
+
+static void
+organigramma_ruoli_on_btn_annulla_clicked (GtkButton *button,
+                        gpointer user_data)
+{
+       OrganigrammaRuoliPrivate *priv = ORGANIGRAMMA_RUOLI_GET_PRIVATE ((OrganigrammaRuoli *)user_data);
+
+       gtk_widget_destroy (priv->widget);
+       g_object_unref (G_OBJECT (user_data));
+}
+
+static void
+organigramma_ruoli_on_btn_seleziona_clicked (GtkButton *button,
+                        gpointer user_data)
+{
+       organigramma_ruoli_selezionato ((OrganigrammaRuoli *)user_data);
+}
diff --git a/src/ruoli.h b/src/ruoli.h
new file mode 100644 (file)
index 0000000..f53d26d
--- /dev/null
@@ -0,0 +1,65 @@
+/* 
+ * Copyright (C) 2013 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 __ORGANIGRAMMA_RUOLI_H__
+#define __ORGANIGRAMMA_RUOLI_H__
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include <gtk/gtk.h>
+
+#include "commons.h"
+
+G_BEGIN_DECLS
+
+
+#define TYPE_ORGANIGRAMMA_RUOLI                 (organigramma_ruoli_get_type ())
+#define ORGANIGRAMMA_RUOLI(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_ORGANIGRAMMA_RUOLI, OrganigrammaRuoli))
+#define ORGANIGRAMMA_RUOLI_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_ORGANIGRAMMA_RUOLI, OrganigrammaRuoliClass))
+#define IS_ORGANIGRAMMA_RUOLI(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_ORGANIGRAMMA_RUOLI))
+#define IS_ORGANIGRAMMA_RUOLI_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_ORGANIGRAMMA_RUOLI))
+#define ORGANIGRAMMA_RUOLI_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_ORGANIGRAMMA_RUOLI, OrganigrammaRuoliClass))
+
+
+typedef struct _OrganigrammaRuoli OrganigrammaRuoli;
+typedef struct _OrganigrammaRuoliClass OrganigrammaRuoliClass;
+
+struct _OrganigrammaRuoli
+       {
+               GObject parent;
+       };
+
+struct _OrganigrammaRuoliClass
+       {
+               GObjectClass parent_class;
+
+               guint selezionato_signal_id;
+       };
+
+GType organigramma_ruoli_get_type (void) G_GNUC_CONST;
+
+OrganigrammaRuoli *organigramma_ruoli_new (OrganigrammaCommons *commons, gboolean selezione);
+
+GtkWidget *organigramma_ruoli_get_widget (OrganigrammaRuoli *ruoli);
+
+
+G_END_DECLS
+
+#endif /* __ORGANIGRAMMA_RUOLI_H__ */
diff --git a/src/ruolo.c b/src/ruolo.c
new file mode 100644 (file)
index 0000000..8a20e02
--- /dev/null
@@ -0,0 +1,349 @@
+/* 
+ * Copyright (C) 2013 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 <libautoz/autoz.h>
+#include <libgtkform/form.h>
+#include <libsolipa/utils.h>
+
+#include "ruolo.h"
+
+static void organigramma_ruolo_class_init (OrganigrammaRuoloClass *klass);
+static void organigramma_ruolo_init (OrganigrammaRuolo *ruolo);
+
+static void organigramma_ruolo_carica (OrganigrammaRuolo *ruolo);
+static void organigramma_ruolo_salva (OrganigrammaRuolo *ruolo, gboolean chiudi);
+
+static gboolean organigramma_ruolo_conferma_chiusura (OrganigrammaRuolo *ruolo);
+
+static void organigramma_ruolo_set_property (GObject *object,
+                                     guint property_id,
+                                     const GValue *value,
+                                     GParamSpec *pspec);
+static void organigramma_ruolo_get_property (GObject *object,
+                                     guint property_id,
+                                     GValue *value,
+                                     GParamSpec *pspec);
+
+static gboolean organigramma_ruolo_on_w_organigramma_ruolo_delete_event (GtkWidget *widget,
+                               GdkEvent *event,
+                               gpointer user_data);
+
+static void organigramma_ruolo_on_btn_annulla_clicked (GtkButton *button,
+                                    gpointer user_data);
+static void organigramma_ruolo_on_btn_salva_clicked (GtkButton *button,
+                                  gpointer user_data);
+static void organigramma_ruolo_on_btn_salvaechiudi_clicked (GtkButton *button,
+                                  gpointer user_data);
+
+#define ORGANIGRAMMA_RUOLO_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_ORGANIGRAMMA_RUOLO, OrganigrammaRuoloPrivate))
+
+enum
+{
+       LBL_ID
+};
+
+typedef struct _OrganigrammaRuoloPrivate OrganigrammaRuoloPrivate;
+struct _OrganigrammaRuoloPrivate
+       {
+               OrganigrammaCommons *commons;
+
+               GtkForm *form;
+
+               GtkWidget *w;
+
+               GObject **objects;
+
+               gint id;
+       };
+
+G_DEFINE_TYPE (OrganigrammaRuolo, organigramma_ruolo, G_TYPE_OBJECT)
+
+static void
+organigramma_ruolo_class_init (OrganigrammaRuoloClass *klass)
+{
+       GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+       g_type_class_add_private (object_class, sizeof (OrganigrammaRuoloPrivate));
+
+       object_class->set_property = organigramma_ruolo_set_property;
+       object_class->get_property = organigramma_ruolo_get_property;
+
+       /**
+        * OrganigrammaRuolo::aggiornato:
+        * @ruolo:
+        *
+        */
+       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
+organigramma_ruolo_init (OrganigrammaRuolo *ruolo)
+{
+       OrganigrammaRuoloPrivate *priv = ORGANIGRAMMA_RUOLO_GET_PRIVATE (ruolo);
+}
+
+/**
+ * organigramma_ruolo_new:
+ * @commons:
+ * @id:
+ *
+ * Returns: the newly created #OrganigrammaRuolo object.
+ */
+OrganigrammaRuolo
+*organigramma_ruolo_new (OrganigrammaCommons *commons, gint id)
+{
+       GError *error;
+       AutozIResource *ires1;
+
+       OrganigrammaRuolo *a = ORGANIGRAMMA_RUOLO (g_object_new (organigramma_ruolo_get_type (), NULL));
+
+       OrganigrammaRuoloPrivate *priv = ORGANIGRAMMA_RUOLO_GET_PRIVATE (a);
+
+       priv->commons = commons;
+
+       error = NULL;
+       gtk_builder_add_objects_from_file (priv->commons->gtkbuilder, priv->commons->guifile,
+                                          g_strsplit ("w_ruolo", "|", -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, "ruolo.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_ruolo"));
+
+       priv->objects = gtk_form_get_objects_by_name (priv->form,
+                                                     "label175",
+                                                     NULL);
+
+       g_signal_connect (priv->w,
+                         "delete-event", G_CALLBACK (organigramma_ruolo_on_w_organigramma_ruolo_delete_event), (gpointer)a);
+
+       g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button171"),
+                         "clicked", G_CALLBACK (organigramma_ruolo_on_btn_annulla_clicked), (gpointer)a);
+       g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button172"),
+                         "clicked", G_CALLBACK (organigramma_ruolo_on_btn_salva_clicked), (gpointer)a);
+       g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button173"),
+                         "clicked", G_CALLBACK (organigramma_ruolo_on_btn_salvaechiudi_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));
+                       organigramma_ruolo_carica (a);
+               }
+
+       ires1 = autoz_get_resource_from_id (priv->commons->autoz, "organigramma_rw");
+       if (!autoz_is_allowed (priv->commons->autoz, priv->commons->role_utente, ires1, FALSE))
+               {
+                       gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (commons->gtkbuilder, "button172")), FALSE);
+                       gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (commons->gtkbuilder, "button173")), FALSE);
+               }
+
+       return a;
+}
+
+/**
+ * organigramma_ruolo_get_widget:
+ * @ruolo:
+ *
+ */
+GtkWidget
+*organigramma_ruolo_get_widget (OrganigrammaRuolo *ruolo)
+{
+       OrganigrammaRuoloPrivate *priv = ORGANIGRAMMA_RUOLO_GET_PRIVATE (ruolo);
+
+       return priv->w;
+}
+
+/* PRIVATE */
+static void
+organigramma_ruolo_carica (OrganigrammaRuolo *ruolo)
+{
+       OrganigrammaRuoloPrivate *priv = ORGANIGRAMMA_RUOLO_GET_PRIVATE (ruolo);
+
+       gtk_form_fill_from_table (priv->form);
+}
+
+static void
+organigramma_ruolo_salva (OrganigrammaRuolo *ruolo, gboolean chiudi)
+{
+       gchar *sql;
+
+       OrganigrammaRuoloClass *klass = ORGANIGRAMMA_RUOLO_GET_CLASS (ruolo);
+
+       OrganigrammaRuoloPrivate *priv = ORGANIGRAMMA_RUOLO_GET_PRIVATE (ruolo);
+
+       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 (ruolo, 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);
+                               }
+
+                       solipa_message_dialog (priv->w,
+                                              GTK_MESSAGE_INFO,
+                                              GTK_BUTTONS_OK,
+                                              "Salvataggio eseguito con successo.");
+
+                       if (chiudi)
+                               {
+                                       gtk_widget_destroy (priv->w);
+                                       g_object_unref (ruolo);
+                               }
+               }
+       else
+               {
+                       if (priv->id == 0)
+                               {
+                                       gtk_label_set_text (GTK_LABEL (priv->objects[LBL_ID]), "");
+                               }
+
+                       solipa_message_dialog (priv->w,
+                                              GTK_MESSAGE_WARNING,
+                                              GTK_BUTTONS_OK,
+                                              "Errore durante il salvataggio.");
+               }
+}
+
+static void
+organigramma_ruolo_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
+{
+       OrganigrammaRuolo *ruolo = ORGANIGRAMMA_RUOLO (object);
+       OrganigrammaRuoloPrivate *priv = ORGANIGRAMMA_RUOLO_GET_PRIVATE (ruolo);
+
+       switch (property_id)
+               {
+                       default:
+                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                               break;
+               }
+}
+
+static void
+organigramma_ruolo_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
+{
+       OrganigrammaRuolo *ruolo = ORGANIGRAMMA_RUOLO (object);
+       OrganigrammaRuoloPrivate *priv = ORGANIGRAMMA_RUOLO_GET_PRIVATE (ruolo);
+
+       switch (property_id)
+               {
+                       default:
+                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                               break;
+               }
+}
+
+static gboolean
+organigramma_ruolo_conferma_chiusura (OrganigrammaRuolo *ruolo)
+{
+       gboolean ret;
+
+       OrganigrammaRuoloPrivate *priv = ORGANIGRAMMA_RUOLO_GET_PRIVATE (ruolo);
+
+       ret = TRUE;
+       if (gtk_form_is_changed (priv->form))
+               {
+                       if (solipa_message_dialog (priv->w,
+                                                  GTK_MESSAGE_QUESTION,
+                                                  GTK_BUTTONS_YES_NO,
+                                                  "Sicuro di voler chiudere senza salvare?") == GTK_RESPONSE_NO)
+                               {
+                                       ret = FALSE;
+                               }
+               }
+
+       return ret;
+}
+
+/* CALLBACK */
+static gboolean
+organigramma_ruolo_on_w_organigramma_ruolo_delete_event (GtkWidget *widget,
+                               GdkEvent *event,
+                               gpointer user_data)
+{
+       return !organigramma_ruolo_conferma_chiusura ((OrganigrammaRuolo *)user_data);
+}
+
+static void
+organigramma_ruolo_on_btn_annulla_clicked (GtkButton *button,
+                        gpointer user_data)
+{
+       OrganigrammaRuolo *ruolo = (OrganigrammaRuolo *)user_data;
+
+       OrganigrammaRuoloPrivate *priv = ORGANIGRAMMA_RUOLO_GET_PRIVATE (ruolo);
+
+       if (organigramma_ruolo_conferma_chiusura (ruolo)) gtk_widget_destroy (priv->w);
+}
+
+static void
+organigramma_ruolo_on_btn_salva_clicked (GtkButton *button,
+                      gpointer user_data)
+{
+       organigramma_ruolo_salva ((OrganigrammaRuolo *)user_data, FALSE);
+}
+
+static void
+organigramma_ruolo_on_btn_salvaechiudi_clicked (GtkButton *button,
+                      gpointer user_data)
+{
+       organigramma_ruolo_salva ((OrganigrammaRuolo *)user_data, TRUE);
+}
diff --git a/src/ruolo.h b/src/ruolo.h
new file mode 100644 (file)
index 0000000..c8f9b2e
--- /dev/null
@@ -0,0 +1,65 @@
+/* 
+ * Copyright (C) 2013 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 __ORGANIGRAMMA_RUOLO_H__
+#define __ORGANIGRAMMA_RUOLO_H__
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include <gtk/gtk.h>
+
+#include "commons.h"
+
+G_BEGIN_DECLS
+
+
+#define TYPE_ORGANIGRAMMA_RUOLO                 (organigramma_ruolo_get_type ())
+#define ORGANIGRAMMA_RUOLO(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_ORGANIGRAMMA_RUOLO, OrganigrammaRuolo))
+#define ORGANIGRAMMA_RUOLO_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_ORGANIGRAMMA_RUOLO, OrganigrammaRuoloClass))
+#define IS_ORGANIGRAMMA_RUOLO(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_ORGANIGRAMMA_RUOLO))
+#define IS_ORGANIGRAMMA_RUOLO_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_ORGANIGRAMMA_RUOLO))
+#define ORGANIGRAMMA_RUOLO_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_ORGANIGRAMMA_RUOLO, OrganigrammaRuoloClass))
+
+
+typedef struct _OrganigrammaRuolo OrganigrammaRuolo;
+typedef struct _OrganigrammaRuoloClass OrganigrammaRuoloClass;
+
+struct _OrganigrammaRuolo
+       {
+               GObject parent;
+       };
+
+struct _OrganigrammaRuoloClass
+       {
+               GObjectClass parent_class;
+
+               guint aggiornato_signal_id;
+       };
+
+GType organigramma_ruolo_get_type (void) G_GNUC_CONST;
+
+OrganigrammaRuolo *organigramma_ruolo_new (OrganigrammaCommons *commons, gint id);
+
+GtkWidget *organigramma_ruolo_get_widget (OrganigrammaRuolo *ruolo);
+
+
+G_END_DECLS
+
+#endif /* __ORGANIGRAMMA_RUOLO_H__ */