diff options
author | Christian Persch <chpe@cvs.gnome.org> | 2005-09-22 04:21:30 +0800 |
---|---|---|
committer | Christian Persch <chpe@src.gnome.org> | 2005-09-22 04:21:30 +0800 |
commit | 01cd0058fa70e2180f459eb80fb97e3427a119ab (patch) | |
tree | 120b9bc11062560e3f7a4e3272d1dac32ca0065b | |
parent | 810d08d92d2cccd07e75ec60a415cc3d15320fcd (diff) | |
download | gsoc2013-epiphany-01cd0058fa70e2180f459eb80fb97e3427a119ab.tar gsoc2013-epiphany-01cd0058fa70e2180f459eb80fb97e3427a119ab.tar.gz gsoc2013-epiphany-01cd0058fa70e2180f459eb80fb97e3427a119ab.tar.bz2 gsoc2013-epiphany-01cd0058fa70e2180f459eb80fb97e3427a119ab.tar.lz gsoc2013-epiphany-01cd0058fa70e2180f459eb80fb97e3427a119ab.tar.xz gsoc2013-epiphany-01cd0058fa70e2180f459eb80fb97e3427a119ab.tar.zst gsoc2013-epiphany-01cd0058fa70e2180f459eb80fb97e3427a119ab.zip |
Don't use "cat >" as output command, it fails inpredicably. Instead, use
2005-09-21 Christian Persch <chpe@cvs.gnome.org>
* embed/mozilla/EphyUtils.cpp:
* embed/print-dialog.c: (ephy_print_do_print_idle_cb):
Don't use "cat >" as output command, it fails inpredicably.
Instead, use the tempfile setting, and set "PostScript/default"
as printer name. fflush before printing the temp file
using gnome-print. If not using gecko 1.9, translate the paper
name to the one mozilla expects (mozilla bug
https://bugzilla.mozilla.org/show_bug.cgi?id=307404).
-rw-r--r-- | ChangeLog | 12 | ||||
-rw-r--r-- | embed/mozilla/EphyUtils.cpp | 38 | ||||
-rwxr-xr-x | embed/print-dialog.c | 13 |
3 files changed, 48 insertions, 15 deletions
@@ -1,3 +1,15 @@ +2005-09-21 Christian Persch <chpe@cvs.gnome.org> + + * embed/mozilla/EphyUtils.cpp: + * embed/print-dialog.c: (ephy_print_do_print_idle_cb): + + Don't use "cat >" as output command, it fails inpredicably. + Instead, use the tempfile setting, and set "PostScript/default" + as printer name. fflush before printing the temp file + using gnome-print. If not using gecko 1.9, translate the paper + name to the one mozilla expects (mozilla bug + https://bugzilla.mozilla.org/show_bug.cgi?id=307404). + 2005-09-19 Christian Persch <chpe@cvs.gnome.org> * embed/ephy-embed.h: diff --git a/embed/mozilla/EphyUtils.cpp b/embed/mozilla/EphyUtils.cpp index 681f297a5..12d49460e 100644 --- a/embed/mozilla/EphyUtils.cpp +++ b/embed/mozilla/EphyUtils.cpp @@ -130,6 +130,12 @@ EphyUtils::CollatePrintSettings (EmbedPrintInfo *info, nsIPrintSettings *options, gboolean preview) { + NS_ENSURE_ARG (options); + + /* FIXME: for CUPS printers, print directly instead of to a tmp file? */ + const static PRUnichar pName[] = { 'P', 'o', 's', 't', 'S', 'c', 'r', 'i', 'p', 't', '/', 'd', 'e', 'f', 'a', 'u', 'l', 't', '\0' }; + options->SetPrinterName(nsEmbedString(pName).get()); + const static int frame_types[] = { nsIPrintSettings::kFramesAsIs, nsIPrintSettings::kSelectedFrame, @@ -225,7 +231,11 @@ EphyUtils::CollatePrintSettings (EmbedPrintInfo *info, options->SetPrintToFile (PR_FALSE); - if (!preview) + if (preview) + { + options->SetPrintToFile (PR_FALSE); + } + else { char *cmd, *base; const char *temp_dir; @@ -235,16 +245,12 @@ EphyUtils::CollatePrintSettings (EmbedPrintInfo *info, info->tempfile = ephy_file_tmp_filename (base, "ps"); g_free (base); - /* use cat instead of print to file to avoid fflush to ensure - * the file has been written completely and we don't need to - * select a printer (i.e. should be printing backend independent) - */ + if (info->tempfile == NULL) return NS_ERROR_FAILURE; - cmd = g_strconcat ("cat > ", info->tempfile, NULL); - NS_CStringToUTF16 (nsEmbedCString(cmd), + NS_CStringToUTF16 (nsEmbedCString(info->tempfile), NS_CSTRING_ENCODING_UTF8, tmp); - options->SetPrintCommand (tmp.get()); - g_free (cmd); + options->SetPrintToFile (PR_TRUE); + options->SetToFileName (tmp.get()); } /* paper size */ @@ -275,6 +281,11 @@ EphyUtils::CollatePrintSettings (EmbedPrintInfo *info, options->SetPaperHeight (value); } + /* Mozilla bug https://bugzilla.mozilla.org/show_bug.cgi?id=307404 + * means that we cannot actually use any paper sizes except mozilla's + * builtin list, and we must refer to them *by name*! + */ +#ifndef HAVE_GECKO_1_9 /* Gnome-Print names some papers differently than what moz understands */ static const struct { @@ -286,14 +297,14 @@ EphyUtils::CollatePrintSettings (EmbedPrintInfo *info, { "USLetter", "Letter" }, { "USLegal", "Legal" } }; - - char *string; +#endif /* !HAVE_GECKO_1_9 */ /* paper name */ - string = (char *) gnome_print_config_get (info->config, + char *string = (char *) gnome_print_config_get (info->config, (const guchar *) GNOME_PRINT_KEY_PAPER_SIZE); - const char *paper = string; + +#ifndef HAVE_GECKO_1_9 for (PRUint32 i = 0; i < G_N_ELEMENTS (paper_table); i++) { if (string != NULL && @@ -303,6 +314,7 @@ EphyUtils::CollatePrintSettings (EmbedPrintInfo *info, break; } } +#endif /* !HAVE_GECKO_1_9 */ NS_CStringToUTF16 (nsEmbedCString(paper), NS_CSTRING_ENCODING_UTF8, tmp); diff --git a/embed/print-dialog.c b/embed/print-dialog.c index 69140ca8d..cc920d181 100755 --- a/embed/print-dialog.c +++ b/embed/print-dialog.c @@ -34,6 +34,7 @@ #include <unistd.h> #include <string.h> +#include <stdio.h> #include <gtk/gtkwindow.h> #include <gtk/gtkdialog.h> #include <gtk/gtkentry.h> @@ -309,14 +310,22 @@ static gboolean ephy_print_do_print_idle_cb (EmbedPrintInfo *info) { GnomePrintJob *job; + int ret; + + /* Sometimes mozilla doesn't even create the temp file!? */ + if (g_file_test (info->tempfile, G_FILE_TEST_EXISTS) == FALSE) return FALSE; + + /* FIXME: is this actually necessary? libc docs say all streams + * are flushed when reading from any stream. + */ + fflush(NULL); job = gnome_print_job_new (info->config); gnome_print_job_set_file (job, info->tempfile); gnome_print_job_print (job); - g_object_unref (job); - + unlink (info->tempfile); ephy_print_info_free (info); |