From f7df354c5a8a1fe53b712356932ae8b7d6a1f027 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Tue, 15 Nov 2011 21:30:46 +0100 Subject: [PATCH] a11y: Fix get_column_index() --- gtk/a11y/gtktreeviewaccessible.c | 45 +++++--------------------------- 1 file changed, 6 insertions(+), 39 deletions(-) diff --git a/gtk/a11y/gtktreeviewaccessible.c b/gtk/a11y/gtktreeviewaccessible.c index 26bcf8e2a2..682673389c 100644 --- a/gtk/a11y/gtktreeviewaccessible.c +++ b/gtk/a11y/gtktreeviewaccessible.c @@ -82,8 +82,6 @@ static gint get_row_from_tree_path (GtkTreeView GtkTreePath *path); static GtkTreeViewColumn* get_column (GtkTreeView *tree_view, gint in_col); -static gint get_visible_column_number (GtkTreeView *tree_view, - gint actual_column); static void iterate_thru_children (GtkTreeView *tree_view, GtkTreeModel *tree_model, GtkTreePath *tree_path, @@ -922,22 +920,21 @@ gtk_tree_view_accessible_get_column_at_index (AtkTable *table, gint index) { GtkWidget *widget; - GtkTreeView *tree_view; gint n_columns; widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (table)); if (widget == NULL) return -1; - tree_view = GTK_TREE_VIEW (widget); + if (index >= gtk_tree_view_accessible_get_n_children (ATK_OBJECT (table))) + return -1; + n_columns = GTK_TREE_VIEW_ACCESSIBLE (table)->n_cols; - if (n_columns == 0) - return 0; + /* checked by the n_children() check above */ + g_assert (n_columns > 0); - index = index % n_columns; - - return get_visible_column_number (tree_view, index); + return index % n_columns; } static gint @@ -2478,36 +2475,6 @@ get_column (GtkTreeView *tree_view, return tv_col; } -static gint -get_visible_column_number (GtkTreeView *tree_view, - gint actual_column) -{ - GtkTreeViewColumn *tv_col; - gint column = 0; - gint visible_columns = -1; - - /* This function calculates the visible column number - * which corresponds to the specified actual column number - */ - tv_col = gtk_tree_view_get_column (tree_view, column); - - while (tv_col != NULL) - { - if (gtk_tree_view_column_get_visible (tv_col)) - { - visible_columns++; - if (actual_column == column) - return visible_columns; - } - else - if (actual_column == column) - return -1; - tv_col = gtk_tree_view_get_column (tree_view, ++column); - } - g_warning ("get_visible_column_number failed for %d\n", actual_column); - return -1; -} - /* Helper recursive function that returns an iter to nth row */ static GtkTreeIter *