]> saetta.ns0.it Git - solipa/organigramma/commitdiff
Possibilità di filtrare gli uffici da programma chiamante.
authorAndrea Zagli <a.zagli@comune.scandicci.fi.it>
Tue, 11 Dec 2012 15:17:18 +0000 (16:17 +0100)
committerAndrea Zagli <a.zagli@comune.scandicci.fi.it>
Tue, 11 Dec 2012 15:17:18 +0000 (16:17 +0100)
configure.ac
libreria/Makefile.am
src/Makefile.am
src/marshal.c [new file with mode: 0644]
src/marshal.h [new file with mode: 0644]
src/organigramma_marshal.list [new file with mode: 0644]
src/uffici.c
src/uffici.h

index dce3522d128827719768951750cf45a5b8b11c68..2acf1f51e53e5e489de80d9b2f81b9b1ecd9181e 100644 (file)
@@ -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
index 633d9a100fd4fbb89e4517073e015a4dbfc9f559..c17062a41decc8faa3e12f5607c115a45ca5ce5f 100644 (file)
@@ -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 \
index e95a221b6b464596b05ab2f7f08f952bb4693c8b..43a7fc4f60e8e3d913cc33602535c59cecac48d4 100644 (file)
@@ -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 (file)
index 0000000..272f9d0
--- /dev/null
@@ -0,0 +1,90 @@
+
+#include       <glib-object.h>
+
+
+#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 (file)
index 0000000..31f289f
--- /dev/null
@@ -0,0 +1,20 @@
+
+#ifndef ___organigramma_marshal_MARSHAL_H__
+#define ___organigramma_marshal_MARSHAL_H__
+
+#include       <glib-object.h>
+
+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 (file)
index 0000000..435fbd4
--- /dev/null
@@ -0,0 +1 @@
+BOOLEAN:UINT
index 569c38266bbac3d3a921e06b2b5a6216759fa52c..658181446f96014cf3ed6c13d0021fe0829bddba 100644 (file)
@@ -21,6 +21,7 @@
 #include <libsolipa/utils.h>
 
 #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,
index 1ee62e7af7772440f6692b20ae10b39a9bf1a070..f2f1d8530b4beb36eb2449a15d89281171eb497e 100644 (file)
@@ -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;