]> saetta.ns0.it Git - solipa/territorio/commitdiff
Implementate alcune scorciatoie da tastiera.
authorAndrea Zagli <a.zagli@comune.scandicci.fi.it>
Wed, 17 Aug 2011 09:33:34 +0000 (11:33 +0200)
committerAndrea Zagli <a.zagli@comune.scandicci.fi.it>
Wed, 17 Aug 2011 09:33:34 +0000 (11:33 +0200)
Aggiunto il caricamento record in vie, comuni e province
nell'evento map, per dare poi la possibilità di impostare dei filtri
dagli oggetti chiamanti.

data/territorio/gui/territorio.gui
src/comuni.c
src/province.c
src/regioni.c
src/stati.c
src/vie.c

index d4fa37ad5e63b050029c093face4f65c154206b4..3c59509d945bf7c3b815c53e5dd829af8b1de5d8 100644 (file)
                 <property name="label">gtk-ok</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="has_default">True</property>
                 <property name="receives_default">True</property>
                 <property name="use_stock">True</property>
               </object>
                 <property name="label">gtk-ok</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="has_default">True</property>
                 <property name="receives_default">True</property>
                 <property name="use_stock">True</property>
               </object>
                 <property name="label">gtk-ok</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="has_default">True</property>
                 <property name="receives_default">True</property>
                 <property name="use_stock">True</property>
               </object>
index 864978fda4567c5888e1d51f52581e6119fb2799..0046aecf79033bfd29af4c96d1ec136186d98581 100644 (file)
@@ -1,5 +1,5 @@
 /* 
- * Copyright (C) 2010 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2010-2011 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
@@ -17,6 +17,8 @@
  *
  */
 
+#include <gdk/gdkkeysyms.h>
+
 #include <libautoz/autoz.h>
 
 #include "comuni.h"
@@ -43,6 +45,13 @@ static void territorio_comuni_get_property (GObject *object,
                                      GValue *value,
                                      GParamSpec *pspec);
 
+static gboolean territorio_comuni_on_key_release_event (GtkWidget *widget,
+                                                          GdkEventKey *event,
+                                                          gpointer user_data);
+
+static void territorio_comuni_on_map (GtkWidget *widget,
+                                        gpointer user_data);
+
 static void territorio_comuni_on_btn_nuovo_clicked (GtkButton *button,
                       gpointer user_data);
 static void territorio_comuni_on_btn_modifica_clicked (GtkButton *button,
@@ -85,6 +94,8 @@ struct _TerritorioComuniPrivate
 
                gboolean selezione;
                GtkWindow *wtransient;
+
+               guint signal_map;
        };
 
 G_DEFINE_TYPE (TerritorioComuni, territorio_comuni, G_TYPE_OBJECT)
@@ -166,6 +177,11 @@ TerritorioComuni
                        priv->wtransient = GTK_WINDOW (gtk_builder_get_object (priv->commons->gtkbuilder, "w_main"));
                }
 
+       g_signal_connect (priv->widget,
+                         "key-release-event", G_CALLBACK (territorio_comuni_on_key_release_event), (gpointer)a);
+       priv->signal_map = g_signal_connect (priv->widget,
+                         "map", G_CALLBACK (territorio_comuni_on_map), (gpointer)a);
+
        g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button22"),
                          "clicked", G_CALLBACK (territorio_comuni_on_btn_nuovo_clicked), (gpointer)a);
        g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button23"),
@@ -191,8 +207,6 @@ TerritorioComuni
                        gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (priv->commons->gtkbuilder, "button26")));
                }
 
