From: Andrea Zagli Date: Wed, 17 Aug 2011 09:33:34 +0000 (+0200) Subject: Implementate alcune scorciatoie da tastiera. X-Git-Tag: gtk3~15^2 X-Git-Url: https://saetta.ns0.it/gitweb?a=commitdiff_plain;h=5040683a77c5dfef8517964617918bad63beb712;p=solipa%2Fterritorio Implementate alcune scorciatoie da tastiera. Aggiunto il caricamento record in vie, comuni e province nell'evento map, per dare poi la possibilità di impostare dei filtri dagli oggetti chiamanti. --- diff --git a/data/territorio/gui/territorio.gui b/data/territorio/gui/territorio.gui index d4fa37a..3c59509 100644 --- a/data/territorio/gui/territorio.gui +++ b/data/territorio/gui/territorio.gui @@ -2915,6 +2915,8 @@ gtk-ok True True + True + True True True @@ -3076,6 +3078,8 @@ gtk-ok True True + True + True True True @@ -3237,6 +3241,8 @@ gtk-ok True True + True + True True True diff --git a/src/comuni.c b/src/comuni.c index 864978f..0046aec 100644 --- a/src/comuni.c +++ b/src/comuni.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 Andrea Zagli + * Copyright (C) 2010-2011 Andrea Zagli * * 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 + #include #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) diff --git a/src/province.c b/src/province.c index b1f79d3..233e320 100644 --- a/src/province.c +++ b/src/province.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 Andrea Zagli + * Copyright (C) 2010-2011 Andrea Zagli * * 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 + #include #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) diff --git a/src/regioni.c b/src/regioni.c index f9a6755..2c488cc 100644 --- a/src/regioni.c +++ b/src/regioni.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 Andrea Zagli + * Copyright (C) 2010-2011 Andrea Zagli * * 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 + #include #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) diff --git a/src/stati.c b/src/stati.c index c8147b1..9ce4caa 100644 --- a/src/stati.c +++ b/src/stati.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 Andrea Zagli + * Copyright (C) 2010-2011 Andrea Zagli * * 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 + #include #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) diff --git a/src/vie.c b/src/vie.c index a777a2d..10b03e8 100644 --- a/src/vie.c +++ b/src/vie.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 Andrea Zagli + * Copyright (C) 2010-2011 Andrea Zagli * * 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 + +#include + #include #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)