From 52bd5f2f1fcd48a47363a72d86a2859692cca417 Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Mon, 26 Mar 2012 16:14:08 -0400 Subject: [PATCH] treeview: filter out invisible columns in get_path_for_child() Since we check for !list->next (and !list->prev for RTL) to set the GTK_REGION_LAST flag, we have to filter out invisible columns before looping; if we don't do that we might end up assigning GTK_REGION_LAST to an invisible column. https://bugzilla.gnome.org/show_bug.cgi?id=672937 --- gtk/gtktreeview.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c index 7bca6a365e..b9b90ab0eb 100644 --- a/gtk/gtktreeview.c +++ b/gtk/gtktreeview.c @@ -8509,22 +8509,28 @@ gtk_tree_view_get_path_for_child (GtkContainer *container, GtkTreeView *tree_view = GTK_TREE_VIEW (container); GtkWidgetPath *path; gboolean rtl; - GList *list; + GList *list, *visible_columns = NULL; gint n_col = 0; path = GTK_CONTAINER_CLASS (gtk_tree_view_parent_class)->get_path_for_child (container, child); rtl = (gtk_widget_get_direction (GTK_WIDGET (container)) == 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)) + for (list = tree_view->priv->columns; list; list = list->next) + { + GtkTreeViewColumn *column = list->data; + + if (gtk_tree_view_column_get_visible (column)) + visible_columns = g_list_prepend (visible_columns, column); + } + + if (!rtl) + visible_columns = g_list_reverse (visible_columns); + + for (list = visible_columns; list != NULL; list = list->next) { GtkTreeViewColumn *column = list->data; GtkRegionFlags flags = 0; - if (!gtk_tree_view_column_get_visible (column)) - continue; - n_col++; if (gtk_tree_view_column_get_widget (column) != child && @@ -8539,13 +8545,13 @@ gtk_tree_view_get_path_for_child (GtkContainer *container, if (n_col == 1) flags |= GTK_REGION_FIRST; - if ((rtl && !list->prev) || - (!rtl && !list->next)) + if (!list->next) flags |= GTK_REGION_LAST; gtk_widget_path_iter_add_region (path, -1, GTK_STYLE_REGION_COLUMN_HEADER, flags); break; } + g_list_free (visible_columns); gtk_widget_path_append_for_widget (path, child);