[gtk+] a11y: Compute index the easy way
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] a11y: Compute index the easy way
- Date: Wed, 16 Nov 2011 03:42:25 +0000 (UTC)
commit b8dec90f3a078b1a8a1b1c52abd8537b7231b900
Author: Benjamin Otte <otte redhat com>
Date: Sat Nov 12 05:05:19 2011 +0100
a11y: Compute index the easy way
index is row_index * n_columns + column_index
We use it everywhere, why not here?
gtk/a11y/gtktreeviewaccessible.c | 42 +-------------------------------------
1 files changed, 1 insertions(+), 41 deletions(-)
---
diff --git a/gtk/a11y/gtktreeviewaccessible.c b/gtk/a11y/gtktreeviewaccessible.c
index 8431e32..d5648a5 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_actual_column_number (GtkTreeView *tree_view,
- gint visible_column);
static gint get_visible_column_number (GtkTreeView *tree_view,
gint actual_column);
static void iterate_thru_children (GtkTreeView *tree_view,
@@ -884,12 +882,7 @@ gtk_tree_view_accessible_get_index_at (AtkTable *table,
gint column)
{
GtkWidget *widget;
- GtkTreeView *tree_view;
- gint actual_column;
gint n_cols, n_rows;
- GtkTreeIter iter;
- GtkTreePath *path;
- gint index;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (table));
if (widget == NULL)
@@ -901,16 +894,7 @@ gtk_tree_view_accessible_get_index_at (AtkTable *table,
if (row >= n_rows || column >= n_cols)
return -1;
- tree_view = GTK_TREE_VIEW (widget);
- actual_column = get_actual_column_number (tree_view, column);
-
- set_iter_nth_row (tree_view, &iter, row);
- path = gtk_tree_model_get_path (gtk_tree_view_get_model (tree_view), &iter);
-
- index = get_index (tree_view, path, actual_column);
- gtk_tree_path_free (path);
-
- return index;
+ return (row + 1) * n_cols + column;
}
static gint
@@ -2482,30 +2466,6 @@ get_column (GtkTreeView *tree_view,
}
static gint
-get_actual_column_number (GtkTreeView *tree_view,
- gint visible_column)
-{
- GtkTreeViewColumn *tv_col;
- gint actual_column = 0;
- gint visible_columns = -1;
-
- /* This function calculates the column number which corresponds
- * to the specified visible column number
- */
- tv_col = gtk_tree_view_get_column (tree_view, actual_column);
- while (tv_col != NULL)
- {
- if (gtk_tree_view_column_get_visible (tv_col))
- visible_columns++;
- if (visible_columns == visible_column)
- return actual_column;
- tv_col = gtk_tree_view_get_column (tree_view, ++actual_column);
- }
- g_warning ("get_actual_column_number failed for %d\n", visible_column);
- return -1;
-}
-
-static gint
get_visible_column_number (GtkTreeView *tree_view,
gint actual_column)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]