OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/printing/print_dialog_gtk.h" | 5 #include "chrome/browser/printing/print_dialog_gtk.h" |
6 | 6 |
7 #include <fcntl.h> | 7 #include <fcntl.h> |
8 #include <gtk/gtkpagesetupunixdialog.h> | 8 #include <gtk/gtkpagesetupunixdialog.h> |
9 #include <gtk/gtkprintjob.h> | 9 #include <gtk/gtkprintjob.h> |
10 #include <sys/stat.h> | 10 #include <sys/stat.h> |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "chrome/browser/ui/browser_window.h" | 21 #include "chrome/browser/ui/browser_window.h" |
22 #include "printing/metafile.h" | 22 #include "printing/metafile.h" |
23 #include "printing/print_job_constants.h" | 23 #include "printing/print_job_constants.h" |
24 #include "printing/print_settings_initializer_gtk.h" | 24 #include "printing/print_settings_initializer_gtk.h" |
25 | 25 |
26 using printing::PageRanges; | 26 using printing::PageRanges; |
27 using printing::PrintSettings; | 27 using printing::PrintSettings; |
28 | 28 |
29 namespace { | 29 namespace { |
30 | 30 |
| 31 // CUPS ColorModel attribute and values. |
| 32 const char kCMYK[] = "CMYK"; |
| 33 const char kCUPSColorModel[] = "cups-ColorModel"; |
| 34 const char kColor[] = "Color"; |
| 35 const char kGrayscale[] = "Grayscale"; |
| 36 |
31 // CUPS Duplex attribute and values. | 37 // CUPS Duplex attribute and values. |
32 const char kCUPSDuplex[] = "cups-Duplex"; | 38 const char kCUPSDuplex[] = "cups-Duplex"; |
33 const char kDuplexNone[] = "None"; | 39 const char kDuplexNone[] = "None"; |
34 const char kDuplexTumble[] = "DuplexTumble"; | 40 const char kDuplexTumble[] = "DuplexTumble"; |
35 const char kDuplexNoTumble[] = "DuplexNoTumble"; | 41 const char kDuplexNoTumble[] = "DuplexNoTumble"; |
36 | 42 |
37 // Helper class to track GTK printers. | 43 // Helper class to track GTK printers. |
38 class GtkPrinterList { | 44 class GtkPrinterList { |
39 public: | 45 public: |
40 GtkPrinterList() : default_printer_(NULL) { | 46 GtkPrinterList() : default_printer_(NULL) { |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 gtk_print_settings_set_printer(gtk_settings_, | 186 gtk_print_settings_set_printer(gtk_settings_, |
181 gtk_printer_get_name(printer_)); | 187 gtk_printer_get_name(printer_)); |
182 if (!page_setup_) { | 188 if (!page_setup_) { |
183 page_setup_ = gtk_printer_get_default_page_size(printer_); | 189 page_setup_ = gtk_printer_get_default_page_size(printer_); |
184 } | 190 } |
185 } | 191 } |
186 | 192 |
187 gtk_print_settings_set_n_copies(gtk_settings_, copies); | 193 gtk_print_settings_set_n_copies(gtk_settings_, copies); |
188 gtk_print_settings_set_collate(gtk_settings_, collate); | 194 gtk_print_settings_set_collate(gtk_settings_, collate); |
189 | 195 |
190 std::string color_value; | 196 const char* color_mode; |
191 std::string color_setting_name; | 197 switch (color) { |
192 printing::GetColorModelForMode(color, &color_setting_name, &color_value); | 198 case printing::COLOR: |
193 gtk_print_settings_set(gtk_settings_, color_setting_name.c_str(), | 199 color_mode = kColor; |
194 color_value.c_str()); | 200 break; |
| 201 case printing::CMYK: |
| 202 color_mode = kCMYK; |
| 203 break; |
| 204 default: |
| 205 color_mode = kGrayscale; |
| 206 break; |
| 207 } |
| 208 gtk_print_settings_set(gtk_settings_, kCUPSColorModel, color_mode); |
195 | 209 |
196 if (duplex_mode != printing::UNKNOWN_DUPLEX_MODE) { | 210 if (duplex_mode != printing::UNKNOWN_DUPLEX_MODE) { |
197 const char* cups_duplex_mode = NULL; | 211 const char* cups_duplex_mode = NULL; |
198 switch (duplex_mode) { | 212 switch (duplex_mode) { |
199 case printing::LONG_EDGE: | 213 case printing::LONG_EDGE: |
200 cups_duplex_mode = kDuplexNoTumble; | 214 cups_duplex_mode = kDuplexNoTumble; |
201 break; | 215 break; |
202 case printing::SHORT_EDGE: | 216 case printing::SHORT_EDGE: |
203 cups_duplex_mode = kDuplexTumble; | 217 cups_duplex_mode = kDuplexTumble; |
204 break; | 218 break; |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 // Printing finished. Matches AddRef() in PrintDocument(); | 408 // Printing finished. Matches AddRef() in PrintDocument(); |
395 Release(); | 409 Release(); |
396 } | 410 } |
397 | 411 |
398 void PrintDialogGtk::InitPrintSettings(const PageRanges& page_ranges) { | 412 void PrintDialogGtk::InitPrintSettings(const PageRanges& page_ranges) { |
399 PrintSettings settings; | 413 PrintSettings settings; |
400 printing::PrintSettingsInitializerGtk::InitPrintSettings( | 414 printing::PrintSettingsInitializerGtk::InitPrintSettings( |
401 gtk_settings_, page_setup_, page_ranges, false, &settings); | 415 gtk_settings_, page_setup_, page_ranges, false, &settings); |
402 context_->InitWithSettings(settings); | 416 context_->InitWithSettings(settings); |
403 } | 417 } |
OLD | NEW |