]> saetta.ns0.it Git - solipa/territorio/commitdiff
Migrato il form aggregazione_territoriale a zakform.
authorAndrea Zagli <azagli@libero.it>
Sat, 21 Dec 2019 10:28:06 +0000 (11:28 +0100)
committerAndrea Zagli <azagli@libero.it>
Sat, 21 Dec 2019 10:28:06 +0000 (11:28 +0100)
Utilizzo di ZakGtkDecoder.

data/territorio/form/aggregazione_territoriale.form
data/territorio/gui/territorio.gui
src/aggregazioneterritoriale.c
src/tipiaggregazioneterritoriale.c

index 823d6a13100381ebbc6c713f2fbd662e2c5705d3..299ec15c920b7bfd9e33ec472cd64739c90ac4b3 100644 (file)
@@ -1,29 +1,25 @@
 <?xml version="1.0"?>
-<gtkform>
-
-       <table>aggregazioni_territoriali</table>
-
-       <widget type="label" name="label32" label="label31">
-               <field type="integer" name="id">
-                       <is-key>t</is-key>
-                       <auto-increment>t</auto-increment>
-               </field>
-       </widget>
-
-       <widget type="combobox" name="combobox1" label="label34">
-               <column-field>0</column-field>
-               <sql with-empty-entry="t">
-                       SELECT id, nome FROM tipi_aggregazione_territoriale WHERE status &lt;&gt; 'E' ORDER BY nome
-               </sql>
-               <field type="integer" name="id_tipi_aggregazione_territoriale">
-                       <obligatory>t</obligatory>
-               </field>
-       </widget>
-
-       <widget type="entry" name="entry14" label="label33">
-               <field type="text" name="nome">
-                       <obligatory>t</obligatory>
-               </field>
-       </widget>
-
-</gtkform>
+<zakform>
+  <element type="zak_form_gtk_form_element_label">
+    <name>id</name>
+    <type>integer</type>
+    <label>label31</label>
+    <is-key>TRUE</is-key>
+    <widget>label32</widget>
+    <format thousands_separator="" />
+  </element>
+  <element type="zak_form_gtk_form_element_decoder">
+    <name>id_tipi_aggregazione_territoriale</name>
+    <type>integer</type>
+    <label>label34</label>
+    <widget>zakgtkdecoder1</widget>
+    <validator type="zak_form_element_validator_notempty"/>
+  </element>
+  <element type="zak_form_gtk_form_element_entry">
+    <name>nome</name>
+    <type>string</type>
+    <label>label33</label>
+    <widget>entry14</widget>
+    <validator type="zak_form_element_validator_notempty"/>
+  </element>
+</zakform>
index 46b0e00f779b99b59a87a4cdac466945f209d25d..9ad998d1a380f7c5a6a95f3e7dd4f08c4a432254 100644 (file)
@@ -3,6 +3,7 @@
 <interface>
   <requires lib="gtk+" version="3.12"/>
   <requires lib="gtkformui" version="0.0"/>
+  <requires lib="zakgtkdecoder" version="0.0"/>
   <object class="GtkAboutDialog" id="dlg_about">
     <property name="can_focus">False</property>
     <property name="border_width">5</property>
       <column type="gchararray"/>
     </columns>
   </object>
