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
This commit is contained in:
Vadim Godunko 2013-03-23 14:01:35 -04:00 committed by Matthias Clasen
parent d2c8b65fd9
commit 55012318a6

View File

@ -4676,31 +4676,31 @@ gtk_tree_view_draw_line (GtkTreeView *tree_view,
static void static void
gtk_tree_view_draw_grid_lines (GtkTreeView *tree_view, gtk_tree_view_draw_grid_lines (GtkTreeView *tree_view,
cairo_t *cr, cairo_t *cr)
gint n_visible_columns)
{ {
GList *list = tree_view->priv->columns; GList *list;
gint i = 0; GtkTreeViewColumn *last;
gboolean rtl;
gint current_x = 0; gint current_x = 0;
if (tree_view->priv->grid_lines != GTK_TREE_VIEW_GRID_LINES_VERTICAL if (tree_view->priv->grid_lines != GTK_TREE_VIEW_GRID_LINES_VERTICAL
&& tree_view->priv->grid_lines != GTK_TREE_VIEW_GRID_LINES_BOTH) && tree_view->priv->grid_lines != GTK_TREE_VIEW_GRID_LINES_BOTH)
return; return;
/* Only draw the lines for visible rows and columns */ rtl = (gtk_widget_get_direction (GTK_WIDGET (tree_view)) == GTK_TEXT_DIR_RTL);
for (list = tree_view->priv->columns; list; list = list->next, i++)
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; 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); 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_draw_line (tree_view, cr,
GTK_TREE_VIEW_GRID_LINE, GTK_TREE_VIEW_GRID_LINE,
current_x - 1, 0, current_x - 1, 0,
@ -5357,7 +5357,7 @@ gtk_tree_view_bin_draw (GtkWidget *widget,
while (y_offset < clip.height); while (y_offset < clip.height);
done: 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) if (tree_view->priv->rubber_band_status == RUBBER_BAND_ACTIVE)
gtk_tree_view_paint_rubber_band (tree_view, cr); gtk_tree_view_paint_rubber_band (tree_view, cr);