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

Unified Diff: chrome/browser/ui/libgtk2ui/printing_gtk2_util.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, 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/libgtk2ui/printing_gtk2_util.cc
diff --git a/chrome/browser/ui/libgtk2ui/printing_gtk2_util.cc b/chrome/browser/ui/libgtk2ui/printing_gtk2_util.cc
deleted file mode 100644
index f2961481876d4c96e290de30c656c3eb2ba3b79c..0000000000000000000000000000000000000000
--- a/chrome/browser/ui/libgtk2ui/printing_gtk2_util.cc
+++ /dev/null
@@ -1,99 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ui/libgtk2ui/printing_gtk2_util.h"
-
-#include <gtk/gtk.h>
-#include <gtk/gtkunixprint.h>
-
-#include "base/strings/string16.h"
-#include "base/strings/utf_string_conversions.h"
-#include "printing/print_settings.h"
-#include "printing/printing_context_linux.h"
-#include "printing/units.h"
-#include "ui/gfx/geometry/size.h"
-#include "ui/gfx/geometry/size_f.h"
-
-namespace {
-
-const double kTopMarginInInch = 0.25;
-const double kBottomMarginInInch = 0.56;
-const double kLeftMarginInInch = 0.25;
-const double kRightMarginInInch = 0.25;
-
-} // namespace
-
-gfx::Size GetPdfPaperSizeDeviceUnitsGtk(
- printing::PrintingContextLinux* context) {
- GtkPageSetup* page_setup = gtk_page_setup_new();
-
- gfx::SizeF paper_size(
- gtk_page_setup_get_paper_width(page_setup, GTK_UNIT_INCH),
- gtk_page_setup_get_paper_height(page_setup, GTK_UNIT_INCH));
-
- g_object_unref(page_setup);
-
- const printing::PrintSettings& settings = context->settings();
-
- return gfx::Size(
- paper_size.width() * settings.device_units_per_inch(),
- paper_size.height() * settings.device_units_per_inch());
-}
-
-void InitPrintSettingsGtk(GtkPrintSettings* settings,
- GtkPageSetup* page_setup,
- printing::PrintSettings* print_settings) {
- DCHECK(settings);
- DCHECK(page_setup);
- DCHECK(print_settings);
-
- base::string16 name(base::UTF8ToUTF16(static_cast<const char*>(
- gtk_print_settings_get_printer(settings))));
- print_settings->set_device_name(name);
-
- gfx::Size physical_size_device_units;
- gfx::Rect printable_area_device_units;
- int dpi = gtk_print_settings_get_resolution(settings);
- if (dpi) {
- // Initialize page_setup_device_units_.
- physical_size_device_units.SetSize(
- gtk_page_setup_get_paper_width(page_setup, GTK_UNIT_INCH) * dpi,
- gtk_page_setup_get_paper_height(page_setup, GTK_UNIT_INCH) * dpi);
- printable_area_device_units.SetRect(
- gtk_page_setup_get_left_margin(page_setup, GTK_UNIT_INCH) * dpi,
- gtk_page_setup_get_top_margin(page_setup, GTK_UNIT_INCH) * dpi,
- gtk_page_setup_get_page_width(page_setup, GTK_UNIT_INCH) * dpi,
- gtk_page_setup_get_page_height(page_setup, GTK_UNIT_INCH) * dpi);
- } else {
- // Use default values if we cannot get valid values from the print dialog.
- dpi = printing::kPixelsPerInch;
- double page_width_in_pixel = printing::kLetterWidthInch * dpi;
- double page_height_in_pixel = printing::kLetterHeightInch * dpi;
- physical_size_device_units.SetSize(
- static_cast<int>(page_width_in_pixel),
- static_cast<int>(page_height_in_pixel));
- printable_area_device_units.SetRect(
- static_cast<int>(kLeftMarginInInch * dpi),
- static_cast<int>(kTopMarginInInch * dpi),
- page_width_in_pixel - (kLeftMarginInInch + kRightMarginInInch) * dpi,
- page_height_in_pixel - (kTopMarginInInch + kBottomMarginInInch) * dpi);
- }
-
- print_settings->set_dpi(dpi);
-
- // Note: With the normal GTK print dialog, when the user selects the landscape
- // orientation, all that does is change the paper size. Which seems to be
- // enough to render the right output and send it to the printer.
- // The orientation value stays as portrait and does not actually affect
- // printing.
- // Thus this is only useful in print preview mode, where we manually set the
- // orientation and change the paper size ourselves.
- GtkPageOrientation orientation = gtk_print_settings_get_orientation(settings);
- // Set before SetPrinterPrintableArea to make it flip area if necessary.
- print_settings->SetOrientation(orientation == GTK_PAGE_ORIENTATION_LANDSCAPE);
- DCHECK_EQ(print_settings->device_units_per_inch(), dpi);
- print_settings->SetPrinterPrintableArea(physical_size_device_units,
- printable_area_device_units,
- true);
-}
« no previous file with comments | « chrome/browser/ui/libgtk2ui/printing_gtk2_util.h ('k') | chrome/browser/ui/libgtk2ui/select_file_dialog_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698