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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 InitPrintSettings(ranges_vector); | 154 InitPrintSettings(ranges_vector); |
155 } | 155 } |
156 | 156 |
157 bool PrintDialogGtk::UpdateSettings(const DictionaryValue& settings, | 157 bool PrintDialogGtk::UpdateSettings(const DictionaryValue& settings, |
158 const printing::PageRanges& ranges) { | 158 const printing::PageRanges& ranges) { |
159 bool collate; | 159 bool collate; |
160 bool color; | 160 bool color; |
161 bool landscape; | 161 bool landscape; |
162 bool print_to_pdf; | 162 bool print_to_pdf; |
163 int copies; | 163 int copies; |
164 int duplex_mode; | 164 DictionaryValue* duplex_info; |
| 165 int user_selected_duplex_value; |
165 std::string device_name; | 166 std::string device_name; |
166 | 167 |
167 if (!settings.GetBoolean(printing::kSettingLandscape, &landscape) || | 168 if (!settings.GetBoolean(printing::kSettingLandscape, &landscape) || |
168 !settings.GetBoolean(printing::kSettingCollate, &collate) || | 169 !settings.GetBoolean(printing::kSettingCollate, &collate) || |
169 !settings.GetBoolean(printing::kSettingColor, &color) || | 170 !settings.GetBoolean(printing::kSettingColor, &color) || |
170 !settings.GetBoolean(printing::kSettingPrintToPDF, &print_to_pdf) || | 171 !settings.GetBoolean(printing::kSettingPrintToPDF, &print_to_pdf) || |
171 !settings.GetInteger(printing::kSettingDuplexMode, &duplex_mode) || | 172 !settings.GetDictionary(printing::kSettingDuplexModeInfo, &duplex_info) || |
172 !settings.GetInteger(printing::kSettingCopies, &copies) || | 173 !settings.GetInteger(printing::kSettingCopies, &copies) || |
173 !settings.GetString(printing::kSettingDeviceName, &device_name)) { | 174 !settings.GetString(printing::kSettingDeviceName, &device_name) || |
| 175 !duplex_info->GetInteger(printing::kUserSelectedDuplexValue, |
| 176 &user_selected_duplex_value)) { |
174 return false; | 177 return false; |
175 } | 178 } |
176 | 179 |
| 180 |
177 if (!print_to_pdf) { | 181 if (!print_to_pdf) { |
178 scoped_ptr<GtkPrinterList> printer_list(new GtkPrinterList); | 182 scoped_ptr<GtkPrinterList> printer_list(new GtkPrinterList); |
179 printer_ = printer_list->GetPrinterWithName(device_name.c_str()); | 183 printer_ = printer_list->GetPrinterWithName(device_name.c_str()); |
180 if (printer_) { | 184 if (printer_) { |
181 g_object_ref(printer_); | 185 g_object_ref(printer_); |
182 gtk_print_settings_set_printer(gtk_settings_, | 186 gtk_print_settings_set_printer(gtk_settings_, |
183 gtk_printer_get_name(printer_)); | 187 gtk_printer_get_name(printer_)); |
184 } | 188 } |
185 gtk_print_settings_set_n_copies(gtk_settings_, copies); | 189 gtk_print_settings_set_n_copies(gtk_settings_, copies); |
186 gtk_print_settings_set_collate(gtk_settings_, collate); | 190 gtk_print_settings_set_collate(gtk_settings_, collate); |
187 gtk_print_settings_set(gtk_settings_, kCUPSColorModel, | 191 gtk_print_settings_set(gtk_settings_, kCUPSColorModel, |
188 color ? kColor : kGrayscale); | 192 color ? kColor : kGrayscale); |
189 const char* cups_duplex_mode; | 193 const char* cups_duplex_mode; |
190 switch (duplex_mode) { | 194 switch (user_selected_duplex_value) { |
191 case printing::LONG_EDGE: | 195 case printing::LONG_EDGE: |
192 cups_duplex_mode = kDuplexNoTumble; | 196 cups_duplex_mode = kDuplexNoTumble; |
193 break; | 197 break; |
194 case printing::SHORT_EDGE: | 198 case printing::SHORT_EDGE: |
195 cups_duplex_mode = kDuplexTumble; | 199 cups_duplex_mode = kDuplexTumble; |
196 break; | 200 break; |
197 default: | 201 default: |
198 cups_duplex_mode = kDuplexNone; | 202 cups_duplex_mode = kDuplexNone; |
199 break; | 203 break; |
200 } | 204 } |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 // Printing finished. Matches AddRef() in PrintDocument(); | 384 // Printing finished. Matches AddRef() in PrintDocument(); |
381 Release(); | 385 Release(); |
382 } | 386 } |
383 | 387 |
384 void PrintDialogGtk::InitPrintSettings(const PageRanges& page_ranges) { | 388 void PrintDialogGtk::InitPrintSettings(const PageRanges& page_ranges) { |
385 PrintSettings settings; | 389 PrintSettings settings; |
386 printing::PrintSettingsInitializerGtk::InitPrintSettings( | 390 printing::PrintSettingsInitializerGtk::InitPrintSettings( |
387 gtk_settings_, page_setup_, page_ranges, false, &settings); | 391 gtk_settings_, page_setup_, page_ranges, false, &settings); |
388 context_->InitWithSettings(settings); | 392 context_->InitWithSettings(settings); |
389 } | 393 } |
OLD | NEW |