From 5a365655a530cbdd9c217e6b53cac2c505a1c1e9 Mon Sep 17 00:00:00 2001 From: Andrea Zagli Date: Thu, 3 Oct 2013 10:44:30 +0200 Subject: [PATCH] GdaExGrid: integration with reptool, when present (closes #119). --- configure.ac | 11 ++++++++++ src/Makefile.am | 8 +++++++ src/grid.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+) diff --git a/configure.ac b/configure.ac index 19df4b0..5572827 100644 --- a/configure.ac +++ b/configure.ac @@ -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]) diff --git a/src/Makefile.am b/src/Makefile.am index 9baa50e..f9c9273 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -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 \ diff --git a/src/grid.c b/src/grid.c index d41ffeb..da74ea0 100644 --- a/src/grid.c +++ b/src/grid.c @@ -27,6 +27,11 @@ #include +#ifdef REPTOOL_FOUND + #include + #include +#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 -- 2.49.0