Ensure that the leftmost vertical gridline gets rendered in RTL mode.
[pspp] / src / ui / gui / pspp-sheet-view.c
index ad86bd69d8cf5b7e9952877d5ea715554c586d7d..65b15fe574e937d588d74b90f167373ff1d4801c 100644 (file)
@@ -2032,6 +2032,9 @@ pspp_sheet_view_size_allocate (GtkWidget     *widget,
   if (allocation->width != old_allocation.width)
     width_changed = TRUE;
 
+  if (gtk_widget_get_direction(widget) == GTK_TEXT_DIR_RTL)   
+    allocation->x += allocation->width - tree_view->priv->width ;
+
   gtk_widget_set_allocation (widget, allocation);
 
   /* We size-allocate the columns first because the width of the
@@ -3825,36 +3828,35 @@ pspp_sheet_view_draw_vertical_grid_lines (PsppSheetView    *tree_view,
                                          gint max_y)
 {
   GList *list = tree_view->priv->columns;
-  gint i = 0;
-  gint current_x = 0;
+  gint x = 0;
 
   if (tree_view->priv->grid_lines != PSPP_SHEET_VIEW_GRID_LINES_VERTICAL
       && tree_view->priv->grid_lines != PSPP_SHEET_VIEW_GRID_LINES_BOTH)
     return;
 
   /* Only draw the lines for visible rows and columns */
-  for (list = tree_view->priv->columns; list; list = list->next, i++)
+  gboolean rtl = (gtk_widget_get_direction (GTK_WIDGET (tree_view)) == GTK_TEXT_DIR_RTL);
+
+  for (list = (rtl ? g_list_last (tree_view->priv->columns) : g_list_first (tree_view->priv->columns));
+       list;
+       list = (rtl ? list->prev : list->next))
     {
       PsppSheetViewColumn *column = list->data;
-      gint x;
 
       if (! column->visible)
        continue;
 
-      current_x += column->width;
-
-      /* Generally the grid lines should fit within the column, but for the
-         last visible column we put it just past the end of the column.
-         (Otherwise horizontal grid lines sometimes stick out by one pixel.) */
-      x = current_x;
-      if (i != n_visible_columns - 1)
-        x--;
+      if (!rtl)
+       x += column->width;
 
       cairo_set_line_width (cr, 1.0);
       cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
       cairo_move_to (cr, x + 0.5, min_y);
-      cairo_line_to (cr, x + 0.5, max_y - min_y);
+      cairo_line_to (cr, x + 0.5, max_y - min_y - 0.5);
       cairo_stroke (cr);
+
+      if (rtl)
+       x += column->width;
     }
 }