-       territorio_comuni_carica (a);
-
        ires1 = autoz_get_resource_from_id (priv->commons->autoz, "territorio_rw");
        if (!autoz_is_allowed (priv->commons->autoz, priv->commons->role_utente, ires1, FALSE))
                {
@@ -404,6 +418,43 @@ territorio_comuni_get_property (GObject *object, guint property_id, GValue *valu
 }
 
 /* CALLBACK */
+static gboolean
+territorio_comuni_on_key_release_event (GtkWidget *widget,
+                            GdkEventKey *event,
+                            gpointer user_data)
+{
+       if (event->keyval == GDK_Escape)
+               {
+                       TerritorioComuniPrivate *priv = TERRITORIO_COMUNI_GET_PRIVATE ((TerritorioComuni *)user_data);
+
+                       if (priv->selezione)
+                               {
+                                       gtk_button_clicked (GTK_BUTTON (gtk_builder_get_object (priv->commons->gtkbuilder, "button25")));
+                                       return TRUE;
+                               }
+               }
+       else if (event->keyval == GDK_F2)
+               {
+                       TerritorioComuniPrivate *priv = TERRITORIO_COMUNI_GET_PRIVATE ((TerritorioComuni *)user_data);
+
+                       gtk_button_clicked (GTK_BUTTON (gtk_builder_get_object (priv->commons->gtkbuilder, "button58")));
+                       return TRUE;
+               }
+
+       return FALSE;
+}
+
+static void
+territorio_comuni_on_map (GtkWidget *widget,
+                            gpointer user_data)
+{
+       TerritorioComuni *territorio_comuni = (TerritorioComuni *)user_data;
+       TerritorioComuniPrivate *priv = TERRITORIO_COMUNI_GET_PRIVATE (territorio_comuni);
+
+       territorio_comuni_carica (territorio_comuni);
+       g_signal_handler_disconnect (G_OBJECT (priv->widget), priv->signal_map);
+}
+
 static void
 territorio_comuni_on_btn_nuovo_clicked (GtkButton *button,
                       gpointer user_data)
index b1f79d3407b7e925e955268ec1e9f7d1d9aa7f2b..233e320bac1b7aa8bcc9cb0397233a02aba40520 100644 (file)
@@ -1,5 +1,5 @@
 /* 
- * Copyright (C) 2010 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2010-2011 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
@@ -17,6 +17,8 @@
  *
  */
 
+#include <gdk/gdkkeysyms.h>
+
 #include <libautoz/autoz.h>
 
 #include "province.h"
@@ -35,32 +37,39 @@ static void territorio_province_on_provincia_aggiornato (gpointer instance, gpoi
 static void territorio_province_on_filtra (gpointer instance, gpointer parametri, gpointer user_data);
 
 static void territorio_province_set_property (GObject *object,
-                                     guint property_id,
-                                     const GValue *value,
-                                     GParamSpec *pspec);
+                                              guint property_id,
+                                              const GValue *value,
+                                              GParamSpec *pspec);
 static void territorio_province_get_property (GObject *object,
-                                     guint property_id,
-                                     GValue *value,
-                                     GParamSpec *pspec);
+                                              guint property_id,
+                                              GValue *value,
+                                              GParamSpec *pspec);
+
+static gboolean territorio_province_on_key_release_event (GtkWidget *widget,
+                                                          GdkEventKey *event,
+                                                          gpointer user_data);
+
+static void territorio_province_on_map (GtkWidget *widget,
+                                        gpointer user_data);
 
 static void territorio_province_on_btn_nuovo_clicked (GtkButton *button,
-                      gpointer user_data);
+                                                      gpointer user_data);
 static void territorio_province_on_btn_modifica_clicked (GtkButton *button,
-                      gpointer user_data);
+                                                         gpointer user_data);
 static void territorio_province_on_btn_elimina_clicked (GtkButton *button,
-                        gpointer user_data);
+                                                        gpointer user_data);
 static void territorio_province_on_trv_territorio_province_row_activated (GtkTreeView *tree_view,
                                              GtkTreePath *tree_path,
                                              GtkTreeViewColumn *column,
                                              gpointer user_data);
 
 static void territorio_province_on_btn_trova_clicked (GtkButton *button,
-                                    gpointer user_data);
+                                                      gpointer user_data);
 
 static void territorio_province_on_btn_annulla_clicked (GtkButton *button,
-                                    gpointer user_data);
+                                                        gpointer user_data);
 static void territorio_province_on_btn_seleziona_clicked (GtkButton *button,
-                                  gpointer user_data);
+                                                          gpointer user_data);
 
 #define TERRITORIO_PROVINCE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_TERRITORIO_PROVINCE, TerritorioProvincePrivate))
 
@@ -85,6 +94,8 @@ struct _TerritorioProvincePrivate
 
                gboolean selezione;
                GtkWindow *wtransient;
+
+               guint signal_map;
        };
 
 G_DEFINE_TYPE (TerritorioProvince, territorio_province, G_TYPE_OBJECT)
