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

Side by Side Diff: printing/printing_context_gtk.cc

Issue 46623002: Move settings setup for PDF and cloud print into single location in PrintingContext (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | Annotate | Revision Log
OLDNEW
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 "printing/printing_context_gtk.h" 5 #include "printing/printing_context_gtk.h"
6 6
7 #include <gtk/gtk.h> 7 #include <gtk/gtk.h>
8 #include <gtk/gtkunixprint.h> 8 #include <gtk/gtkunixprint.h>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 ResetSettings(); 71 ResetSettings();
72 if (!print_dialog_) { 72 if (!print_dialog_) {
73 print_dialog_ = create_dialog_func_(this); 73 print_dialog_ = create_dialog_func_(this);
74 print_dialog_->AddRefToDialog(); 74 print_dialog_->AddRefToDialog();
75 } 75 }
76 print_dialog_->UseDefaultSettings(); 76 print_dialog_->UseDefaultSettings();
77 77
78 return OK; 78 return OK;
79 } 79 }
80 80
81 gfx::Size PrintingContextGtk::GetPdfPaperSizeDeviceUnits() {
82 GtkPageSetup* page_setup = gtk_page_setup_new();
83
84 gfx::SizeF paper_size(
85 gtk_page_setup_get_paper_width(page_setup, GTK_UNIT_INCH),
86 gtk_page_setup_get_paper_height(page_setup, GTK_UNIT_INCH));
87
88 g_object_unref(page_setup);
89
90 return gfx::Size(
91 paper_size.width() * settings_.device_units_per_inch(),
92 paper_size.height() * settings_.device_units_per_inch());
93 }
94
81 PrintingContext::Result PrintingContextGtk::UpdatePrinterSettings( 95 PrintingContext::Result PrintingContextGtk::UpdatePrinterSettings(
82 bool target_is_pdf,
83 bool external_preview) { 96 bool external_preview) {
84 DCHECK(!in_print_job_); 97 DCHECK(!in_print_job_);
85 DCHECK(!external_preview) << "Not implemented"; 98 DCHECK(!external_preview) << "Not implemented";
86 99
87 if (!print_dialog_) { 100 if (!print_dialog_) {
88 print_dialog_ = create_dialog_func_(this); 101 print_dialog_ = create_dialog_func_(this);
89 print_dialog_->AddRefToDialog(); 102 print_dialog_->AddRefToDialog();
90 } 103 }
91 104
92 if (!print_dialog_->UpdateSettings(target_is_pdf, &settings_)) 105 if (!print_dialog_->UpdateSettings(&settings_))
93 return OnError(); 106 return OnError();
94 107
95 return OK; 108 return OK;
96 } 109 }
97 110
98 PrintingContext::Result PrintingContextGtk::InitWithSettings( 111 PrintingContext::Result PrintingContextGtk::InitWithSettings(
99 const PrintSettings& settings) { 112 const PrintSettings& settings) {
100 DCHECK(!in_print_job_); 113 DCHECK(!in_print_job_);
101 114
102 settings_ = settings; 115 settings_ = settings;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 // Intentional No-op. 165 // Intentional No-op.
153 } 166 }
154 167
155 gfx::NativeDrawingContext PrintingContextGtk::context() const { 168 gfx::NativeDrawingContext PrintingContextGtk::context() const {
156 // Intentional No-op. 169 // Intentional No-op.
157 return NULL; 170 return NULL;
158 } 171 }
159 172
160 } // namespace printing 173 } // namespace printing
161 174
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698