From fff02fb02e85164f61e7183e8ee823b2d66775f8 Mon Sep 17 00:00:00 2001 From: Sven Neumann Date: Tue, 26 Feb 2008 18:46:20 +0000 Subject: [PATCH] take the reading direction into account and do the right thing for RTL 2008-02-26 Sven Neumann * plug-ins/print/print-preview.c: take the reading direction into account and do the right thing for RTL languages. svn path=/trunk/; revision=24982 --- ChangeLog | 5 +++++ plug-ins/print/print-preview.c | 36 +++++++++++++++++++++++++++------- 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index edd05a9927..acadf98d05 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-02-26 Sven Neumann + + * plug-ins/print/print-preview.c: take the reading direction into + account and do the right thing for RTL languages. + 2008-02-26 Kevin Cozens * plug-ins/script-fu/scripts/frosty-logo.scm: Commited slightly diff --git a/plug-ins/print/print-preview.c b/plug-ins/print/print-preview.c index d4edef7ac7..24675af953 100644 --- a/plug-ins/print/print-preview.c +++ b/plug-ins/print/print-preview.c @@ -416,6 +416,13 @@ print_preview_expose_event (GtkWidget *widget, widget->allocation.x + border, widget->allocation.y + border); + if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) + { + gint width = widget->allocation.width - 2 * border; + + cairo_translate (cr, width - scale * paper_width, 0); + } + cairo_set_line_width (cr, 1.0); /* draw page background */ @@ -632,18 +639,33 @@ print_preview_is_inside (PrintPreview *preview, gdouble x, gdouble y) { - gdouble left_margin; - gdouble right_margin; - gdouble top_margin; - gdouble bottom_margin; - gdouble scale; + GtkWidget *widget = GTK_WIDGET (preview); + gdouble left_margin; + gdouble right_margin; + gdouble top_margin; + gdouble bottom_margin; + gdouble scale; + gint border = GTK_CONTAINER (widget)->border_width + 1; + + x -= border; + + scale = print_preview_get_scale (preview); + + if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) + { + gdouble paper_width; + gdouble paper_height; + gint width = widget->allocation.width - 2 * border; + + print_preview_get_page_size (preview, &paper_width, &paper_height); + + x -= width - scale * paper_width; + } print_preview_get_page_margins (preview, &left_margin, &right_margin, &top_margin, &bottom_margin); - scale = print_preview_get_scale (preview); - x = x / scale - left_margin; y = y / scale - top_margin;