Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(46)

Side by Side Diff: chrome/browser/ui/libgtk2ui/print_dialog_gtk2.cc

Issue 221813010: Sets transient for PrintDialogGtk2 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/ui/libgtk2ui/print_dialog_gtk2.h" 5 #include "chrome/browser/ui/libgtk2ui/print_dialog_gtk2.h"
6 6
7 #include <gtk/gtkunixprint.h> 7 #include <gtk/gtkunixprint.h>
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/file_util.h" 13 #include "base/file_util.h"
14 #include "base/files/file_util_proxy.h" 14 #include "base/files/file_util_proxy.h"
15 #include "base/lazy_instance.h" 15 #include "base/lazy_instance.h"
16 #include "base/logging.h" 16 #include "base/logging.h"
17 #include "base/message_loop/message_loop_proxy.h" 17 #include "base/message_loop/message_loop_proxy.h"
18 #include "base/strings/utf_string_conversions.h" 18 #include "base/strings/utf_string_conversions.h"
19 #include "base/values.h" 19 #include "base/values.h"
20 #include "chrome/browser/ui/libgtk2ui/gtk2_util.h"
20 #include "chrome/browser/ui/libgtk2ui/printing_gtk2_util.h" 21 #include "chrome/browser/ui/libgtk2ui/printing_gtk2_util.h"
21 #include "printing/metafile.h" 22 #include "printing/metafile.h"
22 #include "printing/print_job_constants.h" 23 #include "printing/print_job_constants.h"
23 #include "printing/print_settings.h" 24 #include "printing/print_settings.h"
25 #include "ui/aura/window.h"
24 26
25 using content::BrowserThread; 27 using content::BrowserThread;
26 using printing::PageRanges; 28 using printing::PageRanges;
27 using printing::PrintSettings; 29 using printing::PrintSettings;
28 30
29 namespace { 31 namespace {
30 32
31 // CUPS Duplex attribute and values. 33 // CUPS Duplex attribute and values.
32 const char kCUPSDuplex[] = "cups-Duplex"; 34 const char kCUPSDuplex[] = "cups-Duplex";
33 const char kDuplexNone[] = "None"; 35 const char kDuplexNone[] = "None";
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 dialog_(NULL), 131 dialog_(NULL),
130 gtk_settings_(NULL), 132 gtk_settings_(NULL),
131 page_setup_(NULL), 133 page_setup_(NULL),
132 printer_(NULL) { 134 printer_(NULL) {
133 } 135 }
134 136
135 PrintDialogGtk2::~PrintDialogGtk2() { 137 PrintDialogGtk2::~PrintDialogGtk2() {
136 DCHECK_CURRENTLY_ON(BrowserThread::UI); 138 DCHECK_CURRENTLY_ON(BrowserThread::UI);
137 139
138 if (dialog_) { 140 if (dialog_) {
141 aura::Window* parent = libgtk2ui::GetAuraTransientParent(dialog_);
142 if (parent) {
143 parent->RemoveObserver(this);
144 libgtk2ui::ClearAuraTransientParent(dialog_);
145 }
139 gtk_widget_destroy(dialog_); 146 gtk_widget_destroy(dialog_);
140 dialog_ = NULL; 147 dialog_ = NULL;
141 } 148 }
142 if (gtk_settings_) { 149 if (gtk_settings_) {
143 g_object_unref(gtk_settings_); 150 g_object_unref(gtk_settings_);
144 gtk_settings_ = NULL; 151 gtk_settings_ = NULL;
145 } 152 }
146 if (page_setup_) { 153 if (page_setup_) {
147 g_object_unref(page_setup_); 154 g_object_unref(page_setup_);
148 page_setup_ = NULL; 155 page_setup_ = NULL;
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 } 234 }
228 235
229 void PrintDialogGtk2::ShowDialog( 236 void PrintDialogGtk2::ShowDialog(
230 gfx::NativeView parent_view, 237 gfx::NativeView parent_view,
231 bool has_selection, 238 bool has_selection,
232 const PrintingContextLinux::PrintSettingsCallback& callback) { 239 const PrintingContextLinux::PrintSettingsCallback& callback) {
233 callback_ = callback; 240 callback_ = callback;
234 241
235 // TODO(mukai): take care of parent as select_file_dialog_impl_gtk2. 242 // TODO(mukai): take care of parent as select_file_dialog_impl_gtk2.
236 dialog_ = gtk_print_unix_dialog_new(NULL, NULL); 243 dialog_ = gtk_print_unix_dialog_new(NULL, NULL);
244 libgtk2ui::SetGtkTransientForAura(dialog_, parent_view);
245 parent_view->AddObserver(this);
237 g_signal_connect(dialog_, "delete-event", 246 g_signal_connect(dialog_, "delete-event",
238 G_CALLBACK(gtk_widget_hide_on_delete), NULL); 247 G_CALLBACK(gtk_widget_hide_on_delete), NULL);
239 248
240 249
241 // Set modal so user cannot focus the same tab and press print again. 250 // Set modal so user cannot focus the same tab and press print again.
242 gtk_window_set_modal(GTK_WINDOW(dialog_), TRUE); 251 gtk_window_set_modal(GTK_WINDOW(dialog_), TRUE);
243 252
244 // Since we only generate PDF, only show printers that support PDF. 253 // Since we only generate PDF, only show printers that support PDF.
245 // TODO(thestig) Add more capabilities to support? 254 // TODO(thestig) Add more capabilities to support?
246 GtkPrintCapabilities cap = static_cast<GtkPrintCapabilities>( 255 GtkPrintCapabilities cap = static_cast<GtkPrintCapabilities>(
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 false, 434 false,
426 base::FileUtilProxy::StatusCallback()); 435 base::FileUtilProxy::StatusCallback());
427 // Printing finished. Matches AddRef() in PrintDocument(); 436 // Printing finished. Matches AddRef() in PrintDocument();
428 Release(); 437 Release();
429 } 438 }
430 439
431 void PrintDialogGtk2::InitPrintSettings(PrintSettings* settings) { 440 void PrintDialogGtk2::InitPrintSettings(PrintSettings* settings) {
432 InitPrintSettingsGtk(gtk_settings_, page_setup_, settings); 441 InitPrintSettingsGtk(gtk_settings_, page_setup_, settings);
433 context_->InitWithSettings(*settings); 442 context_->InitWithSettings(*settings);
434 } 443 }
444
445 void PrintDialogGtk2::OnWindowDestroying(aura::Window* window) {
446 DCHECK_EQ(libgtk2ui::GetAuraTransientParent(dialog_), window);
447
448 libgtk2ui::ClearAuraTransientParent(dialog_);
449 window->RemoveObserver(this);
450 Release();
451 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/libgtk2ui/print_dialog_gtk2.h ('k') | chrome/browser/ui/libgtk2ui/select_file_dialog_impl_gtk2.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698