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.
24 #ifdef GDK_WINDOWING_X11
25 #include <gdk/x11/gdkx.h>
27 #include "gailtreeview.h"
28 #include "gailrenderercell.h"
29 #include "gailbooleancell.h"
30 #include "gailcontainercell.h"
31 #include "gailtextcell.h"
32 #include "gailcellparent.h"
33 #include "gail-private-macros.h"
35 typedef struct _GailTreeViewRowInfo GailTreeViewRowInfo;
36 typedef struct _GailTreeViewCellInfo GailTreeViewCellInfo;
38 static void gail_tree_view_class_init (GailTreeViewClass *klass);
39 static void gail_tree_view_init (GailTreeView *view);
40 static void gail_tree_view_real_initialize (AtkObject *obj,
42 static void gail_tree_view_real_notify_gtk (GObject *obj,
44 static void gail_tree_view_finalize (GObject *object);
46 static void gail_tree_view_connect_widget_destroyed
47 (GtkAccessible *accessible);
48 static void gail_tree_view_destroyed (GtkWidget *widget,
49 GtkAccessible *accessible);
52 static gint gail_tree_view_get_n_children (AtkObject *obj);
53 static AtkObject* gail_tree_view_ref_child (AtkObject *obj,
55 static AtkStateSet* gail_tree_view_ref_state_set (AtkObject *obj);
59 static void atk_component_interface_init (AtkComponentIface *iface);
61 static AtkObject* gail_tree_view_ref_accessible_at_point
62 (AtkComponent *component,
65 AtkCoordType coord_type);
69 static void atk_table_interface_init (AtkTableIface *iface);
71 static gint gail_tree_view_get_index_at (AtkTable *table,
74 static gint gail_tree_view_get_column_at_index
77 static gint gail_tree_view_get_row_at_index (AtkTable *table,
80 static AtkObject* gail_tree_view_table_ref_at (AtkTable *table,
83 static gint gail_tree_view_get_n_rows (AtkTable *table);
84 static gint gail_tree_view_get_n_columns (AtkTable *table);
85 static gint get_n_actual_columns (GtkTreeView *tree_view);
86 static gboolean gail_tree_view_is_row_selected (AtkTable *table,
88 static gboolean gail_tree_view_is_selected (AtkTable *table,
91 static gint gail_tree_view_get_selected_rows
94 static gboolean gail_tree_view_add_row_selection
97 static gboolean gail_tree_view_remove_row_selection
100 static AtkObject* gail_tree_view_get_row_header (AtkTable *table,
102 static AtkObject* gail_tree_view_get_column_header
105 static void gail_tree_view_set_row_header (AtkTable *table,
108 static void gail_tree_view_set_column_header
113 gail_tree_view_get_caption (AtkTable *table);
114 static void gail_tree_view_set_caption (AtkTable *table,
116 static AtkObject* gail_tree_view_get_summary (AtkTable *table);
117 static void gail_tree_view_set_summary (AtkTable *table,
118 AtkObject *accessible);
119 static G_CONST_RETURN gchar*
120 gail_tree_view_get_row_description
123 static void gail_tree_view_set_row_description
126 const gchar *description);
127 static G_CONST_RETURN gchar*
128 gail_tree_view_get_column_description
131 static void gail_tree_view_set_column_description
134 const gchar *description);
136 static void set_row_data (AtkTable *table,
139 const gchar *description,
141 static GailTreeViewRowInfo*
142 get_row_info (AtkTable *table,
147 static void atk_selection_interface_init (AtkSelectionIface *iface);
148 static gboolean gail_tree_view_add_selection (AtkSelection *selection,
150 static gboolean gail_tree_view_clear_selection (AtkSelection *selection);
151 static AtkObject* gail_tree_view_ref_selection (AtkSelection *selection,
153 static gint gail_tree_view_get_selection_count
154 (AtkSelection *selection);
155 static gboolean gail_tree_view_is_child_selected
156 (AtkSelection *selection,
159 /* gailcellparent.h */
161 static void gail_cell_parent_interface_init (GailCellParentIface *iface);
162 static void gail_tree_view_get_cell_extents (GailCellParent *parent,
168 AtkCoordType coord_type);
169 static void gail_tree_view_get_cell_area (GailCellParent *parent,
171 GdkRectangle *cell_rect);
172 static gboolean gail_tree_view_grab_cell_focus (GailCellParent *parent,
175 /* signal handling */
177 static gboolean gail_tree_view_expand_row_gtk (GtkTreeView *tree_view,
180 static gint idle_expand_row (gpointer data);
181 static gboolean gail_tree_view_collapse_row_gtk (GtkTreeView *tree_view,
184 static void gail_tree_view_size_allocate_gtk (GtkWidget *widget,
185 GtkAllocation *allocation);
186 static void gail_tree_view_set_scroll_adjustments
189 GtkAdjustment *vadj);
190 static void gail_tree_view_changed_gtk (GtkTreeSelection *selection,
193 static void columns_changed (GtkTreeView *tree_view);
194 static void cursor_changed (GtkTreeView *tree_view);
195 static gint idle_cursor_changed (gpointer data);
196 static void focus_in (GtkWidget *widget);
197 static void focus_out (GtkWidget *widget);
199 static void model_row_changed (GtkTreeModel *tree_model,
203 static void column_visibility_changed (GObject *object,
206 static void column_destroy (GtkObject *obj);
207 static void model_row_inserted (GtkTreeModel *tree_model,
211 static void model_row_deleted (GtkTreeModel *tree_model,
214 static void destroy_count_func (GtkTreeView *tree_view,
218 static void model_rows_reordered (GtkTreeModel *tree_model,
223 static void adjustment_changed (GtkAdjustment *adjustment,
224 GtkTreeView *tree_view);
228 static void set_iter_nth_row (GtkTreeView *tree_view,
231 static gint get_row_from_tree_path (GtkTreeView *tree_view,
233 static GtkTreeViewColumn* get_column (GtkTreeView *tree_view,
235 static gint get_actual_column_number (GtkTreeView *tree_view,
236 gint visible_column);
237 static gint get_visible_column_number (GtkTreeView *tree_view,
239 static void iterate_thru_children (GtkTreeView *tree_view,
240 GtkTreeModel *tree_model,
241 GtkTreePath *tree_path,
245 static GtkTreeIter* return_iter_nth_row (GtkTreeView *tree_view,
246 GtkTreeModel *tree_model,
250 static void free_row_info (GArray *array,
253 static void clean_cell_info (GailTreeView *tree_view,
255 static void clean_rows (GailTreeView *tree_view);
256 static void clean_cols (GailTreeView *tree_view,
257 GtkTreeViewColumn *tv_col);
258 static void traverse_cells (GailTreeView *tree_view,
259 GtkTreePath *tree_path,
262 static gboolean update_cell_value (GailRendererCell *renderer_cell,
263 GailTreeView *gailview,
264 gboolean emit_change_signal);
265 static void set_cell_visibility (GtkTreeView *tree_view,
267 GtkTreeViewColumn *tv_col,
268 GtkTreePath *tree_path,
269 gboolean emit_signal);
270 static gboolean is_cell_showing (GtkTreeView *tree_view,
271 GdkRectangle *cell_rect);
272 static void set_expand_state (GtkTreeView *tree_view,
273 GtkTreeModel *tree_model,
274 GailTreeView *gailview,
275 GtkTreePath *tree_path,
276 gboolean set_on_ancestor);
277 static void add_cell_actions (GailCell *cell,
280 static void toggle_cell_expanded (GailCell *cell);
281 static void toggle_cell_toggled (GailCell *cell);
282 static void edit_cell (GailCell *cell);
283 static void activate_cell (GailCell *cell);
284 static void cell_destroyed (gpointer data);
286 static void cell_info_remove (GailTreeView *tree_view,
289 static void cell_info_get_index (GtkTreeView *tree_view,
290 GailTreeViewCellInfo *info,
292 static void cell_info_new (GailTreeView *gailview,
293 GtkTreeModel *tree_model,
295 GtkTreeViewColumn *tv_col,
297 static GailCell* find_cell (GailTreeView *gailview,
299 static void refresh_cell_index (GailCell *cell);
300 static void get_selected_rows (GtkTreeModel *model,
304 static void connect_model_signals (GtkTreeView *view,
305 GailTreeView *gailview);
306 static void disconnect_model_signals (GailTreeView *gailview);
307 static void clear_cached_data (GailTreeView *view);
308 static gint get_column_number (GtkTreeView *tree_view,
309 GtkTreeViewColumn *column,
311 static gint get_focus_index (GtkTreeView *tree_view);
312 static gint get_index (GtkTreeView *tree_view,
315 static void count_rows (GtkTreeModel *model,
317 GtkTreePath *end_path,
322 static gboolean get_next_node_with_child_at_depth
323 (GtkTreeModel *model,
328 static gboolean get_next_node_with_child (GtkTreeModel *model,
330 GtkTreePath **return_path);
331 static gboolean get_tree_path_from_row_index (GtkTreeModel *model,
333 GtkTreePath **tree_path);
334 static gint get_row_count (GtkTreeModel *model);
335 static gboolean get_path_column_from_index (GtkTreeView *tree_view,
338 GtkTreeViewColumn **column);
339 static void set_cell_expandable (GailCell *cell);
341 static GailTreeViewCellInfo* find_cell_info (GailTreeView *view,
345 static AtkObject * get_header_from_column (GtkTreeViewColumn *tv_col);
346 static gboolean idle_garbage_collect_cell_data (gpointer data);
347 static gboolean garbage_collect_cell_data (gpointer data);
349 static GQuark quark_column_desc_object = 0;
350 static GQuark quark_column_header_object = 0;
351 static gboolean editing = FALSE;
352 static const gchar* hadjustment = "hadjustment";
353 static const gchar* vadjustment = "vadjustment";
355 struct _GailTreeViewRowInfo
357 GtkTreeRowReference *row_ref;
362 struct _GailTreeViewCellInfo
365 GtkTreeRowReference *cell_row_ref;
366 GtkTreeViewColumn *cell_col_ref;
371 G_DEFINE_TYPE_WITH_CODE (GailTreeView, gail_tree_view, GAIL_TYPE_CONTAINER,
372 G_IMPLEMENT_INTERFACE (ATK_TYPE_TABLE, atk_table_interface_init)
373 G_IMPLEMENT_INTERFACE (ATK_TYPE_SELECTION, atk_selection_interface_init)
374 G_IMPLEMENT_INTERFACE (ATK_TYPE_COMPONENT, atk_component_interface_init)
375 G_IMPLEMENT_INTERFACE (GAIL_TYPE_CELL_PARENT, gail_cell_parent_interface_init))
378 gail_tree_view_class_init (GailTreeViewClass *klass)
380 AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
381 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
382 GtkAccessibleClass *accessible_class;
383 GailWidgetClass *widget_class;
384 GailContainerClass *container_class;
386 accessible_class = (GtkAccessibleClass*)klass;
387 widget_class = (GailWidgetClass*)klass;
388 container_class = (GailContainerClass*)klass;
390 class->get_n_children = gail_tree_view_get_n_children;
391 class->ref_child = gail_tree_view_ref_child;
392 class->ref_state_set = gail_tree_view_ref_state_set;
393 class->initialize = gail_tree_view_real_initialize;
395 widget_class->notify_gtk = gail_tree_view_real_notify_gtk;
397 accessible_class->connect_widget_destroyed = gail_tree_view_connect_widget_destroyed;
400 * The children of a GtkTreeView are the buttons at the top of the columns
401 * we do not represent these as children so we do not want to report
402 * children added or deleted when these changed.
404 container_class->add_gtk = NULL;
405 container_class->remove_gtk = NULL;
407 gobject_class->finalize = gail_tree_view_finalize;
409 quark_column_desc_object = g_quark_from_static_string ("gtk-column-object");
410 quark_column_header_object = g_quark_from_static_string ("gtk-header-object");
414 gail_tree_view_init (GailTreeView *view)
419 gail_tree_view_real_initialize (AtkObject *obj,
423 GtkTreeView *tree_view;
424 GtkTreeModel *tree_model;
426 GList *tv_cols, *tmp_list;
429 ATK_OBJECT_CLASS (gail_tree_view_parent_class)->initialize (obj, data);
431 view = GAIL_TREE_VIEW (obj);
432 view->caption = NULL;
433 view->summary = NULL;
434 view->row_data = NULL;
435 view->col_data = NULL;
436 view->cell_data = NULL;
437 view->focus_cell = NULL;
438 view->old_hadj = NULL;
439 view->old_vadj = NULL;
440 view->idle_expand_id = 0;
441 view->idle_expand_path = NULL;
443 view->n_children_deleted = 0;
445 widget = GTK_WIDGET (data);
446 g_signal_connect_after (widget,
448 G_CALLBACK (gail_tree_view_collapse_row_gtk),
450 g_signal_connect (widget,
452 G_CALLBACK (gail_tree_view_expand_row_gtk),
454 g_signal_connect (widget,
456 G_CALLBACK (gail_tree_view_size_allocate_gtk),
459 tree_view = GTK_TREE_VIEW (widget);
460 tree_model = gtk_tree_view_get_model (tree_view);
462 /* Set up signal handling */
464 g_signal_connect_data (gtk_tree_view_get_selection (tree_view),
466 (GCallback) gail_tree_view_changed_gtk,
469 g_signal_connect_data (tree_view, "columns-changed",
470 (GCallback) columns_changed, NULL, NULL, 0);
471 g_signal_connect_data (tree_view, "cursor-changed",
472 (GCallback) cursor_changed, NULL, NULL, 0);
473 g_signal_connect_data (GTK_WIDGET (tree_view), "focus-in-event",
474 (GCallback) focus_in, NULL, NULL, 0);
475 g_signal_connect_data (GTK_WIDGET (tree_view), "focus-out-event",
476 (GCallback) focus_out, NULL, NULL, 0);
478 view->tree_model = tree_model;
481 g_object_add_weak_pointer (G_OBJECT (view->tree_model), (gpointer *)&view->tree_model);
482 connect_model_signals (tree_view, view);
484 if (GTK_IS_TREE_STORE (tree_model))
485 obj->role = ATK_ROLE_TREE_TABLE;
487 obj->role = ATK_ROLE_TABLE;
491 obj->role = ATK_ROLE_UNKNOWN;
494 /* adjustment callbacks */
496 g_object_get (tree_view, hadjustment, &adj, NULL);
497 view->old_hadj = adj;
498 g_object_add_weak_pointer (G_OBJECT (view->old_hadj), (gpointer *)&view->old_hadj);
499 g_signal_connect (adj,
501 G_CALLBACK (adjustment_changed),
504 g_object_get (tree_view, vadjustment, &adj, NULL);
505 view->old_vadj = adj;
506 g_object_add_weak_pointer (G_OBJECT (view->old_vadj), (gpointer *)&view->old_vadj);
507 g_signal_connect (adj,
509 G_CALLBACK (adjustment_changed),
511 g_signal_connect_after (widget,
512 "set_scroll_adjustments",
513 G_CALLBACK (gail_tree_view_set_scroll_adjustments),
516 view->col_data = g_array_sized_new (FALSE, TRUE,
517 sizeof(GtkTreeViewColumn *), 0);
519 tv_cols = gtk_tree_view_get_columns (tree_view);
521 for (tmp_list = tv_cols; tmp_list; tmp_list = tmp_list->next)
523 g_signal_connect_data (tmp_list->data, "notify::visible",
524 (GCallback)column_visibility_changed,
525 tree_view, NULL, FALSE);
526 g_signal_connect_data (tmp_list->data, "destroy",
527 (GCallback)column_destroy,
529 g_array_append_val (view->col_data, tmp_list->data);
532 gtk_tree_view_set_destroy_count_func (tree_view,
535 g_list_free (tv_cols);
539 gail_tree_view_real_notify_gtk (GObject *obj,
544 GtkTreeView *tree_view;
545 GailTreeView *gailview;
548 widget = GTK_WIDGET (obj);
549 atk_obj = gtk_widget_get_accessible (widget);
550 tree_view = GTK_TREE_VIEW (widget);
551 gailview = GAIL_TREE_VIEW (atk_obj);
553 if (strcmp (pspec->name, "model") == 0)
555 GtkTreeModel *tree_model;
558 tree_model = gtk_tree_view_get_model (tree_view);
559 if (gailview->tree_model)
560 disconnect_model_signals (gailview);
561 clear_cached_data (gailview);
562 gailview->tree_model = tree_model;
564 * if there is no model the GtkTreeView is probably being destroyed
568 g_object_add_weak_pointer (G_OBJECT (gailview->tree_model), (gpointer *)&gailview->tree_model);
569 connect_model_signals (tree_view, gailview);
571 if (GTK_IS_TREE_STORE (tree_model))
572 role = ATK_ROLE_TREE_TABLE;
574 role = ATK_ROLE_TABLE;
578 role = ATK_ROLE_UNKNOWN;
580 atk_object_set_role (atk_obj, role);
581 g_object_freeze_notify (G_OBJECT (atk_obj));
582 g_signal_emit_by_name (atk_obj, "model_changed");
583 g_signal_emit_by_name (atk_obj, "visible_data_changed");
584 g_object_thaw_notify (G_OBJECT (atk_obj));
586 else if (strcmp (pspec->name, hadjustment) == 0)
588 g_object_get (tree_view, hadjustment, &adj, NULL);
589 g_signal_handlers_disconnect_by_func (gailview->old_hadj,
590 (gpointer) adjustment_changed,
592 gailview->old_hadj = adj;
593 g_object_add_weak_pointer (G_OBJECT (gailview->old_hadj), (gpointer *)&gailview->old_hadj);
594 g_signal_connect (adj,
596 G_CALLBACK (adjustment_changed),
599 else if (strcmp (pspec->name, vadjustment) == 0)
601 g_object_get (tree_view, vadjustment, &adj, NULL);
602 g_signal_handlers_disconnect_by_func (gailview->old_vadj,
603 (gpointer) adjustment_changed,
605 gailview->old_vadj = adj;
606 g_object_add_weak_pointer (G_OBJECT (gailview->old_hadj), (gpointer *)&gailview->old_vadj);
607 g_signal_connect (adj,
609 G_CALLBACK (adjustment_changed),
613 GAIL_WIDGET_CLASS (gail_tree_view_parent_class)->notify_gtk (obj, pspec);
617 gail_tree_view_finalize (GObject *object)
619 GailTreeView *view = GAIL_TREE_VIEW (object);
621 clear_cached_data (view);
623 /* remove any idle handlers still pending */
624 if (view->idle_garbage_collect_id)
625 g_source_remove (view->idle_garbage_collect_id);
626 if (view->idle_cursor_changed_id)
627 g_source_remove (view->idle_cursor_changed_id);
628 if (view->idle_expand_id)
629 g_source_remove (view->idle_expand_id);
632 g_object_unref (view->caption);
634 g_object_unref (view->summary);
636 if (view->tree_model)
637 disconnect_model_signals (view);
641 GArray *array = view->col_data;
644 * No need to free the contents of the array since it
645 * just contains pointers to the GtkTreeViewColumn
646 * objects that are in the GtkTreeView.
648 g_array_free (array, TRUE);
651 G_OBJECT_CLASS (gail_tree_view_parent_class)->finalize (object);
655 gail_tree_view_connect_widget_destroyed (GtkAccessible *accessible)
657 if (accessible->widget)
659 g_signal_connect_after (accessible->widget,
661 G_CALLBACK (gail_tree_view_destroyed),
664 GTK_ACCESSIBLE_CLASS (gail_tree_view_parent_class)->connect_widget_destroyed (accessible);
668 gail_tree_view_destroyed (GtkWidget *widget,
669 GtkAccessible *accessible)
672 GailTreeView *gailview;
674 gail_return_if_fail (GTK_IS_TREE_VIEW (widget));
676 gailview = GAIL_TREE_VIEW (accessible);
677 adj = gailview->old_hadj;
679 g_signal_handlers_disconnect_by_func (adj,
680 (gpointer) adjustment_changed,
682 adj = gailview->old_vadj;
684 g_signal_handlers_disconnect_by_func (adj,
685 (gpointer) adjustment_changed,
687 if (gailview->tree_model)
689 disconnect_model_signals (gailview);
690 gailview->tree_model = NULL;
692 if (gailview->focus_cell)
694 g_object_unref (gailview->focus_cell);
695 gailview->focus_cell = NULL;
697 if (gailview->idle_expand_id)
699 g_source_remove (gailview->idle_expand_id);
700 gailview->idle_expand_id = 0;
705 get_focus_index (GtkTreeView *tree_view)
707 GtkTreePath *focus_path;
708 GtkTreeViewColumn *focus_column;
711 gtk_tree_view_get_cursor (tree_view, &focus_path, &focus_column);
712 if (focus_path && focus_column)
715 index = get_index (tree_view, focus_path,
716 get_column_number (tree_view, focus_column, FALSE));
722 gtk_tree_path_free (focus_path);
728 gail_tree_view_ref_focus_cell (GtkTreeView *tree_view)
731 * This function returns a reference to the accessible object for the cell
732 * in the treeview which has focus, if a cell has focus.
734 AtkObject *focus_cell = NULL;
738 focus_index = get_focus_index (tree_view);
739 if (focus_index >= 0)
741 atk_obj = gtk_widget_get_accessible (GTK_WIDGET (tree_view));
742 focus_cell = atk_object_ref_accessible_child (atk_obj, focus_index);
751 gail_tree_view_get_n_children (AtkObject *obj)
754 GtkTreeView *tree_view;
755 GtkTreeModel *tree_model;
758 gail_return_val_if_fail (GAIL_IS_TREE_VIEW (obj), 0);
760 widget = GTK_ACCESSIBLE (obj)->widget;
767 tree_view = GTK_TREE_VIEW (widget);
768 tree_model = gtk_tree_view_get_model (tree_view);
771 * We get the total number of rows including those which are collapsed
773 n_rows = get_row_count (tree_model);
775 * We get the total number of columns including those which are not visible
777 n_cols = get_n_actual_columns (tree_view);
778 return (n_rows * n_cols);
782 gail_tree_view_ref_child (AtkObject *obj,
786 GailTreeView *gailview;
788 GtkTreeView *tree_view;
789 GtkTreeModel *tree_model;
790 GtkCellRenderer *renderer;
792 GtkTreeViewColumn *tv_col;
793 GtkTreeSelection *selection;
795 AtkRegistry *default_registry;
796 AtkObjectFactory *factory;
799 GtkTreeViewColumn *expander_tv;
800 GList *renderer_list;
802 GailContainerCell *container = NULL;
803 GailRendererCell *renderer_cell;
804 gboolean is_expander, is_expanded, retval;
805 gboolean editable = FALSE;
808 g_return_val_if_fail (GAIL_IS_TREE_VIEW (obj), NULL);
809 g_return_val_if_fail (i >= 0, NULL);
811 widget = GTK_ACCESSIBLE (obj)->widget;
818 if (i >= gail_tree_view_get_n_children (obj))
821 tree_view = GTK_TREE_VIEW (widget);
822 if (i < get_n_actual_columns (tree_view))
824 tv_col = gtk_tree_view_get_column (tree_view, i);
825 child = get_header_from_column (tv_col);
827 g_object_ref (child);
831 gailview = GAIL_TREE_VIEW (obj);
833 * Check whether the child is cached
835 cell = find_cell (gailview, i);
839 return ATK_OBJECT (cell);
842 if (gailview->focus_cell == NULL)
843 focus_index = get_focus_index (tree_view);
847 * Find the TreePath and GtkTreeViewColumn for the index
849 if (!get_path_column_from_index (tree_view, i, &path, &tv_col))
852 tree_model = gtk_tree_view_get_model (tree_view);
853 retval = gtk_tree_model_get_iter (tree_model, &iter, path);
854 gail_return_val_if_fail (retval, NULL);
856 expander_tv = gtk_tree_view_get_expander_column (tree_view);
859 if (gtk_tree_model_iter_has_child (tree_model, &iter))
861 if (expander_tv == tv_col)
864 is_expanded = gtk_tree_view_row_expanded (tree_view, path);
867 gtk_tree_view_column_cell_set_cell_data (tv_col, tree_model, &iter,
868 is_expander, is_expanded);
870 renderer_list = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (tv_col));
872 /* If there are more than one renderer in the list, make a container */
874 if (renderer_list && renderer_list->next)
876 GailCell *container_cell;
878 container = gail_container_cell_new ();
879 gail_return_val_if_fail (container, NULL);
881 container_cell = GAIL_CELL (container);
882 gail_cell_initialise (container_cell,
883 widget, ATK_OBJECT (gailview),
886 * The GailTreeViewCellInfo structure for the container will be before
887 * the ones for the cells so that the first one we find for a position
888 * will be for the container
890 cell_info_new (gailview, tree_model, path, tv_col, container_cell);
891 container_cell->refresh_index = refresh_cell_index;
892 parent = ATK_OBJECT (container);
895 parent = ATK_OBJECT (gailview);
900 * Now we make a fake cell_renderer if there is no cell in renderer_list
903 if (renderer_list == NULL)
905 GtkCellRenderer *fake_renderer;
906 fake_renderer = g_object_new (GTK_TYPE_CELL_RENDERER_TEXT, NULL);
907 default_registry = atk_get_default_registry ();
908 factory = atk_registry_get_factory (default_registry,
909 G_OBJECT_TYPE (fake_renderer));
910 child = atk_object_factory_create_accessible (factory,
911 G_OBJECT (fake_renderer));
912 gail_return_val_if_fail (GAIL_IS_RENDERER_CELL (child), NULL);
913 cell = GAIL_CELL (child);
914 renderer_cell = GAIL_RENDERER_CELL (child);
915 renderer_cell->renderer = fake_renderer;
917 /* Create the GailTreeViewCellInfo structure for this cell */
918 cell_info_new (gailview, tree_model, path, tv_col, cell);
920 gail_cell_initialise (cell,
924 cell->refresh_index = refresh_cell_index;
926 /* set state if it is expandable */
929 set_cell_expandable (cell);
931 gail_cell_add_state (cell,
936 for (l = renderer_list; l; l = l->next)
938 renderer = GTK_CELL_RENDERER (l->data);
940 if (GTK_IS_CELL_RENDERER_TEXT (renderer))
941 g_object_get (G_OBJECT (renderer), "editable", &editable, NULL);
943 default_registry = atk_get_default_registry ();
944 factory = atk_registry_get_factory (default_registry,
945 G_OBJECT_TYPE (renderer));
946 child = atk_object_factory_create_accessible (factory,
947 G_OBJECT (renderer));
948 gail_return_val_if_fail (GAIL_IS_RENDERER_CELL (child), NULL);
949 cell = GAIL_CELL (child);
950 renderer_cell = GAIL_RENDERER_CELL (child);
952 /* Create the GailTreeViewCellInfo structure for this cell */
953 cell_info_new (gailview, tree_model, path, tv_col, cell);
955 gail_cell_initialise (cell,
960 gail_container_cell_add_child (container, cell);
962 cell->refresh_index = refresh_cell_index;
964 update_cell_value (renderer_cell, gailview, FALSE);
965 /* Add the actions appropriate for this cell */
966 add_cell_actions (cell, editable);
968 /* set state if it is expandable */
971 set_cell_expandable (cell);
973 gail_cell_add_state (cell,
978 * If the column is visible, sets the cell's state
980 if (gtk_tree_view_column_get_visible (tv_col))
981 set_cell_visibility (tree_view, cell, tv_col, path, FALSE);
983 * If the row is selected, all cells on the row are selected
985 selection = gtk_tree_view_get_selection (tree_view);
987 if (gtk_tree_selection_path_is_selected (selection, path))
988 gail_cell_add_state (cell, ATK_STATE_SELECTED, FALSE);
990 gail_cell_add_state (cell, ATK_STATE_FOCUSABLE, FALSE);
991 if (focus_index == i)
993 gailview->focus_cell = g_object_ref (cell);
994 gail_cell_add_state (cell, ATK_STATE_FOCUSED, FALSE);
995 g_signal_emit_by_name (gailview,
996 "active-descendant-changed",
1000 g_list_free (renderer_list);
1002 child = ATK_OBJECT (container);
1005 if (expander_tv == tv_col)
1007 AtkRelationSet *relation_set;
1008 AtkObject *accessible_array[1];
1009 AtkRelation* relation;
1010 AtkObject *parent_node;
1012 relation_set = atk_object_ref_relation_set (ATK_OBJECT (child));
1014 gtk_tree_path_up (path);
1015 if (gtk_tree_path_get_depth (path) == 0)
1022 n_columns = get_n_actual_columns (tree_view);
1023 parent_index = get_index (tree_view, path, i % n_columns);
1024 parent_node = atk_object_ref_accessible_child (obj, parent_index);
1026 accessible_array[0] = parent_node;
1027 relation = atk_relation_new (accessible_array, 1,
1028 ATK_RELATION_NODE_CHILD_OF);
1029 atk_relation_set_add (relation_set, relation);
1030 atk_object_add_relationship (parent_node, ATK_RELATION_NODE_PARENT_OF,
1032 g_object_unref (relation);
1033 g_object_unref (relation_set);
1035 gtk_tree_path_free (path);
1038 * We do not increase the reference count here; when g_object_unref() is
1039 * called for the cell then cell_destroyed() is called and
1040 * this removes the cell from the cache.
1046 gail_tree_view_ref_state_set (AtkObject *obj)
1048 AtkStateSet *state_set;
1051 state_set = ATK_OBJECT_CLASS (gail_tree_view_parent_class)->ref_state_set (obj);
1052 widget = GTK_ACCESSIBLE (obj)->widget;
1055 atk_state_set_add_state (state_set, ATK_STATE_MANAGES_DESCENDANTS);
1060 /* atkcomponent.h */
1063 atk_component_interface_init (AtkComponentIface *iface)
1065 iface->ref_accessible_at_point = gail_tree_view_ref_accessible_at_point;
1069 gail_tree_view_ref_accessible_at_point (AtkComponent *component,
1072 AtkCoordType coord_type)
1075 GtkTreeView *tree_view;
1077 GtkTreeViewColumn *tv_column;
1082 widget = GTK_ACCESSIBLE (component)->widget;
1084 /* State is defunct */
1087 tree_view = GTK_TREE_VIEW (widget);
1089 atk_component_get_extents (component, &x_pos, &y_pos, NULL, NULL, coord_type);
1090 gtk_tree_view_convert_widget_to_bin_window_coords (tree_view, x, y, &bx, &by);
1091 ret_val = gtk_tree_view_get_path_at_pos (tree_view,
1092 bx - x_pos, by - y_pos,
1093 &path, &tv_column, NULL, NULL);
1098 column = get_column_number (tree_view, tv_column, FALSE);
1099 index = get_index (tree_view, path, column);
1100 gtk_tree_path_free (path);
1102 return gail_tree_view_ref_child (ATK_OBJECT (component), index);
1106 g_warning ("gail_tree_view_ref_accessible_at_point: gtk_tree_view_get_path_at_pos () failed\n");
1114 atk_table_interface_init (AtkTableIface *iface)
1116 iface->ref_at = gail_tree_view_table_ref_at;
1117 iface->get_n_rows = gail_tree_view_get_n_rows;
1118 iface->get_n_columns = gail_tree_view_get_n_columns;
1119 iface->get_index_at = gail_tree_view_get_index_at;
1120 iface->get_column_at_index = gail_tree_view_get_column_at_index;
1121 iface->get_row_at_index = gail_tree_view_get_row_at_index;
1122 iface->is_row_selected = gail_tree_view_is_row_selected;
1123 iface->is_selected = gail_tree_view_is_selected;
1124 iface->get_selected_rows = gail_tree_view_get_selected_rows;
1125 iface->add_row_selection = gail_tree_view_add_row_selection;
1126 iface->remove_row_selection = gail_tree_view_remove_row_selection;
1127 iface->get_column_extent_at = NULL;
1128 iface->get_row_extent_at = NULL;
1129 iface->get_row_header = gail_tree_view_get_row_header;
1130 iface->set_row_header = gail_tree_view_set_row_header;
1131 iface->get_column_header = gail_tree_view_get_column_header;
1132 iface->set_column_header = gail_tree_view_set_column_header;
1133 iface->get_caption = gail_tree_view_get_caption;
1134 iface->set_caption = gail_tree_view_set_caption;
1135 iface->get_summary = gail_tree_view_get_summary;
1136 iface->set_summary = gail_tree_view_set_summary;
1137 iface->get_row_description = gail_tree_view_get_row_description;
1138 iface->set_row_description = gail_tree_view_set_row_description;
1139 iface->get_column_description = gail_tree_view_get_column_description;
1140 iface->set_column_description = gail_tree_view_set_column_description;
1144 gail_tree_view_get_index_at (AtkTable *table,
1149 GtkTreeView *tree_view;
1151 gint n_cols, n_rows;
1156 n_cols = atk_table_get_n_columns (table);
1157 n_rows = atk_table_get_n_rows (table);
1159 if (row >= n_rows ||
1163 widget = GTK_ACCESSIBLE (table)->widget;
1165 /* State is defunct */
1168 tree_view = GTK_TREE_VIEW (widget);
1169 actual_column = get_actual_column_number (tree_view, column);
1171 set_iter_nth_row (tree_view, &iter, row);
1172 path = gtk_tree_model_get_path (gtk_tree_view_get_model (tree_view), &iter);
1174 index = get_index (tree_view, path, actual_column);
1175 gtk_tree_path_free (path);
1181 gail_tree_view_get_column_at_index (AtkTable *table,
1185 GtkTreeView *tree_view;
1188 widget = GTK_ACCESSIBLE (table)->widget;
1190 /* State is defunct */
1193 tree_view = GTK_TREE_VIEW (widget);
1194 n_columns = get_n_actual_columns (tree_view);
1198 index = index % n_columns;
1200 return get_visible_column_number (tree_view, index);
1204 gail_tree_view_get_row_at_index (AtkTable *table,
1208 GtkTreeView *tree_view;
1211 widget = GTK_ACCESSIBLE (table)->widget;
1213 /* State is defunct */
1216 tree_view = GTK_TREE_VIEW (widget);
1217 if (get_path_column_from_index (tree_view, index, &path, NULL))
1219 gint row = get_row_from_tree_path (tree_view, path);
1220 gtk_tree_path_free (path);
1228 gail_tree_view_table_ref_at (AtkTable *table,
1234 index = gail_tree_view_get_index_at (table, row, column);
1238 return gail_tree_view_ref_child (ATK_OBJECT (table), index);
1242 gail_tree_view_get_n_rows (AtkTable *table)
1245 GtkTreeView *tree_view;
1246 GtkTreeModel *tree_model;
1249 widget = GTK_ACCESSIBLE (table)->widget;
1251 /* State is defunct */
1254 tree_view = GTK_TREE_VIEW (widget);
1255 tree_model = gtk_tree_view_get_model (tree_view);
1257 if (gtk_tree_model_get_flags (tree_model) & GTK_TREE_MODEL_LIST_ONLY)
1259 * If working with a LIST store, then this is a faster way
1260 * to get the number of rows.
1262 n_rows = gtk_tree_model_iter_n_children (tree_model, NULL);
1265 GtkTreePath *root_tree;
1268 root_tree = gtk_tree_path_new_first ();
1269 iterate_thru_children (tree_view, tree_model,
1270 root_tree, NULL, &n_rows, 0);
1271 gtk_tree_path_free (root_tree);
1278 * The function get_n_actual_columns returns the number of columns in the
1279 * GtkTreeView. i.e. it include both visible and non-visible columns.
1282 get_n_actual_columns (GtkTreeView *tree_view)
1287 columns = gtk_tree_view_get_columns (tree_view);
1288 n_cols = g_list_length (columns);
1289 g_list_free (columns);
1294 gail_tree_view_get_n_columns (AtkTable *table)
1297 GtkTreeView *tree_view;
1298 GtkTreeViewColumn *tv_col;
1302 widget = GTK_ACCESSIBLE (table)->widget;
1304 /* State is defunct */
1307 tree_view = GTK_TREE_VIEW (widget);
1308 tv_col = gtk_tree_view_get_column (tree_view, i);
1310 while (tv_col != NULL)
1312 if (gtk_tree_view_column_get_visible (tv_col))
1316 tv_col = gtk_tree_view_get_column (tree_view, i);
1323 gail_tree_view_is_row_selected (AtkTable *table,
1327 GtkTreeView *tree_view;
1328 GtkTreeSelection *selection;
1331 widget = GTK_ACCESSIBLE (table)->widget;
1333 /* State is defunct */
1339 tree_view = GTK_TREE_VIEW (widget);
1341 selection = gtk_tree_view_get_selection (tree_view);
1343 set_iter_nth_row (tree_view, &iter, row);
1345 return gtk_tree_selection_iter_is_selected (selection, &iter);
1349 gail_tree_view_is_selected (AtkTable *table,
1353 return gail_tree_view_is_row_selected (table, row);
1357 gail_tree_view_get_selected_rows (AtkTable *table,
1358 gint **rows_selected)
1361 GtkTreeView *tree_view;
1362 GtkTreeModel *tree_model;
1364 GtkTreeSelection *selection;
1365 GtkTreePath *tree_path;
1368 widget = GTK_ACCESSIBLE (table)->widget;
1370 /* State is defunct */
1373 tree_view = GTK_TREE_VIEW (widget);
1375 selection = gtk_tree_view_get_selection (tree_view);
1377 switch (selection->type)
1379 case GTK_SELECTION_SINGLE:
1380 case GTK_SELECTION_BROWSE:
1381 if (gtk_tree_selection_get_selected (selection, &tree_model, &iter))
1387 *rows_selected = (gint *)g_malloc (sizeof(gint));
1388 tree_path = gtk_tree_model_get_path (tree_model, &iter);
1389 row = get_row_from_tree_path (tree_view, tree_path);
1390 gtk_tree_path_free (tree_path);
1392 /* shouldn't ever happen */
1393 g_return_val_if_fail (row != -1, 0);
1395 *rows_selected[0] = row;
1400 case GTK_SELECTION_MULTIPLE:
1402 GPtrArray *array = g_ptr_array_new();
1404 gtk_tree_selection_selected_foreach (selection,
1407 ret_val = array->len;
1409 if (rows_selected && ret_val)
1412 *rows_selected = (gint *) g_malloc (ret_val * sizeof (gint));
1414 for (i = 0; i < ret_val; i++)
1418 tree_path = (GtkTreePath *) g_ptr_array_index (array, i);
1419 row = get_row_from_tree_path (tree_view, tree_path);
1420 gtk_tree_path_free (tree_path);
1421 (*rows_selected)[i] = row;
1424 g_ptr_array_free (array, FALSE);
1427 case GTK_SELECTION_NONE:
1434 gail_tree_view_add_row_selection (AtkTable *table,
1438 GtkTreeView *tree_view;
1439 GtkTreeModel *tree_model;
1440 GtkTreeSelection *selection;
1441 GtkTreePath *tree_path;
1442 GtkTreeIter iter_to_row;
1444 widget = GTK_ACCESSIBLE (table)->widget;
1446 /* State is defunct */
1449 if (!gail_tree_view_is_row_selected (table, row))
1451 tree_view = GTK_TREE_VIEW (widget);
1452 tree_model = gtk_tree_view_get_model (tree_view);
1453 selection = gtk_tree_view_get_selection (tree_view);
1455 if (gtk_tree_model_get_flags (tree_model) & GTK_TREE_MODEL_LIST_ONLY)
1457 tree_path = gtk_tree_path_new ();
1458 gtk_tree_path_append_index (tree_path, row);
1459 gtk_tree_selection_select_path (selection,tree_path);
1460 gtk_tree_path_free (tree_path);
1464 set_iter_nth_row (tree_view, &iter_to_row, row);
1465 if (&iter_to_row != NULL)
1466 gtk_tree_selection_select_iter (selection, &iter_to_row);
1472 return gail_tree_view_is_row_selected (table, row);
1476 gail_tree_view_remove_row_selection (AtkTable *table,
1480 GtkTreeView *tree_view;
1481 GtkTreeSelection *selection;
1483 widget = GTK_ACCESSIBLE (table)->widget;
1485 /* State is defunct */
1488 tree_view = GTK_TREE_VIEW (widget);
1490 selection = gtk_tree_view_get_selection (tree_view);
1492 if (gail_tree_view_is_row_selected (table, row))
1494 gtk_tree_selection_unselect_all (selection);
1501 gail_tree_view_get_row_header (AtkTable *table,
1504 GailTreeViewRowInfo *row_info;
1506 row_info = get_row_info (table, row);
1508 return row_info->header;
1514 gail_tree_view_set_row_header (AtkTable *table,
1518 set_row_data (table, row, header, NULL, TRUE);
1522 gail_tree_view_get_column_header (AtkTable *table,
1526 GtkTreeView *tree_view;
1527 GtkTreeViewColumn *tv_col;
1529 widget = GTK_ACCESSIBLE (table)->widget;
1531 /* State is defunct */
1534 tree_view = GTK_TREE_VIEW (widget);
1535 tv_col = get_column (tree_view, in_col);
1536 return get_header_from_column (tv_col);
1540 gail_tree_view_set_column_header (AtkTable *table,
1545 GtkTreeView *tree_view;
1546 GtkTreeViewColumn *tv_col;
1548 AtkPropertyValues values = { NULL };
1550 widget = GTK_ACCESSIBLE (table)->widget;
1552 /* State is defunct */
1555 tree_view = GTK_TREE_VIEW (widget);
1556 tv_col = get_column (tree_view, in_col);
1560 rc = g_object_get_qdata (G_OBJECT (tv_col),
1561 quark_column_header_object);
1563 g_object_unref (rc);
1565 g_object_set_qdata (G_OBJECT (tv_col),
1566 quark_column_header_object,
1569 g_object_ref (header);
1570 g_value_init (&values.new_value, G_TYPE_INT);
1571 g_value_set_int (&values.new_value, in_col);
1573 values.property_name = "accessible-table-column-header";
1574 g_signal_emit_by_name (table,
1575 "property_change::accessible-table-column-header",
1580 gail_tree_view_get_caption (AtkTable *table)
1582 GailTreeView* obj = GAIL_TREE_VIEW (table);
1584 return obj->caption;
1588 gail_tree_view_set_caption (AtkTable *table,
1591 GailTreeView* obj = GAIL_TREE_VIEW (table);
1592 AtkPropertyValues values = { NULL };
1593 AtkObject *old_caption;
1595 old_caption = obj->caption;
1596 obj->caption = caption;
1598 g_object_ref (obj->caption);
1599 g_value_init (&values.old_value, G_TYPE_POINTER);
1600 g_value_set_pointer (&values.old_value, old_caption);
1601 g_value_init (&values.new_value, G_TYPE_POINTER);
1602 g_value_set_pointer (&values.new_value, obj->caption);
1604 values.property_name = "accessible-table-caption-object";
1605 g_signal_emit_by_name (table,
1606 "property_change::accessible-table-caption-object",
1609 g_object_unref (old_caption);
1612 static G_CONST_RETURN gchar*
1613 gail_tree_view_get_column_description (AtkTable *table,
1617 GtkTreeView *tree_view;
1618 GtkTreeViewColumn *tv_col;
1621 widget = GTK_ACCESSIBLE (table)->widget;
1623 /* State is defunct */
1626 tree_view = GTK_TREE_VIEW (widget);
1627 tv_col = get_column (tree_view, in_col);
1631 rc = g_object_get_qdata (G_OBJECT (tv_col),
1632 quark_column_desc_object);
1640 g_object_get (tv_col, "title", &title_text, NULL);
1646 gail_tree_view_set_column_description (AtkTable *table,
1648 const gchar *description)
1651 GtkTreeView *tree_view;
1652 GtkTreeViewColumn *tv_col;
1653 AtkPropertyValues values = { NULL };
1655 widget = GTK_ACCESSIBLE (table)->widget;
1657 /* State is defunct */
1660 tree_view = GTK_TREE_VIEW (widget);
1661 tv_col = get_column (tree_view, in_col);
1665 g_object_set_qdata (G_OBJECT (tv_col),
1666 quark_column_desc_object,
1667 g_strdup (description));
1668 g_value_init (&values.new_value, G_TYPE_INT);
1669 g_value_set_int (&values.new_value, in_col);
1671 values.property_name = "accessible-table-column-description";
1672 g_signal_emit_by_name (table,
1673 "property_change::accessible-table-column-description",
1677 static G_CONST_RETURN gchar*
1678 gail_tree_view_get_row_description (AtkTable *table,
1681 GailTreeViewRowInfo *row_info;
1683 row_info = get_row_info (table, row);
1685 return row_info->description;
1691 gail_tree_view_set_row_description (AtkTable *table,
1693 const gchar *description)
1695 set_row_data (table, row, NULL, description, FALSE);
1699 gail_tree_view_get_summary (AtkTable *table)
1701 GailTreeView* obj = GAIL_TREE_VIEW (table);
1703 return obj->summary;
1707 gail_tree_view_set_summary (AtkTable *table,
1708 AtkObject *accessible)
1710 GailTreeView* obj = GAIL_TREE_VIEW (table);
1711 AtkPropertyValues values = { NULL };
1712 AtkObject *old_summary;
1714 old_summary = obj->summary;
1715 obj->summary = accessible;
1717 g_object_ref (obj->summary);
1718 g_value_init (&values.old_value, G_TYPE_POINTER);
1719 g_value_set_pointer (&values.old_value, old_summary);
1720 g_value_init (&values.new_value, G_TYPE_POINTER);
1721 g_value_set_pointer (&values.new_value, obj->summary);
1723 values.property_name = "accessible-table-summary";
1724 g_signal_emit_by_name (table,
1725 "property_change::accessible-table-ummary",
1728 g_object_unref (old_summary);
1732 set_row_data (AtkTable *table,
1735 const gchar *description,
1739 GtkTreeView *tree_view;
1740 GtkTreeModel *tree_model;
1741 GailTreeView* obj = GAIL_TREE_VIEW (table);
1742 GailTreeViewRowInfo* row_info;
1746 gboolean found = FALSE;
1748 AtkPropertyValues values = { NULL };
1751 widget = GTK_ACCESSIBLE (table)->widget;
1753 /* State is defunct */
1756 tree_view = GTK_TREE_VIEW (widget);
1757 tree_model = gtk_tree_view_get_model (tree_view);
1759 set_iter_nth_row (tree_view, &iter, row);
1760 path = gtk_tree_model_get_path (tree_model, &iter);
1762 if (obj->row_data == NULL)
1763 obj->row_data = g_array_sized_new (FALSE, TRUE,
1764 sizeof(GailTreeViewRowInfo *), 0);
1766 array = obj->row_data;
1768 for (i = 0; i < array->len; i++)
1770 GtkTreePath *row_path;
1772 row_info = g_array_index (array, GailTreeViewRowInfo*, i);
1773 row_path = gtk_tree_row_reference_get_path (row_info->row_ref);
1775 if (row_path != NULL)
1777 if (path && gtk_tree_path_compare (row_path, path) == 0)
1780 gtk_tree_path_free (row_path);
1786 if (row_info->header)
1787 g_object_unref (row_info->header);
1788 row_info->header = header;
1789 if (row_info->header)
1790 g_object_ref (row_info->header);
1794 g_free (row_info->description);
1795 row_info->description = g_strdup (description);
1805 row_info = g_malloc (sizeof(GailTreeViewRowInfo));
1806 row_info->row_ref = gtk_tree_row_reference_new (tree_model, path);
1809 row_info->header = header;
1810 if (row_info->header)
1811 g_object_ref (row_info->header);
1812 row_info->description = NULL;
1816 row_info->header = NULL;
1817 row_info->description = g_strdup (description);
1819 g_array_append_val (array, row_info);
1821 g_value_init (&values.new_value, G_TYPE_INT);
1822 g_value_set_int (&values.new_value, row);
1826 values.property_name = "accessible-table-row-header";
1827 signal_name = "property_change::accessible-table-row-header";
1831 values.property_name = "accessible-table-row-description";
1832 signal_name = "property-change::accessible-table-row-description";
1834 g_signal_emit_by_name (table,
1838 gtk_tree_path_free (path);
1842 static GailTreeViewRowInfo*
1843 get_row_info (AtkTable *table,
1847 GtkTreeView *tree_view;
1848 GtkTreeModel *tree_model;
1849 GailTreeView* obj = GAIL_TREE_VIEW (table);
1853 GailTreeViewRowInfo *rc = NULL;
1855 widget = GTK_ACCESSIBLE (table)->widget;
1857 /* State is defunct */
1860 tree_view = GTK_TREE_VIEW (widget);
1861 tree_model = gtk_tree_view_get_model (tree_view);
1863 set_iter_nth_row (tree_view, &iter, row);
1864 path = gtk_tree_model_get_path (tree_model, &iter);
1865 array = obj->row_data;
1869 GailTreeViewRowInfo *row_info;
1870 GtkTreePath *row_path;
1873 for (i = 0; i < array->len; i++)
1875 row_info = g_array_index (array, GailTreeViewRowInfo*, i);
1876 row_path = gtk_tree_row_reference_get_path (row_info->row_ref);
1877 if (row_path != NULL)
1879 if (path && gtk_tree_path_compare (row_path, path) == 0)
1882 gtk_tree_path_free (row_path);
1890 gtk_tree_path_free (path);
1893 /* atkselection.h */
1895 static void atk_selection_interface_init (AtkSelectionIface *iface)
1897 iface->add_selection = gail_tree_view_add_selection;
1898 iface->clear_selection = gail_tree_view_clear_selection;
1899 iface->ref_selection = gail_tree_view_ref_selection;
1900 iface->get_selection_count = gail_tree_view_get_selection_count;
1901 iface->is_child_selected = gail_tree_view_is_child_selected;
1905 gail_tree_view_add_selection (AtkSelection *selection,
1912 table = ATK_TABLE (selection);
1913 n_columns = gail_tree_view_get_n_columns (table);
1917 row = gail_tree_view_get_row_at_index (table, i);
1918 return gail_tree_view_add_row_selection (table, row);
1922 gail_tree_view_clear_selection (AtkSelection *selection)
1925 GtkTreeView *tree_view;
1926 GtkTreeSelection *tree_selection;
1928 widget = GTK_ACCESSIBLE (selection)->widget;
1930 /* State is defunct */
1933 tree_view = GTK_TREE_VIEW (widget);
1935 tree_selection = gtk_tree_view_get_selection (tree_view);
1936 gtk_tree_selection_unselect_all (tree_selection);
1942 gail_tree_view_ref_selection (AtkSelection *selection,
1951 table = ATK_TABLE (selection);
1952 n_columns = gail_tree_view_get_n_columns (table);
1953 n_selected = gail_tree_view_get_selected_rows (table, &selected);
1954 if (i >= n_columns * n_selected)
1957 row = selected[i / n_columns];
1960 return gail_tree_view_table_ref_at (table, row, i % n_columns);
1964 gail_tree_view_get_selection_count (AtkSelection *selection)
1969 table = ATK_TABLE (selection);
1970 n_selected = gail_tree_view_get_selected_rows (table, NULL);
1972 n_selected *= gail_tree_view_get_n_columns (table);
1977 gail_tree_view_is_child_selected (AtkSelection *selection,
1983 widget = GTK_ACCESSIBLE (selection)->widget;
1985 /* State is defunct */
1988 row = atk_table_get_row_at_index (ATK_TABLE (selection), i);
1990 return gail_tree_view_is_row_selected (ATK_TABLE (selection), row);
1994 static void gail_cell_parent_interface_init (GailCellParentIface *iface)
1996 iface->get_cell_extents = gail_tree_view_get_cell_extents;
1997 iface->get_cell_area = gail_tree_view_get_cell_area;
1998 iface->grab_focus = gail_tree_view_grab_cell_focus;
2002 gail_tree_view_get_cell_extents (GailCellParent *parent,
2008 AtkCoordType coord_type)
2011 GtkTreeView *tree_view;
2012 GdkWindow *bin_window;
2013 GdkRectangle cell_rect;
2016 widget = GTK_ACCESSIBLE (parent)->widget;
2018 /* State is defunct */
2021 tree_view = GTK_TREE_VIEW (widget);
2022 gail_tree_view_get_cell_area (parent, cell, &cell_rect);
2023 bin_window = gtk_tree_view_get_bin_window (tree_view);
2024 gdk_window_get_origin (bin_window, &w_x, &w_y);
2026 if (coord_type == ATK_XY_WINDOW)
2029 gint x_toplevel, y_toplevel;
2031 window = gdk_window_get_toplevel (bin_window);
2032 gdk_window_get_origin (window, &x_toplevel, &y_toplevel);
2038 *width = cell_rect.width;
2039 *height = cell_rect.height;
2040 if (is_cell_showing (tree_view, &cell_rect))
2042 *x = cell_rect.x + w_x;
2043 *y = cell_rect.y + w_y;
2052 #define EXTRA_EXPANDER_PADDING 4
2055 gail_tree_view_get_cell_area (GailCellParent *parent,
2057 GdkRectangle *cell_rect)
2060 GtkTreeView *tree_view;
2061 GtkTreeViewColumn *tv_col;
2063 AtkObject *parent_cell;
2064 GailTreeViewCellInfo *cell_info;
2067 widget = GTK_ACCESSIBLE (parent)->widget;
2069 /* State is defunct */
2072 tree_view = GTK_TREE_VIEW (widget);
2073 parent_cell = atk_object_get_parent (ATK_OBJECT (cell));
2074 if (parent_cell != ATK_OBJECT (parent))
2077 * GailCell is in a GailContainerCell
2079 top_cell = GAIL_CELL (parent_cell);
2085 cell_info = find_cell_info (GAIL_TREE_VIEW (parent), top_cell, NULL, TRUE);
2086 gail_return_if_fail (cell_info);
2087 gail_return_if_fail (cell_info->cell_col_ref);
2088 gail_return_if_fail (cell_info->cell_row_ref);
2089 path = gtk_tree_row_reference_get_path (cell_info->cell_row_ref);
2090 tv_col = cell_info->cell_col_ref;
2091 if (path && cell_info->in_use)
2093 GtkTreeViewColumn *expander_column;
2094 gint focus_line_width;
2096 gtk_tree_view_get_cell_area (tree_view, path, tv_col, cell_rect);
2097 expander_column = gtk_tree_view_get_expander_column (tree_view);
2098 if (expander_column == tv_col)
2102 gtk_widget_style_get (widget,
2103 "expander_size", &expander_size,
2106 cell_rect->x += expander_size + EXTRA_EXPANDER_PADDING;
2107 cell_rect->width -= expander_size + EXTRA_EXPANDER_PADDING;
2109 gtk_widget_style_get (widget,
2110 "focus-line-width", &focus_line_width,
2113 cell_rect->x += focus_line_width;
2114 cell_rect->width -= 2 * focus_line_width;
2116 gtk_tree_path_free (path);
2119 * A column has more than one renderer so we find the position and width
2122 if (top_cell != cell)
2129 GtkCellRenderer *renderer;
2131 cell_index = atk_object_get_index_in_parent (ATK_OBJECT (cell));
2132 renderers = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (tv_col));
2133 renderer = g_list_nth_data (renderers, cell_index);
2135 found = gtk_tree_view_column_cell_get_position (tv_col, renderer, &cell_start, &cell_width);
2138 cell_rect->x += cell_start;
2139 cell_rect->width = cell_width;
2141 g_list_free (renderers);
2148 gail_tree_view_grab_cell_focus (GailCellParent *parent,
2152 GtkTreeView *tree_view;
2153 GtkTreeViewColumn *tv_col;
2155 AtkObject *parent_cell;
2156 AtkObject *cell_object;
2157 GailTreeViewCellInfo *cell_info;
2158 GtkCellRenderer *renderer = NULL;
2159 GtkWidget *toplevel;
2162 widget = GTK_ACCESSIBLE (parent)->widget;
2164 /* State is defunct */
2167 tree_view = GTK_TREE_VIEW (widget);
2169 cell_info = find_cell_info (GAIL_TREE_VIEW (parent), cell, NULL, TRUE);
2170 gail_return_val_if_fail (cell_info, FALSE);
2171 gail_return_val_if_fail (cell_info->cell_col_ref, FALSE);
2172 gail_return_val_if_fail (cell_info->cell_row_ref, FALSE);
2173 cell_object = ATK_OBJECT (cell);
2174 parent_cell = atk_object_get_parent (cell_object);
2175 tv_col = cell_info->cell_col_ref;
2176 if (parent_cell != ATK_OBJECT (parent))
2179 * GailCell is in a GailContainerCell.
2180 * The GtkTreeViewColumn has multiple renderers;
2181 * find the corresponding one.
2185 renderers = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (tv_col));
2186 if (cell_info->in_use) {
2187 index = atk_object_get_index_in_parent (cell_object);
2188 renderer = g_list_nth_data (renderers, index);
2190 g_list_free (renderers);
2192 path = gtk_tree_row_reference_get_path (cell_info->cell_row_ref);
2193 if (path && cell_info->in_use)
2196 gtk_tree_view_set_cursor_on_cell (tree_view, path, tv_col, renderer, FALSE);
2198 gtk_tree_view_set_cursor (tree_view, path, tv_col, FALSE);
2200 gtk_tree_path_free (path);
2201 gtk_widget_grab_focus (widget);
2202 toplevel = gtk_widget_get_toplevel (widget);
2203 if (gtk_widget_is_toplevel (toplevel))
2205 #ifdef GDK_WINDOWING_X11
2206 gtk_window_present_with_time (GTK_WINDOW (toplevel), gdk_x11_get_server_time (widget->window));
2208 gtk_window_present (GTK_WINDOW (toplevel));
2218 /* signal handling */
2221 gail_tree_view_expand_row_gtk (GtkTreeView *tree_view,
2226 GailTreeView *gailview;
2228 g_assert (GTK_IS_TREE_VIEW (tree_view));
2230 atk_obj = gtk_widget_get_accessible (GTK_WIDGET (tree_view));
2232 g_assert (GAIL_IS_TREE_VIEW (atk_obj));
2234 gailview = GAIL_TREE_VIEW (atk_obj);
2237 * The visible rectangle has not been updated when this signal is emitted
2238 * so we process the signal when the GTK processing is completed
2240 /* this seems wrong since it overwrites any other pending expand handlers... */
2241 gailview->idle_expand_path = gtk_tree_path_copy (path);
2242 if (gailview->idle_expand_id)
2243 g_source_remove (gailview->idle_expand_id);
2244 gailview->idle_expand_id = gdk_threads_add_idle (idle_expand_row, gailview);
2249 idle_expand_row (gpointer data)
2251 GailTreeView *gailview = data;
2253 GtkTreeView *tree_view;
2255 GtkTreeModel *tree_model;
2256 gint n_inserted, row;
2258 gailview->idle_expand_id = 0;
2260 path = gailview->idle_expand_path;
2261 tree_view = GTK_TREE_VIEW (GTK_ACCESSIBLE (gailview)->widget);
2263 g_assert (GTK_IS_TREE_VIEW (tree_view));
2265 tree_model = gtk_tree_view_get_model(tree_view);
2269 if (!path || !gtk_tree_model_get_iter (tree_model, &iter, path))
2273 * Update visibility of cells below expansion row
2275 traverse_cells (gailview, path, FALSE, FALSE);
2277 * Figure out number of visible children, the following test
2280 if (gtk_tree_model_iter_has_child (tree_model, &iter))
2282 GtkTreePath *path_copy;
2285 * By passing path into this function, we find the number of
2286 * visible children of path.
2288 path_copy = gtk_tree_path_copy (path);
2289 gtk_tree_path_append_index(path_copy, 0);
2292 iterate_thru_children (tree_view, tree_model,
2293 path_copy, NULL, &n_inserted, 0);
2294 gtk_tree_path_free (path_copy);
2298 /* We can get here if the row expanded callback deleted the row */
2302 /* Set expand state */
2303 set_expand_state (tree_view, tree_model, gailview, path, TRUE);
2305 row = get_row_from_tree_path (tree_view, path);
2307 /* shouldn't ever happen */
2309 g_assert_not_reached ();
2311 /* Must add 1 because the "added rows" are below the row being expanded */
2314 g_signal_emit_by_name (gailview, "row_inserted", row, n_inserted);
2316 gailview->idle_expand_path = NULL;
2318 gtk_tree_path_free (path);
2324 gail_tree_view_collapse_row_gtk (GtkTreeView *tree_view,
2328 GtkTreeModel *tree_model;
2329 AtkObject *atk_obj = gtk_widget_get_accessible (GTK_WIDGET (tree_view));
2330 GailTreeView *gailview = GAIL_TREE_VIEW (atk_obj);
2333 tree_model = gtk_tree_view_get_model (tree_view);
2335 clean_rows (gailview);
2338 * Update visibility of cells below collapsed row
2340 traverse_cells (gailview, path, FALSE, FALSE);
2341 /* Set collapse state */
2342 set_expand_state (tree_view, tree_model, gailview, path, FALSE);
2344 gail_return_val_if_fail (gailview->n_children_deleted, FALSE);
2345 row = get_row_from_tree_path (tree_view, path);
2346 gail_return_val_if_fail (row != -1, FALSE);
2347 g_signal_emit_by_name (atk_obj, "row_deleted", row,
2348 gailview->n_children_deleted);
2349 gailview->n_children_deleted = 0;
2354 gail_tree_view_size_allocate_gtk (GtkWidget *widget,
2355 GtkAllocation *allocation)
2357 AtkObject *atk_obj = gtk_widget_get_accessible (widget);
2358 GailTreeView *gailview = GAIL_TREE_VIEW (atk_obj);
2361 * If the size allocation changes, the visibility of cells may change so
2362 * update the cells visibility.
2364 traverse_cells (gailview, NULL, FALSE, FALSE);
2368 gail_tree_view_set_scroll_adjustments (GtkWidget *widget,
2369 GtkAdjustment *hadj,
2370 GtkAdjustment *vadj)
2372 AtkObject *atk_obj = gtk_widget_get_accessible (widget);
2373 GailTreeView *gailview = GAIL_TREE_VIEW (atk_obj);
2376 g_object_get (widget, hadjustment, &adj, NULL);
2377 if (gailview->old_hadj != adj)
2379 g_signal_handlers_disconnect_by_func (gailview->old_hadj,
2380 (gpointer) adjustment_changed,
2382 gailview->old_hadj = adj;
2383 g_object_add_weak_pointer (G_OBJECT (gailview->old_hadj), (gpointer *)&gailview->old_hadj);
2384 g_signal_connect (adj,
2386 G_CALLBACK (adjustment_changed),
2389 g_object_get (widget, vadjustment, &adj, NULL);
2390 if (gailview->old_vadj != adj)
2392 g_signal_handlers_disconnect_by_func (gailview->old_vadj,
2393 (gpointer) adjustment_changed,
2395 gailview->old_vadj = adj;
2396 g_object_add_weak_pointer (G_OBJECT (gailview->old_vadj), (gpointer *)&gailview->old_vadj);
2397 g_signal_connect (adj,
2399 G_CALLBACK (adjustment_changed),
2405 gail_tree_view_changed_gtk (GtkTreeSelection *selection,
2408 GailTreeView *gailview;
2409 GtkTreeView *tree_view;
2413 GailTreeViewCellInfo *info;
2414 GtkTreeSelection *tree_selection;
2417 gailview = GAIL_TREE_VIEW (data);
2418 cell_list = gailview->cell_data;
2419 widget = GTK_ACCESSIBLE (gailview)->widget;
2422 * destroy signal emitted for widget
2425 tree_view = GTK_TREE_VIEW (widget);
2427 tree_selection = gtk_tree_view_get_selection (tree_view);
2429 clean_rows (gailview);
2431 for (l = cell_list; l; l = l->next)
2433 info = (GailTreeViewCellInfo *) (l->data);
2437 gail_cell_remove_state (info->cell, ATK_STATE_SELECTED, TRUE);
2439 path = gtk_tree_row_reference_get_path (info->cell_row_ref);
2440 if (path && gtk_tree_selection_path_is_selected (tree_selection, path))
2441 gail_cell_add_state (info->cell, ATK_STATE_SELECTED, TRUE);
2442 gtk_tree_path_free (path);
2445 if (GTK_WIDGET_REALIZED (widget))
2446 g_signal_emit_by_name (gailview, "selection_changed");
2450 columns_changed (GtkTreeView *tree_view)
2452 AtkObject *atk_obj = gtk_widget_get_accessible (GTK_WIDGET(tree_view));
2453 GailTreeView *gailview = GAIL_TREE_VIEW (atk_obj);
2454 GList *tv_cols, *tmp_list;
2455 gboolean column_found;
2456 gboolean move_found = FALSE;
2457 gboolean stale_set = FALSE;
2458 gint column_count = 0;
2462 * This function must determine if the change is an add, delete or
2463 * a move based upon its cache of TreeViewColumns in
2464 * gailview->col_data
2466 tv_cols = gtk_tree_view_get_columns (tree_view);
2468 /* check for adds or moves */
2469 for (tmp_list = tv_cols; tmp_list; tmp_list = tmp_list->next)
2471 column_found = FALSE;
2473 for (i = 0; i < gailview->col_data->len; i++)
2476 if ((GtkTreeViewColumn *)tmp_list->data ==
2477 (GtkTreeViewColumn *)g_array_index (gailview->col_data,
2478 GtkTreeViewColumn *, i))
2480 column_found = TRUE;
2482 /* If the column isn't in the same position, a move happened */
2483 if (!move_found && i != column_count)
2487 /* Set all rows to ATK_STATE_STALE */
2488 traverse_cells (gailview, NULL, TRUE, FALSE);
2492 /* Just emit one column reordered signal when a move happens */
2493 g_signal_emit_by_name (atk_obj, "column_reordered");
2502 * If column_found is FALSE, then an insert happened for column
2503 * number column_count
2507 gint n_cols, n_rows, row;
2511 /* Set all rows to ATK_STATE_STALE */
2512 traverse_cells (gailview, NULL, TRUE, FALSE);
2516 /* Generate column-inserted signal */
2517 g_signal_emit_by_name (atk_obj, "column_inserted", column_count, 1);
2519 /* Generate children-changed signals */
2520 n_rows = get_row_count (gtk_tree_view_get_model (tree_view));
2521 n_cols = get_n_actual_columns (tree_view);
2522 for (row = 0; row < n_rows; row++)
2525 * Pass NULL as the child object, i.e. 4th argument.
2527 g_signal_emit_by_name (atk_obj, "children_changed::add",
2528 ((row * n_cols) + column_count), NULL, NULL);
2535 /* check for deletes */
2536 for (i = 0; i < gailview->col_data->len; i++)
2538 column_found = FALSE;
2540 for (tmp_list = tv_cols; tmp_list; tmp_list = tmp_list->next)
2542 if ((GtkTreeViewColumn *)tmp_list->data ==
2543 (GtkTreeViewColumn *)g_array_index (gailview->col_data,
2544 GtkTreeViewColumn *, i))
2546 column_found = TRUE;
2552 * If column_found is FALSE, then a delete happened for column
2557 gint n_rows, n_cols, row;
2559 clean_cols (gailview,
2560 (GtkTreeViewColumn *)g_array_index (gailview->col_data,
2561 GtkTreeViewColumn *, i));
2565 /* Set all rows to ATK_STATE_STALE */
2566 traverse_cells (gailview, NULL, TRUE, FALSE);
2570 /* Generate column-deleted signal */
2571 g_signal_emit_by_name (atk_obj, "column_deleted", i, 1);
2573 /* Generate children-changed signals */
2574 n_rows = get_row_count (gtk_tree_view_get_model (tree_view));
2575 n_cols = get_n_actual_columns (tree_view);
2576 for (row = 0; row < n_rows; row++)
2579 * Pass NULL as the child object, 4th argument.
2581 g_signal_emit_by_name (atk_obj, "children_changed::remove",
2582 ((row * n_cols) + column_count), NULL, NULL);
2587 /* rebuild the array */
2589 g_array_free (gailview->col_data, TRUE);
2590 gailview->col_data = g_array_sized_new (FALSE, TRUE,
2591 sizeof(GtkTreeViewColumn *), 0);
2593 for (tmp_list = tv_cols; tmp_list; tmp_list = tmp_list->next)
2594 g_array_append_val (gailview->col_data, tmp_list->data);
2595 g_list_free (tv_cols);
2599 cursor_changed (GtkTreeView *tree_view)
2601 GailTreeView *gailview;
2603 gailview = GAIL_TREE_VIEW (gtk_widget_get_accessible (GTK_WIDGET (tree_view)));
2604 if (gailview->idle_cursor_changed_id != 0)
2608 * We notify the focus change in a idle handler so that the processing
2609 * of the cursor change is completed when the focus handler is called.
2610 * This will allow actions to be called in the focus handler
2612 gailview->idle_cursor_changed_id = gdk_threads_add_idle (idle_cursor_changed, gailview);
2616 idle_cursor_changed (gpointer data)
2618 GailTreeView *gail_tree_view = GAIL_TREE_VIEW (data);
2619 GtkTreeView *tree_view;
2623 gail_tree_view->idle_cursor_changed_id = 0;
2625 widget = GTK_ACCESSIBLE (gail_tree_view)->widget;
2627 * Widget has been deleted
2632 tree_view = GTK_TREE_VIEW (widget);
2634 cell = gail_tree_view_ref_focus_cell (tree_view);
2637 if (cell != gail_tree_view->focus_cell)
2639 if (gail_tree_view->focus_cell)
2641 gail_cell_remove_state (GAIL_CELL (gail_tree_view->focus_cell), ATK_STATE_ACTIVE, FALSE);
2642 gail_cell_remove_state (GAIL_CELL (gail_tree_view->focus_cell), ATK_STATE_FOCUSED, FALSE);
2643 g_object_unref (gail_tree_view->focus_cell);
2645 gail_tree_view->focus_cell = cell;
2647 if (GTK_WIDGET_HAS_FOCUS (widget))
2649 gail_cell_add_state (GAIL_CELL (cell), ATK_STATE_ACTIVE, FALSE);
2650 gail_cell_add_state (GAIL_CELL (cell), ATK_STATE_FOCUSED, FALSE);
2652 g_signal_emit_by_name (gail_tree_view,
2653 "active-descendant-changed",
2657 g_object_unref (cell);
2664 focus_in (GtkWidget *widget)
2666 GtkTreeView *tree_view;
2667 GailTreeView *gail_tree_view;
2668 AtkStateSet *state_set;
2671 tree_view = GTK_TREE_VIEW (widget);
2672 gail_tree_view = GAIL_TREE_VIEW (gtk_widget_get_accessible (widget));
2674 if (gail_tree_view->focus_cell == NULL)
2676 cell = gail_tree_view_ref_focus_cell (tree_view);
2679 state_set = atk_object_ref_state_set (cell);
2682 if (!atk_state_set_contains_state (state_set, ATK_STATE_FOCUSED))
2684 gail_cell_add_state (GAIL_CELL (cell), ATK_STATE_ACTIVE, FALSE);
2685 gail_tree_view->focus_cell = cell;
2686 gail_cell_add_state (GAIL_CELL (cell), ATK_STATE_FOCUSED, FALSE);
2687 g_signal_emit_by_name (gail_tree_view,
2688 "active-descendant-changed",
2691 g_object_unref (state_set);
2698 focus_out (GtkWidget *widget)
2700 GailTreeView *gail_tree_view;
2702 gail_tree_view = GAIL_TREE_VIEW (gtk_widget_get_accessible (widget));
2703 if (gail_tree_view->focus_cell)
2705 gail_cell_remove_state (GAIL_CELL (gail_tree_view->focus_cell), ATK_STATE_ACTIVE, FALSE);
2706 gail_cell_remove_state (GAIL_CELL (gail_tree_view->focus_cell), ATK_STATE_FOCUSED, FALSE);
2707 g_object_unref (gail_tree_view->focus_cell);
2708 gail_tree_view->focus_cell = NULL;
2713 model_row_changed (GtkTreeModel *tree_model,
2718 GtkTreeView *tree_view = GTK_TREE_VIEW(user_data);
2719 GailTreeView *gailview;
2720 GtkTreePath *cell_path;
2722 GailTreeViewCellInfo *cell_info;
2724 gailview = GAIL_TREE_VIEW (gtk_widget_get_accessible (GTK_WIDGET (tree_view)));
2726 /* Loop through our cached cells */
2727 /* Must loop through them all */
2728 for (l = gailview->cell_data; l; l = l->next)
2730 cell_info = (GailTreeViewCellInfo *) l->data;
2731 if (cell_info->in_use)
2733 cell_path = gtk_tree_row_reference_get_path (cell_info->cell_row_ref);
2735 if (cell_path != NULL)
2737 if (path && gtk_tree_path_compare (cell_path, path) == 0)
2739 if (GAIL_IS_RENDERER_CELL (cell_info->cell))
2741 update_cell_value (GAIL_RENDERER_CELL (cell_info->cell),
2745 gtk_tree_path_free (cell_path);
2749 g_signal_emit_by_name (gailview, "visible-data-changed");
2753 column_visibility_changed (GObject *object,
2757 if (strcmp (pspec->name, "visible") == 0)
2760 * A column has been made visible or invisible
2762 * We update our cache of cells and emit model_changed signal
2764 GtkTreeView *tree_view = (GtkTreeView *)user_data;
2765 GailTreeView *gailview;
2767 GailTreeViewCellInfo *cell_info;
2768 GtkTreeViewColumn *this_col = GTK_TREE_VIEW_COLUMN (object);
2769 GtkTreeViewColumn *tv_col;
2771 gailview = GAIL_TREE_VIEW (gtk_widget_get_accessible (GTK_WIDGET (tree_view))
2773 g_signal_emit_by_name (gailview, "model_changed");
2775 for (l = gailview->cell_data; l; l = l->next)
2777 cell_info = (GailTreeViewCellInfo *) l->data;
2778 if (cell_info->in_use)
2780 tv_col = cell_info->cell_col_ref;
2781 if (tv_col == this_col)
2783 GtkTreePath *row_path;
2784 row_path = gtk_tree_row_reference_get_path (cell_info->cell_row_ref);
2785 if (GAIL_IS_RENDERER_CELL (cell_info->cell))
2787 if (gtk_tree_view_column_get_visible (tv_col))
2788 set_cell_visibility (tree_view,
2790 tv_col, row_path, FALSE);
2793 gail_cell_remove_state (cell_info->cell,
2794 ATK_STATE_VISIBLE, TRUE);
2795 gail_cell_remove_state (cell_info->cell,
2796 ATK_STATE_SHOWING, TRUE);
2799 gtk_tree_path_free (row_path);
2807 * This is the signal handler for the "destroy" signal for a GtkTreeViewColumn
2809 * We check whether we have stored column description or column header
2810 * and if so we get rid of it.
2813 column_destroy (GtkObject *obj)
2815 GtkTreeViewColumn *tv_col = GTK_TREE_VIEW_COLUMN (obj);
2819 header = g_object_get_qdata (G_OBJECT (tv_col),
2820 quark_column_header_object);
2822 g_object_unref (header);
2823 desc = g_object_get_qdata (G_OBJECT (tv_col),
2824 quark_column_desc_object);
2829 model_row_inserted (GtkTreeModel *tree_model,
2834 GtkTreeView *tree_view = (GtkTreeView *)user_data;
2835 GtkTreePath *path_copy;
2836 AtkObject *atk_obj = gtk_widget_get_accessible (GTK_WIDGET (tree_view));
2837 GailTreeView *gailview = GAIL_TREE_VIEW (atk_obj);
2838 gint row, n_inserted, child_row;
2840 if (gailview->idle_expand_id)
2842 g_source_remove (gailview->idle_expand_id);
2843 gailview->idle_expand_id = 0;
2845 /* don't do this if the insertion precedes the idle path, since it will now be invalid */
2846 if (path && gailview->idle_expand_path &&
2847 (gtk_tree_path_compare (path, gailview->idle_expand_path) > 0))
2848 set_expand_state (tree_view, tree_model, gailview, gailview->idle_expand_path, FALSE);
2849 if (gailview->idle_expand_path)
2850 gtk_tree_path_free (gailview->idle_expand_path);
2852 /* Check to see if row is visible */
2853 row = get_row_from_tree_path (tree_view, path);
2856 * A row insert is not necessarily visible. For example,
2857 * a row can be draged & dropped into another row, which
2858 * causes an insert on the model that isn't visible in the
2859 * view. Only generate a signal if the inserted row is
2867 gtk_tree_model_get_iter (tree_model, &iter, path);
2869 /* Figure out number of visible children. */
2870 if (gtk_tree_model_iter_has_child (tree_model, &iter))
2873 * By passing path into this function, we find the number of
2874 * visible children of path.
2877 iterate_thru_children (tree_view, tree_model,
2878 path, NULL, &n_inserted, 0);
2880 /* Must add one to include the row that is being added */
2886 /* Set rows below the inserted row to ATK_STATE_STALE */
2887 traverse_cells (gailview, path, TRUE, TRUE);
2889 /* Generate row-inserted signal */
2890 g_signal_emit_by_name (atk_obj, "row_inserted", row, n_inserted);
2892 /* Generate children-changed signals */
2893 n_cols = gail_tree_view_get_n_columns (ATK_TABLE (atk_obj));
2894 for (child_row = row; child_row < (row + n_inserted); child_row++)
2896 for (col = 0; col < n_cols; col++)
2899 * Pass NULL as the child object, i.e. 4th argument
2901 g_signal_emit_by_name (atk_obj, "children_changed::add",
2902 ((row * n_cols) + col), NULL, NULL);
2909 * The row has been inserted inside another row. This can
2910 * cause a row that previously couldn't be expanded to now
2913 path_copy = gtk_tree_path_copy (path);
2914 gtk_tree_path_up (path_copy);
2915 set_expand_state (tree_view, tree_model, gailview, path_copy, TRUE);
2916 gtk_tree_path_free (path_copy);
2921 model_row_deleted (GtkTreeModel *tree_model,
2925 GtkTreeView *tree_view;
2926 GtkTreePath *path_copy;
2928 GailTreeView *gailview;
2929 gint row, col, n_cols;
2931 tree_view = (GtkTreeView *)user_data;
2932 atk_obj = gtk_widget_get_accessible (GTK_WIDGET (tree_view));
2933 gailview = GAIL_TREE_VIEW (atk_obj);
2935 if (gailview->idle_expand_id)
2937 g_source_remove (gailview->idle_expand_id);
2938 gtk_tree_path_free (gailview->idle_expand_path);
2939 gailview->idle_expand_id = 0;
2941 /* Check to see if row is visible */
2942 clean_rows (gailview);
2944 /* Set rows at or below the specified row to ATK_STATE_STALE */
2945 traverse_cells (gailview, path, TRUE, TRUE);
2948 * If deleting a row with a depth > 1, then this may affect the
2949 * expansion/contraction of its parent(s). Make sure this is
2952 if (gtk_tree_path_get_depth (path) > 1)
2954 path_copy = gtk_tree_path_copy (path);
2955 gtk_tree_path_up (path_copy);
2956 set_expand_state (tree_view, tree_model, gailview, path_copy, TRUE);
2957 gtk_tree_path_free (path_copy);
2959 row = get_row_from_tree_path (tree_view, path);
2961 * If the row which is deleted is not visible because it is a child of
2962 * a collapsed row then row will be -1
2965 g_signal_emit_by_name (atk_obj, "row_deleted", row,
2966 gailview->n_children_deleted + 1);
2967 gailview->n_children_deleted = 0;
2969 /* Generate children-changed signals */
2970 n_cols = get_n_actual_columns (tree_view);
2971 for (col = 0; col < n_cols; col++)
2974 * Pass NULL as the child object, 4th argument.
2976 g_signal_emit_by_name (atk_obj, "children_changed::remove",
2977 ((row * n_cols) + col), NULL, NULL);
2982 * This function gets called when a row is deleted or when rows are
2983 * removed from the view due to a collapse event. Note that the
2984 * count is the number of visible *children* of the deleted row,
2985 * so it does not include the row being deleted.
2987 * As this function is called before the rows are removed we just note the
2988 * number of rows and then deal with it when we get a notification that
2989 * rows were deleted or collapsed.
2992 destroy_count_func (GtkTreeView *tree_view,
2997 AtkObject *atk_obj = gtk_widget_get_accessible (GTK_WIDGET (tree_view));
2998 GailTreeView *gailview = GAIL_TREE_VIEW (atk_obj);
3000 gail_return_if_fail (gailview->n_children_deleted == 0);
3001 gailview->n_children_deleted = count;
3005 model_rows_reordered (GtkTreeModel *tree_model,
3011 GtkTreeView *tree_view = (GtkTreeView *)user_data;
3012 AtkObject *atk_obj = gtk_widget_get_accessible (GTK_WIDGET (tree_view));
3013 GailTreeView *gailview = GAIL_TREE_VIEW (atk_obj);
3015 if (gailview->idle_expand_id)
3017 g_source_remove (gailview->idle_expand_id);
3018 gtk_tree_path_free (gailview->idle_expand_path);
3019 gailview->idle_expand_id = 0;
3021 traverse_cells (gailview, NULL, TRUE, FALSE);
3023 g_signal_emit_by_name (atk_obj, "row_reordered");
3027 adjustment_changed (GtkAdjustment *adjustment,
3028 GtkTreeView *tree_view)
3034 * The scrollbars have changed
3036 atk_obj = gtk_widget_get_accessible (GTK_WIDGET (tree_view));
3037 obj = GAIL_TREE_VIEW (atk_obj);
3039 traverse_cells (obj, NULL, FALSE, FALSE);
3043 set_cell_visibility (GtkTreeView *tree_view,
3045 GtkTreeViewColumn *tv_col,
3046 GtkTreePath *tree_path,
3047 gboolean emit_signal)
3049 GdkRectangle cell_rect;
3051 /* Get these three values in tree coords */
3052 if (GTK_WIDGET_REALIZED (GTK_WIDGET (tree_view)))
3053 gtk_tree_view_get_cell_area (tree_view, tree_path, tv_col, &cell_rect);
3055 cell_rect.height = 0;
3057 if (cell_rect.height > 0)
3060 * The height will be zero for a cell for which an antecedent is not
3063 gail_cell_add_state (cell, ATK_STATE_VISIBLE, emit_signal);
3064 if (is_cell_showing (tree_view, &cell_rect))
3065 gail_cell_add_state (cell, ATK_STATE_SHOWING, emit_signal);
3067 gail_cell_remove_state (cell, ATK_STATE_SHOWING, emit_signal);
3071 gail_cell_remove_state (cell, ATK_STATE_VISIBLE, emit_signal);
3072 gail_cell_remove_state (cell, ATK_STATE_SHOWING, emit_signal);
3077 is_cell_showing (GtkTreeView *tree_view,
3078 GdkRectangle *cell_rect)
3080 GdkRectangle rect, *visible_rect;
3081 GdkRectangle rect1, *tree_cell_rect;
3083 gboolean is_showing;
3085 * A cell is considered "SHOWING" if any part of the cell is in the visible
3086 * area. Other ways we could do this is by a cell's midpoint or if the cell
3087 * is fully in the visible range. Since we have the cell_rect x,y,width,height
3088 * of the cell, any of these is easy to compute.
3090 * It is assumed that cell's rectangle is in widget coordinates so we
3091 * must transform to tree cordinates.
3093 visible_rect = ▭
3094 tree_cell_rect = &rect1;
3095 tree_cell_rect->x = cell_rect->x;
3096 tree_cell_rect->y = cell_rect->y;
3097 tree_cell_rect->width = cell_rect->width;
3098 tree_cell_rect->height = cell_rect->height;
3100 gtk_tree_view_get_visible_rect (tree_view, visible_rect);
3101 gtk_tree_view_convert_tree_to_bin_window_coords (tree_view, visible_rect->x,
3102 visible_rect->y, &bx, &by);
3104 if (((tree_cell_rect->x + tree_cell_rect->width) < bx) ||
3105 ((tree_cell_rect->y + tree_cell_rect->height) < by) ||
3106 (tree_cell_rect->x > (bx + visible_rect->width)) ||
3107 (tree_cell_rect->y > (by + visible_rect->height)))
3118 * This function is called when a cell's flyweight is created in
3119 * gail_tree_view_table_ref_at with emit_change_signal set to FALSE
3120 * and in model_row_changed() on receipt of "row-changed" signal when
3121 * emit_change_signal is set to TRUE
3124 update_cell_value (GailRendererCell *renderer_cell,
3125 GailTreeView *gailview,
3126 gboolean emit_change_signal)
3128 GailTreeViewCellInfo *cell_info;
3129 GtkTreeView *tree_view;
3130 GtkTreeModel *tree_model;
3133 GList *renderers, *cur_renderer;
3135 GailRendererCellClass *gail_renderer_cell_class;
3136 GtkCellRendererClass *gtk_cell_renderer_class;
3140 gboolean is_expander, is_expanded;
3142 gail_renderer_cell_class = GAIL_RENDERER_CELL_GET_CLASS (renderer_cell);
3143 if (renderer_cell->renderer)
3144 gtk_cell_renderer_class = GTK_CELL_RENDERER_GET_CLASS (renderer_cell->renderer);
3146 gtk_cell_renderer_class = NULL;
3148 prop_list = gail_renderer_cell_class->property_list;
3150 cell = GAIL_CELL (renderer_cell);
3151 cell_info = find_cell_info (gailview, cell, NULL, TRUE);
3152 gail_return_val_if_fail (cell_info, FALSE);
3153 gail_return_val_if_fail (cell_info->cell_col_ref, FALSE);
3154 gail_return_val_if_fail (cell_info->cell_row_ref, FALSE);
3156 if (emit_change_signal && cell_info->in_use)
3158 tree_view = GTK_TREE_VIEW (GTK_ACCESSIBLE (gailview)->widget);
3159 tree_model = gtk_tree_view_get_model (tree_view);
3160 path = gtk_tree_row_reference_get_path (cell_info->cell_row_ref);
3164 gtk_tree_model_get_iter (tree_model, &iter, path);
3165 is_expander = FALSE;
3166 is_expanded = FALSE;
3167 if (gtk_tree_model_iter_has_child (tree_model, &iter))
3169 GtkTreeViewColumn *expander_tv;
3171 expander_tv = gtk_tree_view_get_expander_column (tree_view);
3172 if (expander_tv == cell_info->cell_col_ref)
3175 is_expanded = gtk_tree_view_row_expanded (tree_view, path);
3178 gtk_tree_path_free (path);
3179 gtk_tree_view_column_cell_set_cell_data (cell_info->cell_col_ref,
3180 tree_model, &iter, is_expander, is_expanded);
3182 renderers = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (cell_info->cell_col_ref));
3183 gail_return_val_if_fail (renderers, FALSE);
3186 * If the cell is in a container, it's index is used to find the renderer
3191 * Otherwise, we assume that the cell is represented by the first renderer
3195 if (cell_info->in_use) {
3196 parent = atk_object_get_parent (ATK_OBJECT (cell));
3197 if (!ATK_IS_OBJECT (cell)) g_on_error_query (NULL);
3198 if (GAIL_IS_CONTAINER_CELL (parent))
3199 cur_renderer = g_list_nth (renderers, cell->index);
3201 cur_renderer = renderers;
3207 gail_return_val_if_fail (cur_renderer != NULL, FALSE);
3209 if (gtk_cell_renderer_class)
3213 spec = g_object_class_find_property
3214 (G_OBJECT_CLASS (gtk_cell_renderer_class), *prop_list);
3218 GValue value = { 0, };
3220 g_value_init (&value, spec->value_type);
3221 g_object_get_property (cur_renderer->data, *prop_list, &value);
3222 g_object_set_property (G_OBJECT (renderer_cell->renderer),
3223 *prop_list, &value);
3224 g_value_unset(&value);
3227 g_warning ("Invalid property: %s\n", *prop_list);
3231 g_list_free (renderers);
3232 return gail_renderer_cell_update_cache (renderer_cell, emit_change_signal);
3236 set_iter_nth_row (GtkTreeView *tree_view,
3240 GtkTreeModel *tree_model;
3242 tree_model = gtk_tree_view_get_model (tree_view);
3243 gtk_tree_model_get_iter_first (tree_model, iter);
3244 iter = return_iter_nth_row (tree_view, tree_model, iter, 0 , row);
3248 get_row_from_tree_path (GtkTreeView *tree_view,
3251 GtkTreeModel *tree_model;
3252 GtkTreePath *root_tree;
3255 tree_model = gtk_tree_view_get_model (tree_view);
3257 if (gtk_tree_model_get_flags (tree_model) & GTK_TREE_MODEL_LIST_ONLY)
3258 row = gtk_tree_path_get_indices (path)[0];
3261 root_tree = gtk_tree_path_new_first ();
3263 iterate_thru_children (tree_view, tree_model, root_tree, path, &row, 0);
3264 gtk_tree_path_free (root_tree);
3273 * Get the specified GtkTreeViewColumn in the GtkTreeView.
3274 * Only visible columns are considered.
3276 static GtkTreeViewColumn*
3277 get_column (GtkTreeView *tree_view,
3280 GtkTreeViewColumn *tv_col;
3286 g_warning ("Request for invalid column %d\n", in_col);
3290 tv_col = gtk_tree_view_get_column (tree_view, i);
3292 while (tv_col != NULL)
3294 if (gtk_tree_view_column_get_visible (tv_col))
3296 if (in_col == n_cols)
3298 tv_col = gtk_tree_view_get_column (tree_view, ++i);
3301 if (in_col != n_cols)
3303 g_warning ("Request for invalid column %d\n", in_col);
3310 get_actual_column_number (GtkTreeView *tree_view,
3311 gint visible_column)
3313 GtkTreeViewColumn *tv_col;
3314 gint actual_column = 0;
3315 gint visible_columns = -1;
3317 * This function calculates the column number which corresponds to the
3318 * specified visible column number
3320 tv_col = gtk_tree_view_get_column (tree_view, actual_column);
3322 while (tv_col != NULL)
3324 if (gtk_tree_view_column_get_visible (tv_col))
3326 if (visible_columns == visible_column)
3327 return actual_column;
3328 tv_col = gtk_tree_view_get_column (tree_view, ++actual_column);
3330 g_warning ("get_actual_column_number failed for %d\n", visible_column);
3335 get_visible_column_number (GtkTreeView *tree_view,
3338 GtkTreeViewColumn *tv_col;
3340 gint visible_columns = -1;
3342 * This function calculates the visible column number which corresponds to the
3343 * specified actual column number
3345 tv_col = gtk_tree_view_get_column (tree_view, column);
3347 while (tv_col != NULL)
3349 if (gtk_tree_view_column_get_visible (tv_col))
3352 if (actual_column == column)
3353 return visible_columns;
3356 if (actual_column == column)
3358 tv_col = gtk_tree_view_get_column (tree_view, ++column);
3360 g_warning ("get_visible_column_number failed for %d\n", actual_column);
3365 * Helper recursive function that returns GtkTreeIter pointer to nth row.
3368 return_iter_nth_row(GtkTreeView *tree_view,
3369 GtkTreeModel *tree_model,
3374 GtkTreePath *current_path = gtk_tree_model_get_path (tree_model, iter);
3375 GtkTreeIter new_iter;
3376 gboolean row_expanded;
3378 if (increment == row) {
3379 gtk_tree_path_free (current_path);
3383 row_expanded = gtk_tree_view_row_expanded (tree_view, current_path);
3384 gtk_tree_path_free (current_path);
3387 if ((row_expanded && gtk_tree_model_iter_children (tree_model, iter, &new_iter)) ||
3388 (gtk_tree_model_iter_next (tree_model, iter)) ||
3389 (gtk_tree_model_iter_parent (tree_model, iter, &new_iter) &&
3390 (gtk_tree_model_iter_next (tree_model, iter))))
3391 return return_iter_nth_row (tree_view, tree_model, iter,
3398 * Recursively called until the row specified by orig is found.
3400 * *count will be set to the visible row number of the child
3401 * relative to the row that was initially passed in as tree_path.
3403 * *count will be -1 if orig is not found as a child (a row that is
3404 * not visible will not be found, e.g. if the row is inside a
3405 * collapsed row). If NULL is passed in as orig, *count will
3406 * be a count of the visible children.
3408 * NOTE: the value for depth must be 0 when this recursive function
3409 * is initially called, or it may not function as expected.
3412 iterate_thru_children(GtkTreeView *tree_view,
3413 GtkTreeModel *tree_model,
3414 GtkTreePath *tree_path,
3421 if (!gtk_tree_model_get_iter (tree_model, &iter, tree_path))
3424 if (tree_path && orig && !gtk_tree_path_compare (tree_path, orig))
3428 if (tree_path && orig && gtk_tree_path_compare (tree_path, orig) > 0)
3430 /* Past it, so return -1 */
3434 else if (gtk_tree_view_row_expanded (tree_view, tree_path) &&
3435 gtk_tree_model_iter_has_child (tree_model, &iter))
3438 gtk_tree_path_append_index (tree_path, 0);
3439 iterate_thru_children (tree_view, tree_model, tree_path,
3440 orig, count, (depth + 1));
3443 else if (gtk_tree_model_iter_next (tree_model, &iter))
3446 tree_path = gtk_tree_model_get_path (tree_model, &iter);
3449 iterate_thru_children (tree_view, tree_model, tree_path,
3450 orig, count, depth);
3451 gtk_tree_path_free (tree_path);
3455 else if (gtk_tree_path_up (tree_path))
3457 GtkTreeIter temp_iter;
3458 gboolean exit_loop = FALSE;
3459 gint new_depth = depth - 1;
3464 * Make sure that we back up until we find a row
3465 * where gtk_tree_path_next does not return NULL.
3469 if (gtk_tree_path_get_depth (tree_path) == 0)
3470 /* depth is now zero so */
3472 gtk_tree_path_next (tree_path);
3474 /* Verify that the next row is a valid row! */
3475 exit_loop = gtk_tree_model_get_iter (tree_model, &temp_iter, tree_path);
3479 /* Keep going up until we find a row that has a valid next */
3480 if (gtk_tree_path_get_depth(tree_path) > 1)
3483 gtk_tree_path_up (tree_path);
3488 * If depth is 1 and gtk_tree_model_get_iter returns FALSE,
3489 * then we are at the last row, so just return.
3500 * This guarantees that we will stop when we hit the end of the
3506 iterate_thru_children (tree_view, tree_model, tree_path,
3507 orig, count, new_depth);
3512 * If it gets here, then the path wasn't found. Situations
3513 * that would cause this would be if the path passed in is
3514 * invalid or contained within the last row, but not visible
3515 * because the last row is not expanded. If NULL was passed
3516 * in then a row count is desired, so only set count to -1
3517 * if orig is not NULL.
3526 clean_cell_info (GailTreeView *gailview,
3529 GailTreeViewCellInfo *cell_info;
3532 g_assert (GAIL_IS_TREE_VIEW (gailview));
3534 cell_info = list->data;
3536 if (cell_info->in_use) {
3537 obj = G_OBJECT (cell_info->cell);
3539 gail_cell_add_state (cell_info->cell, ATK_STATE_DEFUNCT, FALSE);
3540 g_object_weak_unref (obj, (GWeakNotify) cell_destroyed, cell_info);
3541 cell_info->in_use = FALSE;
3542 if (!gailview->garbage_collection_pending) {
3543 gailview->garbage_collection_pending = TRUE;
3544 g_assert (gailview->idle_garbage_collect_id == 0);
3545 gailview->idle_garbage_collect_id =
3546 gdk_threads_add_idle (idle_garbage_collect_cell_data, gailview);
3552 clean_rows (GailTreeView *gailview)
3556 /* Clean GailTreeViewRowInfo data */
3558 array = gailview->row_data;
3561 GailTreeViewRowInfo *row_info;
3562 GtkTreePath *row_path;
3566 * Loop backwards so that calls to free_row_info
3567 * do not affect the index numbers
3569 for (i = (array->len - 1); i >= 0; i --)
3571 row_info = g_array_index (array, GailTreeViewRowInfo*, i);
3572 row_path = gtk_tree_row_reference_get_path (row_info->row_ref);
3574 /* Remove any rows that have become invalid */
3575 if (row_path == NULL)
3576 free_row_info (array, i, TRUE);
3578 gtk_tree_path_free (row_path);
3582 /* Clean GailTreeViewCellInfo data */
3584 if (gailview->cell_data != NULL)
3586 GailTreeViewCellInfo *cell_info;
3587 GtkTreePath *row_path;
3591 temp_list = gailview->cell_data;
3593 /* Must loop through them all */
3594 while (temp_list != NULL)
3596 cur_list = temp_list;
3597 cell_info = temp_list->data;
3598 temp_list = temp_list->next;
3599 row_path = gtk_tree_row_reference_get_path (cell_info->cell_row_ref);
3602 * If the cell has become invalid because the row has been removed,
3603 * then set the cell's state to ATK_STATE_DEFUNCT and remove the cell
3604 * from gailview->cell_data. If row_path is NULL then the row has
3607 if (row_path == NULL)
3609 clean_cell_info (gailview, cur_list);
3613 gtk_tree_path_free (row_path);
3620 clean_cols (GailTreeView *gailview,
3621 GtkTreeViewColumn *tv_col)
3623 /* Clean GailTreeViewCellInfo data */
3625 if (gailview->cell_data != NULL)
3627 GailTreeViewCellInfo *cell_info;
3628 GList *cur_list, *temp_list;
3630 temp_list = gailview->cell_data;
3632 while (temp_list != NULL)
3634 cur_list = temp_list;
3635 cell_info = temp_list->data;
3636 temp_list = temp_list->next;
3639 * If the cell has become invalid because the column tv_col
3640 * has been removed, then set the cell's state to ATK_STATE_DEFUNCT
3641 * and remove the cell from gailview->cell_data.
3643 if (cell_info->cell_col_ref == tv_col)
3645 clean_cell_info (gailview, cur_list);
3652 idle_garbage_collect_cell_data (gpointer data)
3654 GailTreeView *tree_view;
3656 g_assert (GAIL_IS_TREE_VIEW (data));
3657 tree_view = (GailTreeView *)data;
3659 /* this is the idle handler (only one instance allowed), so
3660 * we can safely delete it.
3662 tree_view->garbage_collection_pending = FALSE;
3663 tree_view->idle_garbage_collect_id = 0;
3665 tree_view->garbage_collection_pending = garbage_collect_cell_data (data);
3667 /* N.B.: if for some reason another handler has re-enterantly been queued
3668 * while this handler was being serviced, it has its own gsource, therefore this handler
3669 * should always return FALSE.
3675 garbage_collect_cell_data (gpointer data)
3677 GailTreeView *tree_view;
3678 GList *temp_list, *list;
3679 GailTreeViewCellInfo *cell_info;
3681 g_assert (GAIL_IS_TREE_VIEW (data));
3682 tree_view = (GailTreeView *)data;
3683 list = g_list_copy (tree_view->cell_data);
3685 tree_view->garbage_collection_pending = FALSE;
3686 if (tree_view->idle_garbage_collect_id != 0)
3688 g_source_remove (tree_view->idle_garbage_collect_id);
3689 tree_view->idle_garbage_collect_id = 0;
3692 /* Must loop through them all */
3694 while (temp_list != NULL)
3696 cell_info = temp_list->data;
3697 if (!cell_info->in_use)
3699 /* g_object_unref (cell_info->cell); */
3700 tree_view->cell_data = g_list_remove (tree_view->cell_data,
3702 if (cell_info->cell_row_ref)
3703 gtk_tree_row_reference_free (cell_info->cell_row_ref);
3706 temp_list = temp_list->next;
3710 return tree_view->garbage_collection_pending;
3714 * If tree_path is passed in as NULL, then all cells are acted on.
3715 * Otherwise, just act on those cells that are on a row greater than
3716 * the specified tree_path. If inc_row is passed in as TRUE, then rows
3717 * greater and equal to the specified tree_path are acted on.
3719 * if set_stale is set the ATK_STATE_STALE is set on cells which are to be
3722 * The function set_cell_visibility() is called on all cells to be
3723 * acted on to update the visibility of the cell.
3726 traverse_cells (GailTreeView *tree_view,
3727 GtkTreePath *tree_path,
3731 if (tree_view->cell_data != NULL)
3733 GailTreeViewCellInfo *cell_info;
3734 GtkTreeView *gtk_tree_view;
3738 g_assert (GTK_IS_ACCESSIBLE (tree_view));
3740 widget = GTK_ACCESSIBLE (tree_view)->widget;
3742 /* Widget is being deleted */
3745 gtk_tree_view = GTK_TREE_VIEW (widget);
3746 temp_list = tree_view->cell_data;
3748 /* Must loop through them all */
3749 while (temp_list != NULL)
3751 GtkTreePath *row_path;
3752 gboolean act_on_cell;
3754 cell_info = temp_list->data;
3755 temp_list = temp_list->next;
3757 if (cell_info->in_use)
3759 row_path = gtk_tree_row_reference_get_path (cell_info->cell_row_ref);
3760 g_return_if_fail (row_path != NULL);
3761 if (tree_path == NULL)
3767 comparison = gtk_tree_path_compare (row_path, tree_path);
3768 if ((comparison > 0) ||
3769 (comparison == 0 && inc_row))
3772 act_on_cell = FALSE;
3774 if (!cell_info->in_use) g_warning ("warning: cell info destroyed during traversal");
3775 if (act_on_cell && cell_info->in_use)
3778 gail_cell_add_state (cell_info->cell, ATK_STATE_STALE, TRUE);
3779 set_cell_visibility (gtk_tree_view,
3781 cell_info->cell_col_ref,
3784 gtk_tree_path_free (row_path);
3788 g_signal_emit_by_name (tree_view, "visible-data-changed");
3792 free_row_info (GArray *array,
3796 GailTreeViewRowInfo* obj;
3798 obj = g_array_index (array, GailTreeViewRowInfo*, array_idx);
3800 g_free (obj->description);
3801 if (obj->row_ref != NULL)
3802 gtk_tree_row_reference_free (obj->row_ref);
3804 g_object_unref (obj->header);
3808 g_array_remove_index (array, array_idx);
3812 * If the tree_path passed in has children, then
3813 * ATK_STATE_EXPANDABLE is set. If the row is expanded
3814 * ATK_STATE_EXPANDED is turned on. If the row is
3815 * collapsed, then ATK_STATE_EXPANDED is removed.
3817 * If the tree_path passed in has no children, then
3818 * ATK_STATE_EXPANDABLE and ATK_STATE_EXPANDED are removed.
3820 * If set_on_ancestor is TRUE, then this function will also
3821 * update all cells that are ancestors of the tree_path.
3824 set_expand_state (GtkTreeView *tree_view,
3825 GtkTreeModel *tree_model,
3826 GailTreeView *gailview,
3827 GtkTreePath *tree_path,
3828 gboolean set_on_ancestor)
3830 if (gailview->cell_data != NULL)
3832 GtkTreeViewColumn *expander_tv;
3833 GailTreeViewCellInfo *cell_info;
3835 GtkTreePath *cell_path;
3839 temp_list = gailview->cell_data;
3841 while (temp_list != NULL)
3843 cell_info = temp_list->data;
3844 temp_list = temp_list->next;
3845 if (cell_info->in_use)
3847 cell_path = gtk_tree_row_reference_get_path (cell_info->cell_row_ref);
3850 if (cell_path != NULL)
3852 GailCell *cell = GAIL_CELL (cell_info->cell);
3854 expander_tv = gtk_tree_view_get_expander_column (tree_view);
3857 * Only set state for the cell that is in the column with the
3860 if (expander_tv == cell_info->cell_col_ref)
3862 if (tree_path && gtk_tree_path_compare (cell_path, tree_path) == 0)
3864 else if (set_on_ancestor &&
3865 gtk_tree_path_get_depth (cell_path) <
3866 gtk_tree_path_get_depth (tree_path) &&
3867 gtk_tree_path_is_ancestor (cell_path, tree_path) == 1)
3868 /* Only set if set_on_ancestor was passed in as TRUE */
3873 * Set ATK_STATE_EXPANDABLE and ATK_STATE_EXPANDED
3874 * for ancestors and found cells.
3879 * Must check against cell_path since cell_path
3880 * can be equal to or an ancestor of tree_path.
3882 gtk_tree_model_get_iter (tree_model, &iter, cell_path);
3884 /* Set or unset ATK_STATE_EXPANDABLE as appropriate */
3885 if (gtk_tree_model_iter_has_child (tree_model, &iter))
3887 set_cell_expandable (cell);
3889 if (gtk_tree_view_row_expanded (tree_view, cell_path))
3890 gail_cell_add_state (cell, ATK_STATE_EXPANDED, TRUE);
3892 gail_cell_remove_state (cell,
3893 ATK_STATE_EXPANDED, TRUE);
3897 gail_cell_remove_state (cell,
3898 ATK_STATE_EXPANDED, TRUE);
3899 if (gail_cell_remove_state (cell,
3900 ATK_STATE_EXPANDABLE, TRUE))
3901 /* The state may have been propagated to the container cell */
3902 if (!GAIL_IS_CONTAINER_CELL (cell))
3903 gail_cell_remove_action_by_name (cell,
3904 "expand or contract");
3908 * We assume that each cell in the cache once and
3909 * a container cell is before its child cells so we are
3910 * finished if set_on_ancestor is not set to TRUE.
3912 if (!set_on_ancestor)
3916 gtk_tree_path_free (cell_path);
3924 add_cell_actions (GailCell *cell,
3927 if (GAIL_IS_BOOLEAN_CELL (cell))
3928 gail_cell_add_action (cell,
3930 "toggles the cell", /* action description */
3932 toggle_cell_toggled);
3934 gail_cell_add_action (cell,
3936 "creates a widget in which the contents of the cell can be edited",
3939 gail_cell_add_action (cell,
3941 "activate the cell",
3947 toggle_cell_expanded (GailCell *cell)
3949 GailTreeViewCellInfo *cell_info;
3950 GtkTreeView *tree_view;
3953 AtkStateSet *stateset;
3955 parent = atk_object_get_parent (ATK_OBJECT (cell));
3956 if (GAIL_IS_CONTAINER_CELL (parent))
3957 parent = atk_object_get_parent (parent);
3959 cell_info = find_cell_info (GAIL_TREE_VIEW (parent), cell, NULL, TRUE);
3960 gail_return_if_fail (cell_info);
3961 gail_return_if_fail (cell_info->cell_col_ref);
3962 gail_return_if_fail (cell_info->cell_row_ref);
3964 tree_view = GTK_TREE_VIEW (GTK_ACCESSIBLE (parent)->widget);
3965 path = gtk_tree_row_reference_get_path (cell_info->cell_row_ref);
3966 gail_return_if_fail (path);
3968 stateset = atk_object_ref_state_set (ATK_OBJECT (cell));
3969 if (atk_state_set_contains_state (stateset, ATK_STATE_EXPANDED))
3970 gtk_tree_view_collapse_row (tree_view, path);
3972 gtk_tree_view_expand_row (tree_view, path, TRUE);
3973 g_object_unref (stateset);
3974 gtk_tree_path_free (path);
3979 toggle_cell_toggled (GailCell *cell)
3981 GailTreeViewCellInfo *cell_info;
3982 GtkTreeView *tree_view;
3985 GList *renderers, *cur_renderer;
3987 gboolean is_container_cell = FALSE;
3989 parent = atk_object_get_parent (ATK_OBJECT (cell));
3990 if (GAIL_IS_CONTAINER_CELL (parent))
3992 is_container_cell = TRUE;
3993 parent = atk_object_get_parent (parent);
3996 cell_info = find_cell_info (GAIL_TREE_VIEW (parent), cell, NULL, TRUE);
3997 gail_return_if_fail (cell_info);
3998 gail_return_if_fail (cell_info->cell_col_ref);
3999 gail_return_if_fail (cell_info->cell_row_ref);
4001 tree_view = GTK_TREE_VIEW (GTK_ACCESSIBLE (parent)->widget);
4002 path = gtk_tree_row_reference_get_path (cell_info->cell_row_ref);
4003 gail_return_if_fail (path);
4004 pathstring = gtk_tree_path_to_string (path);
4006 renderers = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (cell_info->cell_col_ref));
4007 gail_return_if_fail (renderers);
4010 * if the cell is in a container, it's index is used to find the
4011 * renderer in the list
4014 if (is_container_cell)
4015 cur_renderer = g_list_nth (renderers, cell->index);
4018 * Otherwise, we assume that the cell is represented by the first
4019 * renderer in the list
4021 cur_renderer = renderers;
4023 gail_return_if_fail (cur_renderer);
4025 g_signal_emit_by_name (cur_renderer->data, "toggled", pathstring);
4026 g_list_free (renderers);
4027 g_free (pathstring);
4028 gtk_tree_path_free (path);
4033 edit_cell (GailCell *cell)
4035 GailTreeViewCellInfo *cell_info;
4036 GtkTreeView *tree_view;
4039 gboolean is_container_cell = FALSE;
4042 parent = atk_object_get_parent (ATK_OBJECT (cell));
4043 if (GAIL_IS_CONTAINER_CELL (parent))
4045 is_container_cell = TRUE;
4046 parent = atk_object_get_parent (parent);
4049 cell_info = find_cell_info (GAIL_TREE_VIEW (parent), cell, NULL, TRUE);
4050 gail_return_if_fail (cell_info);
4051 gail_return_if_fail (cell_info->cell_col_ref);
4052 gail_return_if_fail (cell_info->cell_row_ref);
4054 tree_view = GTK_TREE_VIEW (GTK_ACCESSIBLE (parent)->widget);
4055 path = gtk_tree_row_reference_get_path (cell_info->cell_row_ref);
4056 gail_return_if_fail (path);
4057 gtk_tree_view_set_cursor (tree_view, path, cell_info->cell_col_ref, TRUE);
4058 gtk_tree_path_free (path);
4063 activate_cell (GailCell *cell)
4065 GailTreeViewCellInfo *cell_info;
4066 GtkTreeView *tree_view;
4069 gboolean is_container_cell = FALSE;
4072 parent = atk_object_get_parent (ATK_OBJECT (cell));
4073 if (GAIL_IS_CONTAINER_CELL (parent))
4075 is_container_cell = TRUE;
4076 parent = atk_object_get_parent (parent);
4079 cell_info = find_cell_info (GAIL_TREE_VIEW (parent), cell, NULL, TRUE);
4080 gail_return_if_fail (cell_info);
4081 gail_return_if_fail (cell_info->cell_col_ref);
4082 gail_return_if_fail (cell_info->cell_row_ref);
4084 tree_view = GTK_TREE_VIEW (GTK_ACCESSIBLE (parent)->widget);
4085 path = gtk_tree_row_reference_get_path (cell_info->cell_row_ref);
4086 gail_return_if_fail (path);
4087 gtk_tree_view_row_activated (tree_view, path, cell_info->cell_col_ref);
4088 gtk_tree_path_free (path);
4093 cell_destroyed (gpointer data)
4095 GailTreeViewCellInfo *cell_info = data;
4097 gail_return_if_fail (cell_info);
4098 if (cell_info->in_use) {
4099 cell_info->in_use = FALSE;
4101 g_assert (GAIL_IS_TREE_VIEW (cell_info->view));
4102 if (!cell_info->view->garbage_collection_pending) {
4103 cell_info->view->garbage_collection_pending = TRUE;
4104 cell_info->view->idle_garbage_collect_id =
4105 gdk_threads_add_idle (idle_garbage_collect_cell_data, cell_info->view);
4112 cell_info_remove (GailTreeView *tree_view,
4115 GailTreeViewCellInfo *info;
4118 info = find_cell_info (tree_view, cell, &temp_list, FALSE);
4121 info->in_use = FALSE;
4124 g_warning ("No cell removed in cell_info_remove\n");
4129 cell_info_get_index (GtkTreeView *tree_view,
4130 GailTreeViewCellInfo *info,
4136 path = gtk_tree_row_reference_get_path (info->cell_row_ref);
4137 gail_return_if_fail (path);
4139 column_number = get_column_number (tree_view, info->cell_col_ref, FALSE);
4140 *index = get_index (tree_view, path, column_number);
4141 gtk_tree_path_free (path);
4145 cell_info_new (GailTreeView *gailview,
4146 GtkTreeModel *tree_model,
4148 GtkTreeViewColumn *tv_col,
4151 GailTreeViewCellInfo *cell_info;
4153 g_assert (GAIL_IS_TREE_VIEW (gailview));
4155 cell_info = g_new (GailTreeViewCellInfo, 1);
4156 cell_info->cell_row_ref = gtk_tree_row_reference_new (tree_model, path);
4158 cell_info->cell_col_ref = tv_col;
4159 cell_info->cell = cell;
4160 cell_info->in_use = TRUE; /* if we've created it, assume it's in use */
4161 cell_info->view = gailview;
4162 gailview->cell_data = g_list_append (gailview->cell_data, cell_info);
4164 /* Setup weak reference notification */
4166 g_object_weak_ref (G_OBJECT (cell),
4167 (GWeakNotify) cell_destroyed,
4172 find_cell (GailTreeView *gailview,
4175 GailTreeViewCellInfo *info;
4176 GtkTreeView *tree_view;
4180 gboolean needs_cleaning = FALSE;
4181 GailCell *retval = NULL;
4183 tree_view = GTK_TREE_VIEW (GTK_ACCESSIBLE (gailview)->widget);
4184 cell_list = gailview->cell_data;
4186 for (l = cell_list; l; l = l->next)
4188 info = (GailTreeViewCellInfo *) (l->data);
4191 cell_info_get_index (tree_view, info, &real_index);
4192 if (index == real_index)
4194 retval = info->cell;
4200 needs_cleaning = TRUE;
4204 garbage_collect_cell_data (gailview);
4210 refresh_cell_index (GailCell *cell)
4212 GailTreeViewCellInfo *info;
4214 GtkTreeView *tree_view;
4217 parent = atk_object_get_parent (ATK_OBJECT (cell));
4218 gail_return_if_fail (GAIL_IS_TREE_VIEW (parent));
4220 tree_view = GTK_TREE_VIEW (GTK_ACCESSIBLE (parent)->widget);
4222 /* Find this cell in the GailTreeView's cache */
4224 info = find_cell_info (GAIL_TREE_VIEW (parent), cell, NULL, TRUE);
4225 gail_return_if_fail (info);
4227 cell_info_get_index (tree_view, info, &index);
4228 cell->index = index;
4232 get_selected_rows (GtkTreeModel *model,
4237 GPtrArray *array = (GPtrArray *)data;
4239 g_ptr_array_add (array, gtk_tree_path_copy (path));
4243 connect_model_signals (GtkTreeView *view,
4244 GailTreeView *gailview)
4248 obj = G_OBJECT (gailview->tree_model);
4249 g_signal_connect_data (obj, "row-changed",
4250 (GCallback) model_row_changed, view, NULL, 0);
4251 g_signal_connect_data (obj, "row-inserted",
4252 (GCallback) model_row_inserted, view, NULL,
4254 g_signal_connect_data (obj, "row-deleted",
4255 (GCallback) model_row_deleted, view, NULL,
4257 g_signal_connect_data (obj, "rows-reordered",
4258 (GCallback) model_rows_reordered, view, NULL,
4263 disconnect_model_signals (GailTreeView *view)
4268 obj = G_OBJECT (view->tree_model);
4269 widget = GTK_ACCESSIBLE (view)->widget;
4270 g_signal_handlers_disconnect_by_func (obj, (gpointer) model_row_changed, widget);
4271 g_signal_handlers_disconnect_by_func (obj, (gpointer) model_row_inserted, widget);
4272 g_signal_handlers_disconnect_by_func (obj, (gpointer) model_row_deleted, widget);
4273 g_signal_handlers_disconnect_by_func (obj, (gpointer) model_rows_reordered, widget);
4277 clear_cached_data (GailTreeView *view)
4283 GArray *array = view->row_data;
4287 * Since the third argument to free_row_info is FALSE, we don't remove
4288 * the element. Therefore it is safe to loop forward.
4290 for (i = 0; i < array->len; i++)
4291 free_row_info (array, i, FALSE);
4293 g_array_free (array, TRUE);
4295 view->row_data = NULL;
4298 if (view->cell_data)
4300 /* Must loop through them all */
4301 for (temp_list = view->cell_data; temp_list; temp_list = temp_list->next)
4303 clean_cell_info (view, temp_list);
4306 garbage_collect_cell_data (view);
4307 if (view->cell_data)
4308 g_list_free (view->cell_data);
4310 view->cell_data = NULL;
4314 * Returns the column number of the specified GtkTreeViewColumn
4316 * If visible is set, the value returned will be the visible column number,
4317 * i.e. suitable for use in AtkTable function. If visible is not set, the
4318 * value returned is the actual column number, which is suitable for use in
4319 * getting an index value.
4322 get_column_number (GtkTreeView *tree_view,
4323 GtkTreeViewColumn *column,
4326 GList *temp_list, *column_list;
4327 GtkTreeViewColumn *tv_column;
4330 column_list = gtk_tree_view_get_columns (tree_view);
4332 for (temp_list = column_list; temp_list; temp_list = temp_list->next)
4334 tv_column = GTK_TREE_VIEW_COLUMN (temp_list->data);
4335 if (tv_column == column)
4337 if (!visible || gtk_tree_view_column_get_visible (tv_column))
4340 if (temp_list == NULL)
4344 g_list_free (column_list);
4349 get_index (GtkTreeView *tree_view,
4355 gint *indices = NULL;
4360 depth = gtk_tree_path_get_depth (path);
4361 indices = gtk_tree_path_get_indices (path);
4366 GtkTreePath *copy_path;
4367 GtkTreeModel *model;
4369 model = gtk_tree_view_get_model (tree_view);
4370 copy_path = gtk_tree_path_copy (path);
4371 gtk_tree_path_up (copy_path);
4372 count_rows (model, NULL, copy_path, &index, 0, depth);
4373 gtk_tree_path_free (copy_path);
4377 index += indices[depth-1];
4378 index *= get_n_actual_columns (tree_view);
4379 index += actual_column;
4384 * The function count_rows counts the number of rows starting at iter and ending
4385 * at end_path. The value of level is the depth of iter and the value of depth
4386 * is the depth of end_path. Rows at depth before end_path are counted.
4387 * This functions counts rows which are not visible because an ancestor is
4391 count_rows (GtkTreeModel *model,
4393 GtkTreePath *end_path,
4398 GtkTreeIter child_iter;
4404 *count += gtk_tree_model_iter_n_children (model, iter);
4407 g_print ("count_rows : %d level: %d depth: %d\n", *count, level, depth);
4409 g_print ("path: %s\n",
4410 gtk_tree_path_to_string (gtk_tree_model_get_path (model, iter)));
4416 if (gtk_tree_model_iter_children (model, &child_iter, iter))
4418 gboolean ret_val = TRUE;
4422 if (level == depth - 1)
4424 GtkTreePath *iter_path;
4425 gboolean finished = FALSE;
4427 iter_path = gtk_tree_model_get_path (model, &child_iter);
4428 if (end_path && gtk_tree_path_compare (iter_path, end_path) >= 0)
4430 gtk_tree_path_free (iter_path);
4434 if (gtk_tree_model_iter_has_child (model, &child_iter))
4435 count_rows (model, &child_iter, end_path, count, level, depth);
4436 ret_val = gtk_tree_model_iter_next (model, &child_iter);
4442 * Find the next node, which has children, at the specified depth below
4443 * the specified iter. The level is the depth of the current iter.
4444 * The position of the node is returned in path and the return value of TRUE
4445 * means that a node was found.
4448 gboolean get_next_node_with_child_at_depth (GtkTreeModel *model,
4454 GtkTreeIter child_iter;
4458 if (gtk_tree_model_iter_children (model, &child_iter, iter))
4464 while (!gtk_tree_model_iter_has_child (model, &child_iter))
4466 if (!gtk_tree_model_iter_next (model, &child_iter))
4471 /* We have found what we were looking for */
4473 *path = gtk_tree_model_get_path (model, &child_iter);
4477 if (get_next_node_with_child_at_depth (model, &child_iter, path,
4481 if (!gtk_tree_model_iter_next (model, &child_iter))
4489 * Find the next node, which has children, at the same depth as
4490 * the specified GtkTreePath.
4493 get_next_node_with_child (GtkTreeModel *model,
4495 GtkTreePath **return_path)
4500 gtk_tree_model_get_iter (model, &iter, path);
4502 while (gtk_tree_model_iter_next (model, &iter))
4504 if (gtk_tree_model_iter_has_child (model, &iter))
4506 *return_path = gtk_tree_model_get_path (model, &iter);
4510 depth = gtk_tree_path_get_depth (path);
4511 while (gtk_tree_path_up (path))
4513 if (gtk_tree_path_get_depth (path) == 0)
4516 gtk_tree_model_get_iter (model, &iter, path);
4517 while (gtk_tree_model_iter_next (model, &iter))
4518 if (get_next_node_with_child_at_depth (model, &iter, return_path,
4519 gtk_tree_path_get_depth (path), depth))
4522 *return_path = NULL;
4527 get_tree_path_from_row_index (GtkTreeModel *model,
4529 GtkTreePath **tree_path)
4535 count = gtk_tree_model_iter_n_children (model, NULL);
4536 if (count > row_index)
4538 if (gtk_tree_model_iter_nth_child (model, &iter, NULL, row_index))
4540 *tree_path = gtk_tree_model_get_path (model, &iter);
4554 if (get_next_node_with_child_at_depth (model, NULL, tree_path, 0, depth))
4556 GtkTreePath *next_path;
4560 gtk_tree_model_get_iter (model, &iter, *tree_path);
4561 count = gtk_tree_model_iter_n_children (model, &iter);
4562 if (count > row_index)
4564 gtk_tree_path_append_index (*tree_path, row_index);
4570 if (!get_next_node_with_child (model, *tree_path, &next_path))
4573 gtk_tree_path_free (*tree_path);
4574 *tree_path = next_path;
4579 g_warning ("Index value is too large\n");
4580 gtk_tree_path_free (*tree_path);
4588 * This function returns the number of rows, including those which are collapsed
4591 get_row_count (GtkTreeModel *model)
4595 count_rows (model, NULL, NULL, &n_rows, 0, G_MAXINT);
4601 get_path_column_from_index (GtkTreeView *tree_view,
4604 GtkTreeViewColumn **column)
4606 GtkTreeModel *tree_model;
4609 tree_model = gtk_tree_view_get_model (tree_view);
4610 n_columns = get_n_actual_columns (tree_view);
4613 /* First row is the column headers */
4623 row_index = index / n_columns;
4624 retval = get_tree_path_from_row_index (tree_model, row_index, path);
4625 gail_return_val_if_fail (retval, FALSE);
4632 *column = gtk_tree_view_get_column (tree_view, index % n_columns);
4633 if (*column == NULL)
4636 gtk_tree_path_free (*path);
4644 set_cell_expandable (GailCell *cell)
4646 if (gail_cell_add_state (cell,
4647 ATK_STATE_EXPANDABLE,
4649 gail_cell_add_action (cell,
4650 "expand or contract", /* action name */
4651 "expands or contracts the row in the tree view "
4652 "containing this cell", /* description */
4653 NULL, /* Keybinding */
4654 toggle_cell_expanded);
4657 static GailTreeViewCellInfo*
4658 find_cell_info (GailTreeView *view,
4664 GailTreeViewCellInfo *cell_info;
4666 for (temp_list = view->cell_data; temp_list; temp_list = temp_list->next)
4668 cell_info = (GailTreeViewCellInfo *) temp_list->data;
4669 if (cell_info->cell == cell && (!live_only || cell_info->in_use))
4680 get_header_from_column (GtkTreeViewColumn *tv_col)
4683 GtkWidget *header_widget;
4688 /* If the user has set a header object, use that */
4690 rc = g_object_get_qdata (G_OBJECT (tv_col), quark_column_header_object);
4694 /* If the user has not set a header object, grab the column */
4695 /* header object defined by the GtkTreeView */
4697 header_widget = tv_col->button;
4701 rc = gtk_widget_get_accessible (header_widget);