@@ -105,14 +116,14 @@ territorio_province_class_init (TerritorioProvinceClass *klass)
         *
         */
        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);
+                                                    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
@@ -143,9 +154,10 @@ TerritorioProvince
 
        error = NULL;
        gtk_builder_add_objects_from_file (priv->commons->gtkbuilder, priv->commons->guifile,
-                                          g_strsplit (g_strconcat ("lstore_province|",
-                                          (selezione ? "w_province" : "vbox6"),
-                                          NULL), "|", -1),
+                                          g_strsplit (g_strconcat ("lstore_province",
+                                                                   selezione ? "|w_province" : "|vbox6",
+                                                                   NULL),
+                                                      "|", -1),
                                           &error);
        if (error != NULL)
                {
@@ -166,6 +178,11 @@ TerritorioProvince
                        priv->wtransient = GTK_WINDOW (gtk_builder_get_object (priv->commons->gtkbuilder, "w_main"));
                }
 
+       g_signal_connect (priv->widget,
+                         "key-release-event", G_CALLBACK (territorio_province_on_key_release_event), (gpointer)a);
+       priv->signal_map = g_signal_connect (priv->widget,
+                         "map", G_CALLBACK (territorio_province_on_map), (gpointer)a);
+
        g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button15"),
                          "clicked", G_CALLBACK (territorio_province_on_btn_nuovo_clicked), (gpointer)a);
        g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button16"),
@@ -191,8 +208,6 @@ TerritorioProvince
                        gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (priv->commons->gtkbuilder, "button19")));
                }
 
-       territorio_province_carica (a);
-
        ires1 = autoz_get_resource_from_id (priv->commons->autoz, "territorio_rw");
        if (!autoz_is_allowed (priv->commons->autoz, priv->commons->role_utente, ires1, FALSE))
                {
@@ -266,6 +281,8 @@ territorio_province_carica (TerritorioProvince *territorio_province)
                               sql_where);
 
     dm = gdaex_query (priv->commons->gdaex, sql);
+    g_free (sql);
+    g_free (sql_where);
        if (dm != NULL)
                {
                        rows = gda_data_model_get_n_rows (dm);
@@ -402,6 +419,43 @@ territorio_province_get_property (GObject *object, guint property_id, GValue *va
 }
 
 /* CALLBACK */
+static gboolean
+territorio_province_on_key_release_event (GtkWidget *widget,
+                            GdkEventKey *event,
+                            gpointer user_data)
+{
+       if (event->keyval == GDK_Escape)
+               {
+                       TerritorioProvincePrivate *priv = TERRITORIO_PROVINCE_GET_PRIVATE ((TerritorioProvince *)user_data);
+
+                       if (priv->selezione)
+                               {
+                                       gtk_button_clicked (GTK_BUTTON (gtk_builder_get_object (priv->commons->gtkbuilder, "button18")));
+                                       return TRUE;
+                               }
+               }
+       else if (event->keyval == GDK_F2)
+               {
+                       TerritorioProvincePrivate *priv = TERRITORIO_PROVINCE_GET_PRIVATE ((TerritorioProvince *)user_data);
+
+                       gtk_button_clicked (GTK_BUTTON (gtk_builder_get_object (priv->commons->gtkbuilder, "button53")));
+                       return TRUE;
+               }
+
+       return FALSE;
+}
+
+static void
+territorio_province_on_map (GtkWidget *widget,
+                            gpointer user_data)
+{
+       TerritorioProvince *territorio_province = (TerritorioProvince *)user_data;
+       TerritorioProvincePrivate *priv = TERRITORIO_PROVINCE_GET_PRIVATE (territorio_province);
+
+       territorio_province_carica (territorio_province);
+       g_signal_handler_disconnect (G_OBJECT (priv->widget), priv->signal_map);
+}
+
 static void
 territorio_province_on_btn_nuovo_clicked (GtkButton *button,
                       gpointer user_data)
index f9a675565e4e2d963372674d64df780c7822bb68..2c488cc15cbef186c584b97517287a492609f664 100644 (file)
@@ -1,5 +1,5 @@
 /* 
- * Copyright (C) 2010 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2010-2011 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
@@ -17,6 +17,8 @@
  *
  */
 
+#include <gdk/gdkkeysyms.h>
+
 #include <libautoz/autoz.h>
 
 #include "regioni.h"
@@ -40,6 +42,10 @@ static void territorio_regioni_get_property (GObject *object,
                                      GValue *value,
                                      GParamSpec *pspec);
 
+static gboolean territorio_regioni_on_key_release_event (GtkWidget *widget,
+                                                          GdkEventKey *event,
+                                                          gpointer user_data);
+
 static void territorio_regioni_on_btn_nuovo_clicked (GtkButton *button,
                       gpointer user_data);
 static void territorio_regioni_on_btn_modifica_clicked (GtkButton *button,
@@ -156,6 +162,9 @@ TerritorioRegioni
                        priv->wtransient = GTK_WINDOW (gtk_builder_get_object (priv->commons->gtkbuilder, "w_main"));
                }
 
+       g_signal_connect (priv->widget,
+                         "key-release-event", G_CALLBACK (territorio_regioni_on_key_release_event), (gpointer)a);
+
        g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button8"),
                          "clicked", G_CALLBACK (territorio_regioni_on_btn_nuovo_clicked), (gpointer)a);
        g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button9"),
