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. | 31 // CUPS ColorModel attributes. |
32 const char kCMYK[] = "CMYK"; | 32 const char kCUPSColorMode[] = "cups-ColorMode"; |
33 const char kCUPSColorModel[] = "cups-ColorModel"; | 33 const char kCUPSColorModel[] = "cups-ColorModel"; |
34 const char kColor[] = "Color"; | 34 const char kCUPSPrintoutMode[] = "cups-PrintoutMode"; |
35 const char kGrayscale[] = "Grayscale"; | 35 const char kCUPSProcessColorModel[] = "cups-ProcessColorModel"; |
36 | 36 |
37 // CUPS Duplex attribute and values. | 37 // CUPS Duplex attribute and values. |
38 const char kCUPSDuplex[] = "cups-Duplex"; | 38 const char kCUPSDuplex[] = "cups-Duplex"; |
39 const char kDuplexNone[] = "None"; | 39 const char kDuplexNone[] = "None"; |
40 const char kDuplexTumble[] = "DuplexTumble"; | 40 const char kDuplexTumble[] = "DuplexTumble"; |
41 const char kDuplexNoTumble[] = "DuplexNoTumble"; | 41 const char kDuplexNoTumble[] = "DuplexNoTumble"; |
42 | 42 |
43 // Helper class to track GTK printers. | 43 // Helper class to track GTK printers. |
44 class GtkPrinterList { | 44 class GtkPrinterList { |
45 public: | 45 public: |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
186 gtk_print_settings_set_printer(gtk_settings_, | 186 gtk_print_settings_set_printer(gtk_settings_, |
187 gtk_printer_get_name(printer_)); | 187 gtk_printer_get_name(printer_)); |
188 if (!page_setup_) { | 188 if (!page_setup_) { |
189 page_setup_ = gtk_printer_get_default_page_size(printer_); | 189 page_setup_ = gtk_printer_get_default_page_size(printer_); |
190 } | 190 } |
191 } | 191 } |
192 | 192 |
193 gtk_print_settings_set_n_copies(gtk_settings_, copies); | 193 gtk_print_settings_set_n_copies(gtk_settings_, copies); |
194 gtk_print_settings_set_collate(gtk_settings_, collate); | 194 gtk_print_settings_set_collate(gtk_settings_, collate); |
195 | 195 |
196 const char* color_mode; | 196 const char* color_mode; |
vandebo (ex-Chrome)
2011/10/07 18:23:30
maybe call these two color_setting_name and color_
kmadhusu
2011/10/10 23:34:26
Done.
| |
197 const char* color_settings = kCUPSColorModel; | |
197 switch (color) { | 198 switch (color) { |
198 case printing::COLOR: | 199 case printing::COLOR: |
199 color_mode = kColor; | 200 color_mode = printing::kColor; |
200 break; | 201 break; |
201 case printing::CMYK: | 202 case printing::CMYK: |
202 color_mode = kCMYK; | 203 color_mode = printing::kCMYK; |
204 break; | |
205 case printing::PRINTOUTMODE_NORMAL: | |
206 color_mode = printing::kNormal; | |
207 color_settings = kCUPSPrintoutMode; | |
208 break; | |
209 case printing::PRINTOUTMODE_NORMAL_GRAY: | |
210 color_mode = printing::kNormalGray; | |
211 color_settings = kCUPSPrintoutMode; | |
212 break; | |
213 case printing::RGB16: | |
214 color_mode = printing::kRGB16; | |
215 break; | |
216 case printing::CMY: | |
217 color_mode = printing::kCMY; | |
218 break; | |
219 case printing::CMY_K: | |
220 color_mode = printing::kCMY_K; | |
221 break; | |
222 case printing::BLACK: | |
223 color_mode = printing::kBlack; | |
224 break; | |
225 case printing::GRAY: | |
226 color_mode = printing::kGray; | |
227 break; | |
228 case printing::COLORMODE_COLOR: | |
229 color_settings = kCUPSColorMode; | |
230 color_mode = printing::kColor; | |
231 break; | |
232 case printing::COLORMODE_MONOCHROME: | |
233 color_settings = kCUPSColorMode; | |
234 color_mode = printing::kMonochrome; | |
235 break; | |
236 case printing::PROCESSCOLORMODEL_CMYK: | |
237 color_settings = kCUPSProcessColorModel; | |
238 color_mode = printing::kCMYK; | |
239 break; | |
240 case printing::PROCESSCOLORMODEL_GREYSCALE: | |
241 color_settings = kCUPSProcessColorModel; | |
242 color_mode = printing::kGreyscale; | |
243 break; | |
244 case printing::PROCESSCOLORMODEL_RGB: | |
245 color_settings = kCUPSProcessColorModel; | |
246 color_mode = printing::kRGB; | |
203 break; | 247 break; |
204 default: | 248 default: |
205 color_mode = kGrayscale; | 249 color_mode = printing::kGrayscale; |
206 break; | 250 break; |
207 } | 251 } |
208 gtk_print_settings_set(gtk_settings_, kCUPSColorModel, color_mode); | 252 gtk_print_settings_set(gtk_settings_, color_settings, color_mode); |
209 | 253 |
210 if (duplex_mode != printing::UNKNOWN_DUPLEX_MODE) { | 254 if (duplex_mode != printing::UNKNOWN_DUPLEX_MODE) { |
211 const char* cups_duplex_mode = NULL; | 255 const char* cups_duplex_mode = NULL; |
212 switch (duplex_mode) { | 256 switch (duplex_mode) { |
213 case printing::LONG_EDGE: | 257 case printing::LONG_EDGE: |
214 cups_duplex_mode = kDuplexNoTumble; | 258 cups_duplex_mode = kDuplexNoTumble; |
215 break; | 259 break; |
216 case printing::SHORT_EDGE: | 260 case printing::SHORT_EDGE: |
217 cups_duplex_mode = kDuplexTumble; | 261 cups_duplex_mode = kDuplexTumble; |
218 break; | 262 break; |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
408 // Printing finished. Matches AddRef() in PrintDocument(); | 452 // Printing finished. Matches AddRef() in PrintDocument(); |
409 Release(); | 453 Release(); |
410 } | 454 } |
411 | 455 |
412 void PrintDialogGtk::InitPrintSettings(const PageRanges& page_ranges) { | 456 void PrintDialogGtk::InitPrintSettings(const PageRanges& page_ranges) { |
413 PrintSettings settings; | 457 PrintSettings settings; |
414 printing::PrintSettingsInitializerGtk::InitPrintSettings( | 458 printing::PrintSettingsInitializerGtk::InitPrintSettings( |
415 gtk_settings_, page_setup_, page_ranges, false, &settings); | 459 gtk_settings_, page_setup_, page_ranges, false, &settings); |
416 context_->InitWithSettings(settings); | 460 context_->InitWithSettings(settings); |
417 } | 461 } |
OLD | NEW |