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

Side by Side Diff: chrome/browser/printing/print_dialog_gtk.cc

Issue 8201027: Move margin processing code to the browser process. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address nits Created 9 years, 2 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
« no previous file with comments | « chrome/browser/printing/print_dialog_gtk.h ('k') | chrome/browser/printing/print_job_worker.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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>
11 #include <sys/types.h> 11 #include <sys/types.h>
12 12
13 #include <string> 13 #include <string>
14 #include <vector> 14 #include <vector>
15 15
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/utf_string_conversions.h" 19 #include "base/utf_string_conversions.h"
20 #include "chrome/browser/ui/browser_list.h" 20 #include "chrome/browser/ui/browser_list.h"
21 #include "chrome/browser/ui/browser_window.h" 21 #include "chrome/browser/ui/browser_window.h"
22 #include "printing/metafile.h" 22 #include "printing/metafile.h"
23 #include "printing/print_job_constants.h" 23 #include "printing/print_job_constants.h"
24 #include "printing/print_settings.h"
24 #include "printing/print_settings_initializer_gtk.h" 25 #include "printing/print_settings_initializer_gtk.h"
25 26
26 using printing::PageRanges; 27 using printing::PageRanges;
27 using printing::PrintSettings; 28 using printing::PrintSettings;
28 29
29 namespace { 30 namespace {
30 31
31 // CUPS Duplex attribute and values. 32 // CUPS Duplex attribute and values.
32 const char kCUPSDuplex[] = "cups-Duplex"; 33 const char kCUPSDuplex[] = "cups-Duplex";
33 const char kDuplexNone[] = "None"; 34 const char kDuplexNone[] = "None";
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 gtk_print_settings_set_printer(gtk_settings_, 140 gtk_print_settings_set_printer(gtk_settings_,
140 gtk_printer_get_name(printer_)); 141 gtk_printer_get_name(printer_));
141 page_setup_ = gtk_printer_get_default_page_size(printer_); 142 page_setup_ = gtk_printer_get_default_page_size(printer_);
142 } 143 }
143 144
144 if (!page_setup_) 145 if (!page_setup_)
145 page_setup_ = gtk_page_setup_new(); 146 page_setup_ = gtk_page_setup_new();
146 147
147 // No page range to initialize for default settings. 148 // No page range to initialize for default settings.
148 PageRanges ranges_vector; 149 PageRanges ranges_vector;
149 InitPrintSettings(ranges_vector); 150 PrintSettings settings;
151 InitPrintSettings(ranges_vector, &settings);
150 } 152 }
151 153
152 bool PrintDialogGtk::UpdateSettings(const DictionaryValue& settings, 154 bool PrintDialogGtk::UpdateSettings(const DictionaryValue& job_settings,
153 const printing::PageRanges& ranges) { 155 const printing::PageRanges& ranges,
156 printing::PrintSettings* settings) {
154 bool collate; 157 bool collate;
155 int color; 158 int color;
156 bool landscape; 159 bool landscape;
157 bool print_to_pdf; 160 bool print_to_pdf;
158 int copies; 161 int copies;
159 int duplex_mode; 162 int duplex_mode;
160 std::string device_name; 163 std::string device_name;
161 164
162 if (!settings.GetBoolean(printing::kSettingLandscape, &landscape) || 165 if (!job_settings.GetBoolean(printing::kSettingLandscape, &landscape) ||
163 !settings.GetBoolean(printing::kSettingCollate, &collate) || 166 !job_settings.GetBoolean(printing::kSettingCollate, &collate) ||
164 !settings.GetInteger(printing::kSettingColor, &color) || 167 !job_settings.GetInteger(printing::kSettingColor, &color) ||
165 !settings.GetBoolean(printing::kSettingPrintToPDF, &print_to_pdf) || 168 !job_settings.GetBoolean(printing::kSettingPrintToPDF, &print_to_pdf) ||
166 !settings.GetInteger(printing::kSettingDuplexMode, &duplex_mode) || 169 !job_settings.GetInteger(printing::kSettingDuplexMode, &duplex_mode) ||
167 !settings.GetInteger(printing::kSettingCopies, &copies) || 170 !job_settings.GetInteger(printing::kSettingCopies, &copies) ||
168 !settings.GetString(printing::kSettingDeviceName, &device_name)) { 171 !job_settings.GetString(printing::kSettingDeviceName, &device_name)) {
169 return false; 172 return false;
170 } 173 }
171 174
172 if (!gtk_settings_) 175 if (!gtk_settings_)
173 gtk_settings_ = gtk_print_settings_new(); 176 gtk_settings_ = gtk_print_settings_new();
174 177
175 if (!print_to_pdf) { 178 if (!print_to_pdf) {
176 scoped_ptr<GtkPrinterList> printer_list(new GtkPrinterList); 179 scoped_ptr<GtkPrinterList> printer_list(new GtkPrinterList);
177 printer_ = printer_list->GetPrinterWithName(device_name.c_str()); 180 printer_ = printer_list->GetPrinterWithName(device_name.c_str());
178 if (printer_) { 181 if (printer_) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 } 216 }
214 } 217 }
215 if (!page_setup_) 218 if (!page_setup_)
216 page_setup_ = gtk_page_setup_new(); 219 page_setup_ = gtk_page_setup_new();
217 220
218 gtk_print_settings_set_orientation( 221 gtk_print_settings_set_orientation(
219 gtk_settings_, 222 gtk_settings_,
220 landscape ? GTK_PAGE_ORIENTATION_LANDSCAPE : 223 landscape ? GTK_PAGE_ORIENTATION_LANDSCAPE :
221 GTK_PAGE_ORIENTATION_PORTRAIT); 224 GTK_PAGE_ORIENTATION_PORTRAIT);
222 225
223 InitPrintSettings(ranges); 226 InitPrintSettings(ranges, settings);
224 return true; 227 return true;
225 } 228 }
226 229
227 void PrintDialogGtk::ShowDialog( 230 void PrintDialogGtk::ShowDialog(
228 PrintingContextCairo::PrintSettingsCallback* callback) { 231 PrintingContextCairo::PrintSettingsCallback* callback) {
229 callback_ = callback; 232 callback_ = callback;
230 233
231 GtkWindow* parent = BrowserList::GetLastActive()->window()->GetNativeHandle(); 234 GtkWindow* parent = BrowserList::GetLastActive()->window()->GetNativeHandle();
232 // TODO(estade): We need a window title here. 235 // TODO(estade): We need a window title here.
233 dialog_ = gtk_print_unix_dialog_new(NULL, parent); 236 dialog_ = gtk_print_unix_dialog_new(NULL, parent);
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 g_object_unref(print_job); 391 g_object_unref(print_job);
389 base::FileUtilProxy::Delete( 392 base::FileUtilProxy::Delete(
390 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), 393 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE),
391 path_to_pdf_, 394 path_to_pdf_,
392 false, 395 false,
393 NULL); 396 NULL);
394 // Printing finished. Matches AddRef() in PrintDocument(); 397 // Printing finished. Matches AddRef() in PrintDocument();
395 Release(); 398 Release();
396 } 399 }
397 400
398 void PrintDialogGtk::InitPrintSettings(const PageRanges& page_ranges) { 401 void PrintDialogGtk::InitPrintSettings(const PageRanges& page_ranges,
399 PrintSettings settings; 402 PrintSettings* settings) {
400 printing::PrintSettingsInitializerGtk::InitPrintSettings( 403 printing::PrintSettingsInitializerGtk::InitPrintSettings(
401 gtk_settings_, page_setup_, page_ranges, false, &settings); 404 gtk_settings_, page_setup_, page_ranges, false, settings);
402 context_->InitWithSettings(settings); 405 context_->InitWithSettings(*settings);
403 } 406 }
OLDNEW
« no previous file with comments | « chrome/browser/printing/print_dialog_gtk.h ('k') | chrome/browser/printing/print_job_worker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698