[gtk+] a11y: Simplify code
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] a11y: Simplify code
- Date: Mon, 19 Dec 2011 15:49:47 +0000 (UTC)
commit e4f6a7124b3d83fea9b09bd8fb14d98fd8c5c3c9
Author: Benjamin Otte <otte redhat com>
Date: Fri Dec 16 23:11:45 2011 +0100
a11y: Simplify code
Use peek_cell() instead of a custom find_cell() function that duplicates
loads of functionality.
gtk/a11y/gtktreeviewaccessible.c | 79 ++++++++++++--------------------------
1 files changed, 25 insertions(+), 54 deletions(-)
---
diff --git a/gtk/a11y/gtktreeviewaccessible.c b/gtk/a11y/gtktreeviewaccessible.c
index 61762e1..f59cab1 100644
--- a/gtk/a11y/gtktreeviewaccessible.c
+++ b/gtk/a11y/gtktreeviewaccessible.c
@@ -66,8 +66,6 @@ static void cell_info_new (GtkTreeViewAccessible
GtkRBNode *node,
GtkTreeViewColumn *tv_col,
GtkCellAccessible *cell);
-static GtkCellAccessible *find_cell (GtkTreeViewAccessible *accessible,
- gint index);
static gint get_column_number (GtkTreeView *tree_view,
GtkTreeViewColumn *column);
static gint get_focus_index (GtkTreeView *tree_view);
@@ -387,6 +385,25 @@ set_cell_data (GtkTreeView *treeview,
is_expanded);
}
+static GtkCellAccessible *
+peek_cell (GtkTreeViewAccessible *accessible,
+ GtkRBTree *tree,
+ GtkRBNode *node,
+ GtkTreeViewColumn *column)
+{
+ GtkTreeViewAccessibleCellInfo lookup, *cell_info;
+
+ lookup.tree = tree;
+ lookup.node = node;
+ lookup.cell_col_ref = column;
+
+ cell_info = g_hash_table_lookup (accessible->cell_infos, &lookup);
+ if (cell_info == NULL)
+ return NULL;
+
+ return cell_info->cell;
+}
+
static AtkObject *
gtk_tree_view_accessible_ref_child (AtkObject *obj,
gint i)
@@ -426,23 +443,19 @@ gtk_tree_view_accessible_ref_child (AtkObject *obj,
return child;
}
- /* Check whether the child is cached */
- cell = find_cell (accessible, i);
+ /* Find the RBTree and GtkTreeViewColumn for the index */
+ if (!get_rbtree_column_from_index (tree_view, i, &tree, &node, &tv_col))
+ return NULL;
+
+ cell = peek_cell (accessible, tree, node, tv_col);
if (cell)
- {
- g_object_ref (cell);
- return ATK_OBJECT (cell);
- }
+ return g_object_ref (cell);
if (accessible->focus_cell == NULL)
focus_index = get_focus_index (tree_view);
else
focus_index = -1;
- /* Find the RBTree and GtkTreeViewColumn for the index */
- if (!get_rbtree_column_from_index (tree_view, i, &tree, &node, &tv_col))
- return NULL;
-
path = _gtk_tree_path_new_from_rbtree (tree, node);
tree_model = gtk_tree_view_get_model (tree_view);
@@ -1624,48 +1637,6 @@ cell_info_new (GtkTreeViewAccessible *accessible,
g_hash_table_replace (accessible->cell_infos, cell_info, cell_info);
}
-static GtkCellAccessible *
-peek_cell (GtkTreeViewAccessible *accessible,
- GtkRBTree *tree,
- GtkRBNode *node,
- GtkTreeViewColumn *column)
-{
- GtkTreeViewAccessibleCellInfo lookup, *cell_info;
-
- lookup.tree = tree;
- lookup.node = node;
- lookup.cell_col_ref = column;
-
- cell_info = g_hash_table_lookup (accessible->cell_infos, &lookup);
- if (cell_info == NULL)
- return NULL;
-
- return cell_info->cell;
-}
-
-static GtkCellAccessible *
-find_cell (GtkTreeViewAccessible *accessible,
- gint index)
-{
- GtkTreeView *tree_view;
- GtkRBTree *tree;
- GtkRBNode *node;
-
- tree_view = GTK_TREE_VIEW (gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible)));
-
- if (!_gtk_rbtree_find_index (_gtk_tree_view_get_rbtree (tree_view),
- index / get_n_columns (tree_view) - 1,
- &tree,
- &node))
- {
- g_assert_not_reached ();
- }
-
- return peek_cell (accessible,
- tree, node,
- get_visible_column (tree_view, index % get_n_columns (tree_view)));
-}
-
/* Returns the column number of the specified GtkTreeViewColumn
* The column must be visible.
*/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]