diff options
author | kmadhusu@chromium.org <kmadhusu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-26 15:46:10 +0000 |
---|---|---|
committer | kmadhusu@chromium.org <kmadhusu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-26 15:46:10 +0000 |
commit | a44b0c14173acb28992cd7d843a0de25ee8e33ed (patch) | |
tree | 3f7d4c2ad68126886f1e16df486b3ffee1cd380d /chrome/browser/printing | |
parent | 16aec87fc5c277db901537b5bd56ac09f6b18b11 (diff) | |
download | chromium_src-a44b0c14173acb28992cd7d843a0de25ee8e33ed.zip chromium_src-a44b0c14173acb28992cd7d843a0de25ee8e33ed.tar.gz chromium_src-a44b0c14173acb28992cd7d843a0de25ee8e33ed.tar.bz2 |
PrintPreview: [LINUX] Set color and duplex setting values in print job ticket.
BUG=79931
TEST=Enable print preview in linux. Preview a webpage. Set the color and duplex settings and print the data. Observe the output.
Review URL: http://codereview.chromium.org/6905007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@83021 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/printing')
-rw-r--r-- | chrome/browser/printing/print_dialog_gtk.cc | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/chrome/browser/printing/print_dialog_gtk.cc b/chrome/browser/printing/print_dialog_gtk.cc index 5edab34..596ec9d 100644 --- a/chrome/browser/printing/print_dialog_gtk.cc +++ b/chrome/browser/printing/print_dialog_gtk.cc @@ -29,6 +29,17 @@ using printing::PrintSettings; namespace { +// CUPS ColorModel attribute and values. +const char kCUPSColorModel[] = "cups-ColorModel"; +const char kColor[] = "Color"; +const char kGrayscale[] = "Grayscale"; + +// CUPS Duplex attribute and values. +const char kCUPSDuplex[] = "cups-Duplex"; +const char kDuplexNone[] = "None"; +const char kDuplexTumble[] = "DuplexTumble"; +const char kDuplexNoTumble[] = "DuplexNoTumble"; + // Helper class to track GTK printers. class GtkPrinterList { public: @@ -179,8 +190,29 @@ bool PrintDialogGtk::UpdateSettings(const DictionaryValue& settings, return false; gtk_print_settings_set_collate(gtk_settings_, collate); - // TODO(thestig) Color: gtk_print_settings_set_color() does not work. - // TODO(thestig) Duplex: gtk_print_settings_set_duplex() does not work. + bool is_color; + if (!settings.GetBoolean(printing::kSettingColor, &is_color)) + return false; + + gtk_print_settings_set(gtk_settings_, kCUPSColorModel, + is_color ? kColor : kGrayscale); + int mode; + if (!settings.GetInteger(printing::kSettingDuplexMode, &mode)) + return false; + + const char* cups_duplex_mode; + switch (mode) { + case printing::LONG_EDGE: + cups_duplex_mode = kDuplexNoTumble; + break; + case printing::SHORT_EDGE: + cups_duplex_mode = kDuplexTumble; + break; + default: + cups_duplex_mode = kDuplexNone; + break; + } + gtk_print_settings_set(gtk_settings_, kCUPSDuplex, cups_duplex_mode); InitPrintSettings(ranges); return true; |