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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
184 gtk_print_settings_set_printer(gtk_settings_, | 184 gtk_print_settings_set_printer(gtk_settings_, |
185 gtk_printer_get_name(printer_)); | 185 gtk_printer_get_name(printer_)); |
186 if (!page_setup_) { | 186 if (!page_setup_) { |
187 page_setup_ = gtk_printer_get_default_page_size(printer_); | 187 page_setup_ = gtk_printer_get_default_page_size(printer_); |
188 } | 188 } |
189 } | 189 } |
190 | 190 |
191 gtk_print_settings_set_n_copies(gtk_settings_, copies); | 191 gtk_print_settings_set_n_copies(gtk_settings_, copies); |
192 gtk_print_settings_set_collate(gtk_settings_, collate); | 192 gtk_print_settings_set_collate(gtk_settings_, collate); |
193 | 193 |
194 #if defined(USE_CUPS) | |
194 std::string color_value; | 195 std::string color_value; |
195 std::string color_setting_name; | 196 std::string color_setting_name; |
196 printing::GetColorModelForMode(color, &color_setting_name, &color_value); | 197 printing::GetColorModelForMode(color, &color_setting_name, &color_value); |
197 gtk_print_settings_set(gtk_settings_, color_setting_name.c_str(), | 198 gtk_print_settings_set(gtk_settings_, color_setting_name.c_str(), |
198 color_value.c_str()); | 199 color_value.c_str()); |
200 #endif | |
199 | 201 |
200 if (duplex_mode != printing::UNKNOWN_DUPLEX_MODE) { | 202 if (duplex_mode != printing::UNKNOWN_DUPLEX_MODE) { |
201 const char* cups_duplex_mode = NULL; | 203 const char* cups_duplex_mode = NULL; |
202 switch (duplex_mode) { | 204 switch (duplex_mode) { |
203 case printing::LONG_EDGE: | 205 case printing::LONG_EDGE: |
204 cups_duplex_mode = kDuplexNoTumble; | 206 cups_duplex_mode = kDuplexNoTumble; |
205 break; | 207 break; |
206 case printing::SHORT_EDGE: | 208 case printing::SHORT_EDGE: |
207 cups_duplex_mode = kDuplexTumble; | 209 cups_duplex_mode = kDuplexTumble; |
208 break; | 210 break; |
209 case printing::SIMPLEX: | 211 case printing::SIMPLEX: |
210 cups_duplex_mode = kDuplexNone; | 212 cups_duplex_mode = kDuplexNone; |
211 break; | 213 break; |
212 default: // UNKNOWN_DUPLEX_MODE | 214 default: // UNKNOWN_DUPLEX_MODE |
213 NOTREACHED(); | 215 NOTREACHED(); |
214 break; | 216 break; |
215 } | 217 } |
216 gtk_print_settings_set(gtk_settings_, kCUPSDuplex, cups_duplex_mode); | 218 gtk_print_settings_set(gtk_settings_, kCUPSDuplex, cups_duplex_mode); |
kmadhusu
2011/11/08 02:09:59
If CUPS is disabled, we should not set duplex prin
Lei Zhang
2011/11/08 02:22:09
Done.
| |
217 } | 219 } |
218 } | 220 } |
219 if (!page_setup_) | 221 if (!page_setup_) |
220 page_setup_ = gtk_page_setup_new(); | 222 page_setup_ = gtk_page_setup_new(); |
221 | 223 |
222 gtk_print_settings_set_orientation( | 224 gtk_print_settings_set_orientation( |
223 gtk_settings_, | 225 gtk_settings_, |
224 landscape ? GTK_PAGE_ORIENTATION_LANDSCAPE : | 226 landscape ? GTK_PAGE_ORIENTATION_LANDSCAPE : |
225 GTK_PAGE_ORIENTATION_PORTRAIT); | 227 GTK_PAGE_ORIENTATION_PORTRAIT); |
226 | 228 |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
396 // Printing finished. Matches AddRef() in PrintDocument(); | 398 // Printing finished. Matches AddRef() in PrintDocument(); |
397 Release(); | 399 Release(); |
398 } | 400 } |
399 | 401 |
400 void PrintDialogGtk::InitPrintSettings(const PageRanges& page_ranges, | 402 void PrintDialogGtk::InitPrintSettings(const PageRanges& page_ranges, |
401 PrintSettings* settings) { | 403 PrintSettings* settings) { |
402 printing::PrintSettingsInitializerGtk::InitPrintSettings( | 404 printing::PrintSettingsInitializerGtk::InitPrintSettings( |
403 gtk_settings_, page_setup_, page_ranges, false, settings); | 405 gtk_settings_, page_setup_, page_ranges, false, settings); |
404 context_->InitWithSettings(*settings); | 406 context_->InitWithSettings(*settings); |
405 } | 407 } |
OLD | NEW |