diff options
author | Adrian Johnson <ajohnson@redneon.com> | 2012-09-12 11:34:09 +0200 |
---|---|---|
committer | Marek Kasik <mkasik@redhat.com> | 2012-09-12 15:38:37 +0200 |
commit | dd7e8e9414ddd908c35ba3a8c07d3c554ed21a84 (patch) | |
tree | c0b98de286779897ae7147ed56a8d5ffc73d7293 /gtk | |
parent | 2971446d580c996cccc47adfc23c099bc6f5013a (diff) | |
download | gtk+-dd7e8e9414ddd908c35ba3a8c07d3c554ed21a84.tar.gz |
Don't rotate pdf landscape output
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/gtkprintcontext.c | 30 | ||||
-rw-r--r-- | gtk/gtkprintoperation-private.h | 1 | ||||
-rw-r--r-- | gtk/gtkprintoperation-unix.c | 11 | ||||
-rw-r--r-- | gtk/gtkprintoperation.c | 13 |
4 files changed, 44 insertions, 11 deletions
diff --git a/gtk/gtkprintcontext.c b/gtk/gtkprintcontext.c index 1de8f0c33f..4d55b75e78 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 8d22f4b5f5..6a7b509978 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 59db658b87..6b24217987 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 8cb69d3be2..3fd4f93dc7 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); } |