@@ -346,6 +355,25 @@ territorio_regioni_get_property (GObject *object, guint property_id, GValue *val
 }
 
 /* CALLBACK */
+static gboolean
+territorio_regioni_on_key_release_event (GtkWidget *widget,
+                            GdkEventKey *event,
+                            gpointer user_data)
+{
+       if (event->keyval == GDK_Escape)
+               {
+                       TerritorioRegioniPrivate *priv = TERRITORIO_REGIONI_GET_PRIVATE ((TerritorioRegioni *)user_data);
+
+                       if (priv->selezione)
+                               {
+                                       gtk_button_clicked (GTK_BUTTON (gtk_builder_get_object (priv->commons->gtkbuilder, "button11")));
+                                       return TRUE;
+                               }
+               }
+
+       return FALSE;
+}
+
 static void
 territorio_regioni_on_btn_nuovo_clicked (GtkButton *button,
                       gpointer user_data)
index c8147b114e0276d82339b8b871995fed6832c4bd..9ce4caa6056c121de9972dbb765f32e5b6b77785 100644 (file)
@@ -1,5 +1,5 @@
 /* 
- * Copyright (C) 2010 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2010-2011 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
@@ -17,6 +17,8 @@
  *
  */
 
+#include <gdk/gdkkeysyms.h>
+
 #include <libautoz/autoz.h>
 
 #include "stati.h"
@@ -40,6 +42,10 @@ static void territorio_stati_get_property (GObject *object,
                                      GValue *value,
                                      GParamSpec *pspec);
 
+static gboolean territorio_stati_on_key_release_event (GtkWidget *widget,
+                                                       GdkEventKey *event,
+                                                       gpointer user_data);
+
 static void territorio_stati_on_btn_nuovo_clicked (GtkButton *button,
                       gpointer user_data);
 static void territorio_stati_on_btn_modifica_clicked (GtkButton *button,
@@ -156,6 +162,9 @@ TerritorioStati
                        priv->wtransient = GTK_WINDOW (gtk_builder_get_object (priv->commons->gtkbuilder, "w_main"));
                }
 
+       g_signal_connect (priv->widget,
+                         "key-release-event", G_CALLBACK (territorio_stati_on_key_release_event), (gpointer)a);
+
        g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button1"),
                          "clicked", G_CALLBACK (territorio_stati_on_btn_nuovo_clicked), (gpointer)a);
        g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button2"),
@@ -346,6 +355,25 @@ territorio_stati_get_property (GObject *object, guint property_id, GValue *value
 }
 
 /* CALLBACK */
+static gboolean
+territorio_stati_on_key_release_event (GtkWidget *widget,
+                            GdkEventKey *event,
+                            gpointer user_data)
+{
+       if (event->keyval == GDK_Escape)
+               {
+                       TerritorioStatiPrivate *priv = TERRITORIO_STATI_GET_PRIVATE ((TerritorioStati *)user_data);
+
+                       if (priv->selezione)
+                               {
+                                       gtk_button_clicked (GTK_BUTTON (gtk_builder_get_object (priv->commons->gtkbuilder, "button4")));
+                                       return TRUE;
+                               }
+               }
+
+       return FALSE;
+}
+
 static void
 territorio_stati_on_btn_nuovo_clicked (GtkButton *button,
                       gpointer user_data)
