aboutsummaryrefslogtreecommitdiffstats
path: root/embed/mozilla
diff options
context:
space:
mode:
authorChristian Persch <chpe@svn.gnome.org>2007-01-24 01:41:33 +0800
committerChristian Persch <chpe@src.gnome.org>2007-01-24 01:41:33 +0800
commitdfb53894ddca40e48d6b895a5f35d71897318bd9 (patch)
treefb88f3d196eb2befc54eb104ded479c99dba7d27 /embed/mozilla
parent829181d6405e9d5709a8242282479e8b8e9b25ea (diff)
downloadgsoc2013-epiphany-dfb53894ddca40e48d6b895a5f35d71897318bd9.tar
gsoc2013-epiphany-dfb53894ddca40e48d6b895a5f35d71897318bd9.tar.gz
gsoc2013-epiphany-dfb53894ddca40e48d6b895a5f35d71897318bd9.tar.bz2
gsoc2013-epiphany-dfb53894ddca40e48d6b895a5f35d71897318bd9.tar.lz
gsoc2013-epiphany-dfb53894ddca40e48d6b895a5f35d71897318bd9.tar.xz
gsoc2013-epiphany-dfb53894ddca40e48d6b895a5f35d71897318bd9.tar.zst
gsoc2013-epiphany-dfb53894ddca40e48d6b895a5f35d71897318bd9.zip
Clear some print settings in the settings we hand to the print job, so
2007-01-23 Christian Persch <chpe@svn.gnome.org> * embed/mozilla/EphyBrowser.cpp: * embed/mozilla/GeckoPrintService.cpp: * embed/mozilla/GeckoPrintService.h: * embed/mozilla/GeckoPrintSession.cpp: Clear some print settings in the settings we hand to the print job, so they don't get applied twice. Bug #394818. Prepare for printing to PDF (#if 0'd until the gecko bug is fixed). svn path=/trunk/; revision=6844
Diffstat (limited to 'embed/mozilla')
-rw-r--r--embed/mozilla/EphyBrowser.cpp1
-rw-r--r--embed/mozilla/GeckoPrintService.cpp69
-rw-r--r--embed/mozilla/GeckoPrintService.h3
-rw-r--r--embed/mozilla/GeckoPrintSession.cpp2
4 files changed, 62 insertions, 13 deletions
diff --git a/embed/mozilla/EphyBrowser.cpp b/embed/mozilla/EphyBrowser.cpp
index a233279a3..c04a18710 100644
--- a/embed/mozilla/EphyBrowser.cpp
+++ b/embed/mozilla/EphyBrowser.cpp
@@ -748,6 +748,7 @@ nsresult EphyBrowser::SetPrintPreviewMode (PRBool previewMode)
EphyEmbedShell *shell = ephy_embed_shell_get_default ();
rv = GeckoPrintService::TranslateSettings (ephy_embed_shell_get_print_settings (shell),
ephy_embed_shell_get_page_setup (shell),
+ NULL,
nsCString(),
PR_FALSE,
settings);
diff --git a/embed/mozilla/GeckoPrintService.cpp b/embed/mozilla/GeckoPrintService.cpp
index 59a9c3734..c3c801878 100644
--- a/embed/mozilla/GeckoPrintService.cpp
+++ b/embed/mozilla/GeckoPrintService.cpp
@@ -154,14 +154,18 @@ GeckoPrintService::ShowPrintDialog (nsIDOMWindow *aParent,
GTK_WINDOW (parent));
GtkPrintUnixDialog *print_dialog = GTK_PRINT_UNIX_DIALOG (dialog);
- gtk_print_unix_dialog_set_manual_capabilities
- (print_dialog,
+ GtkPrintCapabilities capabilities =
GtkPrintCapabilities (GTK_PRINT_CAPABILITY_PAGE_SET |
GTK_PRINT_CAPABILITY_COPIES |
GTK_PRINT_CAPABILITY_COLLATE |
GTK_PRINT_CAPABILITY_REVERSE |
GTK_PRINT_CAPABILITY_SCALE |
- GTK_PRINT_CAPABILITY_GENERATE_PS));
+ GTK_PRINT_CAPABILITY_GENERATE_PS);
+#if 0 //def HAVE_GECKO_1_9
+ capabilities = GtkPrintCapabilities (capabilities | GTK_PRINT_CAPABILITY_GENERATE_PDF);
+#endif
+ gtk_print_unix_dialog_set_manual_capabilities (print_dialog, capabilities);
+
gtk_print_unix_dialog_set_page_setup (print_dialog,
ephy_embed_shell_get_page_setup (shell));
gtk_print_unix_dialog_set_settings (print_dialog,
@@ -188,13 +192,22 @@ GeckoPrintService::ShowPrintDialog (nsIDOMWindow *aParent,
return NS_ERROR_ABORT;
}
- GtkPageSetup *pageSetup = gtk_print_unix_dialog_get_page_setup (print_dialog);
+ GtkPageSetup *pageSetup = gtk_print_unix_dialog_get_page_setup (print_dialog); /* no reference owned */
ephy_embed_shell_set_page_setup (shell, pageSetup);
GtkPrintSettings *settings = gtk_print_unix_dialog_get_settings (print_dialog);
ephy_embed_shell_set_print_settings (shell, settings);
- /* This adopts the refcount of |settings| */
+ /* We copy the setup and settings so we can modify them to unset
+ * options handled by gecko.
+ */
+ GtkPageSetup *pageSetupCopy = gtk_page_setup_copy (pageSetup);
+ pageSetup = pageSetupCopy;
+
+ GtkPrintSettings *settingsCopy = gtk_print_settings_copy (settings);
+ g_object_unref (settings);
+ settings = settingsCopy;
+
rv = session->SetSettings (settings, pageSetup, printer);
/* Now translate the settings to nsIPrintSettings */
@@ -202,7 +215,7 @@ GeckoPrintService::ShowPrintDialog (nsIDOMWindow *aParent,
nsCString sourceFile;
session->GetSourceFile (sourceFile);
if (!sourceFile.IsEmpty ()) {
- rv = TranslateSettings (settings, pageSetup, sourceFile, PR_TRUE, aSettings);
+ rv = TranslateSettings (settings, pageSetup, printer, sourceFile, PR_TRUE, aSettings);
} else {
rv = NS_ERROR_FAILURE;
}
@@ -210,6 +223,9 @@ GeckoPrintService::ShowPrintDialog (nsIDOMWindow *aParent,
gtk_widget_destroy (dialog);
+ g_object_unref (settings);
+ g_object_unref (pageSetup);
+
return rv;
}
@@ -470,6 +486,7 @@ GeckoPrintService::PrintUnattended (nsIDOMWindow *aParent,
/* static */ nsresult
GeckoPrintService::TranslateSettings (GtkPrintSettings *aGtkSettings,
GtkPageSetup *aPageSetup,
+ GtkPrinter *aPrinter,
const nsACString &aSourceFile,
PRBool aIsForPrinting,
nsIPrintSettings *aSettings)
@@ -519,6 +536,26 @@ GeckoPrintService::TranslateSettings (GtkPrintSettings *aGtkSettings,
aSettings->SetPrintPageDelay (50);
if (aIsForPrinting) {
+#if 0 //def HAVE_GECKO_1_9
+ NS_ENSURE_TRUE (aPrinter, NS_ERROR_FAILURE);
+
+ const char *format = gtk_print_settings_get (aGtkSettings, GTK_PRINT_SETTINGS_OUTPUT_FILE_FORMAT);
+ if (!format)
+ format = "ps";
+
+ if (strcmp (format, "pdf") == 0 &&
+ gtk_printer_accepts_pdf (aPrinter)) {
+ aSettings->SetOutputFormat (nsIPrintSettings::kOutputFormatPDF);
+ } else if (strcmp (format, "ps") == 0 &&
+ gtk_printer_accepts_ps (aPrinter)) {
+ aSettings->SetOutputFormat (nsIPrintSettings::kOutputFormatPS);
+ } else {
+ g_warning ("Output format '%s' specified, but printer '%s' does not support it!",
+ format, gtk_printer_get_name (aPrinter));
+ return NS_ERROR_FAILURE;
+ }
+#endif
+
GtkPageSet pageSet = gtk_print_settings_get_page_set (aGtkSettings);
aSettings->SetPrintOptions (nsIPrintSettings::kPrintEvenPages,
pageSet != GTK_PAGE_SET_ODD);
@@ -540,8 +577,9 @@ GeckoPrintService::TranslateSettings (GtkPrintSettings *aGtkSettings,
aSettings->SetEndPageRange (pageRanges[0].end + 1);
g_free (pageRanges);
+ break;
}
- break;
+ /* Fall-through to PAGES_ALL */
}
case GTK_PRINT_PAGES_CURRENT:
/* not supported, fall through */
@@ -573,8 +611,6 @@ GeckoPrintService::TranslateSettings (GtkPrintSettings *aGtkSettings,
aSettings->SetPaperSizeUnit(nsIPrintSettings::kPaperSizeMillimeters);
aSettings->SetPaperSize (nsIPrintSettings::kPaperSizeDefined);
- // FIXME for some reason this is always NULL ??
- // GtkPaperSize *paperSize = gtk_print_settings_get_paper_size (aGtkSettings);
GtkPaperSize *paperSize = gtk_page_setup_get_paper_size (aPageSetup);
if (!paperSize) {
return NS_ERROR_FAILURE;
@@ -623,8 +659,6 @@ GeckoPrintService::TranslateSettings (GtkPrintSettings *aGtkSettings,
}
#endif /* !HAVE_GECKO_1_9 */
- // gtk_paper_size_free (paperSize);
-
/* Sucky mozilla wants margins in inch! */
aSettings->SetMarginTop (gtk_page_setup_get_top_margin (aPageSetup, GTK_UNIT_INCH));
aSettings->SetMarginBottom (gtk_page_setup_get_bottom_margin (aPageSetup, GTK_UNIT_INCH));
@@ -658,5 +692,18 @@ GeckoPrintService::TranslateSettings (GtkPrintSettings *aGtkSettings,
/* aSettings->SetResolutionName (LITERAL ("default")); */
/* aSettings->SetDownloadFonts (PR_TRUE); */
+ /* Unset those setting that we can handle, so they don't get applied
+ * again for the print job.
+ */
+ gtk_print_settings_set_print_pages (aGtkSettings, GTK_PRINT_PAGES_ALL);
+ gtk_print_settings_set_page_ranges (aGtkSettings, NULL, 0);
+ gtk_print_settings_set_page_set (aGtkSettings, GTK_PAGE_SET_ALL);
+ gtk_print_settings_set_reverse (aGtkSettings, FALSE);
+ gtk_print_settings_set_scale (aGtkSettings, 1.0);
+ /* gtk_print_settings_set_collate (aGtkSettings, FALSE); not yet */
+ /* FIXME: Unset the orientation for the print job? */
+ /* gtk_print_settings_set_orientation (aGtkSettings, GTK_PAGE_ORIENTATION_PORTRAIT); */
+ /* FIXME: unset output format -> "ps" ? */
+
return NS_OK;
}
diff --git a/embed/mozilla/GeckoPrintService.h b/embed/mozilla/GeckoPrintService.h
index e77e00b6d..c5a2ae429 100644
--- a/embed/mozilla/GeckoPrintService.h
+++ b/embed/mozilla/GeckoPrintService.h
@@ -23,6 +23,7 @@
#include <gtk/gtkpagesetup.h>
#include <gtk/gtkprintsettings.h>
+#include <gtk/gtkprinter.h>
#include <nsIPrintingPromptService.h>
@@ -44,7 +45,7 @@ public:
GeckoPrintService();
virtual ~GeckoPrintService();
- static nsresult TranslateSettings (GtkPrintSettings*, GtkPageSetup *, const nsACString&, PRBool, nsIPrintSettings*);
+ static nsresult TranslateSettings (GtkPrintSettings*, GtkPageSetup *, GtkPrinter *, const nsACString&, PRBool, nsIPrintSettings*);
private:
nsresult PrintUnattended (nsIDOMWindow *, nsIPrintSettings *);
diff --git a/embed/mozilla/GeckoPrintSession.cpp b/embed/mozilla/GeckoPrintSession.cpp
index 4c60bc74f..e433d71a7 100644
--- a/embed/mozilla/GeckoPrintSession.cpp
+++ b/embed/mozilla/GeckoPrintSession.cpp
@@ -105,7 +105,7 @@ GeckoPrintSession::SetSettings (GtkPrintSettings *aSettings,
NS_ASSERTION (!mSettings && !mPageSetup && !mPrinter, "Already have settings!");
NS_ENSURE_ARG (aSettings);
- mSettings = aSettings; /* this one is adopted */
+ mSettings = (GtkPrintSettings *) g_object_ref (aSettings);
NS_ENSURE_ARG (aPageSetup);
NS_ENSURE_ARG (aPrinter);