-  <object class="GtkWindow" id="w_aggregazione_territoriale">
-    <property name="can_focus">False</property>
-    <property name="title" translatable="yes">Aggregazione territoriale - Territorio</property>
-    <property name="modal">True</property>
-    <property name="window_position">center-on-parent</property>
-    <property name="destroy_with_parent">True</property>
-    <child type="titlebar">
-      <placeholder/>
-    </child>
-    <child>
-      <object class="GtkBox" id="vbox13">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="border_width">5</property>
-        <property name="orientation">vertical</property>
-        <property name="spacing">5</property>
-        <child>
-          <object class="GtkGrid" id="table6">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="row_spacing">5</property>
-            <property name="column_spacing">5</property>
-            <child>
-              <object class="GtkLabel" id="label31">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="label" translatable="yes">ID</property>
-                <property name="xalign">0</property>
-              </object>
-              <packing>
-                <property name="left_attach">0</property>
-                <property name="top_attach">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel" id="label32">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="label" translatable="yes">lbl_id</property>
-                <property name="xalign">0</property>
-              </object>
-              <packing>
-                <property name="left_attach">1</property>
-                <property name="top_attach">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkEntry" id="entry14">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="hexpand">True</property>
-                <property name="max_length">150</property>
-                <property name="invisible_char">●</property>
-                <property name="activates_default">True</property>
-                <property name="primary_icon_activatable">False</property>
-                <property name="secondary_icon_activatable">False</property>
-              </object>
-              <packing>
-                <property name="left_attach">1</property>
-                <property name="top_attach">2</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkComboBox" id="combobox1">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="model">lstore_tipi_aggregazione_territoriale</property>
-                <child>
-                  <object class="GtkCellRendererText" id="cellrenderertext7"/>
-                  <attributes>
-                    <attribute name="text">1</attribute>
-                  </attributes>
-                </child>
-              </object>
-              <packing>
-                <property name="left_attach">1</property>
-                <property name="top_attach">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel" id="label34">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="label" translatable="yes">Tipo</property>
-                <property name="xalign">0</property>
-              </object>
-              <packing>
-                <property name="left_attach">0</property>
-                <property name="top_attach">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel" id="label33">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="label" translatable="yes">Nome</property>
-                <property name="xalign">0</property>
-              </object>
-              <packing>
-                <property name="left_attach">0</property>
-                <property name="top_attach">2</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="GtkButtonBox" id="hbuttonbox12">
-            <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="button41">
-                <property name="label">gtk-cancel</property>
-                <property name="use_action_appearance">False</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="button42">
-                <property name="label">gtk-save</property>
-                <property name="use_action_appearance">False</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="button76">
-                <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">True</property>
-                <property name="fill">True</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="GtkListStore" id="lstore_vie">
     <columns>
       <!-- column-name id -->
       </object>
     </child>
   </object>
+  <object class="GtkWindow" id="w_aggregazione_territoriale">
+    <property name="can_focus">False</property>
+    <property name="title" translatable="yes">Aggregazione territoriale - Territorio</property>
+    <property name="modal">True</property>
+    <property name="window_position">center-on-parent</property>
+    <property name="destroy_with_parent">True</property>
+    <child type="titlebar">
+      <placeholder/>
+    </child>
+    <child>
+      <object class="GtkBox" id="vbox13">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="border_width">5</property>
+        <property name="orientation">vertical</property>
+        <property name="spacing">5</property>
+        <child>
+          <object class="GtkGrid" id="table6">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="row_spacing">5</property>
+            <property name="column_spacing">5</property>
+            <child>
+              <object class="GtkLabel" id="label31">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">ID</property>
+                <property name="xalign">0</property>
+              </object>
+              <packing>
+                <property name="left_attach">0</property>
+                <property name="top_attach">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="label32">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">lbl_id</property>
+                <property name="xalign">0</property>
+              </object>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="top_attach">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkEntry" id="entry14">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="hexpand">True</property>
+                <property name="max_length">150</property>
+                <property name="invisible_char">●</property>
+                <property name="activates_default">True</property>
+                <property name="primary_icon_activatable">False</property>
+                <property name="secondary_icon_activatable">False</property>
+              </object>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="top_attach">2</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="label34">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">Tipo</property>
+                <property name="xalign">0</property>
+              </object>
+              <packing>
+                <property name="left_attach">0</property>
+                <property name="top_attach">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="label33">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">Nome</property>
+                <property name="xalign">0</property>
+              </object>
+              <packing>
+                <property name="left_attach">0</property>
+                <property name="top_attach">2</property>
+              </packing>
+            </child>
+            <child>
+              <object class="ZakGtkDecoder" id="zakgtkdecoder1">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+              </object>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="top_attach">1</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="GtkButtonBox" id="hbuttonbox12">
+            <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="button41">
+                <property name="label">gtk-cancel</property>
+                <property name="use_action_appearance">False</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="button42">
+                <property name="label">gtk-save</property>
+                <property name="use_action_appearance">False</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="button76">
+                <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">True</property>
+                <property name="fill">True</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_comune">
     <property name="can_focus">False</property>
     <property name="title" translatable="yes">Comune - Territorio</property>
index cdc116863185c4a639b2ed8c7b4ef4ed7229c75b..11ed6a4d640d4341e3422f6c485ab7423a039373 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010-2018 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2010-2019 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
  *
  */
 
-#include <libgtkform/form.h>
+#include <libzakgtkdecoder/libzakgtkdecoder.h>
+#include <libzakform/libzakform.h>
+#include <libzakformgtk/libzakformgtk.h>
+#include <libzakformgdaex/libzakformgdaex.h>
+#include <libzakformgtkdecoder/libzakformgtkdecoder.h>
 #include <libzakautho/autho.h>
 #include <libsolipa/libsolipa.h>
 
