aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--embed/mozilla/EphyUtils.cpp53
2 files changed, 36 insertions, 23 deletions
diff --git a/ChangeLog b/ChangeLog
index ae8d995af..a04f4a743 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2005-10-06 Christian Persch <chpe@cvs.gnome.org>
+ * embed/mozilla/EphyUtils.cpp:
+
+ Sync with gnome-2-12.
+
+2005-10-06 Christian Persch <chpe@cvs.gnome.org>
+
* src/ephy-toolbar.c: (ephy_toolbar_update_spinner),
(ephy_toolbar_set_show_leave_fullscreen),
(ephy_toolbar_set_security_state),
diff --git a/embed/mozilla/EphyUtils.cpp b/embed/mozilla/EphyUtils.cpp
index 681f297a5..24e674591 100644
--- a/embed/mozilla/EphyUtils.cpp
+++ b/embed/mozilla/EphyUtils.cpp
@@ -122,7 +122,10 @@ EphyUtils::FindGtkParent (nsIDOMWindow *aDOMWindow)
GtkWidget *embed = FindEmbed (aDOMWindow);
NS_ENSURE_TRUE (embed, nsnull);
- return gtk_widget_get_toplevel (GTK_WIDGET (embed));
+ GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (embed));
+ if (!GTK_WIDGET_TOPLEVEL (toplevel)) return nsnull;
+
+ return toplevel;
}
nsresult
@@ -130,6 +133,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,9 +234,13 @@ EphyUtils::CollatePrintSettings (EmbedPrintInfo *info,
options->SetPrintToFile (PR_FALSE);
- if (!preview)
+ if (preview)
+ {
+ options->SetPrintToFile (PR_FALSE);
+ }
+ else
{
- char *cmd, *base;
+ char *base;
const char *temp_dir;
temp_dir = ephy_file_tmp_dir ();
@@ -235,30 +248,18 @@ 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 */
options->SetPaperSize (nsIPrintSettings::kPaperSizeDefined);
options->SetPaperSizeUnit (nsIPrintSettings::kPaperSizeMillimeters);
- /* NOTE: Due to completely braindead mozilla code, the paper
- * dimensions aren't actually used. We have to set the paper name,
- * and only 6 papers formats are accepted
- * (A3, A4, A5, Letter, Legal, Executive).
- *
- * See http://lxr.mozilla.org/seamonkey/source/gfx/src/ps/nsPostScriptObj.cpp#301 and
- * http://lxr.mozilla.org/seamonkey/source/gfx/src/psshared/nsPaperPS.cpp#46 .
- */
if (gnome_print_config_get_length (info->config,
(const guchar *) GNOME_PRINT_KEY_PAPER_WIDTH,
&value, &unit)
@@ -275,6 +276,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 +292,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 +309,7 @@ EphyUtils::CollatePrintSettings (EmbedPrintInfo *info,
break;
}
}
+#endif /* !HAVE_GECKO_1_9 */
NS_CStringToUTF16 (nsEmbedCString(paper),
NS_CSTRING_ENCODING_UTF8, tmp);