[gnumeric] Win32: make print preview work.



commit e48c8640c194220b4c8192887d631be84f4efa97
Author: Morten Welinder <terra gnome org>
Date:   Fri Mar 18 19:34:45 2011 -0400

    Win32: make print preview work.
    
    No guarantees for non-ASCII $TMP.

 ChangeLog   |    4 ++++
 NEWS        |    1 +
 src/print.c |   16 ++++++++++++++++
 3 files changed, 21 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 31f8fde..78cadb0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2011-03-18  Morten Welinder  <terra gnome org>
+
+	* src/print.c (gnm_print_sheet): Punt and use ShellExecute.
+
 2011-03-17  Morten Welinder  <terra gnome org>
 
 	* src/print.c (gnm_print_sheet): Improve error handling.
diff --git a/NEWS b/NEWS
index 5079bb4..0f1d6e9 100644
--- a/NEWS
+++ b/NEWS
@@ -38,6 +38,7 @@ Morten:
 	* Improve date format consistency in document properies.  [#644217]
 	* Hopefully make print preview work on win32.  [#533795]
 	* Improve quit dialog's non-ascii handling.  [#644982]
+	* Make print-preview work on win32 by avoiding gtk+.  [#533795]
 
 Stanley Pinchak:
 	* Improve "dif" output.
diff --git a/src/print.c b/src/print.c
index dee59b9..f532151 100644
--- a/src/print.c
+++ b/src/print.c
@@ -53,6 +53,7 @@
 #include <errno.h>
 
 #ifdef G_OS_WIN32
+#include <windows.h>
 /* see bug #533795. */
 #define PREVIEW_VIA_PDF
 #endif
@@ -1683,12 +1684,27 @@ gnm_print_sheet (WorkbookControl *wbc, Sheet *sheet,
 	}
 
 	if (preview_via_pdf) {
+#ifdef G_OS_WIN32
+		/* For some reason the general code doesn't work for me.
+		   Be brutal, even if this might not work for non-ASCII
+		   filenames.  */
+		int res = (int)ShellExecute (NULL, "open",
+					     tmp_file_name,
+					     NULL,
+					     NULL,
+					     SW_SHOW);
+		if (gnm_debug_flag ("preview")) {
+			g_printerr ("tmp_file_name=%s\n", tmp_file_name);
+			g_printerr ("res=%d\n", res);
+		}
+#else
 		GdkScreen *screen = parent
 			? gtk_widget_get_screen (GTK_WIDGET (parent))
 			: NULL;
 		char *url = go_filename_to_uri (tmp_file_name);
 		go_gtk_url_show (url, screen);
 		g_free (url);
+#endif
 
 		/* We hook this up to delete the temp file when the workbook
 		   is closed or when a new preview is done for the same



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]