diff options
author | Benjamin Otte <otte@redhat.com> | 2011-12-16 23:11:45 +0100 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2011-12-19 16:17:12 +0100 |
commit | e4f6a7124b3d83fea9b09bd8fb14d98fd8c5c3c9 (patch) | |
tree | 7a873b07522231c7f6b85f6b6ac2de7be6e3ecd8 /gtk/a11y/gtktreeviewaccessible.c | |
parent | 19c5b5c9d696bced151293283f64e5ecdf74c62f (diff) | |
download | gtk+-e4f6a7124b3d83fea9b09bd8fb14d98fd8c5c3c9.tar.gz |
a11y: Simplify code
Use peek_cell() instead of a custom find_cell() function that duplicates
loads of functionality.
Diffstat (limited to 'gtk/a11y/gtktreeviewaccessible.c')
-rw-r--r-- | 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 61762e174e..f59cab137e 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. */ |