]> saetta.ns0.it Git - libgdaex/commitdiff
GdaExGrid: integration with reptool, when present (closes #119).
authorAndrea Zagli <a.zagli@comune.scandicci.fi.it>
Thu, 3 Oct 2013 08:44:30 +0000 (10:44 +0200)
committerAndrea Zagli <a.zagli@comune.scandicci.fi.it>
Thu, 3 Oct 2013 09:08:50 +0000 (11:08 +0200)
configure.ac
src/Makefile.am
src/grid.c

index 19df4b0ebe0370a5b62f5698e8ad04fcaf284065..5572827718012f945ec955de8b0ce0cb8433b6f2 100644 (file)
@@ -48,6 +48,17 @@ PKG_CHECK_MODULES(GDAEX, [gmodule-2.0 >= 2
 AC_SUBST(GDAEX_CFLAGS)
 AC_SUBST(GDAEX_LIBS)
 
+PKG_CHECK_EXISTS(libreptool >= 0.2.2, [LIBREPTOOL_FOUND=yes], [LIBREPTOOL_FOUND=no])
+
+AM_CONDITIONAL(LIBREPTOOL_FOUND, test $LIBREPTOOL_FOUND = yes)
+
+if test $LIBREPTOOL_FOUND = yes; then
+PKG_CHECK_MODULES(REPTOOL, libreptool >= 0.2.2)
+
+AC_SUBST(REPTOOL_CFLAGS)
+AC_SUBST(REPTOOL_LIBS)
+fi
+
 # Checks for header files.
 AC_HEADER_STDC
 AC_CHECK_HEADERS([string.h])
index 9baa50e8e7cbe07b426885747894302eb36492e0..f9c927366adc2f369df21237cb6bdb3ea96509ad 100644 (file)
@@ -8,6 +8,14 @@ AM_CPPFLAGS = -I$(top_srcdir) \
 
 LIBS = $(GDAEX_LIBS)
 
+if LIBREPTOOL_FOUND
+AM_CPPFLAGS += \
+               $(REPTOOL_CFLAGS) \
+               -DREPTOOL_FOUND=1
+LIBS += \
+        $(REPTOOL_LIBS)
+endif
+
 lib_LTLIBRARIES = libgdaex.la
 
 libgdaex_la_SOURCES = gdaex.c \
index d41ffeb69fef361f27a3cbd4d25f7785400866d4..da74ea0d7cbae3c49694d6ac2d4c903450c9dacc 100644 (file)
 
 #include <gtk/gtk.h>
 
+#ifdef REPTOOL_FOUND
+       #include <gdk/gdkkeysyms.h>
+       #include <libreptool/libreptool.h>
+#endif
+
 #include "grid.h"
 
 static void gdaex_grid_class_init (GdaExGridClass *klass);
@@ -41,6 +46,12 @@ static void gdaex_grid_get_property (GObject *object,
                                GValue *value,
                                GParamSpec *pspec);
 
+#ifdef REPTOOL_FOUND
+static gboolean gdaex_grid_on_key_release_event (GtkWidget *widget,
+                            GdkEventKey *event,
+                            gpointer user_data);
+#endif
+
 static GtkTreeModel *gdaex_grid_get_model (GdaExGrid *grid);
 static GtkTreeView *gdaex_grid_get_view (GdaExGrid *grid);
 
@@ -418,6 +429,52 @@ static GtkTreeView
                                }
                }
 
+#ifdef REPTOOL_FOUND
+       g_signal_connect (view,
+                         "key-release-event", G_CALLBACK (gdaex_grid_on_key_release_event), (gpointer)view);
+#endif
+
        return GTK_TREE_VIEW (view);
 }
 
+#ifdef REPTOOL_FOUND
+static gboolean
+gdaex_grid_on_key_release_event (GtkWidget *widget,
+                            GdkEventKey *event,
+                            gpointer user_data)
+{
+       RptReport *rptr;
+       RptPrint *rptp;
+
+       switch (event->keyval)
+               {
+                       case GDK_F12:
+                               {
+                                       if (event->state & GDK_CONTROL_MASK)
+                                               {
+                                                       rptr = rpt_report_new_from_gtktreeview (GTK_TREE_VIEW (user_data), NULL);
+
+                                                       if (rptr != NULL)
+                                                               {
+                                                                       xmlDoc *report = rpt_report_get_xml (rptr);
+                                                                       rpt_report_set_output_type (rptr, RPT_OUTPUT_GTK);
+
+                                                                       xmlDoc *rptprint = rpt_report_get_xml_rptprint (rptr);
+
+                                                                       rptp = rpt_print_new_from_xml (rptprint);
+                                                                       if (rptp != NULL)
+                                                                               {
+                                                                                       rpt_print_set_output_type (rptp, RPT_OUTPUT_GTK);
+                                                                                       rpt_print_print (rptp, GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (user_data))));
+                                                                               }
+                                                               }
+
+                                                       return TRUE;
+                                               }
+                                       break;
+                               }
+               }
+
+       return FALSE;
+}
+#endif