OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/gtkunixprint.h> | 8 #include <gtk/gtkunixprint.h> |
9 #include <sys/stat.h> | 9 #include <sys/stat.h> |
10 #include <sys/types.h> | 10 #include <sys/types.h> |
11 | 11 |
12 #include <string> | 12 #include <string> |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "base/bind.h" | 15 #include "base/bind.h" |
16 #include "base/file_util.h" | 16 #include "base/file_util.h" |
17 #include "base/file_util_proxy.h" | 17 #include "base/file_util_proxy.h" |
18 #include "base/logging.h" | 18 #include "base/logging.h" |
19 #include "base/message_loop_proxy.h" | 19 #include "base/message_loop_proxy.h" |
20 #include "base/utf_string_conversions.h" | 20 #include "base/utf_string_conversions.h" |
21 #include "base/values.h" | 21 #include "base/values.h" |
22 #include "chrome/browser/ui/browser.h" | |
23 #include "chrome/browser/ui/browser_list.h" | |
24 #include "chrome/browser/ui/browser_window.h" | |
25 #include "printing/metafile.h" | 22 #include "printing/metafile.h" |
26 #include "printing/print_job_constants.h" | 23 #include "printing/print_job_constants.h" |
27 #include "printing/print_settings.h" | 24 #include "printing/print_settings.h" |
28 #include "printing/print_settings_initializer_gtk.h" | 25 #include "printing/print_settings_initializer_gtk.h" |
29 | 26 |
30 using content::BrowserThread; | 27 using content::BrowserThread; |
31 using printing::PageRanges; | 28 using printing::PageRanges; |
32 using printing::PrintSettings; | 29 using printing::PrintSettings; |
33 | 30 |
34 namespace { | 31 namespace { |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 gtk_print_settings_set_orientation( | 223 gtk_print_settings_set_orientation( |
227 gtk_settings_, | 224 gtk_settings_, |
228 landscape ? GTK_PAGE_ORIENTATION_LANDSCAPE : | 225 landscape ? GTK_PAGE_ORIENTATION_LANDSCAPE : |
229 GTK_PAGE_ORIENTATION_PORTRAIT); | 226 GTK_PAGE_ORIENTATION_PORTRAIT); |
230 | 227 |
231 InitPrintSettings(ranges, settings); | 228 InitPrintSettings(ranges, settings); |
232 return true; | 229 return true; |
233 } | 230 } |
234 | 231 |
235 void PrintDialogGtk::ShowDialog( | 232 void PrintDialogGtk::ShowDialog( |
| 233 gfx::NativeView parent_view, |
236 bool has_selection, | 234 bool has_selection, |
237 const PrintingContextGtk::PrintSettingsCallback& callback) { | 235 const PrintingContextGtk::PrintSettingsCallback& callback) { |
238 callback_ = callback; | 236 callback_ = callback; |
239 | 237 |
240 GtkWindow* parent = BrowserList::GetLastActive()->window()->GetNativeHandle(); | 238 GtkWindow* parent = GTK_WINDOW(gtk_widget_get_toplevel(parent_view)); |
241 // TODO(estade): We need a window title here. | 239 // TODO(estade): We need a window title here. |
242 dialog_ = gtk_print_unix_dialog_new(NULL, parent); | 240 dialog_ = gtk_print_unix_dialog_new(NULL, parent); |
243 g_signal_connect(dialog_, "delete-event", | 241 g_signal_connect(dialog_, "delete-event", |
244 G_CALLBACK(gtk_widget_hide_on_delete), NULL); | 242 G_CALLBACK(gtk_widget_hide_on_delete), NULL); |
245 | 243 |
246 | 244 |
247 // Set modal so user cannot focus the same tab and press print again. | 245 // Set modal so user cannot focus the same tab and press print again. |
248 gtk_window_set_modal(GTK_WINDOW(dialog_), TRUE); | 246 gtk_window_set_modal(GTK_WINDOW(dialog_), TRUE); |
249 | 247 |
250 // Since we only generate PDF, only show printers that support PDF. | 248 // Since we only generate PDF, only show printers that support PDF. |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 // Printing finished. Matches AddRef() in PrintDocument(); | 419 // Printing finished. Matches AddRef() in PrintDocument(); |
422 Release(); | 420 Release(); |
423 } | 421 } |
424 | 422 |
425 void PrintDialogGtk::InitPrintSettings(const PageRanges& page_ranges, | 423 void PrintDialogGtk::InitPrintSettings(const PageRanges& page_ranges, |
426 PrintSettings* settings) { | 424 PrintSettings* settings) { |
427 printing::PrintSettingsInitializerGtk::InitPrintSettings( | 425 printing::PrintSettingsInitializerGtk::InitPrintSettings( |
428 gtk_settings_, page_setup_, page_ranges, false, settings); | 426 gtk_settings_, page_setup_, page_ranges, false, settings); |
429 context_->InitWithSettings(*settings); | 427 context_->InitWithSettings(*settings); |
430 } | 428 } |
OLD | NEW |