| 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 | |
| 37 // CUPS Duplex attribute and values. | 31 // CUPS Duplex attribute and values. |
| 38 const char kCUPSDuplex[] = "cups-Duplex"; | 32 const char kCUPSDuplex[] = "cups-Duplex"; |
| 39 const char kDuplexNone[] = "None"; | 33 const char kDuplexNone[] = "None"; |
| 40 const char kDuplexTumble[] = "DuplexTumble"; | 34 const char kDuplexTumble[] = "DuplexTumble"; |
| 41 const char kDuplexNoTumble[] = "DuplexNoTumble"; | 35 const char kDuplexNoTumble[] = "DuplexNoTumble"; |
| 42 | 36 |
| 43 // Helper class to track GTK printers. | 37 // Helper class to track GTK printers. |
| 44 class GtkPrinterList { | 38 class GtkPrinterList { |
| 45 public: | 39 public: |
| 46 GtkPrinterList() : default_printer_(NULL) { | 40 GtkPrinterList() : default_printer_(NULL) { |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 gtk_print_settings_set_printer(gtk_settings_, | 180 gtk_print_settings_set_printer(gtk_settings_, |
| 187 gtk_printer_get_name(printer_)); | 181 gtk_printer_get_name(printer_)); |
| 188 if (!page_setup_) { | 182 if (!page_setup_) { |
| 189 page_setup_ = gtk_printer_get_default_page_size(printer_); | 183 page_setup_ = gtk_printer_get_default_page_size(printer_); |
| 190 } | 184 } |
| 191 } | 185 } |
| 192 | 186 |
| 193 gtk_print_settings_set_n_copies(gtk_settings_, copies); | 187 gtk_print_settings_set_n_copies(gtk_settings_, copies); |
| 194 gtk_print_settings_set_collate(gtk_settings_, collate); | 188 gtk_print_settings_set_collate(gtk_settings_, collate); |
| 195 | 189 |
| 196 const char* color_mode; | 190 std::string color_value; |
| 197 switch (color) { | 191 std::string color_setting_name; |
| 198 case printing::COLOR: | 192 printing::GetColorModelForMode(color, &color_setting_name, &color_value); |
| 199 color_mode = kColor; | 193 gtk_print_settings_set(gtk_settings_, color_setting_name.c_str(), |
| 200 break; | 194 color_value.c_str()); |
| 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); | |
| 209 | 195 |
| 210 if (duplex_mode != printing::UNKNOWN_DUPLEX_MODE) { | 196 if (duplex_mode != printing::UNKNOWN_DUPLEX_MODE) { |
| 211 const char* cups_duplex_mode = NULL; | 197 const char* cups_duplex_mode = NULL; |
| 212 switch (duplex_mode) { | 198 switch (duplex_mode) { |
| 213 case printing::LONG_EDGE: | 199 case printing::LONG_EDGE: |
| 214 cups_duplex_mode = kDuplexNoTumble; | 200 cups_duplex_mode = kDuplexNoTumble; |
| 215 break; | 201 break; |
| 216 case printing::SHORT_EDGE: | 202 case printing::SHORT_EDGE: |
| 217 cups_duplex_mode = kDuplexTumble; | 203 cups_duplex_mode = kDuplexTumble; |
| 218 break; | 204 break; |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 // Printing finished. Matches AddRef() in PrintDocument(); | 394 // Printing finished. Matches AddRef() in PrintDocument(); |
| 409 Release(); | 395 Release(); |
| 410 } | 396 } |
| 411 | 397 |
| 412 void PrintDialogGtk::InitPrintSettings(const PageRanges& page_ranges) { | 398 void PrintDialogGtk::InitPrintSettings(const PageRanges& page_ranges) { |
| 413 PrintSettings settings; | 399 PrintSettings settings; |
| 414 printing::PrintSettingsInitializerGtk::InitPrintSettings( | 400 printing::PrintSettingsInitializerGtk::InitPrintSettings( |
| 415 gtk_settings_, page_setup_, page_ranges, false, &settings); | 401 gtk_settings_, page_setup_, page_ranges, false, &settings); |
| 416 context_->InitWithSettings(settings); | 402 context_->InitWithSettings(settings); |
| 417 } | 403 } |
| OLD | NEW |