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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 if (!settings.GetBoolean(printing::kSettingLandscape, &landscape) || | 168 if (!settings.GetBoolean(printing::kSettingLandscape, &landscape) || |
169 !settings.GetBoolean(printing::kSettingCollate, &collate) || | 169 !settings.GetBoolean(printing::kSettingCollate, &collate) || |
170 !settings.GetInteger(printing::kSettingColor, &color) || | 170 !settings.GetInteger(printing::kSettingColor, &color) || |
171 !settings.GetBoolean(printing::kSettingPrintToPDF, &print_to_pdf) || | 171 !settings.GetBoolean(printing::kSettingPrintToPDF, &print_to_pdf) || |
172 !settings.GetInteger(printing::kSettingDuplexMode, &duplex_mode) || | 172 !settings.GetInteger(printing::kSettingDuplexMode, &duplex_mode) || |
173 !settings.GetInteger(printing::kSettingCopies, &copies) || | 173 !settings.GetInteger(printing::kSettingCopies, &copies) || |
174 !settings.GetString(printing::kSettingDeviceName, &device_name)) { | 174 !settings.GetString(printing::kSettingDeviceName, &device_name)) { |
175 return false; | 175 return false; |
176 } | 176 } |
177 | 177 |
| 178 if (!gtk_settings_) |
| 179 gtk_settings_ = gtk_print_settings_new(); |
| 180 |
178 if (!print_to_pdf) { | 181 if (!print_to_pdf) { |
179 scoped_ptr<GtkPrinterList> printer_list(new GtkPrinterList); | 182 scoped_ptr<GtkPrinterList> printer_list(new GtkPrinterList); |
180 printer_ = printer_list->GetPrinterWithName(device_name.c_str()); | 183 printer_ = printer_list->GetPrinterWithName(device_name.c_str()); |
181 if (printer_) { | 184 if (printer_) { |
182 g_object_ref(printer_); | 185 g_object_ref(printer_); |
183 gtk_print_settings_set_printer(gtk_settings_, | 186 gtk_print_settings_set_printer(gtk_settings_, |
184 gtk_printer_get_name(printer_)); | 187 gtk_printer_get_name(printer_)); |
| 188 if (!page_setup_) { |
| 189 page_setup_ = gtk_printer_get_default_page_size(printer_); |
| 190 } |
185 } | 191 } |
| 192 if (!page_setup_) |
| 193 page_setup_ = gtk_page_setup_new(); |
| 194 |
186 gtk_print_settings_set_n_copies(gtk_settings_, copies); | 195 gtk_print_settings_set_n_copies(gtk_settings_, copies); |
187 gtk_print_settings_set_collate(gtk_settings_, collate); | 196 gtk_print_settings_set_collate(gtk_settings_, collate); |
188 | 197 |
189 const char* color_mode; | 198 const char* color_mode; |
190 switch (color) { | 199 switch (color) { |
191 case printing::COLOR: | 200 case printing::COLOR: |
192 color_mode = kColor; | 201 color_mode = kColor; |
193 break; | 202 break; |
194 case printing::CMYK: | 203 case printing::CMYK: |
195 color_mode = kCMYK; | 204 color_mode = kCMYK; |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 // Printing finished. Matches AddRef() in PrintDocument(); | 408 // Printing finished. Matches AddRef() in PrintDocument(); |
400 Release(); | 409 Release(); |
401 } | 410 } |
402 | 411 |
403 void PrintDialogGtk::InitPrintSettings(const PageRanges& page_ranges) { | 412 void PrintDialogGtk::InitPrintSettings(const PageRanges& page_ranges) { |
404 PrintSettings settings; | 413 PrintSettings settings; |
405 printing::PrintSettingsInitializerGtk::InitPrintSettings( | 414 printing::PrintSettingsInitializerGtk::InitPrintSettings( |
406 gtk_settings_, page_setup_, page_ranges, false, &settings); | 415 gtk_settings_, page_setup_, page_ranges, false, &settings); |
407 context_->InitWithSettings(settings); | 416 context_->InitWithSettings(settings); |
408 } | 417 } |
OLD | NEW |