+#include "tipiaggregazioneterritoriale.h"
 #include "aggregazioneterritoriale.h"
 
 static void territorio_aggregazione_territoriale_class_init (TerritorioAggregazioneTerritorialeClass *klass);
@@ -29,6 +34,9 @@ static void territorio_aggregazione_territoriale_init (TerritorioAggregazioneTer
 static void territorio_aggregazione_territoriale_carica (TerritorioAggregazioneTerritoriale *territorio_aggregazione_territoriale);
 static void territorio_aggregazione_territoriale_salva (TerritorioAggregazioneTerritoriale *territorio_aggregazione_territoriale, gboolean chiudi);
 
+static void territorio_aggregazione_territoriale_on_tipo_selezionato (gpointer instance, guint id, gpointer user_data);
+static gchar *territorio_aggregazione_territoriale_on_tipo_decode (gpointer instance, gchar *key, gpointer user_data);
+
 static gboolean territorio_aggregazione_territoriale_conferma_chiusura (TerritorioAggregazioneTerritoriale *territorio_aggregazione_territoriale);
 
 static void territorio_aggregazione_territoriale_set_property (GObject *object,
@@ -44,6 +52,8 @@ static gboolean territorio_aggregazione_territoriale_on_w_aggregazione_territori
                                GdkEvent *event,
                                gpointer user_data);
 
+static void territorio_aggregazione_territoriale_on_btn_ricerca_tipo_clicked (GtkButton *button,
+                                    gpointer user_data);
 static void territorio_aggregazione_territoriale_on_btn_annulla_clicked (GtkButton *button,
                                     gpointer user_data);
 static void territorio_aggregazione_territoriale_on_btn_salva_clicked (GtkButton *button,
@@ -63,7 +73,8 @@ struct _TerritorioAggregazioneTerritorialePrivate
        {
                TerritorioCommons *commons;
 
-               GtkForm *form;
+               ZakFormGtkForm *form;
+               ZakFormGdaexProvider *form_provider;
 
                GtkWidget *w;
 
@@ -127,8 +138,7 @@ TerritorioAggregazioneTerritoriale
 
        error = NULL;
        gtk_builder_add_objects_from_file (priv->commons->gtkbuilder, priv->commons->guifile,
-                                          g_strsplit (g_strconcat ("lstore_tipi_aggregazione_territoriale"
-                                          "|w_aggregazione_territoriale", NULL), "|", -1),
+                                          g_strsplit (g_strconcat ("w_aggregazione_territoriale", NULL), "|", -1),
                                           &error);
        if (error != NULL)
                {
@@ -136,19 +146,26 @@ TerritorioAggregazioneTerritoriale
                        return NULL;
                }
 
-       priv->form = gtk_form_new ();
-       g_object_set (G_OBJECT (priv->form), "gdaex", priv->commons->gdaex, NULL);
-       gtk_form_load_from_file (priv->form, g_build_filename (priv->commons->formdir, "aggregazione_territoriale.form", NULL), priv->commons->gtkbuilder);
+       priv->form = zak_form_gtk_form_new ();
+       zak_form_gtk_form_set_gtkbuilder (priv->form, priv->commons->gtkbuilder);
+       zak_form_form_load_from_file (ZAK_FORM_FORM (priv->form), g_build_filename (priv->commons->formdir, "aggregazione_territoriale.form", NULL));
+
+       priv->form_provider = zak_form_gdaex_provider_new (priv->commons->gdaex, "aggregazioni_territoriali");
 
        priv->w = GTK_WIDGET (gtk_builder_get_object (priv->commons->gtkbuilder, "w_aggregazione_territoriale"));
 
-       priv->objects = gtk_form_get_objects_by_name (priv->form,
+       priv->objects = zak_form_gtk_form_get_gobjects_by_name (priv->form,
                                                      "label32",
                                                      NULL);
 
        g_signal_connect (priv->w,
                          "delete-event", G_CALLBACK (territorio_aggregazione_territoriale_on_w_aggregazione_territoriale_delete_event), (gpointer)a);
 
+       g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "zakgtkdecoder1"),
+                         "btn-browse-clicked", G_CALLBACK (territorio_aggregazione_territoriale_on_btn_ricerca_tipo_clicked), (gpointer)a);
+       g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "zakgtkdecoder1"),
+                         "decode", G_CALLBACK (territorio_aggregazione_territoriale_on_tipo_decode), (gpointer)a);
+
        g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button41"),
                          "clicked", G_CALLBACK (territorio_aggregazione_territoriale_on_btn_annulla_clicked), (gpointer)a);
        g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button42"),
