[gtk+/composite-templates] Don't rotate pdf landscape output
- From: Juan Pablo Ugarte <jpu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/composite-templates] Don't rotate pdf landscape output
- Date: Fri, 14 Sep 2012 21:30:21 +0000 (UTC)
commit cd2165da776442c02c5130195b61285b8741c9ab
Author: Adrian Johnson <ajohnson redneon com>
Date: Wed Sep 12 11:34:09 2012 +0200
Don't rotate pdf landscape output
gtk/gtkprintcontext.c | 30 ++++++++++++++++++++++
gtk/gtkprintoperation-private.h | 1 +
gtk/gtkprintoperation-unix.c | 11 +++++---
gtk/gtkprintoperation.c | 13 ++++-----
modules/printbackends/file/gtkprintbackendfile.c | 15 ++++++++++-
5 files changed, 58 insertions(+), 12 deletions(-)
---
diff --git a/gtk/gtkprintcontext.c b/gtk/gtkprintcontext.c
index 1de8f0c..4d55b75 100644
--- a/gtk/gtkprintcontext.c
+++ b/gtk/gtkprintcontext.c
@@ -286,6 +286,36 @@ _gtk_print_context_rotate_according_to_orientation (GtkPrintContext *context)
}
void
+_gtk_print_context_reverse_according_to_orientation (GtkPrintContext *context)
+{
+ cairo_t *cr = context->cr;
+ cairo_matrix_t matrix;
+ gdouble width, height;
+
+ width = gtk_page_setup_get_paper_width (context->page_setup, GTK_UNIT_INCH);
+ width = width * context->surface_dpi_x / context->pixels_per_unit_x;
+ height = gtk_page_setup_get_paper_height (context->page_setup, GTK_UNIT_INCH);
+ height = height * context->surface_dpi_y / context->pixels_per_unit_y;
+
+ switch (gtk_page_setup_get_orientation (context->page_setup))
+ {
+ default:
+ case GTK_PAGE_ORIENTATION_PORTRAIT:
+ case GTK_PAGE_ORIENTATION_LANDSCAPE:
+ break;
+ case GTK_PAGE_ORIENTATION_REVERSE_PORTRAIT:
+ case GTK_PAGE_ORIENTATION_REVERSE_LANDSCAPE:
+ cairo_translate (cr, width, height);
+ cairo_matrix_init (&matrix,
+ -1, 0,
+ 0, -1,
+ 0, 0);
+ cairo_transform (cr, &matrix);
+ break;
+ }
+}
+
+void
_gtk_print_context_translate_into_margin (GtkPrintContext *context)
{
gdouble left, top;
diff --git a/gtk/gtkprintoperation-private.h b/gtk/gtkprintoperation-private.h
index 8d22f4b..6a7b509 100644
--- a/gtk/gtkprintoperation-private.h
+++ b/gtk/gtkprintoperation-private.h
@@ -138,6 +138,7 @@ void _gtk_print_context_set_page_setup (GtkPrintCon
GtkPageSetup *page_setup);
void _gtk_print_context_translate_into_margin (GtkPrintContext *context);
void _gtk_print_context_rotate_according_to_orientation (GtkPrintContext *context);
+void _gtk_print_context_reverse_according_to_orientation (GtkPrintContext *context);
void _gtk_print_context_set_hard_margins (GtkPrintContext *context,
gdouble top,
gdouble bottom,
diff --git a/gtk/gtkprintoperation-unix.c b/gtk/gtkprintoperation-unix.c
index 59db658..6b24217 100644
--- a/gtk/gtkprintoperation-unix.c
+++ b/gtk/gtkprintoperation-unix.c
@@ -106,6 +106,11 @@ unix_start_page (GtkPrintOperation *op,
}
else if (type == CAIRO_SURFACE_TYPE_PDF)
{
+ if (!op->priv->manual_orientation)
+ {
+ w = gtk_page_setup_get_paper_width (page_setup, GTK_UNIT_POINTS);
+ h = gtk_page_setup_get_paper_height (page_setup, GTK_UNIT_POINTS);
+ }
cairo_pdf_surface_set_size (op_unix->surface, w, h);
}
}
@@ -829,12 +834,10 @@ _gtk_print_operation_platform_backend_resize_preview_surface (GtkPrintOperation
GtkPageSetup *page_setup,
cairo_surface_t *surface)
{
- GtkPaperSize *paper_size;
gdouble w, h;
- paper_size = gtk_page_setup_get_paper_size (page_setup);
- w = gtk_paper_size_get_width (paper_size, GTK_UNIT_POINTS);
- h = gtk_paper_size_get_height (paper_size, GTK_UNIT_POINTS);
+ w = gtk_page_setup_get_paper_width (page_setup, GTK_UNIT_POINTS);
+ h = gtk_page_setup_get_paper_height (page_setup, GTK_UNIT_POINTS);
cairo_pdf_surface_set_size (surface, w, h);
}
diff --git a/gtk/gtkprintoperation.c b/gtk/gtkprintoperation.c
index 8cb69d3..3fd4f93 100644
--- a/gtk/gtkprintoperation.c
+++ b/gtk/gtkprintoperation.c
@@ -2050,14 +2050,11 @@ pdf_start_page (GtkPrintOperation *op,
GtkPrintContext *print_context,
GtkPageSetup *page_setup)
{
- GtkPaperSize *paper_size;
cairo_surface_t *surface = op->priv->platform_data;
gdouble w, h;
- paper_size = gtk_page_setup_get_paper_size (page_setup);
-
- w = gtk_paper_size_get_width (paper_size, GTK_UNIT_POINTS);
- h = gtk_paper_size_get_height (paper_size, GTK_UNIT_POINTS);
+ w = gtk_page_setup_get_paper_width (page_setup, GTK_UNIT_POINTS);
+ h = gtk_page_setup_get_paper_height (page_setup, GTK_UNIT_POINTS);
cairo_pdf_surface_set_size (surface, w, h);
}
@@ -2146,7 +2143,7 @@ run_pdf (GtkPrintOperation *op,
priv->manual_reverse = FALSE;
priv->manual_page_set = GTK_PAGE_SET_ALL;
priv->manual_scale = 1.0;
- priv->manual_orientation = TRUE;
+ priv->manual_orientation = FALSE;
priv->manual_number_up = 1;
priv->manual_number_up_layout = GTK_NUMBER_UP_LAYOUT_LEFT_TO_RIGHT_TOP_TO_BOTTOM;
@@ -2498,6 +2495,8 @@ common_render_page (GtkPrintOperation *op,
if (priv->manual_orientation)
_gtk_print_context_rotate_according_to_orientation (print_context);
+ else
+ _gtk_print_context_reverse_according_to_orientation (print_context);
if (priv->manual_number_up > 1)
{
@@ -3048,7 +3047,7 @@ print_pages (GtkPrintOperation *op,
priv->manual_reverse = gtk_print_settings_get_reverse (priv->print_settings);
priv->manual_page_set = gtk_print_settings_get_page_set (priv->print_settings);
priv->manual_scale = gtk_print_settings_get_scale (priv->print_settings) / 100.0;
- priv->manual_orientation = TRUE;
+ priv->manual_orientation = FALSE;
priv->manual_number_up = gtk_print_settings_get_number_up (priv->print_settings);
priv->manual_number_up_layout = gtk_print_settings_get_number_up_layout (priv->print_settings);
}
diff --git a/modules/printbackends/file/gtkprintbackendfile.c b/modules/printbackends/file/gtkprintbackendfile.c
index 25fd49c..843ce59 100644
--- a/modules/printbackends/file/gtkprintbackendfile.c
+++ b/modules/printbackends/file/gtkprintbackendfile.c
@@ -783,6 +783,7 @@ file_printer_prepare_for_print (GtkPrinter *printer,
GtkPrintPages pages;
GtkPageRange *ranges;
gint n_ranges;
+ OutputFormat format;
pages = gtk_print_settings_get_print_pages (settings);
gtk_print_job_set_pages (print_job, pages);
@@ -807,7 +808,19 @@ file_printer_prepare_for_print (GtkPrinter *printer,
gtk_print_job_set_scale (print_job, scale / 100.0);
gtk_print_job_set_page_set (print_job, gtk_print_settings_get_page_set (settings));
- gtk_print_job_set_rotate (print_job, TRUE);
+
+ format = format_from_settings (settings);
+ switch (format)
+ {
+ case FORMAT_PDF:
+ gtk_print_job_set_rotate (print_job, FALSE);
+ break;
+ default:
+ case FORMAT_PS:
+ case FORMAT_SVG:
+ gtk_print_job_set_rotate (print_job, TRUE);
+ break;
+ }
}
static GList *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]