commit 763d74571643276570f4f4e5db5d9ebdf1d1593b
parent e61294d9360620aaf830752a0e666425526e6ae6
Author: Colin Leroy <colin@colino.net>
Date: Wed, 13 Mar 2013 10:56:13 +0000
2013-03-13 [colin] 3.9.0cvs116
* src/plugins/fancy/Makefile.am
* src/plugins/fancy/fancy_viewer.c
Fix bug #2980, "html2ps required...". Use standard GtkPrint
Diffstat:
5 files changed, 32 insertions(+), 130 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -1,3 +1,9 @@
+2013-03-13 [colin] 3.9.0cvs116
+
+ * src/plugins/fancy/Makefile.am
+ * src/plugins/fancy/fancy_viewer.c
+ Fix bug #2980, "html2ps required...". Use standard GtkPrint
+
2013-03-13 [colin] 3.9.0cvs115
* src/plugins/fancy/fancy_prefs.c
diff --git a/PATCHSETS b/PATCHSETS
@@ -4613,3 +4613,4 @@
( cvs diff -u -r 1.61.2.108 -r 1.61.2.109 src/account.c; ) > 3.9.0cvs113.patchset
( cvs diff -u -r 1.29.2.14 -r 1.29.2.15 INSTALL; cvs diff -u -r 1.8.2.68 -r 1.8.2.69 README; ) > 3.9.0cvs114.patchset
( cvs diff -u -r 1.1.2.4 -r 1.1.2.5 src/plugins/fancy/fancy_prefs.c; cvs diff -u -r 1.1.2.2 -r 1.1.2.3 src/plugins/fancy/fancy_prefs.h; cvs diff -u -r 1.1.2.4 -r 1.1.2.5 src/plugins/fancy/fancy_viewer.c; cvs diff -u -r 1.1.2.4 -r 1.1.2.5 src/plugins/fancy/fancy_viewer.h; ) > 3.9.0cvs115.patchset
+( cvs diff -u -r 1.1.2.4 -r 1.1.2.5 src/plugins/fancy/Makefile.am; cvs diff -u -r 1.1.2.5 -r 1.1.2.6 src/plugins/fancy/fancy_viewer.c; ) > 3.9.0cvs116.patchset
diff --git a/configure.ac b/configure.ac
@@ -12,7 +12,7 @@ MINOR_VERSION=9
MICRO_VERSION=0
INTERFACE_AGE=0
BINARY_AGE=0
-EXTRA_VERSION=115
+EXTRA_VERSION=116
EXTRA_RELEASE=
EXTRA_GTK2_VERSION=
@@ -1052,7 +1052,7 @@ dnl During this dependancy check we do the checks themselves, define HAVE_X to
dnl either yes or no, and do the AC_SUBST calls.
dnl Archive: libarchive
-dnl Fancy: Webkit, curl, optionally libsoup-gnome, gtkprintunix
+dnl Fancy: Webkit, curl, optionally libsoup-gnome
dnl Gdata: libgdata
dnl Notification: optionally libnotify libindicate libcanberra_gtk hotkey
dnl Pdf-Viewer: libpoppler
@@ -1089,14 +1089,6 @@ fi
AC_SUBST(LIBSOUP_GNOME_CFLAGS)
AC_SUBST(LIBSOUP_GNOME_LIBS)
-dnl gtkprintunix ***************************************************************
-PKG_CHECK_MODULES(GTKPRINTUNIX, gtk+-unix-print-2.0, HAVE_GTKPRINTUNIX=yes, HAVE_GTKPRINTUNIX=no)
-if test x"$HAVE_GTKPRINTUNIX" = xyes; then
- AC_DEFINE(HAVE_GTKPRINTUNIX, 1, [Define if GtkPrintUnix is available])
-fi
-AC_SUBST(GTKPRINTUNIX_CFLAGS)
-AC_SUBST(GTKPRINTUNIX_LIBS)
-
dnl libarchive *****************************************************************
AC_SEARCH_LIBS([archive_read_new], [archive],
ARCHIVE_LIBS=-larchive
diff --git a/src/plugins/fancy/Makefile.am b/src/plugins/fancy/Makefile.am
@@ -27,7 +27,6 @@ INCLUDES = \
AM_CPPFLAGS = \
$(GLIB_CFLAGS) \
$(GTK_CFLAGS) \
- $(GTKPRINTUNIX_CFLAGS) \
$(WEBKIT_CFLAGS) \
$(LIBSOUP_GNOME_CFLAGS) \
$(CURL_CFLAGS)
diff --git a/src/plugins/fancy/fancy_viewer.c b/src/plugins/fancy/fancy_viewer.c
@@ -27,16 +27,7 @@
#include <fancy_prefs.h>
#include <alertpanel.h>
-#if HAVE_GTKPRINTUNIX
#include <printing.h>
-#if GTK_CHECK_VERSION(2,13,1)
-#include <gtk/gtkunixprint.h>
-#else
-#include <gtk/gtkprintoperation.h>
-#include <gtk/gtkprintjob.h>
-#include <gtk/gtkprintunixdialog.h>
-#endif
-#endif
static void
@@ -65,18 +56,13 @@ fancy_text_search(MimeViewer *_viewer, gboolean backward, const gchar *str,
static void
viewer_menu_handler(GtkWidget *menuitem, FancyViewer *viewer);
-static void
-job_complete_cb (GtkPrintJob *print_job, FancyViewer *viewer, GError *error);
-
static gint keypress_events_cb (GtkWidget *widget, GdkEventKey *event,
FancyViewer *viewer);
static void zoom_in_cb(GtkWidget *widget, GdkEvent *ev, FancyViewer *viewer);
static void zoom_out_cb(GtkWidget *widget, GdkEvent *ev, FancyViewer *viewer);
static gboolean fancy_prefs_cb(GtkWidget *widget, GdkEventButton *ev, FancyViewer *viewer);
static void zoom_100_cb(GtkWidget *widget, GdkEvent *ev, FancyViewer *viewer);
-static void open_inner_cb(GtkWidget *widget, FancyViewer *viewer);
static void open_in_browser_cb(GtkWidget *widget, FancyViewer *viewer);
-static WebKitNavigationResponse fancy_open_uri (FancyViewer *viewer);
static void fancy_create_popup_prefs_menu(FancyViewer *viewer);
static void fancy_show_notice(FancyViewer *viewer, const gchar *message);
static size_t download_file_curl_write_cb(void *buffer, size_t size,
@@ -293,124 +279,44 @@ static void fancy_show_mimepart(MimeViewer *_viewer, const gchar *infile,
viewer->loading = TRUE;
g_timeout_add(5, (GtkFunction)fancy_show_mimepart_prepare, viewer);
}
-#if GTK_CHECK_VERSION(2,10,0) && HAVE_GTKPRINTUNIX
-
-static void
-job_complete_cb (GtkPrintJob *print_job, FancyViewer *viewer, GError *error)
-{
- if (error) {
- alertpanel_error(_("Printing failed:\n %s"), error->message);
- }
- viewer->printing = FALSE;
-}
static void fancy_print(MimeViewer *_viewer)
{
FancyViewer *viewer = (FancyViewer *) _viewer;
- MainWindow *mainwin = mainwindow_get_mainwindow();
- gchar *program = NULL, *cmd = NULL;
- gchar *outfile = NULL;
- gint result;
+ GtkPrintOperationResult res;
GError *error = NULL;
- GtkWidget *dialog;
- GtkPrintUnixDialog *print_dialog;
- GtkPrinter *printer;
- GtkPrintJob *job;
+ GtkPrintOperation *op;
gtk_widget_realize(GTK_WIDGET(viewer->view));
while (viewer->loading)
claws_do_idle();
- debug_print("Preparing print job...\n");
-
- program = g_find_program_in_path("html2ps");
-
- if (program == NULL) {
- alertpanel_error(_("Printing HTML is only possible if the program 'html2ps' is installed."));
- return;
- }
- debug_print("filename: %s\n", viewer->filename);
- if (!viewer->filename) {
- alertpanel_error(_("Filename is null."));
- g_free(program);
- return;
- }
-
- outfile = get_tmp_file();
- cmd = g_strdup_printf("%s%s -o %s %s", program,
- viewer->override_prefs_images ? "":" -T", outfile,
- viewer->filename);
-
- g_free(program);
-
- result = execute_command_line(cmd, FALSE);
- g_free(cmd);
-
- if (result != 0) {
- alertpanel_error(_("Conversion to postscript failed."));
- g_free(outfile);
- return;
- }
-
- debug_print("Starting print job...\n");
-
- dialog = gtk_print_unix_dialog_new (_("Print"),
- mainwin? GTK_WINDOW (mainwin->window):NULL);
- print_dialog = GTK_PRINT_UNIX_DIALOG (dialog);
- gtk_print_unix_dialog_set_page_setup (print_dialog, printing_get_page_setup());
- gtk_print_unix_dialog_set_settings (print_dialog, printing_get_settings());
+ op = gtk_print_operation_new();
- gtk_print_unix_dialog_set_manual_capabilities(print_dialog,
- GTK_PRINT_CAPABILITY_GENERATE_PS);
- gtk_print_unix_dialog_set_manual_capabilities(print_dialog,
- GTK_PRINT_CAPABILITY_PREVIEW);
-
- result = gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_hide (dialog);
-
- printer = gtk_print_unix_dialog_get_selected_printer (print_dialog);
-
- if (result != GTK_RESPONSE_OK || !printer) {
- gtk_widget_destroy (dialog);
- g_free(outfile);
- return;
- }
-
- if (!gtk_printer_accepts_ps(printer)) {
- alertpanel_error(_("Printer %s doesn't accept PostScript files."),
- gtk_printer_get_name(printer));
- g_free(outfile);
- return;
- }
-
- printing_store_settings(gtk_print_unix_dialog_get_settings(print_dialog));
-
- job = gtk_print_job_new(viewer->filename, printer, printing_get_settings(),
- printing_get_page_setup());
-
- gtk_print_job_set_source_file(job, outfile, &error);
-
- if (error) {
- alertpanel_error(_("Printing failed:\n%s"), error->message);
- g_error_free(error);
- g_free(outfile);
- return;
- }
-
- viewer->printing = TRUE;
-
- gtk_print_job_send (job, (GtkPrintJobCompleteFunc) job_complete_cb, viewer,
- NULL);
+ /* Config for printing */
+ gtk_print_operation_set_print_settings(op, printing_get_settings());
+ gtk_print_operation_set_default_page_setup(op, printing_get_page_setup());
+#if GTK_CHECK_VERSION(2,18,0)
+ /* enable Page Size and Orientation in the print dialog */
+ gtk_print_operation_set_embed_page_setup(op, TRUE);
+#endif
- while (viewer->printing) {
- claws_do_idle();
+ /* Start printing process */
+ res = webkit_web_frame_print_full(webkit_web_view_get_main_frame(viewer->view),
+ op, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
+ &error);
+
+ if (res == GTK_PRINT_OPERATION_RESULT_ERROR) {
+ gtk_print_operation_get_error(op, &error);
+ debug_print("Error printing message: %s\n",
+ error ? error->message : "no details");
+ } else if (res == GTK_PRINT_OPERATION_RESULT_APPLY) {
+ /* store settings for next printing session */
+ printing_store_settings(gtk_print_operation_get_print_settings(op));
}
-
- g_free(outfile);
-
}
-#endif
+
static gchar *fancy_get_selection (MimeViewer *_viewer)
{
debug_print("fancy_get_selection\n");
@@ -939,9 +845,7 @@ static MimeViewer *fancy_viewer_create(void)
viewer->mimeviewer.get_widget = fancy_get_widget;
viewer->mimeviewer.get_selection = fancy_get_selection;
viewer->mimeviewer.show_mimepart = fancy_show_mimepart;
-#if GTK_CHECK_VERSION(2,10,0) && HAVE_GTKPRINTUNIX
viewer->mimeviewer.print = fancy_print;
-#endif
viewer->mimeviewer.clear_viewer = fancy_clear_viewer;
viewer->mimeviewer.destroy_viewer = fancy_destroy_viewer;
viewer->mimeviewer.text_search = fancy_text_search;