@@ -156,13 +173,14 @@ TerritorioAggregazioneTerritoriale
        g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button76"),
                          "clicked", G_CALLBACK (territorio_aggregazione_territoriale_on_btn_salva_chiudi_clicked), (gpointer)a);
 
-       priv->id = id;
+       zak_form_form_clear (ZAK_FORM_FORM (priv->form));
 
+       priv->id = id;
        if (priv->id == 0)
                {
                        gtk_label_set_text (GTK_LABEL (priv->objects[LBL_ID]), "");
 
-                       gtk_form_set_as_origin (priv->form);
+                       zak_form_form_set_as_original (ZAK_FORM_FORM (priv->form));
                }
        else
                {
@@ -198,7 +216,7 @@ territorio_aggregazione_territoriale_carica (TerritorioAggregazioneTerritoriale
 {
        TerritorioAggregazioneTerritorialePrivate *priv = TERRITORIO_AGGREGAZIONE_TERRITORIALE_GET_PRIVATE (territorio_aggregazione_territoriale);
 
-       if (gtk_form_fill_from_table (priv->form))
+       if (zak_form_form_load (ZAK_FORM_FORM (priv->form), ZAK_FORM_IPROVIDER (priv->form_provider)))
                {
                }
 }
@@ -206,31 +224,42 @@ territorio_aggregazione_territoriale_carica (TerritorioAggregazioneTerritoriale
 static void
 territorio_aggregazione_territoriale_salva (TerritorioAggregazioneTerritoriale *territorio_aggregazione_territoriale, gboolean chiudi)
 {
-       gchar *sql;
+       gboolean success;;
 
        TerritorioAggregazioneTerritorialeClass *klass = TERRITORIO_AGGREGAZIONE_TERRITORIALE_GET_CLASS (territorio_aggregazione_territoriale);
 
        TerritorioAggregazioneTerritorialePrivate *priv = TERRITORIO_AGGREGAZIONE_TERRITORIALE_GET_PRIVATE (territorio_aggregazione_territoriale);
 
-       if (!gtk_form_check (priv->form, (priv->id != 0), NULL, TRUE, priv->w, TRUE))
+       if (!zak_form_gtk_form_is_valid (priv->form, priv->w))
                {
                        return;
                }
 
+       success = FALSE;
+
        if (priv->id == 0)
                {
-                       sql = gtk_form_get_sql (priv->form, GTK_FORM_SQL_INSERT);
+                       guint new_id;
+
+                       new_id = gdaex_get_new_id (priv->commons->gdaex,
+                                                  "aggregazioni_territoriali",
+                                                  "id",
+                                                  NULL);
+
+                       gtk_label_set_text (GTK_LABEL (priv->objects[LBL_ID]), g_strdup_printf ("%d", new_id));
+
+                       success = zak_form_form_insert (ZAK_FORM_FORM (priv->form), ZAK_FORM_IPROVIDER (priv->form_provider));
                }
        else
                {
-                       sql = gtk_form_get_sql (priv->form, GTK_FORM_SQL_UPDATE);
+                       success = zak_form_form_update (ZAK_FORM_FORM (priv->form), ZAK_FORM_IPROVIDER (priv->form_provider));
                }
 
-       if (gdaex_execute (priv->commons->gdaex, sql) == 1)
+       if (success)
                {
                        g_signal_emit (territorio_aggregazione_territoriale, klass->aggiornato_signal_id, 0);
 
-                       gtk_form_set_as_origin (priv->form);
+                       zak_form_form_set_as_original (ZAK_FORM_FORM (priv->form));
 
                        if (priv->id == 0)
                                {
@@ -301,7 +330,7 @@ territorio_aggregazione_territoriale_conferma_chiusura (TerritorioAggregazioneTe
 
        ret = TRUE;
        if (gtk_widget_get_sensitive (GTK_WIDGET (gtk_builder_get_object (priv->commons->gtkbuilder, "button42")))
-           && gtk_form_is_changed (priv->form))
+           && zak_form_form_is_changed (ZAK_FORM_FORM (priv->form)))
                {
                        if (solipa_message_dialog (priv->w,
                                                   GTK_MESSAGE_QUESTION,
@@ -324,6 +353,61 @@ territorio_aggregazione_territoriale_on_w_aggregazione_territoriale_delete_event
        return !territorio_aggregazione_territoriale_conferma_chiusura ((TerritorioAggregazioneTerritoriale *)user_data);
 }
 
+static void
+territorio_aggregazione_territoriale_on_tipo_selezionato (gpointer instance, guint id, gpointer user_data)
+{
+       TerritorioAggregazioneTerritoriale *f = (TerritorioAggregazioneTerritoriale *)user_data;
+       TerritorioAggregazioneTerritorialePrivate *priv = TERRITORIO_AGGREGAZIONE_TERRITORIALE_GET_PRIVATE (f);
+
+       zak_gtk_decoder_set_key (ZAK_GTK_DECODER (gtk_builder_get_object (priv->commons->gtkbuilder, "zakgtkdecoder1")),
+                                            g_strdup_printf ("%d", id));
+}
+
+static gchar
+*territorio_aggregazione_territoriale_on_tipo_decode (gpointer instance, gchar *key, gpointer user_data)
+{
+       GString *ret;
+       gchar *sql;
+       GdaDataModel *dm;
+
+       TerritorioAggregazioneTerritoriale *f = (TerritorioAggregazioneTerritoriale *)user_data;
+       TerritorioAggregazioneTerritorialePrivate *priv = TERRITORIO_AGGREGAZIONE_TERRITORIALE_GET_PRIVATE (f);
+
+       ret = g_string_new ("");
+
+       sql = g_strdup_printf ("SELECT nome"
+                              " FROM tipi_aggregazione_territoriale"
+                              " WHERE id = %d",
+                              strtol (key, NULL, 10));
+       dm = gdaex_query (priv->commons->gdaex, sql);
+       g_free (sql);
+       if (!gdaex_data_model_is_empty (dm))
+               {
+                       g_string_append (ret, gdaex_data_model_get_value_stringify_at (dm, 0, 0));
+               }
+
+       return ret->str;
+}
+
+static void
+territorio_aggregazione_territoriale_on_btn_ricerca_tipo_clicked (GtkButton *button,
+                        gpointer user_data)
+{
+       GtkWidget *w;
+
+       TerritorioAggregazioneTerritoriale *f = (TerritorioAggregazioneTerritoriale *)user_data;
+       TerritorioAggregazioneTerritorialePrivate *priv = TERRITORIO_AGGREGAZIONE_TERRITORIALE_GET_PRIVATE (f);
+
+       TerritorioTipiAggregazioneTerritoriale *c = territorio_tipi_aggregazione_territoriale_new (priv->commons, TRUE);
+
+       g_signal_connect (G_OBJECT (c), "selezionato",
+                         G_CALLBACK (territorio_aggregazione_territoriale_on_tipo_selezionato), user_data);
+
+       w = territorio_tipi_aggregazione_territoriale_get_widget (c);
+       gtk_window_set_transient_for (GTK_WINDOW (w), GTK_WINDOW (priv->w));
+       gtk_widget_show (w);
+}
+
 static void
 territorio_aggregazione_territoriale_on_btn_annulla_clicked (GtkButton *button,
                         gpointer user_data)
index b8b01922c1f029f45e59b9c2ce1399e80b5aaa44..b210d6ac7be3ec209c3569a401cbd7705d0bfdc5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010-2016 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2010-2019 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
@@ -286,7 +286,7 @@ static void
 territorio_tipi_aggregazione_territoriale_selezionato (TerritorioTipiAggregazioneTerritoriale *territorio_tipi_aggregazione_territoriale)
 {
        GtkTreeIter iter;
-       gchar *id;
+       guint id;
 
        TerritorioTipiAggregazioneTerritorialeClass *klass = TERRITORIO_TIPI_AGGREGAZIONE_TERRITORIALE_GET_CLASS (territorio_tipi_aggregazione_territoriale);
        TerritorioTipiAggregazioneTerritorialePrivate *priv = TERRITORIO_TIPI_AGGREGAZIONE_TERRITORIALE_GET_PRIVATE (territorio_tipi_aggregazione_territoriale);
@@ -297,7 +297,7 @@ territorio_tipi_aggregazione_territoriale_selezionato (TerritorioTipiAggregazion
                                            COL_ID, &id,
                                            -1);
 
-                       g_signal_emit (G_OBJECT (territorio_tipi_aggregazione_territoriale), klass->selezionato_signal_id, 0, strtol (id, NULL, 10));
+                       g_signal_emit (G_OBJECT (territorio_tipi_aggregazione_territoriale), klass->selezionato_signal_id, 0, id);
 
                        gtk_widget_destroy (priv->widget);
                        g_object_unref (G_OBJECT (territorio_tipi_aggregazione_territoriale));