aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Persch <chpe@gnome.org>2007-05-27 19:53:28 +0800
committerChristian Persch <chpe@src.gnome.org>2007-05-27 19:53:28 +0800
commitd439a5efcd743c799c84249b96f79b2a8398f76e (patch)
tree56c6b4720a8dc1db377b57b6bb4b95d50887b560
parent641f5c3fae7ea6bccda0bfa78fdcca7d0ad9de32 (diff)
downloadgsoc2013-epiphany-d439a5efcd743c799c84249b96f79b2a8398f76e.tar
gsoc2013-epiphany-d439a5efcd743c799c84249b96f79b2a8398f76e.tar.gz
gsoc2013-epiphany-d439a5efcd743c799c84249b96f79b2a8398f76e.tar.bz2
gsoc2013-epiphany-d439a5efcd743c799c84249b96f79b2a8398f76e.tar.lz
gsoc2013-epiphany-d439a5efcd743c799c84249b96f79b2a8398f76e.tar.xz
gsoc2013-epiphany-d439a5efcd743c799c84249b96f79b2a8398f76e.tar.zst
gsoc2013-epiphany-d439a5efcd743c799c84249b96f79b2a8398f76e.zip
Take the printer's capabilities into account.
2007-05-27 Christian Persch <chpe@gnome.org> * embed/mozilla/GeckoPrintService.cpp: Take the printer's capabilities into account. svn path=/trunk/; revision=7051
-rw-r--r--ChangeLog6
-rw-r--r--embed/mozilla/GeckoPrintService.cpp49
2 files changed, 46 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index bf5e3d792..7bb56a744 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2007-05-27 Christian Persch <chpe@gnome.org>
+
+ * embed/mozilla/GeckoPrintService.cpp:
+
+ Take the printer's capabilities into account.
+
2007-05-19 Christian Persch <chpe@gnome.org>
* data/glade/epiphany.glade:
diff --git a/embed/mozilla/GeckoPrintService.cpp b/embed/mozilla/GeckoPrintService.cpp
index 376f508b9..98acb7dd9 100644
--- a/embed/mozilla/GeckoPrintService.cpp
+++ b/embed/mozilla/GeckoPrintService.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright © 2006 Christian Persch
+ * Copyright © 2006, 2007 Christian Persch
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
@@ -30,6 +30,7 @@
#include <gtk/gtkprintunixdialog.h>
#include <gtk/gtkstock.h>
#include <gtk/gtkwindow.h>
+#include <gtk/gtkversion.h>
#include <glade/glade-xml.h>
#include <nsStringAPI.h>
@@ -522,6 +523,7 @@ GeckoPrintService::TranslateSettings (GtkPrintSettings *aGtkSettings,
PRBool aIsForPrinting,
nsIPrintSettings *aSettings)
{
+ NS_ENSURE_ARG (aPrinter);
NS_ENSURE_ARG (aGtkSettings);
NS_ENSURE_ARG (aPageSetup);
@@ -533,12 +535,21 @@ GeckoPrintService::TranslateSettings (GtkPrintSettings *aGtkSettings,
}
#endif
+#if GTK_CHECK_VERSION (2, 11, 0)
+ GtkPrintCapabilities capabilities = gtk_printer_get_capabilities (aPrinter);
+#else
+ GtkPrintCapabilities capabilities = GtkPrintCapabilities (GTK_PRINT_CAPABILITY_PAGE_SET |
+ GTK_PRINT_CAPABILITY_COPIES |
+ GTK_PRINT_CAPABILITY_COLLATE |
+ GTK_PRINT_CAPABILITY_REVERSE |
+ GTK_PRINT_CAPABILITY_SCALE);
+#endif
+
/* Initialisation */
aSettings->SetIsInitializedFromPrinter (PR_FALSE); /* FIXME: PR_TRUE? */
aSettings->SetIsInitializedFromPrefs (PR_FALSE); /* FIXME: PR_TRUE? */
aSettings->SetPrintSilent (PR_FALSE);
aSettings->SetShowPrintProgress (PR_TRUE);
- aSettings->SetNumCopies (1);
/* We always print PS to a file and then hand that off to gtk-print */
aSettings->SetPrinterName (LITERAL ("PostScript/default"));
@@ -587,14 +598,31 @@ GeckoPrintService::TranslateSettings (GtkPrintSettings *aGtkSettings,
}
#endif
+ int n_copies = gtk_print_settings_get_n_copies (aGtkSettings);
+ if (n_copies <= 0)
+ return NS_ERROR_FAILURE;
+ if (capabilities & GTK_PRINT_CAPABILITY_COPIES) {
+ aSettings->SetNumCopies (1);
+ } else {
+ /* We have to copy them ourself */
+ aSettings->SetNumCopies (n_copies);
+ gtk_print_settings_set_n_copies (aGtkSettings, 1);
+ }
+
+ gboolean reverse = gtk_print_settings_get_reverse (aGtkSettings);
+ if (capabilities & GTK_PRINT_CAPABILITY_REVERSE) {
+ aSettings->SetPrintReversed (PR_FALSE);
+ } else {
+ aSettings->SetPrintReversed (reverse);
+ gtk_print_settings_set_reverse (aGtkSettings, FALSE);
+ }
+
GtkPageSet pageSet = gtk_print_settings_get_page_set (aGtkSettings);
aSettings->SetPrintOptions (nsIPrintSettings::kPrintEvenPages,
pageSet != GTK_PAGE_SET_ODD);
aSettings->SetPrintOptions (nsIPrintSettings::kPrintEvenPages,
pageSet != GTK_PAGE_SET_EVEN);
- aSettings->SetPrintReversed (gtk_print_settings_get_reverse (aGtkSettings));
-
GtkPrintPages printPages = gtk_print_settings_get_print_pages (aGtkSettings);
switch (printPages) {
case GTK_PRINT_PAGES_RANGES: {
@@ -626,6 +654,11 @@ GeckoPrintService::TranslateSettings (GtkPrintSettings *aGtkSettings,
aSettings->SetPrintRange (nsIPrintSettings::kRangeAllPages);
}
+ /* And clear those in the settings, so the printer doesn't try to apply them too */
+ 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);
+
switch (gtk_print_settings_get_orientation (aGtkSettings)) {
case GTK_PAGE_ORIENTATION_PORTRAIT:
case GTK_PAGE_ORIENTATION_REVERSE_PORTRAIT: /* not supported */
@@ -706,7 +739,10 @@ GeckoPrintService::TranslateSettings (GtkPrintSettings *aGtkSettings,
aSettings->SetPrintFrameType (aPrintFrames);
aSettings->SetPrintFrameTypeUsage (nsIPrintSettings::kUseSettingWhenPossible);
+ /* FIXME: only if GTK_PRINT_CAPABILITY_SCALE is not set? */
aSettings->SetScaling (gtk_print_settings_get_scale (aGtkSettings) / 100.0);
+ gtk_print_settings_set_scale (aGtkSettings, 1.0);
+
aSettings->SetShrinkToFit (PR_FALSE); /* FIXME setting */
aSettings->SetPrintBGColors (eel_gconf_get_boolean (CONF_PRINT_BG_COLORS) != FALSE);
@@ -720,11 +756,6 @@ GeckoPrintService::TranslateSettings (GtkPrintSettings *aGtkSettings,
/* 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); */