1 /* GAIL - The GNOME Accessibility Implementation Library
2 * Copyright 2001, 2002, 2003 Sun Microsystems Inc.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
23 #ifdef GDK_WINDOWING_X11
24 #include <gdk/x11/gdkx.h>
27 #include "gtktreeprivate.h"
28 #include "gtkwidgetprivate.h"
30 #include "gtktreeviewaccessible.h"
31 #include "gtkrenderercellaccessible.h"
32 #include "gtkbooleancellaccessible.h"
33 #include "gtkimagecellaccessible.h"
34 #include "gtkcontainercellaccessible.h"
35 #include "gtktextcellaccessible.h"
36 #include "gtkcellaccessibleparent.h"
38 typedef struct _GtkTreeViewAccessibleCellInfo GtkTreeViewAccessibleCellInfo;
39 struct _GtkTreeViewAccessibleCellInfo
41 GtkCellAccessible *cell;
44 GtkTreeViewColumn *cell_col_ref;
45 GtkTreeViewAccessible *view;
50 static gboolean row_expanded_cb (GtkTreeView *tree_view,
53 static gboolean row_collapsed_cb (GtkTreeView *tree_view,
56 static void size_allocate_cb (GtkWidget *widget,
57 GtkAllocation *allocation);
58 static void selection_changed_cb (GtkTreeSelection *selection,
61 static void columns_changed (GtkTreeView *tree_view);
62 static void cursor_changed (GtkTreeView *tree_view,
63 GtkTreeViewAccessible *accessible);
64 static gboolean focus_in (GtkWidget *widget);
65 static gboolean focus_out (GtkWidget *widget);
67 static void column_visibility_changed
71 static void destroy_count_func (GtkTreeView *tree_view,
78 static void set_iter_nth_row (GtkTreeView *tree_view,
81 static gint get_row_from_tree_path (GtkTreeView *tree_view,
83 static GtkTreeViewColumn* get_column (GtkTreeView *tree_view,
85 static gint get_visible_column_number (GtkTreeView *tree_view,
87 static void iterate_thru_children (GtkTreeView *tree_view,
88 GtkTreeModel *tree_model,
89 GtkTreePath *tree_path,
93 static int cell_info_get_index (GtkTreeView *tree_view,
94 GtkTreeViewAccessibleCellInfo *info);
95 static void clean_rows (GtkTreeViewAccessible *tree_view);
96 static void clean_cols (GtkTreeViewAccessible *tree_view,
97 GtkTreeViewColumn *tv_col);
98 static void traverse_cells (GtkTreeViewAccessible *tree_view,
99 GtkTreePath *tree_path,
101 static gboolean update_cell_value (GtkRendererCellAccessible *renderer_cell,
102 GtkTreeViewAccessible *accessible,
103 gboolean emit_change_signal);
104 static void set_cell_visibility (GtkTreeView *tree_view,
105 GtkCellAccessible *cell,
106 GtkTreeViewColumn *tv_col,
107 GtkTreePath *tree_path,
108 gboolean emit_signal);
109 static gboolean is_cell_showing (GtkTreeView *tree_view,
110 GdkRectangle *cell_rect);
111 static void set_expand_state (GtkTreeView *tree_view,
112 GtkTreeModel *tree_model,
113 GtkTreeViewAccessible *accessible,
114 GtkTreePath *tree_path,
115 gboolean set_on_ancestor);
116 static void set_cell_expandable (GtkCellAccessible *cell);
117 static void add_cell_actions (GtkCellAccessible *cell,
120 static void toggle_cell_toggled (GtkCellAccessible *cell);
121 static void edit_cell (GtkCellAccessible *cell);
122 static void activate_cell (GtkCellAccessible *cell);
123 static void cell_destroyed (gpointer data);
124 static void cell_info_new (GtkTreeViewAccessible *accessible,
125 GtkTreeModel *tree_model,
128 GtkTreeViewColumn *tv_col,
129 GtkCellAccessible *cell);
130 static GtkCellAccessible *find_cell (GtkTreeViewAccessible *accessible,
132 static void connect_model_signals (GtkTreeView *view,
133 GtkTreeViewAccessible *accessible);
134 static void disconnect_model_signals (GtkTreeViewAccessible *accessible);
135 static gint get_column_number (GtkTreeView *tree_view,
136 GtkTreeViewColumn *column,
138 static gint get_focus_index (GtkTreeView *tree_view);
139 static gint get_index (GtkTreeView *tree_view,
142 static void count_rows (GtkTreeModel *model,
144 GtkTreePath *end_path,
149 static gboolean get_rbtree_column_from_index (GtkTreeView *tree_view,
153 GtkTreeViewColumn **column);
155 static GtkTreeViewAccessibleCellInfo* find_cell_info (GtkTreeViewAccessible *view,
156 GtkCellAccessible *cell,
158 static AtkObject * get_header_from_column (GtkTreeViewColumn *tv_col);
161 static void atk_table_interface_init (AtkTableIface *iface);
162 static void atk_selection_interface_init (AtkSelectionIface *iface);
163 static void atk_component_interface_init (AtkComponentIface *iface);
164 static void gtk_cell_accessible_parent_interface_init (GtkCellAccessibleParentIface *iface);
166 G_DEFINE_TYPE_WITH_CODE (GtkTreeViewAccessible, _gtk_tree_view_accessible, GTK_TYPE_CONTAINER_ACCESSIBLE,
167 G_IMPLEMENT_INTERFACE (ATK_TYPE_TABLE, atk_table_interface_init)
168 G_IMPLEMENT_INTERFACE (ATK_TYPE_SELECTION, atk_selection_interface_init)
169 G_IMPLEMENT_INTERFACE (ATK_TYPE_COMPONENT, atk_component_interface_init)
170 G_IMPLEMENT_INTERFACE (GTK_TYPE_CELL_ACCESSIBLE_PARENT, gtk_cell_accessible_parent_interface_init))
174 adjustment_changed (GtkAdjustment *adjustment,
177 GtkTreeViewAccessible *accessible;
179 accessible = GTK_TREE_VIEW_ACCESSIBLE (gtk_widget_get_accessible (widget));
180 traverse_cells (accessible, NULL, FALSE);
184 hadjustment_set_cb (GObject *widget,
188 GtkTreeViewAccessible *accessible = data;
191 g_object_get (widget, "hadjustment", &adj, NULL);
192 accessible->old_hadj = adj;
193 g_object_add_weak_pointer (G_OBJECT (accessible->old_hadj), (gpointer *)&accessible->old_hadj);
194 g_signal_connect (adj, "value-changed", G_CALLBACK (adjustment_changed), widget);
198 vadjustment_set_cb (GObject *widget,
202 GtkTreeViewAccessible *accessible = data;
205 g_object_get (widget, "vadjustment", &adj, NULL);
206 accessible->old_vadj = adj;
207 g_object_add_weak_pointer (G_OBJECT (accessible->old_vadj), (gpointer *)&accessible->old_vadj);
208 g_signal_connect (adj, "value-changed",
209 G_CALLBACK (adjustment_changed), widget);
213 gtk_tree_view_accessible_get_data_quark (void)
215 static GQuark quark = 0;
217 if (G_UNLIKELY (quark == 0))
218 quark = g_quark_from_static_string ("gtk-tree-view-accessible-data");
224 cell_info_free (GtkTreeViewAccessibleCellInfo *cell_info)
228 g_object_steal_qdata (G_OBJECT (cell_info->cell),
229 gtk_tree_view_accessible_get_data_quark ());
230 _gtk_cell_accessible_add_state (cell_info->cell, ATK_STATE_DEFUNCT, FALSE);
237 cell_info_get_path (GtkTreeViewAccessibleCellInfo *cell_info)
239 return _gtk_tree_view_find_path (NULL,
245 gtk_tree_view_accessible_initialize (AtkObject *obj,
248 GtkTreeViewAccessible *accessible;
249 GtkTreeView *tree_view;
250 GtkTreeModel *tree_model;
251 GList *tv_cols, *tmp_list;
253 GtkTreeSelection *selection;
255 ATK_OBJECT_CLASS (_gtk_tree_view_accessible_parent_class)->initialize (obj, data);
257 accessible = GTK_TREE_VIEW_ACCESSIBLE (obj);
258 accessible->col_data = NULL;
259 accessible->focus_cell = NULL;
260 accessible->old_hadj = NULL;
261 accessible->old_vadj = NULL;
262 accessible->idle_expand_id = 0;
263 accessible->idle_expand_path = NULL;
264 accessible->n_children_deleted = 0;
266 accessible->cell_infos = g_hash_table_new_full (g_direct_hash,
267 g_direct_equal, NULL, (GDestroyNotify) cell_info_free);
269 widget = GTK_WIDGET (data);
270 tree_view = GTK_TREE_VIEW (widget);
271 tree_model = gtk_tree_view_get_model (tree_view);
272 selection = gtk_tree_view_get_selection (tree_view);
274 g_signal_connect_after (widget, "row-collapsed",
275 G_CALLBACK (row_collapsed_cb), NULL);
276 g_signal_connect (widget, "row-expanded",
277 G_CALLBACK (row_expanded_cb), NULL);
278 g_signal_connect (widget, "size-allocate",
279 G_CALLBACK (size_allocate_cb), NULL);
280 g_signal_connect (selection, "changed",
281 G_CALLBACK (selection_changed_cb), obj);
283 g_signal_connect (tree_view, "columns-changed",
284 G_CALLBACK (columns_changed), NULL);
285 g_signal_connect (tree_view, "cursor-changed",
286 G_CALLBACK (cursor_changed), accessible);
287 g_signal_connect (tree_view, "focus-in-event",
288 G_CALLBACK (focus_in), NULL);
289 g_signal_connect (tree_view, "focus-out-event",
290 G_CALLBACK (focus_out), NULL);
292 accessible->tree_model = tree_model;
293 accessible->n_cols = 0;
296 g_object_add_weak_pointer (G_OBJECT (accessible->tree_model), (gpointer *)&accessible->tree_model);
297 connect_model_signals (tree_view, accessible);
299 if (gtk_tree_model_get_flags (tree_model) & GTK_TREE_MODEL_LIST_ONLY)
300 obj->role = ATK_ROLE_TABLE;
302 obj->role = ATK_ROLE_TREE_TABLE;
305 hadjustment_set_cb (G_OBJECT (widget), NULL, accessible);
306 vadjustment_set_cb (G_OBJECT (widget), NULL, accessible);
307 g_signal_connect (widget, "notify::hadjustment",
308 G_CALLBACK (hadjustment_set_cb), accessible);
309 g_signal_connect (widget, "notify::vadjustment",
310 G_CALLBACK (vadjustment_set_cb), accessible);
312 accessible->col_data = g_array_sized_new (FALSE, TRUE,
313 sizeof (GtkTreeViewColumn *), 0);
315 tv_cols = gtk_tree_view_get_columns (tree_view);
316 for (tmp_list = tv_cols; tmp_list; tmp_list = tmp_list->next)
318 accessible->n_cols++;
319 g_signal_connect (tmp_list->data, "notify::visible",
320 G_CALLBACK (column_visibility_changed), tree_view);
321 g_array_append_val (accessible->col_data, tmp_list->data);
323 g_list_free (tv_cols);
325 gtk_tree_view_set_destroy_count_func (tree_view,
331 gtk_tree_view_accessible_finalize (GObject *object)
333 GtkTreeViewAccessible *accessible = GTK_TREE_VIEW_ACCESSIBLE (object);
335 /* remove any idle handlers still pending */
336 if (accessible->idle_expand_id)
337 g_source_remove (accessible->idle_expand_id);
339 if (accessible->tree_model)
340 disconnect_model_signals (accessible);
342 if (accessible->cell_infos)
343 g_hash_table_destroy (accessible->cell_infos);
345 if (accessible->col_data)
347 GArray *array = accessible->col_data;
349 /* No need to free the contents of the array since it
350 * just contains pointers to the GtkTreeViewColumn
351 * objects that are in the GtkTreeView.
353 g_array_free (array, TRUE);
356 G_OBJECT_CLASS (_gtk_tree_view_accessible_parent_class)->finalize (object);
360 gtk_tree_view_accessible_notify_gtk (GObject *obj,
364 GtkTreeView *tree_view;
365 GtkTreeViewAccessible *accessible;
368 widget = GTK_WIDGET (obj);
369 accessible = GTK_TREE_VIEW_ACCESSIBLE (gtk_widget_get_accessible (widget));
370 tree_view = GTK_TREE_VIEW (widget);
372 if (g_strcmp0 (pspec->name, "model") == 0)
374 GtkTreeModel *tree_model;
377 tree_model = gtk_tree_view_get_model (tree_view);
378 if (accessible->tree_model)
379 disconnect_model_signals (accessible);
380 g_hash_table_remove_all (accessible->cell_infos);
381 accessible->tree_model = tree_model;
385 g_object_add_weak_pointer (G_OBJECT (accessible->tree_model), (gpointer *)&accessible->tree_model);
386 connect_model_signals (tree_view, accessible);
388 if (gtk_tree_model_get_flags (tree_model) & GTK_TREE_MODEL_LIST_ONLY)
389 role = ATK_ROLE_TABLE;
391 role = ATK_ROLE_TREE_TABLE;
395 role = ATK_ROLE_UNKNOWN;
397 atk_object_set_role (ATK_OBJECT (accessible), role);
398 g_object_freeze_notify (G_OBJECT (accessible));
399 g_signal_emit_by_name (accessible, "model-changed");
400 g_signal_emit_by_name (accessible, "visible-data-changed");
401 g_object_thaw_notify (G_OBJECT (accessible));
403 else if (g_strcmp0 (pspec->name, "hadjustment") == 0)
405 g_object_get (tree_view, "hadjustment", &adj, NULL);
406 g_signal_handlers_disconnect_by_func (accessible->old_hadj,
407 (gpointer) adjustment_changed,
409 accessible->old_hadj = adj;
410 g_object_add_weak_pointer (G_OBJECT (accessible->old_hadj), (gpointer *)&accessible->old_hadj);
411 g_signal_connect (adj, "value-changed", G_CALLBACK (adjustment_changed), tree_view);
413 else if (g_strcmp0 (pspec->name, "vadjustment") == 0)
415 g_object_get (tree_view, "vadjustment", &adj, NULL);
416 g_signal_handlers_disconnect_by_func (accessible->old_vadj,
417 (gpointer) adjustment_changed,
419 accessible->old_vadj = adj;
420 g_object_add_weak_pointer (G_OBJECT (accessible->old_hadj), (gpointer *)&accessible->old_vadj);
421 g_signal_connect (adj, "value-changed", G_CALLBACK (adjustment_changed), tree_view);
424 GTK_WIDGET_ACCESSIBLE_CLASS (_gtk_tree_view_accessible_parent_class)->notify_gtk (obj, pspec);
428 gtk_tree_view_accessible_destroyed (GtkWidget *widget,
429 GtkAccessible *gtk_accessible)
432 GtkTreeViewAccessible *accessible;
434 if (!GTK_IS_TREE_VIEW (widget))
437 accessible = GTK_TREE_VIEW_ACCESSIBLE (gtk_accessible);
438 adj = accessible->old_hadj;
440 g_signal_handlers_disconnect_by_func (adj,
441 (gpointer) adjustment_changed,
443 adj = accessible->old_vadj;
445 g_signal_handlers_disconnect_by_func (adj,
446 (gpointer) adjustment_changed,
448 if (accessible->tree_model)
450 disconnect_model_signals (accessible);
451 accessible->tree_model = NULL;
453 if (accessible->focus_cell)
455 g_object_unref (accessible->focus_cell);
456 accessible->focus_cell = NULL;
458 if (accessible->idle_expand_id)
460 g_source_remove (accessible->idle_expand_id);
461 accessible->idle_expand_id = 0;
466 gtk_tree_view_accessible_connect_widget_destroyed (GtkAccessible *accessible)
470 widget = gtk_accessible_get_widget (accessible);
472 g_signal_connect_after (widget, "destroy",
473 G_CALLBACK (gtk_tree_view_accessible_destroyed), accessible);
475 GTK_ACCESSIBLE_CLASS (_gtk_tree_view_accessible_parent_class)->connect_widget_destroyed (accessible);
479 get_n_rows (GtkTreeView *tree_view)
483 tree = _gtk_tree_view_get_rbtree (tree_view);
488 return tree->root->total_count;
492 gtk_tree_view_accessible_get_n_children (AtkObject *obj)
495 GtkTreeViewAccessible *accessible;
496 GtkTreeView *tree_view;
498 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
502 tree_view = GTK_TREE_VIEW (widget);
503 accessible = GTK_TREE_VIEW_ACCESSIBLE (obj);
504 return (get_n_rows (tree_view) + 1) * accessible->n_cols;
508 gtk_tree_view_accessible_ref_child (AtkObject *obj,
512 GtkTreeViewAccessible *accessible;
513 GtkCellAccessible *cell;
514 GtkTreeView *tree_view;
515 GtkTreeModel *tree_model;
516 GtkCellRenderer *renderer;
518 GtkTreeViewColumn *tv_col;
519 GtkTreeSelection *selection;
525 GtkTreeViewColumn *expander_tv;
526 GList *renderer_list;
528 GtkContainerCellAccessible *container = NULL;
529 GtkRendererCellAccessible *renderer_cell;
530 gboolean is_expander, is_expanded, retval;
531 gboolean editable = FALSE;
534 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
538 if (i >= gtk_tree_view_accessible_get_n_children (obj))
541 accessible = GTK_TREE_VIEW_ACCESSIBLE (obj);
542 tree_view = GTK_TREE_VIEW (widget);
543 if (i < accessible->n_cols)
545 tv_col = gtk_tree_view_get_column (tree_view, i);
546 child = get_header_from_column (tv_col);
548 g_object_ref (child);
552 /* Check whether the child is cached */
553 cell = find_cell (accessible, i);
557 return ATK_OBJECT (cell);
560 if (accessible->focus_cell == NULL)
561 focus_index = get_focus_index (tree_view);
565 /* Find the RBTree and GtkTreeViewColumn for the index */
566 if (!get_rbtree_column_from_index (tree_view, i, &tree, &node, &tv_col))
569 path = _gtk_tree_view_find_path (tree_view, tree, node);
570 tree_model = gtk_tree_view_get_model (tree_view);
571 retval = gtk_tree_model_get_iter (tree_model, &iter, path);
575 expander_tv = gtk_tree_view_get_expander_column (tree_view);
578 if (GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_IS_PARENT))
580 if (expander_tv == tv_col)
583 is_expanded = node->children != NULL;
586 gtk_tree_view_column_cell_set_cell_data (tv_col, tree_model, &iter,
587 is_expander, is_expanded);
589 renderer_list = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (tv_col));
591 /* If there are more than one renderer in the list,
594 if (renderer_list && renderer_list->next)
596 GtkCellAccessible *container_cell;
598 container = _gtk_container_cell_accessible_new ();
600 container_cell = GTK_CELL_ACCESSIBLE (container);
601 _gtk_cell_accessible_initialise (container_cell, widget, ATK_OBJECT (accessible));
603 /* The GtkTreeViewAccessibleCellInfo structure for the container will
604 * be before the ones for the cells so that the first one we find for
605 * a position will be for the container
607 cell_info_new (accessible, tree_model, tree, node, tv_col, container_cell);
608 parent = ATK_OBJECT (container);
611 parent = ATK_OBJECT (accessible);
615 /* Now we make a fake cell_renderer if there is no cell
618 if (renderer_list == NULL)
620 GtkCellRenderer *fake_renderer;
622 fake_renderer = g_object_new (GTK_TYPE_CELL_RENDERER_TEXT, NULL);
623 child = _gtk_text_cell_accessible_new ();
624 cell = GTK_CELL_ACCESSIBLE (child);
625 renderer_cell = GTK_RENDERER_CELL_ACCESSIBLE (child);
626 renderer_cell->renderer = fake_renderer;
628 /* Create the GtkTreeViewAccessibleCellInfo structure for this cell */
629 cell_info_new (accessible, tree_model, tree, node, tv_col, cell);
631 _gtk_cell_accessible_initialise (cell, widget, parent);
633 /* Set state if it is expandable */
636 set_cell_expandable (cell);
638 _gtk_cell_accessible_add_state (cell, ATK_STATE_EXPANDED, FALSE);
643 for (l = renderer_list; l; l = l->next)
645 renderer = GTK_CELL_RENDERER (l->data);
647 if (GTK_IS_CELL_RENDERER_TEXT (renderer))
649 g_object_get (G_OBJECT (renderer), "editable", &editable, NULL);
650 child = _gtk_text_cell_accessible_new ();
652 else if (GTK_IS_CELL_RENDERER_TOGGLE (renderer))
653 child = _gtk_boolean_cell_accessible_new ();
654 else if (GTK_IS_CELL_RENDERER_PIXBUF (renderer))
655 child = _gtk_image_cell_accessible_new ();
657 child = _gtk_renderer_cell_accessible_new ();
659 cell = GTK_CELL_ACCESSIBLE (child);
660 renderer_cell = GTK_RENDERER_CELL_ACCESSIBLE (child);
662 /* Create the GtkTreeViewAccessibleCellInfo for this cell */
663 cell_info_new (accessible, tree_model, tree, node, tv_col, cell);
665 _gtk_cell_accessible_initialise (cell, widget, parent);
668 _gtk_container_cell_accessible_add_child (container, cell);
670 update_cell_value (renderer_cell, accessible, FALSE);
672 /* Add the actions appropriate for this cell */
673 add_cell_actions (cell, editable);
675 /* Set state if it is expandable */
678 set_cell_expandable (cell);
680 _gtk_cell_accessible_add_state (cell, ATK_STATE_EXPANDED, FALSE);
683 /* If the column is visible, sets the cell's state */
684 if (gtk_tree_view_column_get_visible (tv_col))
685 set_cell_visibility (tree_view, cell, tv_col, path, FALSE);
687 /* If the row is selected, all cells on the row are selected */
688 selection = gtk_tree_view_get_selection (tree_view);
690 if (gtk_tree_selection_path_is_selected (selection, path))
691 _gtk_cell_accessible_add_state (cell, ATK_STATE_SELECTED, FALSE);
693 _gtk_cell_accessible_add_state (cell, ATK_STATE_FOCUSABLE, FALSE);
694 if (focus_index == i)
696 accessible->focus_cell = g_object_ref (cell);
697 _gtk_cell_accessible_add_state (cell, ATK_STATE_FOCUSED, FALSE);
698 g_signal_emit_by_name (accessible, "active-descendant-changed", cell);
701 g_list_free (renderer_list);
703 child = ATK_OBJECT (container);
706 if (expander_tv == tv_col)
708 AtkRelationSet *relation_set;
709 AtkObject *accessible_array[1];
710 AtkRelation* relation;
711 AtkObject *parent_node;
713 relation_set = atk_object_ref_relation_set (ATK_OBJECT (child));
715 gtk_tree_path_up (path);
716 if (gtk_tree_path_get_depth (path) == 0)
722 parent_index = get_index (tree_view, path, i % accessible->n_cols);
723 parent_node = atk_object_ref_accessible_child (obj, parent_index);
725 accessible_array[0] = parent_node;
726 relation = atk_relation_new (accessible_array, 1,
727 ATK_RELATION_NODE_CHILD_OF);
728 atk_relation_set_add (relation_set, relation);
729 atk_object_add_relationship (parent_node, ATK_RELATION_NODE_PARENT_OF, child);
730 g_object_unref (relation);
731 g_object_unref (relation_set);
733 gtk_tree_path_free (path);
735 /* We do not increase the reference count here; when g_object_unref()
736 * is called for the cell then cell_destroyed() is called and this
737 * removes the cell from the cache.
743 gtk_tree_view_accessible_ref_state_set (AtkObject *obj)
745 AtkStateSet *state_set;
748 state_set = ATK_OBJECT_CLASS (_gtk_tree_view_accessible_parent_class)->ref_state_set (obj);
749 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
752 atk_state_set_add_state (state_set, ATK_STATE_MANAGES_DESCENDANTS);
758 _gtk_tree_view_accessible_class_init (GtkTreeViewAccessibleClass *klass)
760 AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
761 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
762 GtkAccessibleClass *accessible_class = (GtkAccessibleClass*)klass;
763 GtkWidgetAccessibleClass *widget_class = (GtkWidgetAccessibleClass*)klass;
764 GtkContainerAccessibleClass *container_class = (GtkContainerAccessibleClass*)klass;
766 class->get_n_children = gtk_tree_view_accessible_get_n_children;
767 class->ref_child = gtk_tree_view_accessible_ref_child;
768 class->ref_state_set = gtk_tree_view_accessible_ref_state_set;
769 class->initialize = gtk_tree_view_accessible_initialize;
771 widget_class->notify_gtk = gtk_tree_view_accessible_notify_gtk;
773 accessible_class->connect_widget_destroyed = gtk_tree_view_accessible_connect_widget_destroyed;
775 /* The children of a GtkTreeView are the buttons at the top of the columns
776 * we do not represent these as children so we do not want to report
777 * children added or deleted when these changed.
779 container_class->add_gtk = NULL;
780 container_class->remove_gtk = NULL;
782 gobject_class->finalize = gtk_tree_view_accessible_finalize;
786 _gtk_tree_view_accessible_init (GtkTreeViewAccessible *view)
791 get_focus_index (GtkTreeView *tree_view)
793 GtkTreePath *focus_path;
794 GtkTreeViewColumn *focus_column;
797 gtk_tree_view_get_cursor (tree_view, &focus_path, &focus_column);
798 if (focus_path && focus_column)
799 index = get_index (tree_view, focus_path,
800 get_column_number (tree_view, focus_column, FALSE));
805 gtk_tree_path_free (focus_path);
810 /* This function returns a reference to the accessible object
811 * for the cell in the treeview which has focus, if any
814 gtk_tree_view_accessible_ref_focus_cell (GtkTreeView *tree_view)
816 AtkObject *focus_cell = NULL;
820 focus_index = get_focus_index (tree_view);
821 if (focus_index >= 0)
823 atk_obj = gtk_widget_get_accessible (GTK_WIDGET (tree_view));
824 focus_cell = atk_object_ref_accessible_child (atk_obj, focus_index);
833 gtk_tree_view_accessible_ref_accessible_at_point (AtkComponent *component,
836 AtkCoordType coord_type)
839 GtkTreeView *tree_view;
841 GtkTreeViewColumn *tv_column;
846 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (component));
850 tree_view = GTK_TREE_VIEW (widget);
852 atk_component_get_extents (component, &x_pos, &y_pos, NULL, NULL, coord_type);
853 gtk_tree_view_convert_widget_to_bin_window_coords (tree_view, x, y, &bx, &by);
854 ret_val = gtk_tree_view_get_path_at_pos (tree_view,
855 bx - x_pos, by - y_pos,
856 &path, &tv_column, NULL, NULL);
861 column = get_column_number (tree_view, tv_column, FALSE);
862 index = get_index (tree_view, path, column);
863 gtk_tree_path_free (path);
865 return gtk_tree_view_accessible_ref_child (ATK_OBJECT (component), index);
872 atk_component_interface_init (AtkComponentIface *iface)
874 iface->ref_accessible_at_point = gtk_tree_view_accessible_ref_accessible_at_point;
880 gtk_tree_view_accessible_get_index_at (AtkTable *table,
887 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (table));
891 n_cols = atk_table_get_n_columns (table);
892 n_rows = atk_table_get_n_rows (table);
894 if (row >= n_rows || column >= n_cols)
897 return (row + 1) * n_cols + column;
901 gtk_tree_view_accessible_get_column_at_index (AtkTable *table,
905 GtkTreeView *tree_view;
908 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (table));
912 tree_view = GTK_TREE_VIEW (widget);
913 n_columns = GTK_TREE_VIEW_ACCESSIBLE (table)->n_cols;
918 index = index % n_columns;
920 return get_visible_column_number (tree_view, index);
924 gtk_tree_view_accessible_get_row_at_index (AtkTable *table,
928 GtkTreeView *tree_view;
930 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (table));
934 tree_view = GTK_TREE_VIEW (widget);
936 index /= GTK_TREE_VIEW_ACCESSIBLE (table)->n_cols;
938 if (index >= get_n_rows (tree_view))
945 gtk_tree_view_accessible_table_ref_at (AtkTable *table,
951 index = gtk_tree_view_accessible_get_index_at (table, row, column);
955 return gtk_tree_view_accessible_ref_child (ATK_OBJECT (table), index);
959 gtk_tree_view_accessible_get_n_rows (AtkTable *table)
963 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (table));
967 return get_n_rows (GTK_TREE_VIEW (widget));
971 gtk_tree_view_accessible_get_n_columns (AtkTable *table)
974 GtkTreeView *tree_view;
975 GtkTreeViewColumn *tv_col;
979 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (table));
983 tree_view = GTK_TREE_VIEW (widget);
984 tv_col = gtk_tree_view_get_column (tree_view, i);
986 while (tv_col != NULL)
988 if (gtk_tree_view_column_get_visible (tv_col))
992 tv_col = gtk_tree_view_get_column (tree_view, i);
999 gtk_tree_view_accessible_is_row_selected (AtkTable *table,
1003 GtkTreeView *tree_view;
1004 GtkTreeSelection *selection;
1007 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (table));
1014 tree_view = GTK_TREE_VIEW (widget);
1015 selection = gtk_tree_view_get_selection (tree_view);
1017 set_iter_nth_row (tree_view, &iter, row);
1018 return gtk_tree_selection_iter_is_selected (selection, &iter);
1022 gtk_tree_view_accessible_is_selected (AtkTable *table,
1026 return gtk_tree_view_accessible_is_row_selected (table, row);
1030 get_selected_rows (GtkTreeModel *model,
1035 GPtrArray *array = (GPtrArray *)data;
1037 g_ptr_array_add (array, gtk_tree_path_copy (path));
1041 gtk_tree_view_accessible_get_selected_rows (AtkTable *table,
1042 gint **rows_selected)
1045 GtkTreeView *tree_view;
1046 GtkTreeModel *tree_model;
1048 GtkTreeSelection *selection;
1049 GtkTreePath *tree_path;
1052 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (table));
1056 tree_view = GTK_TREE_VIEW (widget);
1057 selection = gtk_tree_view_get_selection (tree_view);
1059 switch (gtk_tree_selection_get_mode (selection))
1061 case GTK_SELECTION_SINGLE:
1062 case GTK_SELECTION_BROWSE:
1063 if (gtk_tree_selection_get_selected (selection, &tree_model, &iter))
1069 *rows_selected = g_new (gint, 1);
1070 tree_path = gtk_tree_model_get_path (tree_model, &iter);
1071 row = get_row_from_tree_path (tree_view, tree_path);
1072 gtk_tree_path_free (tree_path);
1074 /* shouldn't ever happen */
1075 g_return_val_if_fail (row != -1, 0);
1077 *rows_selected[0] = row;
1082 case GTK_SELECTION_MULTIPLE:
1084 GPtrArray *array = g_ptr_array_new();
1086 gtk_tree_selection_selected_foreach (selection, get_selected_rows, array);
1087 ret_val = array->len;
1089 if (rows_selected && ret_val)
1093 *rows_selected = g_new (gint, ret_val);
1094 for (i = 0; i < ret_val; i++)
1098 tree_path = (GtkTreePath *) g_ptr_array_index (array, i);
1099 row = get_row_from_tree_path (tree_view, tree_path);
1100 gtk_tree_path_free (tree_path);
1101 (*rows_selected)[i] = row;
1104 g_ptr_array_free (array, FALSE);
1107 case GTK_SELECTION_NONE:
1114 gtk_tree_view_accessible_add_row_selection (AtkTable *table,
1118 GtkTreeView *tree_view;
1119 GtkTreeModel *tree_model;
1120 GtkTreeSelection *selection;
1121 GtkTreePath *tree_path;
1122 GtkTreeIter iter_to_row;
1124 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (table));
1128 if (!gtk_tree_view_accessible_is_row_selected (table, row))
1130 tree_view = GTK_TREE_VIEW (widget);
1131 tree_model = gtk_tree_view_get_model (tree_view);
1132 selection = gtk_tree_view_get_selection (tree_view);
1134 if (gtk_tree_model_get_flags (tree_model) & GTK_TREE_MODEL_LIST_ONLY)
1136 tree_path = gtk_tree_path_new ();
1137 gtk_tree_path_append_index (tree_path, row);
1138 gtk_tree_selection_select_path (selection,tree_path);
1139 gtk_tree_path_free (tree_path);
1143 set_iter_nth_row (tree_view, &iter_to_row, row);
1144 gtk_tree_selection_select_iter (selection, &iter_to_row);
1148 return gtk_tree_view_accessible_is_row_selected (table, row);
1152 gtk_tree_view_accessible_remove_row_selection (AtkTable *table,
1156 GtkTreeView *tree_view;
1157 GtkTreeSelection *selection;
1159 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (table));
1163 tree_view = GTK_TREE_VIEW (widget);
1164 selection = gtk_tree_view_get_selection (tree_view);
1166 if (gtk_tree_view_accessible_is_row_selected (table, row))
1168 gtk_tree_selection_unselect_all (selection);
1176 gtk_tree_view_accessible_get_column_header (AtkTable *table,
1180 GtkTreeView *tree_view;
1181 GtkTreeViewColumn *tv_col;
1183 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (table));
1187 tree_view = GTK_TREE_VIEW (widget);
1188 tv_col = get_column (tree_view, in_col);
1189 return get_header_from_column (tv_col);
1192 static const gchar *
1193 gtk_tree_view_accessible_get_column_description (AtkTable *table,
1197 GtkTreeView *tree_view;
1198 GtkTreeViewColumn *tv_col;
1200 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (table));
1204 tree_view = GTK_TREE_VIEW (widget);
1205 tv_col = get_column (tree_view, in_col);
1209 return gtk_tree_view_column_get_title (tv_col);
1213 atk_table_interface_init (AtkTableIface *iface)
1215 iface->ref_at = gtk_tree_view_accessible_table_ref_at;
1216 iface->get_n_rows = gtk_tree_view_accessible_get_n_rows;
1217 iface->get_n_columns = gtk_tree_view_accessible_get_n_columns;
1218 iface->get_index_at = gtk_tree_view_accessible_get_index_at;
1219 iface->get_column_at_index = gtk_tree_view_accessible_get_column_at_index;
1220 iface->get_row_at_index = gtk_tree_view_accessible_get_row_at_index;
1221 iface->is_row_selected = gtk_tree_view_accessible_is_row_selected;
1222 iface->is_selected = gtk_tree_view_accessible_is_selected;
1223 iface->get_selected_rows = gtk_tree_view_accessible_get_selected_rows;
1224 iface->add_row_selection = gtk_tree_view_accessible_add_row_selection;
1225 iface->remove_row_selection = gtk_tree_view_accessible_remove_row_selection;
1226 iface->get_column_extent_at = NULL;
1227 iface->get_row_extent_at = NULL;
1228 iface->get_column_header = gtk_tree_view_accessible_get_column_header;
1229 iface->get_column_description = gtk_tree_view_accessible_get_column_description;
1232 /* atkselection.h */
1235 gtk_tree_view_accessible_add_selection (AtkSelection *selection,
1242 table = ATK_TABLE (selection);
1243 n_columns = gtk_tree_view_accessible_get_n_columns (table);
1247 row = gtk_tree_view_accessible_get_row_at_index (table, i);
1248 return gtk_tree_view_accessible_add_row_selection (table, row);
1252 gtk_tree_view_accessible_clear_selection (AtkSelection *selection)
1255 GtkTreeView *tree_view;
1256 GtkTreeSelection *tree_selection;
1258 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (selection));
1262 tree_view = GTK_TREE_VIEW (widget);
1263 tree_selection = gtk_tree_view_get_selection (tree_view);
1265 gtk_tree_selection_unselect_all (tree_selection);
1270 gtk_tree_view_accessible_ref_selection (AtkSelection *selection,
1279 table = ATK_TABLE (selection);
1280 n_columns = gtk_tree_view_accessible_get_n_columns (table);
1281 n_selected = gtk_tree_view_accessible_get_selected_rows (table, &selected);
1282 if (i >= n_columns * n_selected)
1285 row = selected[i / n_columns];
1288 return gtk_tree_view_accessible_table_ref_at (table, row, i % n_columns);
1292 gtk_tree_view_accessible_get_selection_count (AtkSelection *selection)
1297 table = ATK_TABLE (selection);
1298 n_selected = gtk_tree_view_accessible_get_selected_rows (table, NULL);
1300 n_selected *= gtk_tree_view_accessible_get_n_columns (table);
1305 gtk_tree_view_accessible_is_child_selected (AtkSelection *selection,
1311 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (selection));
1315 row = atk_table_get_row_at_index (ATK_TABLE (selection), i);
1317 return gtk_tree_view_accessible_is_row_selected (ATK_TABLE (selection), row);
1320 static void atk_selection_interface_init (AtkSelectionIface *iface)
1322 iface->add_selection = gtk_tree_view_accessible_add_selection;
1323 iface->clear_selection = gtk_tree_view_accessible_clear_selection;
1324 iface->ref_selection = gtk_tree_view_accessible_ref_selection;
1325 iface->get_selection_count = gtk_tree_view_accessible_get_selection_count;
1326 iface->is_child_selected = gtk_tree_view_accessible_is_child_selected;
1329 #define EXTRA_EXPANDER_PADDING 4
1332 gtk_tree_view_accessible_get_cell_area (GtkCellAccessibleParent *parent,
1333 GtkCellAccessible *cell,
1334 GdkRectangle *cell_rect)
1337 GtkTreeView *tree_view;
1338 GtkTreeViewColumn *tv_col;
1340 AtkObject *parent_cell;
1341 GtkTreeViewAccessibleCellInfo *cell_info;
1342 GtkCellAccessible *top_cell;
1344 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (parent));
1348 tree_view = GTK_TREE_VIEW (widget);
1349 parent_cell = atk_object_get_parent (ATK_OBJECT (cell));
1350 if (parent_cell != ATK_OBJECT (parent))
1351 top_cell = GTK_CELL_ACCESSIBLE (parent_cell);
1354 cell_info = find_cell_info (GTK_TREE_VIEW_ACCESSIBLE (parent), top_cell, TRUE);
1357 path = cell_info_get_path (cell_info);
1358 tv_col = cell_info->cell_col_ref;
1361 GtkTreeViewColumn *expander_column;
1362 gint focus_line_width;
1364 gtk_tree_view_get_cell_area (tree_view, path, tv_col, cell_rect);
1365 expander_column = gtk_tree_view_get_expander_column (tree_view);
1366 if (expander_column == tv_col)
1369 gtk_widget_style_get (widget,
1370 "expander-size", &expander_size,
1372 cell_rect->x += expander_size + EXTRA_EXPANDER_PADDING;
1373 cell_rect->width -= expander_size + EXTRA_EXPANDER_PADDING;
1375 gtk_widget_style_get (widget,
1376 "focus-line-width", &focus_line_width,
1379 cell_rect->x += focus_line_width;
1380 cell_rect->width -= 2 * focus_line_width;
1382 gtk_tree_path_free (path);
1384 /* A column has more than one renderer so we find the position
1387 if (top_cell != cell)
1394 GtkCellRenderer *renderer;
1396 cell_index = atk_object_get_index_in_parent (ATK_OBJECT (cell));
1397 renderers = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (tv_col));
1398 renderer = g_list_nth_data (renderers, cell_index);
1400 found = gtk_tree_view_column_cell_get_position (tv_col, renderer, &cell_start, &cell_width);
1403 cell_rect->x += cell_start;
1404 cell_rect->width = cell_width;
1406 g_list_free (renderers);
1413 gtk_tree_view_accessible_get_cell_extents (GtkCellAccessibleParent *parent,
1414 GtkCellAccessible *cell,
1419 AtkCoordType coord_type)
1422 GtkTreeView *tree_view;
1423 GdkWindow *bin_window;
1424 GdkRectangle cell_rect;
1427 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (parent));
1431 tree_view = GTK_TREE_VIEW (widget);
1432 gtk_tree_view_accessible_get_cell_area (parent, cell, &cell_rect);
1433 bin_window = gtk_tree_view_get_bin_window (tree_view);
1434 gdk_window_get_origin (bin_window, &w_x, &w_y);
1436 if (coord_type == ATK_XY_WINDOW)
1439 gint x_toplevel, y_toplevel;
1441 window = gdk_window_get_toplevel (bin_window);
1442 gdk_window_get_origin (window, &x_toplevel, &y_toplevel);
1448 *width = cell_rect.width;
1449 *height = cell_rect.height;
1450 if (is_cell_showing (tree_view, &cell_rect))
1452 *x = cell_rect.x + w_x;
1453 *y = cell_rect.y + w_y;
1463 gtk_tree_view_accessible_grab_cell_focus (GtkCellAccessibleParent *parent,
1464 GtkCellAccessible *cell)
1467 GtkTreeView *tree_view;
1468 GtkTreeViewColumn *tv_col;
1470 AtkObject *parent_cell;
1471 AtkObject *cell_object;
1472 GtkTreeViewAccessibleCellInfo *cell_info;
1473 GtkCellRenderer *renderer = NULL;
1474 GtkWidget *toplevel;
1477 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (parent));
1481 tree_view = GTK_TREE_VIEW (widget);
1483 cell_info = find_cell_info (GTK_TREE_VIEW_ACCESSIBLE (parent), cell, TRUE);
1486 cell_object = ATK_OBJECT (cell);
1487 parent_cell = atk_object_get_parent (cell_object);
1488 tv_col = cell_info->cell_col_ref;
1489 if (parent_cell != ATK_OBJECT (parent))
1491 /* GtkCellAccessible is in a GtkContainerCellAccessible.
1492 * The GtkTreeViewColumn has multiple renderers;
1493 * find the corresponding one.
1497 renderers = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (tv_col));
1498 index = atk_object_get_index_in_parent (cell_object);
1499 renderer = g_list_nth_data (renderers, index);
1500 g_list_free (renderers);
1502 path = cell_info_get_path (cell_info);
1506 gtk_tree_view_set_cursor_on_cell (tree_view, path, tv_col, renderer, FALSE);
1508 gtk_tree_view_set_cursor (tree_view, path, tv_col, FALSE);
1510 gtk_tree_path_free (path);
1511 gtk_widget_grab_focus (widget);
1512 toplevel = gtk_widget_get_toplevel (widget);
1513 if (gtk_widget_is_toplevel (toplevel))
1515 #ifdef GDK_WINDOWING_X11
1516 gtk_window_present_with_time (GTK_WINDOW (toplevel),
1517 gdk_x11_get_server_time (gtk_widget_get_window (widget)));
1519 gtk_window_present (GTK_WINDOW (toplevel));
1530 gtk_tree_view_accessible_get_child_index (GtkCellAccessibleParent *parent,
1531 GtkCellAccessible *cell)
1533 GtkTreeViewAccessibleCellInfo *cell_info;
1534 GtkTreeView *tree_view;
1536 cell_info = find_cell_info (GTK_TREE_VIEW_ACCESSIBLE (parent), cell, TRUE);
1540 tree_view = GTK_TREE_VIEW (gtk_accessible_get_widget (GTK_ACCESSIBLE (parent)));
1542 return cell_info_get_index (tree_view, cell_info);
1546 gtk_cell_accessible_parent_interface_init (GtkCellAccessibleParentIface *iface)
1548 iface->get_cell_extents = gtk_tree_view_accessible_get_cell_extents;
1549 iface->get_cell_area = gtk_tree_view_accessible_get_cell_area;
1550 iface->grab_focus = gtk_tree_view_accessible_grab_cell_focus;
1551 iface->get_child_index = gtk_tree_view_accessible_get_child_index;
1554 /* signal handling */
1557 idle_expand_row (gpointer data)
1559 GtkTreeViewAccessible *accessible = data;
1561 GtkTreeView *tree_view;
1563 GtkTreeModel *tree_model;
1564 gint n_inserted, row;
1566 accessible->idle_expand_id = 0;
1568 path = accessible->idle_expand_path;
1569 tree_view = GTK_TREE_VIEW (gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible)));
1571 tree_model = gtk_tree_view_get_model (tree_view);
1575 if (!path || !gtk_tree_model_get_iter (tree_model, &iter, path))
1578 /* Update visibility of cells below expansion row */
1579 traverse_cells (accessible, path, FALSE);
1581 /* Figure out number of visible children, the following test
1584 if (gtk_tree_model_iter_has_child (tree_model, &iter))
1586 GtkTreePath *path_copy;
1588 /* By passing path into this function, we find the number of
1589 * visible children of path.
1591 path_copy = gtk_tree_path_copy (path);
1592 gtk_tree_path_append_index (path_copy, 0);
1595 iterate_thru_children (tree_view, tree_model,
1596 path_copy, NULL, &n_inserted, 0);
1597 gtk_tree_path_free (path_copy);
1601 /* We can get here if the row expanded callback deleted the row */
1605 /* Set expand state */
1606 set_expand_state (tree_view, tree_model, accessible, path, TRUE);
1608 row = get_row_from_tree_path (tree_view, path);
1610 /* shouldn't ever happen */
1612 g_assert_not_reached ();
1614 /* Must add 1 because the "added rows" are below the row being expanded */
1617 g_signal_emit_by_name (accessible, "row-inserted", row, n_inserted);
1619 accessible->idle_expand_path = NULL;
1621 gtk_tree_path_free (path);
1627 row_expanded_cb (GtkTreeView *tree_view,
1632 GtkTreeViewAccessible *accessible;
1634 atk_obj = gtk_widget_get_accessible (GTK_WIDGET (tree_view));
1635 accessible = GTK_TREE_VIEW_ACCESSIBLE (atk_obj);
1638 * The visible rectangle has not been updated when this signal is emitted
1639 * so we process the signal when the GTK processing is completed
1641 /* this seems wrong since it overwrites any other pending expand handlers... */
1642 accessible->idle_expand_path = gtk_tree_path_copy (path);
1643 if (accessible->idle_expand_id)
1644 g_source_remove (accessible->idle_expand_id);
1645 accessible->idle_expand_id = gdk_threads_add_idle (idle_expand_row, accessible);
1651 row_collapsed_cb (GtkTreeView *tree_view,
1655 GtkTreeModel *tree_model;
1657 GtkTreeViewAccessible *accessible;
1660 atk_obj = gtk_widget_get_accessible (GTK_WIDGET (tree_view));
1661 accessible = GTK_TREE_VIEW_ACCESSIBLE (atk_obj);
1662 tree_model = gtk_tree_view_get_model (tree_view);
1664 clean_rows (accessible);
1666 /* Update visibility of cells below collapsed row */
1667 traverse_cells (accessible, path, FALSE);
1669 /* Set collapse state */
1670 set_expand_state (tree_view, tree_model, accessible, path, FALSE);
1671 if (accessible->n_children_deleted == 0)
1673 row = get_row_from_tree_path (tree_view, path);
1676 g_signal_emit_by_name (atk_obj, "row-deleted", row,
1677 accessible->n_children_deleted);
1678 accessible->n_children_deleted = 0;
1683 size_allocate_cb (GtkWidget *widget,
1684 GtkAllocation *allocation)
1687 GtkTreeViewAccessible *accessible;
1689 atk_obj = gtk_widget_get_accessible (widget);
1690 accessible = GTK_TREE_VIEW_ACCESSIBLE (atk_obj);
1692 /* If the size allocation changes, the visibility of cells
1693 * may change so update the cells visibility.
1695 traverse_cells (accessible, NULL, FALSE);
1699 selection_changed_cb (GtkTreeSelection *selection,
1702 GtkTreeViewAccessible *accessible;
1703 GtkTreeView *tree_view;
1705 GtkTreeViewAccessibleCellInfo *info;
1706 GtkTreeSelection *tree_selection;
1708 GHashTableIter iter;
1710 accessible = GTK_TREE_VIEW_ACCESSIBLE (data);
1711 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible));
1715 tree_view = GTK_TREE_VIEW (widget);
1716 tree_selection = gtk_tree_view_get_selection (tree_view);
1718 clean_rows (accessible);
1720 /* FIXME: clean rows iterates through all cells too */
1721 g_hash_table_iter_init (&iter, accessible->cell_infos);
1722 while (g_hash_table_iter_next (&iter, NULL, (gpointer *)&info))
1724 _gtk_cell_accessible_remove_state (info->cell, ATK_STATE_SELECTED, TRUE);
1726 path = cell_info_get_path (info);
1727 if (path && gtk_tree_selection_path_is_selected (tree_selection, path))
1728 _gtk_cell_accessible_add_state (info->cell, ATK_STATE_SELECTED, TRUE);
1729 gtk_tree_path_free (path);
1731 if (gtk_widget_get_realized (widget))
1732 g_signal_emit_by_name (accessible, "selection-changed");
1736 columns_changed (GtkTreeView *tree_view)
1739 GtkTreeViewAccessible *accessible;
1740 GList *tv_cols, *tmp_list;
1741 gboolean column_found;
1742 gboolean move_found = FALSE;
1743 gint column_count = 0;
1746 atk_obj = gtk_widget_get_accessible (GTK_WIDGET(tree_view));
1747 accessible = GTK_TREE_VIEW_ACCESSIBLE (atk_obj);
1749 /* This function must determine if the change is an add, delete
1750 * or a move based upon its cache of TreeViewColumns in
1751 * accessible->col_data
1753 tv_cols = gtk_tree_view_get_columns (tree_view);
1754 accessible->n_cols = g_list_length (tv_cols);
1756 /* check for adds or moves */
1757 for (tmp_list = tv_cols; tmp_list; tmp_list = tmp_list->next)
1759 column_found = FALSE;
1761 for (i = 0; i < accessible->col_data->len; i++)
1764 if ((GtkTreeViewColumn *)tmp_list->data ==
1765 (GtkTreeViewColumn *)g_array_index (accessible->col_data,
1766 GtkTreeViewColumn *, i))
1768 column_found = TRUE;
1770 /* If the column isn't in the same position, a move happened */
1771 if (!move_found && i != column_count)
1773 /* Just emit one column reordered signal when a move happens */
1774 g_signal_emit_by_name (atk_obj, "column-reordered");
1782 /* If column_found is FALSE, then an insert happened for column
1783 * number column_count
1789 /* Generate column-inserted signal */
1790 g_signal_emit_by_name (atk_obj, "column-inserted", column_count, 1);
1792 /* Generate children-changed signals */
1793 for (row = 0; row < get_n_rows (tree_view); row++)
1795 /* Pass NULL as the child object, i.e. 4th argument */
1796 g_signal_emit_by_name (atk_obj, "children-changed::add",
1797 ((row * accessible->n_cols) + column_count), NULL, NULL);
1804 /* check for deletes */
1805 for (i = 0; i < accessible->col_data->len; i++)
1807 column_found = FALSE;
1809 for (tmp_list = tv_cols; tmp_list; tmp_list = tmp_list->next)
1811 if ((GtkTreeViewColumn *)tmp_list->data ==
1812 (GtkTreeViewColumn *)g_array_index (accessible->col_data,
1813 GtkTreeViewColumn *, i))
1815 column_found = TRUE;
1820 /* If column_found is FALSE, then a delete happened for column
1827 clean_cols (accessible,
1828 (GtkTreeViewColumn *)g_array_index (accessible->col_data,
1829 GtkTreeViewColumn *, i));
1831 /* Generate column-deleted signal */
1832 g_signal_emit_by_name (atk_obj, "column-deleted", i, 1);
1834 /* Generate children-changed signals */
1835 for (row = 0; row < get_n_rows (tree_view); row++)
1837 /* Pass NULL as the child object, 4th argument */
1838 g_signal_emit_by_name (atk_obj, "children-changed::remove",
1839 ((row * accessible->n_cols) + column_count), NULL, NULL);
1844 traverse_cells (accessible, NULL, FALSE);
1846 /* rebuild the array */
1847 g_array_free (accessible->col_data, TRUE);
1848 accessible->col_data = g_array_sized_new (FALSE, TRUE, sizeof (GtkTreeViewColumn *), 0);
1850 for (tmp_list = tv_cols; tmp_list; tmp_list = tmp_list->next)
1851 g_array_append_val (accessible->col_data, tmp_list->data);
1852 g_list_free (tv_cols);
1856 cursor_changed (GtkTreeView *tree_view,
1857 GtkTreeViewAccessible *accessible)
1861 cell = gtk_tree_view_accessible_ref_focus_cell (tree_view);
1864 if (cell != accessible->focus_cell)
1866 if (accessible->focus_cell)
1868 _gtk_cell_accessible_remove_state (GTK_CELL_ACCESSIBLE (accessible->focus_cell), ATK_STATE_ACTIVE, FALSE);
1869 _gtk_cell_accessible_remove_state (GTK_CELL_ACCESSIBLE (accessible->focus_cell), ATK_STATE_FOCUSED, FALSE);
1870 g_object_unref (accessible->focus_cell);
1871 accessible->focus_cell = cell;
1874 if (gtk_widget_has_focus (GTK_WIDGET (tree_view)))
1876 _gtk_cell_accessible_add_state (GTK_CELL_ACCESSIBLE (cell), ATK_STATE_ACTIVE, FALSE);
1877 _gtk_cell_accessible_add_state (GTK_CELL_ACCESSIBLE (cell), ATK_STATE_FOCUSED, FALSE);
1880 g_signal_emit_by_name (accessible, "active-descendant-changed", cell);
1883 g_object_unref (cell);
1888 focus_in (GtkWidget *widget)
1890 GtkTreeView *tree_view;
1891 GtkTreeViewAccessible *accessible;
1892 AtkStateSet *state_set;
1895 tree_view = GTK_TREE_VIEW (widget);
1896 accessible = GTK_TREE_VIEW_ACCESSIBLE (gtk_widget_get_accessible (widget));
1898 if (accessible->focus_cell == NULL)
1900 cell = gtk_tree_view_accessible_ref_focus_cell (tree_view);
1903 state_set = atk_object_ref_state_set (cell);
1906 if (!atk_state_set_contains_state (state_set, ATK_STATE_FOCUSED))
1908 _gtk_cell_accessible_add_state (GTK_CELL_ACCESSIBLE (cell), ATK_STATE_ACTIVE, FALSE);
1909 accessible->focus_cell = cell;
1910 _gtk_cell_accessible_add_state (GTK_CELL_ACCESSIBLE (cell), ATK_STATE_FOCUSED, FALSE);
1911 g_signal_emit_by_name (accessible, "active-descendant-changed", cell);
1913 g_object_unref (state_set);
1921 focus_out (GtkWidget *widget)
1923 GtkTreeViewAccessible *accessible;
1925 accessible = GTK_TREE_VIEW_ACCESSIBLE (gtk_widget_get_accessible (widget));
1926 if (accessible->focus_cell)
1928 _gtk_cell_accessible_remove_state (GTK_CELL_ACCESSIBLE (accessible->focus_cell), ATK_STATE_ACTIVE, FALSE);
1929 _gtk_cell_accessible_remove_state (GTK_CELL_ACCESSIBLE (accessible->focus_cell), ATK_STATE_FOCUSED, FALSE);
1930 g_object_unref (accessible->focus_cell);
1931 accessible->focus_cell = NULL;
1937 model_row_changed (GtkTreeModel *tree_model,
1942 GtkTreeView *tree_view = GTK_TREE_VIEW (user_data);
1943 GtkTreeViewAccessible *accessible;
1944 GtkTreePath *cell_path;
1945 GtkTreeViewAccessibleCellInfo *cell_info;
1946 GHashTableIter hash_iter;
1948 accessible = GTK_TREE_VIEW_ACCESSIBLE (gtk_widget_get_accessible (GTK_WIDGET (tree_view)));
1950 /* Loop through our cached cells */
1951 /* Must loop through them all */
1952 g_hash_table_iter_init (&hash_iter, accessible->cell_infos);
1953 while (g_hash_table_iter_next (&hash_iter, NULL, (gpointer *)&cell_info))
1955 cell_path = cell_info_get_path (cell_info);
1957 if (cell_path != NULL)
1959 if (path && gtk_tree_path_compare (cell_path, path) == 0)
1961 if (GTK_IS_RENDERER_CELL_ACCESSIBLE (cell_info->cell))
1962 update_cell_value (GTK_RENDERER_CELL_ACCESSIBLE (cell_info->cell),
1965 gtk_tree_path_free (cell_path);
1968 g_signal_emit_by_name (accessible, "visible-data-changed");
1972 column_visibility_changed (GObject *object,
1976 if (g_strcmp0 (pspec->name, "visible") == 0)
1978 /* A column has been made visible or invisible
1979 * We update our cache of cells and emit model_changed signal
1981 GtkTreeView *tree_view = (GtkTreeView *)user_data;
1982 GtkTreeViewAccessible *accessible;
1983 GtkTreeViewAccessibleCellInfo *cell_info;
1984 GtkTreeViewColumn *this_col = GTK_TREE_VIEW_COLUMN (object);
1985 GtkTreeViewColumn *tv_col;
1986 GHashTableIter iter;
1988 accessible = GTK_TREE_VIEW_ACCESSIBLE (gtk_widget_get_accessible (GTK_WIDGET (tree_view))
1990 g_signal_emit_by_name (accessible, "model-changed");
1992 g_hash_table_iter_init (&iter, accessible->cell_infos);
1993 while (g_hash_table_iter_next (&iter, NULL, (gpointer *)&cell_info))
1995 tv_col = cell_info->cell_col_ref;
1996 if (tv_col == this_col)
1998 GtkTreePath *row_path;
1999 row_path = cell_info_get_path (cell_info);
2000 if (GTK_IS_RENDERER_CELL_ACCESSIBLE (cell_info->cell))
2002 if (gtk_tree_view_column_get_visible (tv_col))
2003 set_cell_visibility (tree_view,
2005 tv_col, row_path, FALSE);
2008 _gtk_cell_accessible_remove_state (cell_info->cell, ATK_STATE_VISIBLE, TRUE);
2009 _gtk_cell_accessible_remove_state (cell_info->cell, ATK_STATE_SHOWING, TRUE);
2012 gtk_tree_path_free (row_path);
2019 model_row_inserted (GtkTreeModel *tree_model,
2024 GtkTreeView *tree_view = (GtkTreeView *)user_data;
2026 GtkTreeViewAccessible *accessible;
2027 GtkTreePath *path_copy;
2028 gint row, n_inserted, child_row;
2030 atk_obj = gtk_widget_get_accessible (GTK_WIDGET (tree_view));
2031 accessible = GTK_TREE_VIEW_ACCESSIBLE (atk_obj);
2033 if (accessible->idle_expand_id)
2035 g_source_remove (accessible->idle_expand_id);
2036 accessible->idle_expand_id = 0;
2038 /* don't do this if the insertion precedes the idle path,
2039 * since it will now be invalid
2041 if (path && accessible->idle_expand_path &&
2042 (gtk_tree_path_compare (path, accessible->idle_expand_path) > 0))
2043 set_expand_state (tree_view, tree_model, accessible, accessible->idle_expand_path, FALSE);
2044 if (accessible->idle_expand_path)
2045 gtk_tree_path_free (accessible->idle_expand_path);
2047 /* Check to see if row is visible */
2048 row = get_row_from_tree_path (tree_view, path);
2050 /* A row insert is not necessarily visible. For example,
2051 * a row can be draged & dropped into another row, which
2052 * causes an insert on the model that isn't visible in the
2053 * view. Only generate a signal if the inserted row is
2058 GtkTreeIter tmp_iter;
2061 gtk_tree_model_get_iter (tree_model, &tmp_iter, path);
2063 /* Figure out number of visible children. */
2064 if (gtk_tree_model_iter_has_child (tree_model, &tmp_iter))
2068 * By passing path into this function, we find the number of
2069 * visible children of path.
2072 /* iterate_thru_children modifies path, we don't want that, so give
2074 path2 = gtk_tree_path_copy (path);
2075 iterate_thru_children (tree_view, tree_model,
2076 path2, NULL, &n_inserted, 0);
2077 gtk_tree_path_free (path2);
2079 /* Must add one to include the row that is being added */
2085 traverse_cells (accessible, path, TRUE);
2087 /* Generate row-inserted signal */
2088 g_signal_emit_by_name (atk_obj, "row-inserted", row, n_inserted);
2090 /* Generate children-changed signals */
2091 n_cols = gtk_tree_view_accessible_get_n_columns (ATK_TABLE (atk_obj));
2092 for (child_row = row; child_row < (row + n_inserted); child_row++)
2094 for (col = 0; col < n_cols; col++)
2096 /* Pass NULL as the child object, i.e. 4th argument */
2097 g_signal_emit_by_name (atk_obj, "children-changed::add",
2098 ((row * n_cols) + col), NULL, NULL);
2104 /* The row has been inserted inside another row. This can
2105 * cause a row that previously couldn't be expanded to now
2108 path_copy = gtk_tree_path_copy (path);
2109 gtk_tree_path_up (path_copy);
2110 set_expand_state (tree_view, tree_model, accessible, path_copy, TRUE);
2111 gtk_tree_path_free (path_copy);
2116 model_row_deleted (GtkTreeModel *tree_model,
2120 GtkTreeView *tree_view = (GtkTreeView *)user_data;
2121 GtkTreePath *path_copy;
2123 GtkTreeViewAccessible *accessible;
2126 atk_obj = gtk_widget_get_accessible (GTK_WIDGET (tree_view));
2127 accessible = GTK_TREE_VIEW_ACCESSIBLE (atk_obj);
2129 if (accessible->idle_expand_id)
2131 g_source_remove (accessible->idle_expand_id);
2132 gtk_tree_path_free (accessible->idle_expand_path);
2133 accessible->idle_expand_id = 0;
2136 /* Check to see if row is visible */
2137 clean_rows (accessible);
2139 traverse_cells (accessible, path, TRUE);
2141 /* If deleting a row with a depth > 1, then this may affect the
2142 * expansion/contraction of its parent(s). Make sure this is
2145 if (gtk_tree_path_get_depth (path) > 1)
2147 path_copy = gtk_tree_path_copy (path);
2148 gtk_tree_path_up (path_copy);
2149 set_expand_state (tree_view, tree_model, accessible, path_copy, TRUE);
2150 gtk_tree_path_free (path_copy);
2152 row = get_row_from_tree_path (tree_view, path);
2154 /* If the row which is deleted is not visible because it is a child of
2155 * a collapsed row then row will be -1
2158 g_signal_emit_by_name (atk_obj, "row-deleted", row,
2159 accessible->n_children_deleted + 1);
2160 accessible->n_children_deleted = 0;
2162 /* Generate children-changed signals */
2163 for (col = 0; col < accessible->n_cols; col++)
2165 /* Pass NULL as the child object, 4th argument */
2166 g_signal_emit_by_name (atk_obj, "children-changed::remove",
2167 ((row * accessible->n_cols) + col), NULL, NULL);
2171 /* This function gets called when a row is deleted or when rows are
2172 * removed from the view due to a collapse event. Note that the
2173 * count is the number of visible *children* of the deleted row,
2174 * so it does not include the row being deleted.
2176 * As this function is called before the rows are removed we just note
2177 * the number of rows and then deal with it when we get a notification
2178 * that rows were deleted or collapsed.
2181 destroy_count_func (GtkTreeView *tree_view,
2187 GtkTreeViewAccessible *accessible;
2189 atk_obj = gtk_widget_get_accessible (GTK_WIDGET (tree_view));
2190 accessible = GTK_TREE_VIEW_ACCESSIBLE (atk_obj);
2192 if (accessible->n_children_deleted != 0)
2195 accessible->n_children_deleted = count;
2199 model_rows_reordered (GtkTreeModel *tree_model,
2205 GtkTreeView *tree_view = (GtkTreeView *)user_data;
2207 GtkTreeViewAccessible *accessible;
2209 atk_obj = gtk_widget_get_accessible (GTK_WIDGET (tree_view));
2210 accessible = GTK_TREE_VIEW_ACCESSIBLE (atk_obj);
2212 if (accessible->idle_expand_id)
2214 g_source_remove (accessible->idle_expand_id);
2215 gtk_tree_path_free (accessible->idle_expand_path);
2216 accessible->idle_expand_id = 0;
2218 traverse_cells (accessible, NULL, FALSE);
2220 g_signal_emit_by_name (atk_obj, "row-reordered");
2224 set_cell_visibility (GtkTreeView *tree_view,
2225 GtkCellAccessible *cell,
2226 GtkTreeViewColumn *tv_col,
2227 GtkTreePath *tree_path,
2228 gboolean emit_signal)
2230 GdkRectangle cell_rect;
2232 /* Get these three values in tree coords */
2233 if (gtk_widget_get_realized (GTK_WIDGET (tree_view)))
2234 gtk_tree_view_get_cell_area (tree_view, tree_path, tv_col, &cell_rect);
2236 cell_rect.height = 0;
2238 if (cell_rect.height > 0)
2240 /* The height will be zero for a cell for which an antecedent
2243 _gtk_cell_accessible_add_state (cell, ATK_STATE_VISIBLE, emit_signal);
2244 if (is_cell_showing (tree_view, &cell_rect))
2245 _gtk_cell_accessible_add_state (cell, ATK_STATE_SHOWING, emit_signal);
2247 _gtk_cell_accessible_remove_state (cell, ATK_STATE_SHOWING, emit_signal);
2251 _gtk_cell_accessible_remove_state (cell, ATK_STATE_VISIBLE, emit_signal);
2252 _gtk_cell_accessible_remove_state (cell, ATK_STATE_SHOWING, emit_signal);
2257 is_cell_showing (GtkTreeView *tree_view,
2258 GdkRectangle *cell_rect)
2260 GdkRectangle rect, *visible_rect;
2261 GdkRectangle rect1, *tree_cell_rect;
2263 gboolean is_showing;
2265 /* A cell is considered "SHOWING" if any part of the cell is
2266 * in the visible area. Other ways we could do this is by a
2267 * cell's midpoint or if the cell is fully in the visible range.
2268 * Since we have the cell_rect x, y, width, height of the cell,
2269 * any of these is easy to compute.
2271 * It is assumed that cell's rectangle is in widget coordinates
2272 * so we must transform to tree cordinates.
2274 visible_rect = ▭
2275 tree_cell_rect = &rect1;
2276 tree_cell_rect->x = cell_rect->x;
2277 tree_cell_rect->y = cell_rect->y;
2278 tree_cell_rect->width = cell_rect->width;
2279 tree_cell_rect->height = cell_rect->height;
2281 gtk_tree_view_get_visible_rect (tree_view, visible_rect);
2282 gtk_tree_view_convert_tree_to_bin_window_coords (tree_view, visible_rect->x,
2283 visible_rect->y, &bx, &by);
2285 if (((tree_cell_rect->x + tree_cell_rect->width) < bx) ||
2286 ((tree_cell_rect->y + tree_cell_rect->height) < by) ||
2287 (tree_cell_rect->x > (bx + visible_rect->width)) ||
2288 (tree_cell_rect->y > (by + visible_rect->height)))
2298 /* This function is called when a cell's flyweight is created in
2299 * gtk_tree_view_accessible_table_ref_at with emit_change_signal
2300 * set to FALSE and in model_row_changed() on receipt of "row-changed"
2301 * signal when emit_change_signal is set to TRUE
2304 update_cell_value (GtkRendererCellAccessible *renderer_cell,
2305 GtkTreeViewAccessible *accessible,
2306 gboolean emit_change_signal)
2308 GtkTreeViewAccessibleCellInfo *cell_info;
2309 GtkTreeView *tree_view;
2310 GtkTreeModel *tree_model;
2313 GList *renderers, *cur_renderer;
2315 GtkRendererCellAccessibleClass *renderer_cell_class;
2316 GtkCellRendererClass *gtk_cell_renderer_class;
2317 GtkCellAccessible *cell;
2320 gboolean is_expander, is_expanded;
2322 renderer_cell_class = GTK_RENDERER_CELL_ACCESSIBLE_GET_CLASS (renderer_cell);
2323 if (renderer_cell->renderer)
2324 gtk_cell_renderer_class = GTK_CELL_RENDERER_GET_CLASS (renderer_cell->renderer);
2326 gtk_cell_renderer_class = NULL;
2328 prop_list = renderer_cell_class->property_list;
2330 cell = GTK_CELL_ACCESSIBLE (renderer_cell);
2331 cell_info = find_cell_info (accessible, cell, TRUE);
2335 if (emit_change_signal)
2337 tree_view = GTK_TREE_VIEW (gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible)));
2338 tree_model = gtk_tree_view_get_model (tree_view);
2339 path = cell_info_get_path (cell_info);
2343 gtk_tree_model_get_iter (tree_model, &iter, path);
2344 is_expander = FALSE;
2345 is_expanded = FALSE;
2346 if (gtk_tree_model_iter_has_child (tree_model, &iter))
2348 GtkTreeViewColumn *expander_tv;
2350 expander_tv = gtk_tree_view_get_expander_column (tree_view);
2351 if (expander_tv == cell_info->cell_col_ref)
2354 is_expanded = gtk_tree_view_row_expanded (tree_view, path);
2357 gtk_tree_path_free (path);
2358 gtk_tree_view_column_cell_set_cell_data (cell_info->cell_col_ref,
2360 is_expander, is_expanded);
2362 renderers = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (cell_info->cell_col_ref));
2366 /* If the cell is in a container, its index is used to find the renderer
2367 * in the list. Otherwise, we assume that the cell is represented
2368 * by the first renderer in the list
2370 parent = atk_object_get_parent (ATK_OBJECT (cell));
2372 if (GTK_IS_CONTAINER_CELL_ACCESSIBLE (parent))
2373 cur_renderer = g_list_nth (renderers, atk_object_get_index_in_parent (ATK_OBJECT (cell)));
2375 cur_renderer = renderers;
2377 if (cur_renderer == NULL)
2380 if (gtk_cell_renderer_class)
2384 spec = g_object_class_find_property
2385 (G_OBJECT_CLASS (gtk_cell_renderer_class), *prop_list);
2389 GValue value = G_VALUE_INIT;
2391 g_value_init (&value, spec->value_type);
2392 g_object_get_property (cur_renderer->data, *prop_list, &value);
2393 g_object_set_property (G_OBJECT (renderer_cell->renderer),
2394 *prop_list, &value);
2395 g_value_unset (&value);
2398 g_warning ("Invalid property: %s\n", *prop_list);
2402 g_list_free (renderers);
2404 return _gtk_renderer_cell_accessible_update_cache (renderer_cell, emit_change_signal);
2408 get_row_from_tree_path (GtkTreeView *tree_view,
2411 GtkTreeModel *tree_model;
2412 GtkTreePath *root_tree;
2415 tree_model = gtk_tree_view_get_model (tree_view);
2417 if (gtk_tree_model_get_flags (tree_model) & GTK_TREE_MODEL_LIST_ONLY)
2418 row = gtk_tree_path_get_indices (path)[0];
2421 root_tree = gtk_tree_path_new_first ();
2423 iterate_thru_children (tree_view, tree_model, root_tree, path, &row, 0);
2424 gtk_tree_path_free (root_tree);
2433 * Get the specified GtkTreeViewColumn in the GtkTreeView.
2434 * Only visible columns are considered.
2436 static GtkTreeViewColumn *
2437 get_column (GtkTreeView *tree_view,
2440 GtkTreeViewColumn *tv_col;
2446 g_warning ("Request for invalid column %d\n", in_col);
2450 tv_col = gtk_tree_view_get_column (tree_view, i);
2451 while (tv_col != NULL)
2453 if (gtk_tree_view_column_get_visible (tv_col))
2455 if (in_col == n_cols)
2457 tv_col = gtk_tree_view_get_column (tree_view, ++i);
2460 if (in_col != n_cols)
2462 g_warning ("Request for invalid column %d\n", in_col);
2469 get_visible_column_number (GtkTreeView *tree_view,
2472 GtkTreeViewColumn *tv_col;
2474 gint visible_columns = -1;
2476 /* This function calculates the visible column number
2477 * which corresponds to the specified actual column number
2479 tv_col = gtk_tree_view_get_column (tree_view, column);
2481 while (tv_col != NULL)
2483 if (gtk_tree_view_column_get_visible (tv_col))
2486 if (actual_column == column)
2487 return visible_columns;
2490 if (actual_column == column)
2492 tv_col = gtk_tree_view_get_column (tree_view, ++column);
2494 g_warning ("get_visible_column_number failed for %d\n", actual_column);
2498 /* Helper recursive function that returns an iter to nth row
2500 static GtkTreeIter *
2501 return_iter_nth_row (GtkTreeView *tree_view,
2502 GtkTreeModel *tree_model,
2507 GtkTreePath *current_path;
2508 GtkTreeIter new_iter;
2509 gboolean row_expanded;
2511 current_path = gtk_tree_model_get_path (tree_model, iter);
2512 if (increment == row)
2514 gtk_tree_path_free (current_path);
2518 row_expanded = gtk_tree_view_row_expanded (tree_view, current_path);
2519 gtk_tree_path_free (current_path);
2522 if ((row_expanded && gtk_tree_model_iter_children (tree_model, iter, &new_iter)) ||
2523 (gtk_tree_model_iter_next (tree_model, iter)) ||
2524 (gtk_tree_model_iter_parent (tree_model, iter, &new_iter) &&
2525 (gtk_tree_model_iter_next (tree_model, iter))))
2526 return return_iter_nth_row (tree_view, tree_model, iter,
2533 set_iter_nth_row (GtkTreeView *tree_view,
2537 GtkTreeModel *tree_model;
2539 tree_model = gtk_tree_view_get_model (tree_view);
2540 gtk_tree_model_get_iter_first (tree_model, iter);
2541 iter = return_iter_nth_row (tree_view, tree_model, iter, 0, row);
2544 /* Recursively called until the row specified by orig is found.
2546 * *count will be set to the visible row number of the child
2547 * relative to the row that was initially passed in as tree_path.
2548 * tree_path could be modified by this function.
2550 * *count will be -1 if orig is not found as a child (a row that is
2551 * not visible will not be found, e.g. if the row is inside a
2552 * collapsed row). If NULL is passed in as orig, *count will
2553 * be a count of the visible children.
2555 * NOTE: the value for depth must be 0 when this recursive function
2556 * is initially called, or it may not function as expected.
2559 iterate_thru_children (GtkTreeView *tree_view,
2560 GtkTreeModel *tree_model,
2561 GtkTreePath *tree_path,
2568 if (!gtk_tree_model_get_iter (tree_model, &iter, tree_path))
2571 if (tree_path && orig && !gtk_tree_path_compare (tree_path, orig))
2575 if (tree_path && orig && gtk_tree_path_compare (tree_path, orig) > 0)
2577 /* Past it, so return -1 */
2581 else if (gtk_tree_view_row_expanded (tree_view, tree_path) &&
2582 gtk_tree_model_iter_has_child (tree_model, &iter))
2585 gtk_tree_path_append_index (tree_path, 0);
2586 iterate_thru_children (tree_view, tree_model, tree_path,
2587 orig, count, (depth + 1));
2590 else if (gtk_tree_model_iter_next (tree_model, &iter))
2593 tree_path = gtk_tree_model_get_path (tree_model, &iter);
2596 iterate_thru_children (tree_view, tree_model, tree_path,
2597 orig, count, depth);
2598 gtk_tree_path_free (tree_path);
2602 else if (gtk_tree_path_up (tree_path))
2604 GtkTreeIter temp_iter;
2605 gboolean exit_loop = FALSE;
2606 gint new_depth = depth - 1;
2610 /* Make sure that we back up until we find a row
2611 * where gtk_tree_path_next does not return NULL.
2615 if (gtk_tree_path_get_depth (tree_path) == 0)
2616 /* depth is now zero so */
2618 gtk_tree_path_next (tree_path);
2620 /* Verify that the next row is a valid row! */
2621 exit_loop = gtk_tree_model_get_iter (tree_model, &temp_iter, tree_path);
2625 /* Keep going up until we find a row that has a valid next */
2626 if (gtk_tree_path_get_depth(tree_path) > 1)
2629 gtk_tree_path_up (tree_path);
2633 /* If depth is 1 and gtk_tree_model_get_iter returns FALSE,
2634 * then we are at the last row, so just return.
2644 /* This guarantees that we will stop when we hit the end of the
2650 iterate_thru_children (tree_view, tree_model, tree_path,
2651 orig, count, new_depth);
2655 /* If it gets here, then the path wasn't found. Situations
2656 * that would cause this would be if the path passed in is
2657 * invalid or contained within the last row, but not visible
2658 * because the last row is not expanded. If NULL was passed
2659 * in then a row count is desired, so only set count to -1
2660 * if orig is not NULL.
2669 clean_rows (GtkTreeViewAccessible *accessible)
2671 GtkTreeViewAccessibleCellInfo *cell_info;
2672 GHashTableIter iter;
2674 /* Clean GtkTreeViewAccessibleCellInfo data */
2675 g_hash_table_iter_init (&iter, accessible->cell_infos);
2676 while (g_hash_table_iter_next (&iter, NULL, (gpointer *)&cell_info))
2678 GtkTreePath *row_path;
2680 row_path = cell_info_get_path (cell_info);
2682 /* If the cell has become invalid because the row has been removed,
2683 * then set the cell's state to ATK_STATE_DEFUNCT and schedule
2684 * its removal. If row_path is NULL then the row has
2687 if (row_path == NULL)
2688 g_hash_table_iter_remove (&iter);
2690 gtk_tree_path_free (row_path);
2695 clean_cols (GtkTreeViewAccessible *accessible,
2696 GtkTreeViewColumn *tv_col)
2698 GtkTreeViewAccessibleCellInfo *cell_info;
2699 GHashTableIter iter;
2701 /* Clean GtkTreeViewAccessibleCellInfo data */
2702 g_hash_table_iter_init (&iter, accessible->cell_infos);
2703 while (g_hash_table_iter_next (&iter, NULL, (gpointer *) &cell_info))
2705 /* If the cell has become invalid because the column tv_col
2706 * has been removed, then set the cell's state to ATK_STATE_DEFUNCT
2707 * and remove the cell from accessible->cell_data.
2709 if (cell_info->cell_col_ref == tv_col)
2710 g_hash_table_iter_remove (&iter);
2714 /* If tree_path is passed in as NULL, then all cells are acted on.
2715 * Otherwise, just act on those cells that are on a row greater than
2716 * the specified tree_path. If inc_row is passed in as TRUE, then rows
2717 * greater and equal to the specified tree_path are acted on.
2719 * The function set_cell_visibility() is called on all cells to be
2720 * acted on to update the visibility of the cell.
2723 traverse_cells (GtkTreeViewAccessible *accessible,
2724 GtkTreePath *tree_path,
2727 GtkTreeViewAccessibleCellInfo *cell_info;
2729 GHashTableIter iter;
2731 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible));
2735 /* Must loop through them all */
2736 g_hash_table_iter_init (&iter, accessible->cell_infos);
2737 while (g_hash_table_iter_next (&iter, NULL, (gpointer *)&cell_info))
2739 GtkTreePath *row_path;
2740 gboolean act_on_cell;
2742 row_path = cell_info_get_path (cell_info);
2743 g_return_if_fail (row_path != NULL);
2744 if (tree_path == NULL)
2750 comparison = gtk_tree_path_compare (row_path, tree_path);
2751 if ((comparison > 0) ||
2752 (comparison == 0 && inc_row))
2755 act_on_cell = FALSE;
2760 set_cell_visibility (GTK_TREE_VIEW (widget),
2762 cell_info->cell_col_ref,
2765 gtk_tree_path_free (row_path);
2768 g_signal_emit_by_name (accessible, "visible-data-changed");
2771 /* If the tree_path passed in has children, then
2772 * ATK_STATE_EXPANDABLE is set. If the row is expanded
2773 * ATK_STATE_EXPANDED is turned on. If the row is
2774 * collapsed, then ATK_STATE_EXPANDED is removed.
2776 * If the tree_path passed in has no children, then
2777 * ATK_STATE_EXPANDABLE and ATK_STATE_EXPANDED are removed.
2779 * If set_on_ancestor is TRUE, then this function will also
2780 * update all cells that are ancestors of the tree_path.
2783 set_expand_state (GtkTreeView *tree_view,
2784 GtkTreeModel *tree_model,
2785 GtkTreeViewAccessible *accessible,
2786 GtkTreePath *tree_path,
2787 gboolean set_on_ancestor)
2789 GtkTreeViewColumn *expander_tv;
2790 GtkTreeViewAccessibleCellInfo *cell_info;
2791 GtkTreePath *cell_path;
2794 GHashTableIter hash_iter;
2796 g_hash_table_iter_init (&hash_iter, accessible->cell_infos);
2797 while (g_hash_table_iter_next (&hash_iter, NULL, (gpointer *) &cell_info))
2799 cell_path = cell_info_get_path (cell_info);
2802 if (cell_path != NULL)
2804 GtkCellAccessible *cell = GTK_CELL_ACCESSIBLE (cell_info->cell);
2806 expander_tv = gtk_tree_view_get_expander_column (tree_view);
2808 /* Only set state for the cell that is in the column with the
2811 if (expander_tv == cell_info->cell_col_ref)
2813 if (tree_path && gtk_tree_path_compare (cell_path, tree_path) == 0)
2815 else if (set_on_ancestor &&
2816 gtk_tree_path_get_depth (cell_path) <
2817 gtk_tree_path_get_depth (tree_path) &&
2818 gtk_tree_path_is_ancestor (cell_path, tree_path) == 1)
2819 /* Only set if set_on_ancestor was passed in as TRUE */
2823 /* Set ATK_STATE_EXPANDABLE and ATK_STATE_EXPANDED
2824 * for ancestors and found cells.
2828 /* Must check against cell_path since cell_path
2829 * can be equal to or an ancestor of tree_path.
2831 gtk_tree_model_get_iter (tree_model, &iter, cell_path);
2833 /* Set or unset ATK_STATE_EXPANDABLE as appropriate */
2834 if (gtk_tree_model_iter_has_child (tree_model, &iter))
2836 set_cell_expandable (cell);
2838 if (gtk_tree_view_row_expanded (tree_view, cell_path))
2839 _gtk_cell_accessible_add_state (cell, ATK_STATE_EXPANDED, TRUE);
2841 _gtk_cell_accessible_remove_state (cell, ATK_STATE_EXPANDED, TRUE);
2845 _gtk_cell_accessible_remove_state (cell, ATK_STATE_EXPANDED, TRUE);
2846 if (_gtk_cell_accessible_remove_state (cell, ATK_STATE_EXPANDABLE, TRUE))
2847 /* The state may have been propagated to the container cell */
2848 if (!GTK_IS_CONTAINER_CELL_ACCESSIBLE (cell))
2849 _gtk_cell_accessible_remove_action_by_name (cell,
2850 "expand or contract");
2853 /* We assume that each cell in the cache once and
2854 * a container cell is before its child cells so we are
2855 * finished if set_on_ancestor is not set to TRUE.
2857 if (!set_on_ancestor)
2861 gtk_tree_path_free (cell_path);
2866 add_cell_actions (GtkCellAccessible *cell,
2869 if (GTK_IS_BOOLEAN_CELL_ACCESSIBLE (cell))
2870 _gtk_cell_accessible_add_action (cell,
2871 "toggle", "toggles the cell",
2872 NULL, toggle_cell_toggled);
2874 _gtk_cell_accessible_add_action (cell,
2875 "edit", "creates a widget in which the contents of the cell can be edited",
2877 _gtk_cell_accessible_add_action (cell,
2878 "activate", "activate the cell",
2879 NULL, activate_cell);
2883 toggle_cell_expanded (GtkCellAccessible *cell)
2885 GtkTreeViewAccessibleCellInfo *cell_info;
2886 GtkTreeView *tree_view;
2889 AtkStateSet *stateset;
2891 parent = atk_object_get_parent (ATK_OBJECT (cell));
2892 if (GTK_IS_CONTAINER_CELL_ACCESSIBLE (parent))
2893 parent = atk_object_get_parent (parent);
2895 cell_info = find_cell_info (GTK_TREE_VIEW_ACCESSIBLE (parent), cell, TRUE);
2899 tree_view = GTK_TREE_VIEW (gtk_accessible_get_widget (GTK_ACCESSIBLE (parent)));
2900 path = cell_info_get_path (cell_info);
2904 stateset = atk_object_ref_state_set (ATK_OBJECT (cell));
2905 if (atk_state_set_contains_state (stateset, ATK_STATE_EXPANDED))
2906 gtk_tree_view_collapse_row (tree_view, path);
2908 gtk_tree_view_expand_row (tree_view, path, TRUE);
2909 g_object_unref (stateset);
2910 gtk_tree_path_free (path);
2914 toggle_cell_toggled (GtkCellAccessible *cell)
2916 GtkTreeViewAccessibleCellInfo *cell_info;
2919 GList *renderers, *cur_renderer;
2921 gboolean is_container_cell = FALSE;
2923 parent = atk_object_get_parent (ATK_OBJECT (cell));
2924 if (GTK_IS_CONTAINER_CELL_ACCESSIBLE (parent))
2926 is_container_cell = TRUE;
2927 parent = atk_object_get_parent (parent);
2930 cell_info = find_cell_info (GTK_TREE_VIEW_ACCESSIBLE (parent), cell, TRUE);
2934 path = cell_info_get_path (cell_info);
2938 /* If the cell is in a container, its index is used to find the
2939 * renderer in the list. Otherwise, we assume that the cell is
2940 * represented by the first renderer in the list
2942 renderers = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (cell_info->cell_col_ref));
2943 if (is_container_cell)
2944 cur_renderer = g_list_nth (renderers, atk_object_get_index_in_parent (ATK_OBJECT (cell)));
2946 cur_renderer = renderers;
2950 pathstring = gtk_tree_path_to_string (path);
2951 g_signal_emit_by_name (cur_renderer->data, "toggled", pathstring);
2952 g_free (pathstring);
2955 g_list_free (renderers);
2956 gtk_tree_path_free (path);
2960 edit_cell (GtkCellAccessible *cell)
2962 GtkTreeViewAccessibleCellInfo *cell_info;
2963 GtkTreeView *tree_view;
2967 parent = atk_object_get_parent (ATK_OBJECT (cell));
2968 if (GTK_IS_CONTAINER_CELL_ACCESSIBLE (parent))
2969 parent = atk_object_get_parent (parent);
2971 cell_info = find_cell_info (GTK_TREE_VIEW_ACCESSIBLE (parent), cell, TRUE);
2975 tree_view = GTK_TREE_VIEW (gtk_accessible_get_widget (GTK_ACCESSIBLE (parent)));
2976 path = cell_info_get_path (cell_info);
2979 gtk_tree_view_set_cursor (tree_view, path, cell_info->cell_col_ref, TRUE);
2980 gtk_tree_path_free (path);
2984 activate_cell (GtkCellAccessible *cell)
2986 GtkTreeViewAccessibleCellInfo *cell_info;
2987 GtkTreeView *tree_view;
2991 parent = atk_object_get_parent (ATK_OBJECT (cell));
2992 if (GTK_IS_CONTAINER_CELL_ACCESSIBLE (parent))
2993 parent = atk_object_get_parent (parent);
2995 cell_info = find_cell_info (GTK_TREE_VIEW_ACCESSIBLE (parent), cell, TRUE);
2999 tree_view = GTK_TREE_VIEW (gtk_accessible_get_widget (GTK_ACCESSIBLE (parent)));
3000 path = cell_info_get_path (cell_info);
3003 gtk_tree_view_row_activated (tree_view, path, cell_info->cell_col_ref);
3004 gtk_tree_path_free (path);
3008 cell_destroyed (gpointer data)
3010 GtkTreeViewAccessibleCellInfo *cell_info = data;
3012 cell_info->cell = NULL;
3014 g_hash_table_remove (cell_info->view->cell_infos, cell_info);
3018 cell_info_get_index (GtkTreeView *tree_view,
3019 GtkTreeViewAccessibleCellInfo *info)
3025 path = cell_info_get_path (info);
3029 column_number = get_column_number (tree_view, info->cell_col_ref, FALSE);
3030 index = get_index (tree_view, path, column_number);
3031 gtk_tree_path_free (path);
3037 cell_info_new (GtkTreeViewAccessible *accessible,
3038 GtkTreeModel *tree_model,
3041 GtkTreeViewColumn *tv_col,
3042 GtkCellAccessible *cell)
3044 GtkTreeViewAccessibleCellInfo *cell_info;
3046 cell_info = g_new (GtkTreeViewAccessibleCellInfo, 1);
3048 cell_info->tree = tree;
3049 cell_info->node = node;
3050 cell_info->cell_col_ref = tv_col;
3051 cell_info->cell = cell;
3052 cell_info->view = accessible;
3054 g_object_set_qdata_full (G_OBJECT (cell),
3055 gtk_tree_view_accessible_get_data_quark (),
3059 g_hash_table_replace (accessible->cell_infos, cell_info, cell_info);
3062 static GtkCellAccessible *
3063 find_cell (GtkTreeViewAccessible *accessible,
3066 GtkTreeViewAccessibleCellInfo *info;
3067 GHashTableIter iter;
3068 GtkTreeView *tree_view;
3070 tree_view = GTK_TREE_VIEW (gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible)));
3072 g_hash_table_iter_init (&iter, accessible->cell_infos);
3073 while (g_hash_table_iter_next (&iter, NULL, (gpointer *) &info))
3075 if (index == cell_info_get_index (tree_view, info))
3083 connect_model_signals (GtkTreeView *view,
3084 GtkTreeViewAccessible *accessible)
3088 obj = G_OBJECT (accessible->tree_model);
3089 g_signal_connect_data (obj, "row-changed",
3090 G_CALLBACK (model_row_changed), view, NULL, 0);
3091 g_signal_connect_data (obj, "row-inserted",
3092 G_CALLBACK (model_row_inserted), view, NULL,
3094 g_signal_connect_data (obj, "row-deleted",
3095 G_CALLBACK (model_row_deleted), view, NULL,
3097 g_signal_connect_data (obj, "rows-reordered",
3098 G_CALLBACK (model_rows_reordered), view, NULL,
3103 disconnect_model_signals (GtkTreeViewAccessible *accessible)
3108 obj = G_OBJECT (accessible->tree_model);
3109 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible));
3110 g_signal_handlers_disconnect_by_func (obj, model_row_changed, widget);
3111 g_signal_handlers_disconnect_by_func (obj, model_row_inserted, widget);
3112 g_signal_handlers_disconnect_by_func (obj, model_row_deleted, widget);
3113 g_signal_handlers_disconnect_by_func (obj, model_rows_reordered, widget);
3116 /* Returns the column number of the specified GtkTreeViewColumn
3118 * If visible is set, the value returned will be the visible column number,
3119 * i.e. suitable for use in AtkTable function. If visible is not set, the
3120 * value returned is the actual column number, which is suitable for use in
3121 * getting an index value.
3124 get_column_number (GtkTreeView *tree_view,
3125 GtkTreeViewColumn *column,
3128 GtkTreeViewColumn *tv_column;
3132 GtkTreeViewAccessible *accessible;
3134 atk_obj = gtk_widget_get_accessible (GTK_WIDGET (tree_view));
3135 accessible = GTK_TREE_VIEW_ACCESSIBLE (atk_obj);
3138 for (i = 0; i < accessible->col_data->len; i++)
3140 tv_column = g_array_index (accessible->col_data, GtkTreeViewColumn *, i);
3141 if (tv_column == column)
3143 if (!visible || gtk_tree_view_column_get_visible (tv_column))
3146 if (i == accessible->col_data->len)
3153 get_index (GtkTreeView *tree_view,
3158 GtkTreeViewAccessible *accessible;
3161 gint *indices = NULL;
3163 atk_obj = gtk_widget_get_accessible (GTK_WIDGET (tree_view));
3164 accessible = GTK_TREE_VIEW_ACCESSIBLE (atk_obj);
3168 depth = gtk_tree_path_get_depth (path);
3169 indices = gtk_tree_path_get_indices (path);
3174 GtkTreePath *copy_path;
3175 GtkTreeModel *model;
3177 model = gtk_tree_view_get_model (tree_view);
3178 copy_path = gtk_tree_path_copy (path);
3179 gtk_tree_path_up (copy_path);
3180 count_rows (model, NULL, copy_path, &index, 0, depth);
3181 gtk_tree_path_free (copy_path);
3185 index += indices[depth - 1];
3186 index *= accessible->n_cols;
3187 index += actual_column;
3191 /* The function count_rows counts the number of rows starting at iter
3192 * and ending at end_path. The value of level is the depth of iter and
3193 * the value of depth is the depth of end_path. Rows at depth before
3194 * end_path are counted. This functions counts rows which are not visible
3195 * because an ancestor is collapsed.
3198 count_rows (GtkTreeModel *model,
3200 GtkTreePath *end_path,
3205 GtkTreeIter child_iter;
3211 *count += gtk_tree_model_iter_n_children (model, iter);
3213 if (gtk_tree_model_get_flags (model) & GTK_TREE_MODEL_LIST_ONLY)
3219 if (gtk_tree_model_iter_children (model, &child_iter, iter))
3221 gboolean ret_val = TRUE;
3225 if (level == depth - 1)
3227 GtkTreePath *iter_path;
3228 gboolean finished = FALSE;
3230 iter_path = gtk_tree_model_get_path (model, &child_iter);
3231 if (end_path && gtk_tree_path_compare (iter_path, end_path) >= 0)
3233 gtk_tree_path_free (iter_path);
3237 if (gtk_tree_model_iter_has_child (model, &child_iter))
3238 count_rows (model, &child_iter, end_path, count, level, depth);
3239 ret_val = gtk_tree_model_iter_next (model, &child_iter);
3245 get_rbtree_column_from_index (GtkTreeView *tree_view,
3249 GtkTreeViewColumn **column)
3252 GtkTreeViewAccessible *accessible;
3254 atk_obj = gtk_widget_get_accessible (GTK_WIDGET (tree_view));
3255 accessible = GTK_TREE_VIEW_ACCESSIBLE (atk_obj);
3257 if (accessible->n_cols == 0)
3259 /* First row is the column headers */
3260 index -= accessible->n_cols;
3266 g_return_val_if_fail (node != NULL, FALSE);
3268 if (!_gtk_rbtree_find_index (_gtk_tree_view_get_rbtree (tree_view),
3269 index / accessible->n_cols,
3277 *column = gtk_tree_view_get_column (tree_view, index % accessible->n_cols);
3278 if (*column == NULL)
3285 set_cell_expandable (GtkCellAccessible *cell)
3287 if (_gtk_cell_accessible_add_state (cell, ATK_STATE_EXPANDABLE, FALSE))
3288 _gtk_cell_accessible_add_action (cell,
3289 "expand or contract",
3290 "expands or contracts the row in the tree view containing this cell",
3291 NULL, toggle_cell_expanded);
3294 static GtkTreeViewAccessibleCellInfo *
3295 find_cell_info (GtkTreeViewAccessible *accessible,
3296 GtkCellAccessible *cell,
3299 return g_object_get_qdata (G_OBJECT (cell),
3300 gtk_tree_view_accessible_get_data_quark ());
3304 get_header_from_column (GtkTreeViewColumn *tv_col)
3307 GtkWidget *header_widget;
3312 header_widget = gtk_tree_view_column_get_button (tv_col);
3315 rc = gtk_widget_get_accessible (header_widget);
3323 * _gtk_rbtree_get_ancestor_node:
3324 * @ancestor: the ancestor tree
3325 * @child_tree: the potential child's tree
3326 * @child_node: the potential child's node
3328 * Finds the node that is the ancestor of @child_tree and @child_node
3329 * and belongs to @ancestor. If @ancestor is not an ancestor tree
3330 * of @child_node, %NULL is returned.
3332 * Returns: the ancestor node or %NULL if @ancestor is not an ancestor.
3335 _gtk_rbtree_get_ancestor_node (GtkRBTree *ancestor,
3336 GtkRBTree *child_tree,
3337 GtkRBNode *child_node)
3339 while (child_tree != NULL)
3341 if (child_tree == ancestor)
3344 child_node = child_tree->parent_node;
3345 child_tree = child_tree->parent_tree;
3352 _gtk_tree_view_accessible_remove (GtkTreeView *treeview,
3356 GtkTreeViewAccessibleCellInfo *cell_info;
3357 GHashTableIter iter;
3358 GtkTreeViewAccessible *accessible;
3360 accessible = GTK_TREE_VIEW_ACCESSIBLE (_gtk_widget_peek_accessible (GTK_WIDGET (treeview)));
3361 if (accessible == NULL)
3364 /* if this shows up in profiles, special-case node->children == NULL */
3366 g_hash_table_iter_init (&iter, accessible->cell_infos);
3367 while (g_hash_table_iter_next (&iter, NULL, (gpointer *)&cell_info))
3369 GtkRBNode *child_node = _gtk_rbtree_get_ancestor_node (tree,
3373 if (child_node == NULL)
3376 if (node == NULL || node == child_node)
3377 g_hash_table_iter_remove (&iter);