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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 | 160 |
161 bool PrintDialogGtk::UpdateSettings(const DictionaryValue& settings, | 161 bool PrintDialogGtk::UpdateSettings(const DictionaryValue& settings, |
162 const printing::PageRanges& ranges) { | 162 const printing::PageRanges& ranges) { |
163 bool collate; | 163 bool collate; |
164 bool color; | 164 bool color; |
165 bool landscape; | 165 bool landscape; |
166 bool print_to_pdf; | 166 bool print_to_pdf; |
167 int copies; | 167 int copies; |
168 int duplex_mode; | 168 int duplex_mode; |
169 std::string device_name; | 169 std::string device_name; |
| 170 bool header_footer; |
170 | 171 |
171 if (!settings.GetBoolean(printing::kSettingLandscape, &landscape) || | 172 if (!settings.GetBoolean(printing::kSettingLandscape, &landscape) || |
172 !settings.GetBoolean(printing::kSettingCollate, &collate) || | 173 !settings.GetBoolean(printing::kSettingCollate, &collate) || |
173 !settings.GetBoolean(printing::kSettingColor, &color) || | 174 !settings.GetBoolean(printing::kSettingColor, &color) || |
174 !settings.GetBoolean(printing::kSettingPrintToPDF, &print_to_pdf) || | 175 !settings.GetBoolean(printing::kSettingPrintToPDF, &print_to_pdf) || |
175 !settings.GetInteger(printing::kSettingDuplexMode, &duplex_mode) || | 176 !settings.GetInteger(printing::kSettingDuplexMode, &duplex_mode) || |
176 !settings.GetInteger(printing::kSettingCopies, &copies) || | 177 !settings.GetInteger(printing::kSettingCopies, &copies) || |
177 !settings.GetString(printing::kSettingDeviceName, &device_name)) { | 178 !settings.GetString(printing::kSettingDeviceName, &device_name) || |
| 179 !settings.GetBoolean(printing::kSettingHeaderFooter, &header_footer)) { |
178 return false; | 180 return false; |
179 } | 181 } |
180 | 182 |
181 if (!print_to_pdf) { | 183 if (!print_to_pdf) { |
182 scoped_ptr<GtkPrinterList> printer_list(new GtkPrinterList); | 184 scoped_ptr<GtkPrinterList> printer_list(new GtkPrinterList); |
183 printer_ = printer_list->GetPrinterWithName(device_name.c_str()); | 185 printer_ = printer_list->GetPrinterWithName(device_name.c_str()); |
184 if (printer_) { | 186 if (printer_) { |
185 g_object_ref(printer_); | 187 g_object_ref(printer_); |
186 gtk_print_settings_set_printer(gtk_settings_, | 188 gtk_print_settings_set_printer(gtk_settings_, |
187 gtk_printer_get_name(printer_)); | 189 gtk_printer_get_name(printer_)); |
(...skipping 15 matching lines...) Expand all Loading... |
203 break; | 205 break; |
204 } | 206 } |
205 gtk_print_settings_set(gtk_settings_, kCUPSDuplex, cups_duplex_mode); | 207 gtk_print_settings_set(gtk_settings_, kCUPSDuplex, cups_duplex_mode); |
206 } | 208 } |
207 | 209 |
208 gtk_print_settings_set_orientation( | 210 gtk_print_settings_set_orientation( |
209 gtk_settings_, | 211 gtk_settings_, |
210 landscape ? GTK_PAGE_ORIENTATION_LANDSCAPE : | 212 landscape ? GTK_PAGE_ORIENTATION_LANDSCAPE : |
211 GTK_PAGE_ORIENTATION_PORTRAIT); | 213 GTK_PAGE_ORIENTATION_PORTRAIT); |
212 | 214 |
| 215 gtk_print_settings_set_bool(gtk_settings_, printing::kSettingHeaderFooter, |
| 216 header_footer); |
| 217 |
213 InitPrintSettings(ranges); | 218 InitPrintSettings(ranges); |
214 return true; | 219 return true; |
215 } | 220 } |
216 | 221 |
217 void PrintDialogGtk::ShowDialog( | 222 void PrintDialogGtk::ShowDialog( |
218 PrintingContextCairo::PrintSettingsCallback* callback) { | 223 PrintingContextCairo::PrintSettingsCallback* callback) { |
219 DCHECK(!save_document_event_.get()); | 224 DCHECK(!save_document_event_.get()); |
220 | 225 |
221 callback_ = callback; | 226 callback_ = callback; |
222 | 227 |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 // Printing finished. Matches AddRef() in PrintDocument(); | 412 // Printing finished. Matches AddRef() in PrintDocument(); |
408 Release(); | 413 Release(); |
409 } | 414 } |
410 | 415 |
411 void PrintDialogGtk::InitPrintSettings(const PageRanges& page_ranges) { | 416 void PrintDialogGtk::InitPrintSettings(const PageRanges& page_ranges) { |
412 PrintSettings settings; | 417 PrintSettings settings; |
413 printing::PrintSettingsInitializerGtk::InitPrintSettings( | 418 printing::PrintSettingsInitializerGtk::InitPrintSettings( |
414 gtk_settings_, page_setup_, page_ranges, false, &settings); | 419 gtk_settings_, page_setup_, page_ranges, false, &settings); |
415 context_->InitWithSettings(settings); | 420 context_->InitWithSettings(settings); |
416 } | 421 } |
OLD | NEW |