[gtk+] Fix drawing of grid lines in RTL



commit 55012318a65f9efd0047215696aaec8d060c1b5d
Author: Vadim Godunko <godunko adacore com>
Date:   Sat Mar 23 14:01:35 2013 -0400

    Fix drawing of grid lines in RTL
    
    The vertical grid lines were not properly positions in
    RTL locales.
    https://bugzilla.gnome.org/show_bug.cgi?id=696051

 gtk/gtktreeview.c |   28 ++++++++++++++--------------
 1 files changed, 14 insertions(+), 14 deletions(-)
---
diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c
index 4544c6f..cb43c7f 100644
--- a/gtk/gtktreeview.c
+++ b/gtk/gtktreeview.c
@@ -4676,31 +4676,31 @@ gtk_tree_view_draw_line (GtkTreeView         *tree_view,
                          
 static void
 gtk_tree_view_draw_grid_lines (GtkTreeView    *tree_view,
-                              cairo_t        *cr,
-                              gint            n_visible_columns)
+                              cairo_t        *cr)
 {
-  GList *list = tree_view->priv->columns;
-  gint i = 0;
+  GList *list;
+  GtkTreeViewColumn *last;
+  gboolean rtl;
   gint current_x = 0;
 
   if (tree_view->priv->grid_lines != GTK_TREE_VIEW_GRID_LINES_VERTICAL
       && tree_view->priv->grid_lines != GTK_TREE_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++)
+  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)),
+       last = (rtl ? g_list_first (tree_view->priv->columns) : g_list_last (tree_view->priv->columns))->data;
+       list;
+       list = (rtl ? list->prev : list->next))
     {
       GtkTreeViewColumn *column = list->data;
 
-      /* We don't want a line for the last column */
-      if (i == n_visible_columns - 1)
-       break;
-
-      if (!gtk_tree_view_column_get_visible (column))
-       continue;
-
       current_x += gtk_tree_view_column_get_width (column);
 
+      /* We don't want a line for the last column */
+      if (column == last) break;
+
       gtk_tree_view_draw_line (tree_view, cr,
                                GTK_TREE_VIEW_GRID_LINE,
                                current_x - 1, 0,
@@ -5357,7 +5357,7 @@ gtk_tree_view_bin_draw (GtkWidget      *widget,
   while (y_offset < clip.height);
 
 done:
-  gtk_tree_view_draw_grid_lines (tree_view, cr, n_visible_columns);
+  gtk_tree_view_draw_grid_lines (tree_view, cr);
 
   if (tree_view->priv->rubber_band_status == RUBBER_BAND_ACTIVE)
     gtk_tree_view_paint_rubber_band (tree_view, cr);


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