From 4ee9d25295f2e0289eed42336cff0e0b385ab2e3 Mon Sep 17 00:00:00 2001 From: Andrea Zagli Date: Tue, 11 Dec 2012 16:17:18 +0100 Subject: [PATCH] =?utf8?q?Possibilit=C3=A0=20di=20filtrare=20gli=20uffici?= =?utf8?q?=20da=20programma=20chiamante.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- configure.ac | 5 ++ libreria/Makefile.am | 2 + src/Makefile.am | 8 ++++ src/marshal.c | 90 +++++++++++++++++++++++++++++++++++ src/marshal.h | 20 ++++++++ src/organigramma_marshal.list | 1 + src/uffici.c | 69 +++++++++++++++++++++++---- src/uffici.h | 1 + 8 files changed, 187 insertions(+), 9 deletions(-) create mode 100644 src/marshal.c create mode 100644 src/marshal.h create mode 100644 src/organigramma_marshal.list diff --git a/configure.ac b/configure.ac index dce3522..2acf1f5 100644 --- a/configure.ac +++ b/configure.ac @@ -23,6 +23,11 @@ AC_PROG_CC AC_PROG_LIBTOOL AC_PROG_RANLIB +dnl ****************************** +dnl glib-genmarshal +dnl ****************************** +AC_PATH_PROG(GLIB_GENMARSHAL, glib-genmarshal) + # Checks for libraries. PKG_CHECK_MODULES(ORGANIGRAMMA, [gio-2.0 >= 2.20 gtk+-2.0 >= 2.16 diff --git a/libreria/Makefile.am b/libreria/Makefile.am index 633d9a1..c17062a 100644 --- a/libreria/Makefile.am +++ b/libreria/Makefile.am @@ -12,6 +12,7 @@ LIBS = $(ORGANIGRAMMA_LIBS) \ lib_LTLIBRARIES = liborganigramma.la liborganigramma_la_SOURCES = \ + ../src/marshal.c \ ../src/nodi.c \ ../src/nodo.c \ ../src/persona.c \ @@ -50,6 +51,7 @@ liborganigramma_la_LDFLAGS = -no-undefined liborganigramma_include_HEADERS = \ ../src/commons.h \ + ../src/marshal.h \ ../src/nodi.h \ ../src/nodo.h \ ../src/persona.h \ diff --git a/src/Makefile.am b/src/Makefile.am index e95a221..43a7fc4 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -10,9 +10,17 @@ LIBS = $(ORGANIGRAMMA_LIBS) \ bin_PROGRAMS = organigramma +marshal.c: marshal.h organigramma_marshal.list $(GLIB_GENMARSHAL) + $(GLIB_GENMARSHAL) organigramma_marshal.list --body --prefix=_organigramma_marshal > $@ + +marshal.h: organigramma_marshal.list $(GLIB_GENMARSHAL) + $(GLIB_GENMARSHAL) organigramma_marshal.list --header --prefix=_organigramma_marshal > $@ + organigramma_SOURCES = \ commons.h \ main.c \ + marshal.c \ + marshal.h \ nodi.c \ nodi.h \ nodo.c \ diff --git a/src/marshal.c b/src/marshal.c new file mode 100644 index 0000000..272f9d0 --- /dev/null +++ b/src/marshal.c @@ -0,0 +1,90 @@ + +#include + + +#ifdef G_ENABLE_DEBUG +#define g_marshal_value_peek_boolean(v) g_value_get_boolean (v) +#define g_marshal_value_peek_char(v) g_value_get_schar (v) +#define g_marshal_value_peek_uchar(v) g_value_get_uchar (v) +#define g_marshal_value_peek_int(v) g_value_get_int (v) +#define g_marshal_value_peek_uint(v) g_value_get_uint (v) +#define g_marshal_value_peek_long(v) g_value_get_long (v) +#define g_marshal_value_peek_ulong(v) g_value_get_ulong (v) +#define g_marshal_value_peek_int64(v) g_value_get_int64 (v) +#define g_marshal_value_peek_uint64(v) g_value_get_uint64 (v) +#define g_marshal_value_peek_enum(v) g_value_get_enum (v) +#define g_marshal_value_peek_flags(v) g_value_get_flags (v) +#define g_marshal_value_peek_float(v) g_value_get_float (v) +#define g_marshal_value_peek_double(v) g_value_get_double (v) +#define g_marshal_value_peek_string(v) (char*) g_value_get_string (v) +#define g_marshal_value_peek_param(v) g_value_get_param (v) +#define g_marshal_value_peek_boxed(v) g_value_get_boxed (v) +#define g_marshal_value_peek_pointer(v) g_value_get_pointer (v) +#define g_marshal_value_peek_object(v) g_value_get_object (v) +#define g_marshal_value_peek_variant(v) g_value_get_variant (v) +#else /* !G_ENABLE_DEBUG */ +/* WARNING: This code accesses GValues directly, which is UNSUPPORTED API. + * Do not access GValues directly in your code. Instead, use the + * g_value_get_*() functions + */ +#define g_marshal_value_peek_boolean(v) (v)->data[0].v_int +#define g_marshal_value_peek_char(v) (v)->data[0].v_int +#define g_marshal_value_peek_uchar(v) (v)->data[0].v_uint +#define g_marshal_value_peek_int(v) (v)->data[0].v_int +#define g_marshal_value_peek_uint(v) (v)->data[0].v_uint +#define g_marshal_value_peek_long(v) (v)->data[0].v_long +#define g_marshal_value_peek_ulong(v) (v)->data[0].v_ulong +#define g_marshal_value_peek_int64(v) (v)->data[0].v_int64 +#define g_marshal_value_peek_uint64(v) (v)->data[0].v_uint64 +#define g_marshal_value_peek_enum(v) (v)->data[0].v_long +#define g_marshal_value_peek_flags(v) (v)->data[0].v_ulong +#define g_marshal_value_peek_float(v) (v)->data[0].v_float +#define g_marshal_value_peek_double(v) (v)->data[0].v_double +#define g_marshal_value_peek_string(v) (v)->data[0].v_pointer +#define g_marshal_value_peek_param(v) (v)->data[0].v_pointer +#define g_marshal_value_peek_boxed(v) (v)->data[0].v_pointer +#define g_marshal_value_peek_pointer(v) (v)->data[0].v_pointer +#define g_marshal_value_peek_object(v) (v)->data[0].v_pointer +#define g_marshal_value_peek_variant(v) (v)->data[0].v_pointer +#endif /* !G_ENABLE_DEBUG */ + + +/* BOOLEAN:UINT (organigramma_marshal.list:1) */ +void +_organigramma_marshal_BOOLEAN__UINT (GClosure *closure, + GValue *return_value G_GNUC_UNUSED, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint G_GNUC_UNUSED, + gpointer marshal_data) +{ + typedef gboolean (*GMarshalFunc_BOOLEAN__UINT) (gpointer data1, + guint arg_1, + gpointer data2); + register GMarshalFunc_BOOLEAN__UINT callback; + register GCClosure *cc = (GCClosure*) closure; + register gpointer data1, data2; + gboolean v_return; + + g_return_if_fail (return_value != NULL); + g_return_if_fail (n_param_values == 2); + + if (G_CCLOSURE_SWAP_DATA (closure)) + { + data1 = closure->data; + data2 = g_value_peek_pointer (param_values + 0); + } + else + { + data1 = g_value_peek_pointer (param_values + 0); + data2 = closure->data; + } + callback = (GMarshalFunc_BOOLEAN__UINT) (marshal_data ? marshal_data : cc->callback); + + v_return = callback (data1, + g_marshal_value_peek_uint (param_values + 1), + data2); + + g_value_set_boolean (return_value, v_return); +} + diff --git a/src/marshal.h b/src/marshal.h new file mode 100644 index 0000000..31f289f --- /dev/null +++ b/src/marshal.h @@ -0,0 +1,20 @@ + +#ifndef ___organigramma_marshal_MARSHAL_H__ +#define ___organigramma_marshal_MARSHAL_H__ + +#include + +G_BEGIN_DECLS + +/* BOOLEAN:UINT (organigramma_marshal.list:1) */ +extern void _organigramma_marshal_BOOLEAN__UINT (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); + +G_END_DECLS + +#endif /* ___organigramma_marshal_MARSHAL_H__ */ + diff --git a/src/organigramma_marshal.list b/src/organigramma_marshal.list new file mode 100644 index 0000000..435fbd4 --- /dev/null +++ b/src/organigramma_marshal.list @@ -0,0 +1 @@ +BOOLEAN:UINT diff --git a/src/uffici.c b/src/uffici.c index 569c382..6581814 100644 --- a/src/uffici.c +++ b/src/uffici.c @@ -21,6 +21,7 @@ #include #include "uffici.h" +#include "marshal.h" #include "ufficio.h" static void organigramma_uffici_class_init (OrganigrammaUfficiClass *klass); @@ -41,6 +42,10 @@ static void organigramma_uffici_get_property (GObject *object, GValue *value, GParamSpec *pspec); +static void organigramma_uffici_on_map_event (GtkWidget *widget, + GdkEvent *event, + gpointer user_data); + static void organigramma_uffici_on_btn_nuovo_clicked (GtkButton *button, gpointer user_data); static void organigramma_uffici_on_btn_modifica_clicked (GtkButton *button, @@ -76,6 +81,8 @@ struct _OrganigrammaUfficiPrivate gboolean selezione; GtkWindow *wtransient; + + guint sign_id; }; G_DEFINE_TYPE (OrganigrammaUffici, organigramma_uffici, G_TYPE_OBJECT) @@ -104,6 +111,21 @@ organigramma_uffici_class_init (OrganigrammaUfficiClass *klass) g_cclosure_marshal_VOID__UINT, G_TYPE_NONE, 1, G_TYPE_UINT); + + /** + * OrganigrammaUffici::ask-toshow: + * @uffici: + * + */ + klass->ask_toshow_signal_id = g_signal_new ("ask-toshow", + G_TYPE_FROM_CLASS (object_class), + G_SIGNAL_RUN_LAST, + 0, + NULL, + NULL, + _organigramma_marshal_BOOLEAN__UINT, + G_TYPE_BOOLEAN, + 1, G_TYPE_UINT); } static void @@ -135,8 +157,9 @@ OrganigrammaUffici error = NULL; gtk_builder_add_objects_from_file (priv->commons->gtkbuilder, priv->commons->guifile, g_strsplit (g_strconcat ("lstore_uffici|", - (selezione ? "w_uffici" : "vbx_uffici"), - NULL), "|", -1), + (selezione ? "w_uffici" : "vbx_uffici"), + NULL), + "|", -1), &error); if (error != NULL) { @@ -173,14 +196,17 @@ OrganigrammaUffici "clicked", G_CALLBACK (organigramma_uffici_on_btn_annulla_clicked), (gpointer)a); g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button27"), "clicked", G_CALLBACK (organigramma_uffici_on_btn_seleziona_clicked), (gpointer)a); + + priv->sign_id = g_signal_connect_after (G_OBJECT (priv->widget), + "map-event", G_CALLBACK (organigramma_uffici_on_map_event), (gpointer)a); } else { gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (priv->commons->gtkbuilder, "button26"))); gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (priv->commons->gtkbuilder, "button27"))); - } - organigramma_uffici_carica (a); + organigramma_uffici_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)) @@ -217,6 +243,10 @@ organigramma_uffici_carica (OrganigrammaUffici *uffici) gint rows; gint row; + guint id; + gboolean toshow; + + OrganigrammaUfficiClass *klass = ORGANIGRAMMA_UFFICI_GET_CLASS (uffici); OrganigrammaUfficiPrivate *priv = ORGANIGRAMMA_UFFICI_GET_PRIVATE (uffici); gtk_list_store_clear (priv->lstore_uffici); @@ -232,11 +262,24 @@ organigramma_uffici_carica (OrganigrammaUffici *uffici) rows = gda_data_model_get_n_rows (dm); for (row = 0; row < rows; row++) { - gtk_list_store_append (priv->lstore_uffici, &iter); - gtk_list_store_set (priv->lstore_uffici, &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); + toshow = TRUE; + id = (guint)gdaex_data_model_get_field_value_integer_at (dm, row, "id"); + if (g_signal_has_handler_pending (G_OBJECT (uffici), + klass->ask_toshow_signal_id, + 0, + TRUE)) + { + g_signal_emit (G_OBJECT (uffici), klass->ask_toshow_signal_id, 0, id, &toshow); + } + + if (toshow) + { + gtk_list_store_append (priv->lstore_uffici, &iter); + gtk_list_store_set (priv->lstore_uffici, &iter, + COL_ID, id, + COL_NOME, gdaex_data_model_get_field_value_stringify_at (dm, row, "nome"), + -1); + } } g_object_unref (dm); @@ -340,6 +383,14 @@ organigramma_uffici_get_property (GObject *object, guint property_id, GValue *va } } +static void +organigramma_uffici_on_map_event (GtkWidget *widget, + GdkEvent *event, + gpointer user_data) +{ + organigramma_uffici_carica ((OrganigrammaUffici *)user_data); +} + /* CALLBACK */ static void organigramma_uffici_on_btn_nuovo_clicked (GtkButton *button, diff --git a/src/uffici.h b/src/uffici.h index 1ee62e7..f2f1d85 100644 --- a/src/uffici.h +++ b/src/uffici.h @@ -51,6 +51,7 @@ struct _OrganigrammaUfficiClass GObjectClass parent_class; guint selezionato_signal_id; + guint ask_toshow_signal_id; }; GType organigramma_uffici_get_type (void) G_GNUC_CONST; -- 2.49.0