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

Side by Side Diff: printing/print_settings_initializer_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) 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 "printing/print_settings_initializer_gtk.h" 5 #include "printing/print_settings_initializer_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/strings/string16.h" 10 #include "base/strings/string16.h"
(...skipping 25 matching lines...) Expand all
36 gtk_page_setup_get_paper_width(page_setup, GTK_UNIT_INCH) * dpi, 36 gtk_page_setup_get_paper_width(page_setup, GTK_UNIT_INCH) * dpi,
37 gtk_page_setup_get_paper_height(page_setup, GTK_UNIT_INCH) * dpi); 37 gtk_page_setup_get_paper_height(page_setup, GTK_UNIT_INCH) * dpi);
38 printable_area_device_units.SetRect( 38 printable_area_device_units.SetRect(
39 gtk_page_setup_get_left_margin(page_setup, GTK_UNIT_INCH) * dpi, 39 gtk_page_setup_get_left_margin(page_setup, GTK_UNIT_INCH) * dpi,
40 gtk_page_setup_get_top_margin(page_setup, GTK_UNIT_INCH) * dpi, 40 gtk_page_setup_get_top_margin(page_setup, GTK_UNIT_INCH) * dpi,
41 gtk_page_setup_get_page_width(page_setup, GTK_UNIT_INCH) * dpi, 41 gtk_page_setup_get_page_width(page_setup, GTK_UNIT_INCH) * dpi,
42 gtk_page_setup_get_page_height(page_setup, GTK_UNIT_INCH) * dpi); 42 gtk_page_setup_get_page_height(page_setup, GTK_UNIT_INCH) * dpi);
43 } else { 43 } else {
44 // Use default values if we cannot get valid values from the print dialog. 44 // Use default values if we cannot get valid values from the print dialog.
45 dpi = kPixelsPerInch; 45 dpi = kPixelsPerInch;
46 double page_width_in_pixel = 8.5 * dpi; 46 double page_width_in_pixel = kLetterWidthInch * dpi;
47 double page_height_in_pixel = 11.0 * dpi; 47 double page_height_in_pixel = kLetterHeightInch * dpi;
48 physical_size_device_units.SetSize( 48 physical_size_device_units.SetSize(
49 static_cast<int>(page_width_in_pixel), 49 static_cast<int>(page_width_in_pixel),
50 static_cast<int>(page_height_in_pixel)); 50 static_cast<int>(page_height_in_pixel));
51 printable_area_device_units.SetRect( 51 printable_area_device_units.SetRect(
52 static_cast<int>(kLeftMarginInInch * dpi), 52 static_cast<int>(kLeftMarginInInch * dpi),
53 static_cast<int>(kTopMarginInInch * dpi), 53 static_cast<int>(kTopMarginInInch * dpi),
54 page_width_in_pixel - (kLeftMarginInInch + kRightMarginInInch) * dpi, 54 page_width_in_pixel - (kLeftMarginInInch + kRightMarginInInch) * dpi,
55 page_height_in_pixel - (kTopMarginInInch + kBottomMarginInInch) * dpi); 55 page_height_in_pixel - (kTopMarginInInch + kBottomMarginInInch) * dpi);
56 } 56 }
57 57
58 print_settings->set_dpi(dpi); 58 print_settings->set_dpi(dpi);
59 59
60 // Note: With the normal GTK print dialog, when the user selects the landscape 60 // Note: With the normal GTK print dialog, when the user selects the landscape
61 // orientation, all that does is change the paper size. Which seems to be 61 // orientation, all that does is change the paper size. Which seems to be
62 // enough to render the right output and send it to the printer. 62 // enough to render the right output and send it to the printer.
63 // The orientation value stays as portrait and does not actually affect 63 // The orientation value stays as portrait and does not actually affect
64 // printing. 64 // printing.
65 // Thus this is only useful in print preview mode, where we manually set the 65 // Thus this is only useful in print preview mode, where we manually set the
66 // orientation and change the paper size ourselves. 66 // orientation and change the paper size ourselves.
67 GtkPageOrientation orientation = gtk_print_settings_get_orientation(settings); 67 GtkPageOrientation orientation = gtk_print_settings_get_orientation(settings);
68 // Set before SetPrinterPrintableArea to make it flip area if necessary. 68 // Set before SetPrinterPrintableArea to make it flip area if necessary.
69 print_settings->SetOrientation(orientation == GTK_PAGE_ORIENTATION_LANDSCAPE); 69 print_settings->SetOrientation(orientation == GTK_PAGE_ORIENTATION_LANDSCAPE);
70 70 DCHECK_EQ(dpi, print_settings->device_units_per_inch());
71 print_settings->SetPrinterPrintableArea(physical_size_device_units, 71 print_settings->SetPrinterPrintableArea(physical_size_device_units,
72 printable_area_device_units, 72 printable_area_device_units,
73 dpi, true); 73 true);
74 } 74 }
75 75
76 const double PrintSettingsInitializerGtk::kTopMarginInInch = 0.25; 76 const double PrintSettingsInitializerGtk::kTopMarginInInch = 0.25;
77 const double PrintSettingsInitializerGtk::kBottomMarginInInch = 0.56; 77 const double PrintSettingsInitializerGtk::kBottomMarginInInch = 0.56;
78 const double PrintSettingsInitializerGtk::kLeftMarginInInch = 0.25; 78 const double PrintSettingsInitializerGtk::kLeftMarginInInch = 0.25;
79 const double PrintSettingsInitializerGtk::kRightMarginInInch = 0.25; 79 const double PrintSettingsInitializerGtk::kRightMarginInInch = 0.25;
80 80
81 } // namespace printing 81 } // namespace printing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698