r19025 - gnucash/trunk - When printing WebKit based reports respect the Page Setup settings.

Mike Alexander mta at code.gnucash.org
Fri Apr 16 01:26:25 EDT 2010


Author: mta
Date: 2010-04-16 01:26:25 -0400 (Fri, 16 Apr 2010)
New Revision: 19025
Trac: http://svn.gnucash.org/trac/changeset/19025

Modified:
   gnucash/trunk/configure.in
   gnucash/trunk/src/html/gnc-html-webkit.c
Log:
When printing WebKit based reports respect the Page Setup settings.
If webkit_web_frame_print_full exists in the version of WebKit being used then 
use it with a GtkPrintOperation which has been initialized from the Page
Setup data.

Modified: gnucash/trunk/configure.in
===================================================================
--- gnucash/trunk/configure.in	2010-04-15 11:47:09 UTC (rev 19024)
+++ gnucash/trunk/configure.in	2010-04-16 05:26:25 UTC (rev 19025)
@@ -1033,6 +1033,8 @@
                                [Select HTML engine [default=gtkhtml]]),
                 [],[with_html_engine="gtkhtml"])
 
+    AC_MSG_RESULT([$with_html_engine])
+
     case "$with_html_engine" in
          gtkhtml)
 
@@ -1056,12 +1058,24 @@
 	     webkit)
   		    PKG_CHECK_MODULES(WEBKIT, webkit-1.0 >= "1.0")
   		    AC_DEFINE(WANT_WEBKIT,1,[Use webkit instead of gtkhtml])
+  		    AC_MSG_CHECKING(for webkit_web_frame_print_full)
+  		    saved_CFLAGS="${CFLAGS}"
+	            saved_LIBS="${LIBS}"
+	            CFLAGS="${CFLAGS} ${WEBKIT_CFLAGS}"
+	            LIBS="${LIBS} ${WEBKIT_LIBS}"
+  		    AC_LINK_IFELSE(
+  		        [AC_LANG_PROGRAM(
+  		            [[#include <webkit/webkit.h>]],
+  		            [[webkit_web_frame_print_full( 0, 0, 0, 0 );]])],
+  		            [AC_MSG_RESULT(yes)
+  		             AC_DEFINE(HAVE_WEBKIT_PRINT_FULL,1,[webkit_web_frame_print_full exists])],
+  		            [AC_MSG_RESULT(no)])
+  		    CFLAGS="${saved_CFLAGS}"
+  		    LIBS="${saved_LIBS}"
 		    ;;
 	     *) AC_MSG_ERROR([Invalid HTML engine: must be gtkhtml or webkit]) ;;
     esac
 
-    AC_MSG_RESULT([$with_html_engine])
-
     AM_CONDITIONAL(HTML_USING_WEBKIT, [test x${with_html_engine} = xwebkit])
     AC_SUBST(WEBKIT_CFLAGS)
     AC_SUBST(WEBKIT_LIBS)

Modified: gnucash/trunk/src/html/gnc-html-webkit.c
===================================================================
--- gnucash/trunk/src/html/gnc-html-webkit.c	2010-04-15 11:47:09 UTC (rev 19024)
+++ gnucash/trunk/src/html/gnc-html-webkit.c	2010-04-16 05:26:25 UTC (rev 19025)
@@ -47,6 +47,7 @@
 #include "gnc-html-webkit.h"
 #include "gnc-html-history.h"
 #include "gnc-html-graph-gog-webkit.h"
+#include "print-session.h"
 
 G_DEFINE_TYPE(GncHtmlWebkit, gnc_html_webkit, GNC_TYPE_HTML )
 
@@ -1036,13 +1037,13 @@
 static void
 impl_webkit_print( GncHtml* self )
 {
-#ifndef G_OS_WIN32
+#ifndef HAVE_WEBKIT_PRINT_FULL
     extern void webkit_web_frame_print( WebKitWebFrame * frame );
 #endif
 
     GncHtmlWebkitPrivate* priv;
     WebKitWebFrame* frame;
-#ifdef G_OS_WIN32
+#ifdef HAVE_WEBKIT_PRINT_FULL
     GtkPrintOperation* op = gtk_print_operation_new();
     GError* error = NULL;
 #endif
@@ -1050,8 +1051,11 @@
     priv = GNC_HTML_WEBKIT_GET_PRIVATE(self);
     frame = webkit_web_view_get_main_frame( priv->web_view );
 
+#ifdef HAVE_WEBKIT_PRINT_FULL
+    gnc_print_operation_init( op );
 #ifdef G_OS_WIN32
     gtk_print_operation_set_unit( op, GTK_UNIT_POINTS );
+#endif
     webkit_web_frame_print_full( frame, op, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, &error );
     g_object_unref( op );
 



More information about the gnucash-changes mailing list