Output viewer: Right justify output items if an RTL locale is in effect
authorJohn Darrington <john@cellform.com>
Mon, 30 Nov 2015 13:43:15 +0000 (14:43 +0100)
committerJohn Darrington <john@darrington.wattle.id.au>
Wed, 2 Dec 2015 13:22:17 +0000 (14:22 +0100)
The GtkDrawingArea widgets which contain the rendered tables, must be shifted
to the right hand side of the parent widget for RTL locales.

Reported by: Mohammad Haghighat <hosseinhg@hotmail.com>

src/ui/gui/psppire-output-view.c

index d9597c9b5f04a49708051976f00f1c7c2df6598b..e4617e766fde9b31fc8539e2b9654b66b2013574 100644 (file)
@@ -191,12 +191,13 @@ static void
 rerender (struct psppire_output_view *view)
 {
   struct output_view_item *item;
+  GdkWindow *gdkw = gtk_widget_get_window (GTK_WIDGET (view->output));
   cairo_t *cr;
 
-  if (!view->n_items || !gtk_widget_get_window (GTK_WIDGET (view->output)))
+  if (!view->n_items || ! gdkw)
     return;
 
-  cr = gdk_cairo_create (gtk_widget_get_window (GTK_WIDGET (view->output)));
+  cr = gdk_cairo_create (gdkw);
   if (view->xr == NULL)
     create_xr (view);
   view->y = 0;
@@ -219,6 +220,10 @@ rerender (struct psppire_output_view *view)
 
       xr_rendering_measure (r, &tw, &th);
 
+      guint w = gdk_window_get_width (gdkw);
+      gint xpos = (gtk_widget_get_direction (GTK_WIDGET (view->output)) ==
+                  GTK_TEXT_DIR_RTL) ? w - tw : 0;
+
       if (!item->drawing_area)
         {
           item->drawing_area = gtk_drawing_area_new ();
@@ -229,10 +234,10 @@ rerender (struct psppire_output_view *view)
           g_object_set_data_full (G_OBJECT (item->drawing_area),
                                   "rendering", r, free_rendering);
           gtk_widget_set_size_request (item->drawing_area, tw, th);
-          gtk_layout_move (view->output, item->drawing_area, 0, view->y);
+          gtk_layout_move (view->output, item->drawing_area, xpos, view->y);
         }
 
-      alloc.x = 0;
+      alloc.x = xpos;
       alloc.y = view->y;
       alloc.width = tw;
       alloc.height = th;