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

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

Issue 2449243002: Gtk3 ui: Add libgtk3ui as a separate build component (Closed)
Patch Set: Add theme_properties dep to //chrome/browser/ui Created 4 years, 1 month 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
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/libgtkui/print_dialog_gtk2.h"
6 6
7 #include <gtk/gtkunixprint.h> 7 #include <gtk/gtkunixprint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
11 #include <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/bind.h" 14 #include "base/bind.h"
15 #include "base/files/file_util.h" 15 #include "base/files/file_util.h"
16 #include "base/files/file_util_proxy.h" 16 #include "base/files/file_util_proxy.h"
17 #include "base/lazy_instance.h" 17 #include "base/lazy_instance.h"
18 #include "base/logging.h" 18 #include "base/logging.h"
19 #include "base/macros.h" 19 #include "base/macros.h"
20 #include "base/strings/utf_string_conversions.h" 20 #include "base/strings/utf_string_conversions.h"
21 #include "base/values.h" 21 #include "base/values.h"
22 #include "chrome/browser/ui/libgtk2ui/gtk2_util.h" 22 #include "chrome/browser/ui/libgtkui/gtk2_util.h"
23 #include "chrome/browser/ui/libgtk2ui/printing_gtk2_util.h" 23 #include "chrome/browser/ui/libgtkui/printing_gtk2_util.h"
24 #include "printing/metafile.h" 24 #include "printing/metafile.h"
25 #include "printing/print_job_constants.h" 25 #include "printing/print_job_constants.h"
26 #include "printing/print_settings.h" 26 #include "printing/print_settings.h"
27 #include "ui/aura/window.h" 27 #include "ui/aura/window.h"
28 #include "ui/events/platform/x11/x11_event_source.h" 28 #include "ui/events/platform/x11/x11_event_source.h"
29 29
30 using content::BrowserThread; 30 using content::BrowserThread;
31 using printing::PageRanges; 31 using printing::PageRanges;
32 using printing::PrintSettings; 32 using printing::PrintSettings;
33 33
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 dialog_(NULL), 183 dialog_(NULL),
184 gtk_settings_(NULL), 184 gtk_settings_(NULL),
185 page_setup_(NULL), 185 page_setup_(NULL),
186 printer_(NULL) { 186 printer_(NULL) {
187 } 187 }
188 188
189 PrintDialogGtk2::~PrintDialogGtk2() { 189 PrintDialogGtk2::~PrintDialogGtk2() {
190 DCHECK_CURRENTLY_ON(BrowserThread::UI); 190 DCHECK_CURRENTLY_ON(BrowserThread::UI);
191 191
192 if (dialog_) { 192 if (dialog_) {
193 aura::Window* parent = libgtk2ui::GetAuraTransientParent(dialog_); 193 aura::Window* parent = libgtkui::GetAuraTransientParent(dialog_);
194 if (parent) { 194 if (parent) {
195 parent->RemoveObserver(this); 195 parent->RemoveObserver(this);
196 libgtk2ui::ClearAuraTransientParent(dialog_); 196 libgtkui::ClearAuraTransientParent(dialog_);
197 } 197 }
198 gtk_widget_destroy(dialog_); 198 gtk_widget_destroy(dialog_);
199 dialog_ = NULL; 199 dialog_ = NULL;
200 } 200 }
201 if (gtk_settings_) { 201 if (gtk_settings_) {
202 g_object_unref(gtk_settings_); 202 g_object_unref(gtk_settings_);
203 gtk_settings_ = NULL; 203 gtk_settings_ = NULL;
204 } 204 }
205 if (page_setup_) { 205 if (page_setup_) {
206 g_object_unref(page_setup_); 206 g_object_unref(page_setup_);
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 } 326 }
327 327
328 void PrintDialogGtk2::ShowDialog( 328 void PrintDialogGtk2::ShowDialog(
329 gfx::NativeView parent_view, 329 gfx::NativeView parent_view,
330 bool has_selection, 330 bool has_selection,
331 const PrintingContextLinux::PrintSettingsCallback& callback) { 331 const PrintingContextLinux::PrintSettingsCallback& callback) {
332 callback_ = callback; 332 callback_ = callback;
333 DCHECK(!callback_.is_null()); 333 DCHECK(!callback_.is_null());
334 334
335 dialog_ = gtk_print_unix_dialog_new(NULL, NULL); 335 dialog_ = gtk_print_unix_dialog_new(NULL, NULL);
336 libgtk2ui::SetGtkTransientForAura(dialog_, parent_view); 336 libgtkui::SetGtkTransientForAura(dialog_, parent_view);
337 if (parent_view) 337 if (parent_view)
338 parent_view->AddObserver(this); 338 parent_view->AddObserver(this);
339 g_signal_connect(dialog_, "delete-event", 339 g_signal_connect(dialog_, "delete-event",
340 G_CALLBACK(gtk_widget_hide_on_delete), NULL); 340 G_CALLBACK(gtk_widget_hide_on_delete), NULL);
341 341
342 // Handle the case when the existing |gtk_settings_| has "selection" selected 342 // Handle the case when the existing |gtk_settings_| has "selection" selected
343 // as the page range, but |has_selection| is false. 343 // as the page range, but |has_selection| is false.
344 if (!has_selection) { 344 if (!has_selection) {
345 GtkPrintPages range = gtk_print_settings_get_print_pages(gtk_settings_); 345 GtkPrintPages range = gtk_print_settings_get_print_pages(gtk_settings_);
346 if (range == GTK_PRINT_PAGES_SELECTION) 346 if (range == GTK_PRINT_PAGES_SELECTION)
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 // Printing finished. Matches AddRef() in PrintDocument(); 547 // Printing finished. Matches AddRef() in PrintDocument();
548 Release(); 548 Release();
549 } 549 }
550 550
551 void PrintDialogGtk2::InitPrintSettings(PrintSettings* settings) { 551 void PrintDialogGtk2::InitPrintSettings(PrintSettings* settings) {
552 InitPrintSettingsGtk(gtk_settings_, page_setup_, settings); 552 InitPrintSettingsGtk(gtk_settings_, page_setup_, settings);
553 context_->InitWithSettings(*settings); 553 context_->InitWithSettings(*settings);
554 } 554 }
555 555
556 void PrintDialogGtk2::OnWindowDestroying(aura::Window* window) { 556 void PrintDialogGtk2::OnWindowDestroying(aura::Window* window) {
557 DCHECK_EQ(libgtk2ui::GetAuraTransientParent(dialog_), window); 557 DCHECK_EQ(libgtkui::GetAuraTransientParent(dialog_), window);
558 558
559 libgtk2ui::ClearAuraTransientParent(dialog_); 559 libgtkui::ClearAuraTransientParent(dialog_);
560 window->RemoveObserver(this); 560 window->RemoveObserver(this);
561 if (!callback_.is_null()) { 561 if (!callback_.is_null()) {
562 callback_.Run(PrintingContextLinux::CANCEL); 562 callback_.Run(PrintingContextLinux::CANCEL);
563 callback_.Reset(); 563 callback_.Reset();
564 } 564 }
565 } 565 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/libgtkui/print_dialog_gtk2.h ('k') | chrome/browser/ui/libgtkui/printing_gtk2_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698