[gtk+] a11y: Fix get_column_index()
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] a11y: Fix get_column_index()
- Date: Wed, 16 Nov 2011 03:43:25 +0000 (UTC)
commit f7df354c5a8a1fe53b712356932ae8b7d6a1f027
Author: Benjamin Otte <otte redhat com>
Date: Tue Nov 15 21:30:46 2011 +0100
a11y: Fix get_column_index()
gtk/a11y/gtktreeviewaccessible.c | 45 +++++--------------------------------
1 files changed, 6 insertions(+), 39 deletions(-)
---
diff --git a/gtk/a11y/gtktreeviewaccessible.c b/gtk/a11y/gtktreeviewaccessible.c
index 26bcf8e..6826733 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);
- n_columns = GTK_TREE_VIEW_ACCESSIBLE (table)->n_cols;
+ if (index >= gtk_tree_view_accessible_get_n_children (ATK_OBJECT (table)))
+ return -1;
- if (n_columns == 0)
- return 0;
+ n_columns = GTK_TREE_VIEW_ACCESSIBLE (table)->n_cols;
- index = index % n_columns;
+ /* checked by the n_children() check above */
+ g_assert (n_columns > 0);
- 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 *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]