index a777a2d425c684d8f3e8c4b08bd5bb2fb4cc7ee0..10b03e85dba9d2391cc4ea0963f530ac7f04cb86 100644 (file)
--- a/src/vie.c
+++ b/src/vie.c
@@ -1,5 +1,5 @@
 /* 
- * Copyright (C) 2010 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2010-2011 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
@@ -18,6 +18,9 @@
  */
 
 #include <string.h>
+
+#include <gdk/gdkkeysyms.h>
+
 #include <libautoz/autoz.h>
 
 #include "vie.h"
@@ -44,6 +47,13 @@ static void territorio_vie_get_property (GObject *object,
                                      GValue *value,
                                      GParamSpec *pspec);
 
+static gboolean territorio_vie_on_key_release_event (GtkWidget *widget,
+                                                          GdkEventKey *event,
+                                                          gpointer user_data);
+
+static void territorio_vie_on_map (GtkWidget *widget,
+                                        gpointer user_data);
+
 static void territorio_vie_on_btn_nuovo_clicked (GtkButton *button,
                       gpointer user_data);
 static void territorio_vie_on_btn_modifica_clicked (GtkButton *button,
@@ -94,6 +104,8 @@ struct _TerritorioViePrivate
 
                gboolean selezione;
                GtkWindow *wtransient;
+
+               guint signal_map;
        };
 
 G_DEFINE_TYPE (TerritorioVie, territorio_vie, G_TYPE_OBJECT)
@@ -177,6 +189,11 @@ TerritorioVie
                        priv->wtransient = GTK_WINDOW (gtk_builder_get_object (priv->commons->gtkbuilder, "w_main"));
                }
 
+       g_signal_connect (priv->widget,
+                         "key-release-event", G_CALLBACK (territorio_vie_on_key_release_event), (gpointer)a);
+       priv->signal_map = g_signal_connect (priv->widget,
+                         "map", G_CALLBACK (territorio_vie_on_map), (gpointer)a);
+
        g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button45"),
                          "clicked", G_CALLBACK (territorio_vie_on_btn_nuovo_clicked), (gpointer)a);
        g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button46"),
@@ -202,8 +219,6 @@ TerritorioVie
                        gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (priv->commons->gtkbuilder, "button49")));
                }
 
-       territorio_vie_carica (a);
-
        ires1 = autoz_get_resource_from_id (priv->commons->autoz, "territorio_rw");
        if (!autoz_is_allowed (priv->commons->autoz, priv->commons->role_utente, ires1, FALSE))
                {
@@ -419,6 +434,43 @@ territorio_vie_get_property (GObject *object, guint property_id, GValue *value,
 }
 
 /* CALLBACK */
+static gboolean
+territorio_vie_on_key_release_event (GtkWidget *widget,
+                            GdkEventKey *event,
+                            gpointer user_data)
+{
+       if (event->keyval == GDK_Escape)
+               {
+                       TerritorioViePrivate *priv = TERRITORIO_VIE_GET_PRIVATE ((TerritorioVie *)user_data);
+
+                       if (priv->selezione)
+                               {
+                                       gtk_button_clicked (GTK_BUTTON (gtk_builder_get_object (priv->commons->gtkbuilder, "button48")));
+                                       return TRUE;
+                               }
+               }
+       else if (event->keyval == GDK_F2)
+               {
+                       TerritorioViePrivate *priv = TERRITORIO_VIE_GET_PRIVATE ((TerritorioVie *)user_data);
+
+                       gtk_button_clicked (GTK_BUTTON (gtk_builder_get_object (priv->commons->gtkbuilder, "button63")));
+                       return TRUE;
+               }
+
+       return FALSE;
+}
+
+static void
+territorio_vie_on_map (GtkWidget *widget,
+                            gpointer user_data)
+{
+       TerritorioVie *territorio_vie = (TerritorioVie *)user_data;
+       TerritorioViePrivate *priv = TERRITORIO_VIE_GET_PRIVATE (territorio_vie);
+
+       territorio_vie_carica (territorio_vie);
+       g_signal_handler_disconnect (G_OBJECT (priv->widget), priv->signal_map);
+}
+
 static void
 territorio_vie_on_btn_nuovo_clicked (GtkButton *button,
                       gpointer user_data)