[evince/abderrahim/dual-rtl: 22/22] ev-view: follow the text direction for laying out pages in dual mode



commit ba36247d816048530dbfe3aad6f26a467606122a
Author: Abderrahim Kitouni <akitouni gnome org>
Date:   Fri Feb 22 21:31:50 2019 +0100

    ev-view: follow the text direction for laying out pages in dual mode
    
    This reverses the meaning of "Odd Pages Left" for RTL locales

 libview/ev-view.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/libview/ev-view.c b/libview/ev-view.c
index 8b46fcb3..e3f20fd9 100644
--- a/libview/ev-view.c
+++ b/libview/ev-view.c
@@ -1283,9 +1283,14 @@ ev_view_get_page_extents (EvView       *view,
                max_width = max_width + border->left + border->right;
                /* Get the location of the bounding box */
                if (is_dual_page (view, &odd_left)) {
-                       x = view->spacing + ((page % 2 == !odd_left) ? 0 : 1) * (max_width + view->spacing);
+                       gboolean right_page;
+
+                       right_page = (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR && page % 2 == 
!odd_left) ||
+                                    (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL && page % 2 == 
odd_left);
+
+                       x = view->spacing + (right_page ? 0 : 1) * (max_width + view->spacing);
                        x = x + MAX (0, allocation.width - (max_width * 2 + view->spacing * 3)) / 2;
-                       if (page % 2 == !odd_left)
+                       if (right_page)
                                x = x + (max_width - width - border->left - border->right);
                } else {
                        x = view->spacing;
@@ -1326,7 +1331,8 @@ ev_view_get_page_extents (EvView       *view,
                        y = view->spacing;
 
                        /* Adjust for being the left or right page */
-                       if (page % 2 == !odd_left)
+                       if ((gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR && page % 2 == !odd_left) 
||
+                           (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL && page % 2 == odd_left))
                                x = x + max_width - width;
                        else
                                x = x + (max_width + overall_border.left + overall_border.right) + 
view->spacing;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]