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 GTK_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 GTK_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 g_object_unref (relation);
1031 g_object_unref (relation_set);
1033 gtk_tree_path_free (path);
1036 * We do not increase the reference count here; when g_object_unref() is
1037 * called for the cell then cell_destroyed() is called and
1038 * this removes the cell from the cache.
1044 gail_tree_view_ref_state_set (AtkObject *obj)
1046 AtkStateSet *state_set;
1049 state_set = ATK_OBJECT_CLASS (gail_tree_view_parent_class)->ref_state_set (obj);
1050 widget = GTK_ACCESSIBLE (obj)->widget;
1053 atk_state_set_add_state (state_set, ATK_STATE_MANAGES_DESCENDANTS);
1058 /* atkcomponent.h */
1061 atk_component_interface_init (AtkComponentIface *iface)
1063 iface->ref_accessible_at_point = gail_tree_view_ref_accessible_at_point;
1067 gail_tree_view_ref_accessible_at_point (AtkComponent *component,
1070 AtkCoordType coord_type)
1073 GtkTreeView *tree_view;
1075 GtkTreeViewColumn *tv_column;
1080 widget = GTK_ACCESSIBLE (component)->widget;
1082 /* State is defunct */
1085 tree_view = GTK_TREE_VIEW (widget);
1087 atk_component_get_extents (component, &x_pos, &y_pos, NULL, NULL, coord_type);
1088 gtk_tree_view_convert_widget_to_bin_window_coords (tree_view, x, y, &bx, &by);
1089 ret_val = gtk_tree_view_get_path_at_pos (tree_view,
1090 bx - x_pos, by - y_pos,
1091 &path, &tv_column, NULL, NULL);
1096 column = get_column_number (tree_view, tv_column, FALSE);
1097 index = get_index (tree_view, path, column);
1098 gtk_tree_path_free (path);
1100 return gail_tree_view_ref_child (ATK_OBJECT (component), index);
1104 g_warning ("gail_tree_view_ref_accessible_at_point: gtk_tree_view_get_path_at_pos () failed\n");
1112 atk_table_interface_init (AtkTableIface *iface)
1114 iface->ref_at = gail_tree_view_table_ref_at;
1115 iface->get_n_rows = gail_tree_view_get_n_rows;
1116 iface->get_n_columns = gail_tree_view_get_n_columns;
1117 iface->get_index_at = gail_tree_view_get_index_at;
1118 iface->get_column_at_index = gail_tree_view_get_column_at_index;
1119 iface->get_row_at_index = gail_tree_view_get_row_at_index;
1120 iface->is_row_selected = gail_tree_view_is_row_selected;
1121 iface->is_selected = gail_tree_view_is_selected;
1122 iface->get_selected_rows = gail_tree_view_get_selected_rows;
1123 iface->add_row_selection = gail_tree_view_add_row_selection;
1124 iface->remove_row_selection = gail_tree_view_remove_row_selection;
1125 iface->get_column_extent_at = NULL;
1126 iface->get_row_extent_at = NULL;
1127 iface->get_row_header = gail_tree_view_get_row_header;
1128 iface->set_row_header = gail_tree_view_set_row_header;
1129 iface->get_column_header = gail_tree_view_get_column_header;
1130 iface->set_column_header = gail_tree_view_set_column_header;
1131 iface->get_caption = gail_tree_view_get_caption;
1132 iface->set_caption = gail_tree_view_set_caption;
1133 iface->get_summary = gail_tree_view_get_summary;
1134 iface->set_summary = gail_tree_view_set_summary;
1135 iface->get_row_description = gail_tree_view_get_row_description;
1136 iface->set_row_description = gail_tree_view_set_row_description;
1137 iface->get_column_description = gail_tree_view_get_column_description;
1138 iface->set_column_description = gail_tree_view_set_column_description;
1142 gail_tree_view_get_index_at (AtkTable *table,
1147 GtkTreeView *tree_view;
1149 gint n_cols, n_rows;
1154 n_cols = atk_table_get_n_columns (table);
1155 n_rows = atk_table_get_n_rows (table);
1157 if (row >= n_rows ||
1161 widget = GTK_ACCESSIBLE (table)->widget;
1163 /* State is defunct */
1166 tree_view = GTK_TREE_VIEW (widget);
1167 actual_column = get_actual_column_number (tree_view, column);
1169 set_iter_nth_row (tree_view, &iter, row);
1170 path = gtk_tree_model_get_path (gtk_tree_view_get_model (tree_view), &iter);
1172 index = get_index (tree_view, path, actual_column);
1173 gtk_tree_path_free (path);
1179 gail_tree_view_get_column_at_index (AtkTable *table,
1183 GtkTreeView *tree_view;
1186 widget = GTK_ACCESSIBLE (table)->widget;
1188 /* State is defunct */
1191 tree_view = GTK_TREE_VIEW (widget);
1192 n_columns = get_n_actual_columns (tree_view);
1196 index = index % n_columns;
1198 return get_visible_column_number (tree_view, index);
1202 gail_tree_view_get_row_at_index (AtkTable *table,
1206 GtkTreeView *tree_view;
1209 widget = GTK_ACCESSIBLE (table)->widget;
1211 /* State is defunct */
1214 tree_view = GTK_TREE_VIEW (widget);
1215 if (get_path_column_from_index (tree_view, index, &path, NULL))
1217 gint row = get_row_from_tree_path (tree_view, path);
1218 gtk_tree_path_free (path);
1226 gail_tree_view_table_ref_at (AtkTable *table,
1232 index = gail_tree_view_get_index_at (table, row, column);
1236 return gail_tree_view_ref_child (ATK_OBJECT (table), index);
1240 gail_tree_view_get_n_rows (AtkTable *table)
1243 GtkTreeView *tree_view;
1244 GtkTreeModel *tree_model;
1247 widget = GTK_ACCESSIBLE (table)->widget;
1249 /* State is defunct */
1252 tree_view = GTK_TREE_VIEW (widget);
1253 tree_model = gtk_tree_view_get_model (tree_view);
1255 if (gtk_tree_model_get_flags (tree_model) & GTK_TREE_MODEL_LIST_ONLY)
1257 * If working with a LIST store, then this is a faster way
1258 * to get the number of rows.
1260 n_rows = gtk_tree_model_iter_n_children (tree_model, NULL);
1263 GtkTreePath *root_tree;
1266 root_tree = gtk_tree_path_new_first ();
1267 iterate_thru_children (tree_view, tree_model,
1268 root_tree, NULL, &n_rows, 0);
1269 gtk_tree_path_free (root_tree);
1276 * The function get_n_actual_columns returns the number of columns in the
1277 * GtkTreeView. i.e. it include both visible and non-visible columns.
1280 get_n_actual_columns (GtkTreeView *tree_view)
1285 columns = gtk_tree_view_get_columns (tree_view);
1286 n_cols = g_list_length (columns);
1287 g_list_free (columns);
1292 gail_tree_view_get_n_columns (AtkTable *table)
1295 GtkTreeView *tree_view;
1296 GtkTreeViewColumn *tv_col;
1300 widget = GTK_ACCESSIBLE (table)->widget;
1302 /* State is defunct */
1305 tree_view = GTK_TREE_VIEW (widget);
1306 tv_col = gtk_tree_view_get_column (tree_view, i);
1308 while (tv_col != NULL)
1310 if (gtk_tree_view_column_get_visible (tv_col))
1314 tv_col = gtk_tree_view_get_column (tree_view, i);
1321 gail_tree_view_is_row_selected (AtkTable *table,
1325 GtkTreeView *tree_view;
1326 GtkTreeSelection *selection;
1329 widget = GTK_ACCESSIBLE (table)->widget;
1331 /* State is defunct */
1337 tree_view = GTK_TREE_VIEW (widget);
1339 selection = gtk_tree_view_get_selection (tree_view);
1341 set_iter_nth_row (tree_view, &iter, row);
1343 return gtk_tree_selection_iter_is_selected (selection, &iter);
1347 gail_tree_view_is_selected (AtkTable *table,
1351 return gail_tree_view_is_row_selected (table, row);
1355 gail_tree_view_get_selected_rows (AtkTable *table,
1356 gint **rows_selected)
1359 GtkTreeView *tree_view;
1360 GtkTreeModel *tree_model;
1362 GtkTreeSelection *selection;
1363 GtkTreePath *tree_path;
1366 widget = GTK_ACCESSIBLE (table)->widget;
1368 /* State is defunct */
1371 tree_view = GTK_TREE_VIEW (widget);
1373 selection = gtk_tree_view_get_selection (tree_view);
1375 switch (selection->type)
1377 case GTK_SELECTION_SINGLE:
1378 case GTK_SELECTION_BROWSE:
1379 if (gtk_tree_selection_get_selected (selection, &tree_model, &iter))
1385 *rows_selected = (gint *)g_malloc (sizeof(gint));
1386 tree_path = gtk_tree_model_get_path (tree_model, &iter);
1387 row = get_row_from_tree_path (tree_view, tree_path);
1388 gtk_tree_path_free (tree_path);
1390 /* shouldn't ever happen */
1391 g_return_val_if_fail (row != -1, 0);
1393 *rows_selected[0] = row;
1398 case GTK_SELECTION_MULTIPLE:
1400 GPtrArray *array = g_ptr_array_new();
1402 gtk_tree_selection_selected_foreach (selection,
1405 ret_val = array->len;
1407 if (rows_selected && ret_val)
1410 *rows_selected = (gint *) g_malloc (ret_val * sizeof (gint));
1412 for (i = 0; i < ret_val; i++)
1416 tree_path = (GtkTreePath *) g_ptr_array_index (array, i);
1417 row = get_row_from_tree_path (tree_view, tree_path);
1418 gtk_tree_path_free (tree_path);
1419 (*rows_selected)[i] = row;
1422 g_ptr_array_free (array, FALSE);
1425 case GTK_SELECTION_NONE:
1432 gail_tree_view_add_row_selection (AtkTable *table,
1436 GtkTreeView *tree_view;
1437 GtkTreeModel *tree_model;
1438 GtkTreeSelection *selection;
1439 GtkTreePath *tree_path;
1440 GtkTreeIter iter_to_row;
1442 widget = GTK_ACCESSIBLE (table)->widget;
1444 /* State is defunct */
1447 if (!gail_tree_view_is_row_selected (table, row))
1449 tree_view = GTK_TREE_VIEW (widget);
1450 tree_model = gtk_tree_view_get_model (tree_view);
1451 selection = gtk_tree_view_get_selection (tree_view);
1453 if (gtk_tree_model_get_flags (tree_model) & GTK_TREE_MODEL_LIST_ONLY)
1455 tree_path = gtk_tree_path_new ();
1456 gtk_tree_path_append_index (tree_path, row);
1457 gtk_tree_selection_select_path (selection,tree_path);
1458 gtk_tree_path_free (tree_path);
1462 set_iter_nth_row (tree_view, &iter_to_row, row);
1463 if (&iter_to_row != NULL)
1464 gtk_tree_selection_select_iter (selection, &iter_to_row);
1470 return gail_tree_view_is_row_selected (table, row);
1474 gail_tree_view_remove_row_selection (AtkTable *table,
1478 GtkTreeView *tree_view;
1479 GtkTreeSelection *selection;
1481 widget = GTK_ACCESSIBLE (table)->widget;
1483 /* State is defunct */
1486 tree_view = GTK_TREE_VIEW (widget);
1488 selection = gtk_tree_view_get_selection (tree_view);
1490 if (gail_tree_view_is_row_selected (table, row))
1492 gtk_tree_selection_unselect_all (selection);
1499 gail_tree_view_get_row_header (AtkTable *table,
1502 GailTreeViewRowInfo *row_info;
1504 row_info = get_row_info (table, row);
1506 return row_info->header;
1512 gail_tree_view_set_row_header (AtkTable *table,
1516 set_row_data (table, row, header, NULL, TRUE);
1520 gail_tree_view_get_column_header (AtkTable *table,
1524 GtkTreeView *tree_view;
1525 GtkTreeViewColumn *tv_col;
1527 widget = GTK_ACCESSIBLE (table)->widget;
1529 /* State is defunct */
1532 tree_view = GTK_TREE_VIEW (widget);
1533 tv_col = get_column (tree_view, in_col);
1534 return get_header_from_column (tv_col);
1538 gail_tree_view_set_column_header (AtkTable *table,
1543 GtkTreeView *tree_view;
1544 GtkTreeViewColumn *tv_col;
1546 AtkPropertyValues values = { NULL };
1548 widget = GTK_ACCESSIBLE (table)->widget;
1550 /* State is defunct */
1553 tree_view = GTK_TREE_VIEW (widget);
1554 tv_col = get_column (tree_view, in_col);
1558 rc = g_object_get_qdata (G_OBJECT (tv_col),
1559 quark_column_header_object);
1561 g_object_unref (rc);
1563 g_object_set_qdata (G_OBJECT (tv_col),
1564 quark_column_header_object,
1567 g_object_ref (header);
1568 g_value_init (&values.new_value, G_TYPE_INT);
1569 g_value_set_int (&values.new_value, in_col);
1571 values.property_name = "accessible-table-column-header";
1572 g_signal_emit_by_name (table,
1573 "property_change::accessible-table-column-header",
1578 gail_tree_view_get_caption (AtkTable *table)
1580 GailTreeView* obj = GAIL_TREE_VIEW (table);
1582 return obj->caption;
1586 gail_tree_view_set_caption (AtkTable *table,
1589 GailTreeView* obj = GAIL_TREE_VIEW (table);
1590 AtkPropertyValues values = { NULL };
1591 AtkObject *old_caption;
1593 old_caption = obj->caption;
1594 obj->caption = caption;
1596 g_object_ref (obj->caption);
1597 g_value_init (&values.old_value, G_TYPE_POINTER);
1598 g_value_set_pointer (&values.old_value, old_caption);
1599 g_value_init (&values.new_value, G_TYPE_POINTER);
1600 g_value_set_pointer (&values.new_value, obj->caption);
1602 values.property_name = "accessible-table-caption-object";
1603 g_signal_emit_by_name (table,
1604 "property_change::accessible-table-caption-object",
1607 g_object_unref (old_caption);
1610 static G_CONST_RETURN gchar*
1611 gail_tree_view_get_column_description (AtkTable *table,
1615 GtkTreeView *tree_view;
1616 GtkTreeViewColumn *tv_col;
1619 widget = GTK_ACCESSIBLE (table)->widget;
1621 /* State is defunct */
1624 tree_view = GTK_TREE_VIEW (widget);
1625 tv_col = get_column (tree_view, in_col);
1629 rc = g_object_get_qdata (G_OBJECT (tv_col),
1630 quark_column_desc_object);
1638 g_object_get (tv_col, "title", &title_text, NULL);
1644 gail_tree_view_set_column_description (AtkTable *table,
1646 const gchar *description)
1649 GtkTreeView *tree_view;
1650 GtkTreeViewColumn *tv_col;
1651 AtkPropertyValues values = { NULL };
1653 widget = GTK_ACCESSIBLE (table)->widget;
1655 /* State is defunct */
1658 tree_view = GTK_TREE_VIEW (widget);
1659 tv_col = get_column (tree_view, in_col);
1663 g_object_set_qdata (G_OBJECT (tv_col),
1664 quark_column_desc_object,
1665 g_strdup (description));
1666 g_value_init (&values.new_value, G_TYPE_INT);
1667 g_value_set_int (&values.new_value, in_col);
1669 values.property_name = "accessible-table-column-description";
1670 g_signal_emit_by_name (table,
1671 "property_change::accessible-table-column-description",
1675 static G_CONST_RETURN gchar*
1676 gail_tree_view_get_row_description (AtkTable *table,
1679 GailTreeViewRowInfo *row_info;
1681 row_info = get_row_info (table, row);
1683 return row_info->description;
1689 gail_tree_view_set_row_description (AtkTable *table,
1691 const gchar *description)
1693 set_row_data (table, row, NULL, description, FALSE);
1697 gail_tree_view_get_summary (AtkTable *table)
1699 GailTreeView* obj = GAIL_TREE_VIEW (table);
1701 return obj->summary;
1705 gail_tree_view_set_summary (AtkTable *table,
1706 AtkObject *accessible)
1708 GailTreeView* obj = GAIL_TREE_VIEW (table);
1709 AtkPropertyValues values = { NULL };
1710 AtkObject *old_summary;
1712 old_summary = obj->summary;
1713 obj->summary = accessible;
1715 g_object_ref (obj->summary);
1716 g_value_init (&values.old_value, G_TYPE_POINTER);
1717 g_value_set_pointer (&values.old_value, old_summary);
1718 g_value_init (&values.new_value, G_TYPE_POINTER);
1719 g_value_set_pointer (&values.new_value, obj->summary);
1721 values.property_name = "accessible-table-summary";
1722 g_signal_emit_by_name (table,
1723 "property_change::accessible-table-ummary",
1726 g_object_unref (old_summary);
1730 set_row_data (AtkTable *table,
1733 const gchar *description,
1737 GtkTreeView *tree_view;
1738 GtkTreeModel *tree_model;
1739 GailTreeView* obj = GAIL_TREE_VIEW (table);
1740 GailTreeViewRowInfo* row_info;
1744 gboolean found = FALSE;
1746 AtkPropertyValues values = { NULL };
1749 widget = GTK_ACCESSIBLE (table)->widget;
1751 /* State is defunct */
1754 tree_view = GTK_TREE_VIEW (widget);
1755 tree_model = gtk_tree_view_get_model (tree_view);
1757 set_iter_nth_row (tree_view, &iter, row);
1758 path = gtk_tree_model_get_path (tree_model, &iter);
1760 if (obj->row_data == NULL)
1761 obj->row_data = g_array_sized_new (FALSE, TRUE,
1762 sizeof(GailTreeViewRowInfo *), 0);
1764 array = obj->row_data;
1766 for (i = 0; i < array->len; i++)
1768 GtkTreePath *row_path;
1770 row_info = g_array_index (array, GailTreeViewRowInfo*, i);
1771 row_path = gtk_tree_row_reference_get_path (row_info->row_ref);
1773 if (row_path != NULL)
1775 if (path && gtk_tree_path_compare (row_path, path) == 0)
1778 gtk_tree_path_free (row_path);
1784 if (row_info->header)
1785 g_object_unref (row_info->header);
1786 row_info->header = header;
1787 if (row_info->header)
1788 g_object_ref (row_info->header);
1792 g_free (row_info->description);
1793 row_info->description = g_strdup (description);
1803 row_info = g_malloc (sizeof(GailTreeViewRowInfo));
1804 row_info->row_ref = gtk_tree_row_reference_new (tree_model, path);
1807 row_info->header = header;
1808 if (row_info->header)
1809 g_object_ref (row_info->header);
1810 row_info->description = NULL;
1814 row_info->header = NULL;
1815 row_info->description = g_strdup (description);
1817 g_array_append_val (array, row_info);
1819 g_value_init (&values.new_value, G_TYPE_INT);
1820 g_value_set_int (&values.new_value, row);
1824 values.property_name = "accessible-table-row-header";
1825 signal_name = "property_change::accessible-table-row-header";
1829 values.property_name = "accessible-table-row-description";
1830 signal_name = "property-change::accessible-table-row-description";
1832 g_signal_emit_by_name (table,
1836 gtk_tree_path_free (path);
1840 static GailTreeViewRowInfo*
1841 get_row_info (AtkTable *table,
1845 GtkTreeView *tree_view;
1846 GtkTreeModel *tree_model;
1847 GailTreeView* obj = GAIL_TREE_VIEW (table);
1851 GailTreeViewRowInfo *rc = NULL;
1853 widget = GTK_ACCESSIBLE (table)->widget;
1855 /* State is defunct */
1858 tree_view = GTK_TREE_VIEW (widget);
1859 tree_model = gtk_tree_view_get_model (tree_view);
1861 set_iter_nth_row (tree_view, &iter, row);
1862 path = gtk_tree_model_get_path (tree_model, &iter);
1863 array = obj->row_data;
1867 GailTreeViewRowInfo *row_info;
1868 GtkTreePath *row_path;
1871 for (i = 0; i < array->len; i++)
1873 row_info = g_array_index (array, GailTreeViewRowInfo*, i);
1874 row_path = gtk_tree_row_reference_get_path (row_info->row_ref);
1875 if (row_path != NULL)
1877 if (path && gtk_tree_path_compare (row_path, path) == 0)
1880 gtk_tree_path_free (row_path);
1888 gtk_tree_path_free (path);
1891 /* atkselection.h */
1893 static void atk_selection_interface_init (AtkSelectionIface *iface)
1895 iface->add_selection = gail_tree_view_add_selection;
1896 iface->clear_selection = gail_tree_view_clear_selection;
1897 iface->ref_selection = gail_tree_view_ref_selection;
1898 iface->get_selection_count = gail_tree_view_get_selection_count;
1899 iface->is_child_selected = gail_tree_view_is_child_selected;
1903 gail_tree_view_add_selection (AtkSelection *selection,
1910 table = ATK_TABLE (selection);
1911 n_columns = gail_tree_view_get_n_columns (table);
1915 row = gail_tree_view_get_row_at_index (table, i);
1916 return gail_tree_view_add_row_selection (table, row);
1920 gail_tree_view_clear_selection (AtkSelection *selection)
1923 GtkTreeView *tree_view;
1924 GtkTreeSelection *tree_selection;
1926 widget = GTK_ACCESSIBLE (selection)->widget;
1928 /* State is defunct */
1931 tree_view = GTK_TREE_VIEW (widget);
1933 tree_selection = gtk_tree_view_get_selection (tree_view);
1934 gtk_tree_selection_unselect_all (tree_selection);
1940 gail_tree_view_ref_selection (AtkSelection *selection,
1949 table = ATK_TABLE (selection);
1950 n_columns = gail_tree_view_get_n_columns (table);
1951 n_selected = gail_tree_view_get_selected_rows (table, &selected);
1952 if (i >= n_columns * n_selected)
1955 row = selected[i / n_columns];
1958 return gail_tree_view_table_ref_at (table, row, i % n_columns);
1962 gail_tree_view_get_selection_count (AtkSelection *selection)
1967 table = ATK_TABLE (selection);
1968 n_selected = gail_tree_view_get_selected_rows (table, NULL);
1970 n_selected *= gail_tree_view_get_n_columns (table);
1975 gail_tree_view_is_child_selected (AtkSelection *selection,
1981 widget = GTK_ACCESSIBLE (selection)->widget;
1983 /* State is defunct */
1986 row = atk_table_get_row_at_index (ATK_TABLE (selection), i);
1988 return gail_tree_view_is_row_selected (ATK_TABLE (selection), row);
1992 static void gail_cell_parent_interface_init (GailCellParentIface *iface)
1994 iface->get_cell_extents = gail_tree_view_get_cell_extents;
1995 iface->get_cell_area = gail_tree_view_get_cell_area;
1996 iface->grab_focus = gail_tree_view_grab_cell_focus;
2000 gail_tree_view_get_cell_extents (GailCellParent *parent,
2006 AtkCoordType coord_type)
2009 GtkTreeView *tree_view;
2010 GdkWindow *bin_window;
2011 GdkRectangle cell_rect;
2014 widget = GTK_ACCESSIBLE (parent)->widget;
2016 /* State is defunct */
2019 tree_view = GTK_TREE_VIEW (widget);
2020 gail_tree_view_get_cell_area (parent, cell, &cell_rect);
2021 bin_window = gtk_tree_view_get_bin_window (tree_view);
2022 gdk_window_get_origin (bin_window, &w_x, &w_y);
2024 if (coord_type == ATK_XY_WINDOW)
2027 gint x_toplevel, y_toplevel;
2029 window = gdk_window_get_toplevel (bin_window);
2030 gdk_window_get_origin (window, &x_toplevel, &y_toplevel);
2036 *width = cell_rect.width;
2037 *height = cell_rect.height;
2038 if (is_cell_showing (tree_view, &cell_rect))
2040 *x = cell_rect.x + w_x;
2041 *y = cell_rect.y + w_y;
2050 #define EXTRA_EXPANDER_PADDING 4
2053 gail_tree_view_get_cell_area (GailCellParent *parent,
2055 GdkRectangle *cell_rect)
2058 GtkTreeView *tree_view;
2059 GtkTreeViewColumn *tv_col;
2061 AtkObject *parent_cell;
2062 GailTreeViewCellInfo *cell_info;
2065 widget = GTK_ACCESSIBLE (parent)->widget;
2067 /* State is defunct */
2070 tree_view = GTK_TREE_VIEW (widget);
2071 parent_cell = atk_object_get_parent (ATK_OBJECT (cell));
2072 if (parent_cell != ATK_OBJECT (parent))
2075 * GailCell is in a GailContainerCell
2077 top_cell = GAIL_CELL (parent_cell);
2083 cell_info = find_cell_info (GAIL_TREE_VIEW (parent), top_cell, NULL, TRUE);
2084 gail_return_if_fail (cell_info);
2085 gail_return_if_fail (cell_info->cell_col_ref);
2086 gail_return_if_fail (cell_info->cell_row_ref);
2087 path = gtk_tree_row_reference_get_path (cell_info->cell_row_ref);
2088 tv_col = cell_info->cell_col_ref;
2089 if (path && cell_info->in_use)
2091 GtkTreeViewColumn *expander_column;
2092 gint focus_line_width;
2094 gtk_tree_view_get_cell_area (tree_view, path, tv_col, cell_rect);
2095 expander_column = gtk_tree_view_get_expander_column (tree_view);
2096 if (expander_column == tv_col)
2100 gtk_widget_style_get (widget,
2101 "expander_size", &expander_size,
2104 cell_rect->x += expander_size + EXTRA_EXPANDER_PADDING;
2105 cell_rect->width -= expander_size + EXTRA_EXPANDER_PADDING;
2107 gtk_widget_style_get (widget,
2108 "focus-line-width", &focus_line_width,
2111 cell_rect->x += focus_line_width;
2112 cell_rect->width -= 2 * focus_line_width;
2114 gtk_tree_path_free (path);
2117 * A column has more than one renderer so we find the position and width
2120 if (top_cell != cell)
2127 GtkCellRenderer *renderer;
2129 cell_index = atk_object_get_index_in_parent (ATK_OBJECT (cell));
2130 renderers = gtk_tree_view_column_get_cell_renderers (tv_col);
2131 renderer = g_list_nth_data (renderers, cell_index);
2133 found = gtk_tree_view_column_cell_get_position (tv_col, renderer, &cell_start, &cell_width);
2136 cell_rect->x += cell_start;
2137 cell_rect->width = cell_width;
2139 g_list_free (renderers);
2146 gail_tree_view_grab_cell_focus (GailCellParent *parent,
2150 GtkTreeView *tree_view;
2151 GtkTreeViewColumn *tv_col;
2153 AtkObject *parent_cell;
2154 AtkObject *cell_object;
2155 GailTreeViewCellInfo *cell_info;
2156 GtkCellRenderer *renderer = NULL;
2157 GtkWidget *toplevel;
2160 widget = GTK_ACCESSIBLE (parent)->widget;
2162 /* State is defunct */
2165 tree_view = GTK_TREE_VIEW (widget);
2167 cell_info = find_cell_info (GAIL_TREE_VIEW (parent), cell, NULL, TRUE);
2168 gail_return_val_if_fail (cell_info, FALSE);
2169 gail_return_val_if_fail (cell_info->cell_col_ref, FALSE);
2170 gail_return_val_if_fail (cell_info->cell_row_ref, FALSE);
2171 cell_object = ATK_OBJECT (cell);
2172 parent_cell = atk_object_get_parent (cell_object);
2173 tv_col = cell_info->cell_col_ref;
2174 if (parent_cell != ATK_OBJECT (parent))
2177 * GailCell is in a GailContainerCell.
2178 * The GtkTreeViewColumn has multiple renderers;
2179 * find the corresponding one.
2183 renderers = gtk_tree_view_column_get_cell_renderers (tv_col);
2184 if (cell_info->in_use) {
2185 index = atk_object_get_index_in_parent (cell_object);
2186 renderer = g_list_nth_data (renderers, index);
2188 g_list_free (renderers);
2190 path = gtk_tree_row_reference_get_path (cell_info->cell_row_ref);
2191 if (path && cell_info->in_use)
2194 gtk_tree_view_set_cursor_on_cell (tree_view, path, tv_col, renderer, FALSE);
2196 gtk_tree_view_set_cursor (tree_view, path, tv_col, FALSE);
2198 gtk_tree_path_free (path);
2199 gtk_widget_grab_focus (widget);
2200 toplevel = gtk_widget_get_toplevel (widget);
2201 if (GTK_WIDGET_TOPLEVEL (toplevel))
2203 #ifdef GDK_WINDOWING_X11
2204 gtk_window_present_with_time (GTK_WINDOW (toplevel), gdk_x11_get_server_time (widget->window));
2206 gtk_window_present (GTK_WINDOW (toplevel));
2216 /* signal handling */
2219 gail_tree_view_expand_row_gtk (GtkTreeView *tree_view,
2224 GailTreeView *gailview;
2226 g_assert (GTK_IS_TREE_VIEW (tree_view));
2228 atk_obj = gtk_widget_get_accessible (GTK_WIDGET (tree_view));
2230 g_assert (GAIL_IS_TREE_VIEW (atk_obj));
2232 gailview = GAIL_TREE_VIEW (atk_obj);
2235 * The visible rectangle has not been updated when this signal is emitted
2236 * so we process the signal when the GTK processing is completed
2238 /* this seems wrong since it overwrites any other pending expand handlers... */
2239 gailview->idle_expand_path = gtk_tree_path_copy (path);
2240 if (gailview->idle_expand_id)
2241 g_source_remove (gailview->idle_expand_id);
2242 gailview->idle_expand_id = gdk_threads_add_idle (idle_expand_row, gailview);
2247 idle_expand_row (gpointer data)
2249 GailTreeView *gailview = data;
2251 GtkTreeView *tree_view;
2253 GtkTreeModel *tree_model;
2254 gint n_inserted, row;
2256 gailview->idle_expand_id = 0;
2258 path = gailview->idle_expand_path;
2259 tree_view = GTK_TREE_VIEW (GTK_ACCESSIBLE (gailview)->widget);
2261 g_assert (GTK_IS_TREE_VIEW (tree_view));
2263 tree_model = gtk_tree_view_get_model(tree_view);
2267 if (!path || !gtk_tree_model_get_iter (tree_model, &iter, path))
2271 * Update visibility of cells below expansion row
2273 traverse_cells (gailview, path, FALSE, FALSE);
2275 * Figure out number of visible children, the following test
2278 if (gtk_tree_model_iter_has_child (tree_model, &iter))
2280 GtkTreePath *path_copy;
2283 * By passing path into this function, we find the number of
2284 * visible children of path.
2286 path_copy = gtk_tree_path_copy (path);
2287 gtk_tree_path_append_index(path_copy, 0);
2290 iterate_thru_children (tree_view, tree_model,
2291 path_copy, NULL, &n_inserted, 0);
2292 gtk_tree_path_free (path_copy);
2296 /* We can get here if the row expanded callback deleted the row */
2300 /* Set expand state */
2301 set_expand_state (tree_view, tree_model, gailview, path, TRUE);
2303 row = get_row_from_tree_path (tree_view, path);
2305 /* shouldn't ever happen */
2307 g_assert_not_reached ();
2309 /* Must add 1 because the "added rows" are below the row being expanded */
2312 g_signal_emit_by_name (gailview, "row_inserted", row, n_inserted);
2314 gailview->idle_expand_path = NULL;
2316 gtk_tree_path_free (path);
2322 gail_tree_view_collapse_row_gtk (GtkTreeView *tree_view,
2326 GtkTreeModel *tree_model;
2327 AtkObject *atk_obj = gtk_widget_get_accessible (GTK_WIDGET (tree_view));
2328 GailTreeView *gailview = GAIL_TREE_VIEW (atk_obj);
2331 tree_model = gtk_tree_view_get_model (tree_view);
2333 clean_rows (gailview);
2336 * Update visibility of cells below collapsed row
2338 traverse_cells (gailview, path, FALSE, FALSE);
2339 /* Set collapse state */
2340 set_expand_state (tree_view, tree_model, gailview, path, FALSE);
2342 gail_return_val_if_fail (gailview->n_children_deleted, FALSE);
2343 row = get_row_from_tree_path (tree_view, path);
2344 gail_return_val_if_fail (row != -1, FALSE);
2345 g_signal_emit_by_name (atk_obj, "row_deleted", row,
2346 gailview->n_children_deleted);
2347 gailview->n_children_deleted = 0;
2352 gail_tree_view_size_allocate_gtk (GtkWidget *widget,
2353 GtkAllocation *allocation)
2355 AtkObject *atk_obj = gtk_widget_get_accessible (widget);
2356 GailTreeView *gailview = GAIL_TREE_VIEW (atk_obj);
2359 * If the size allocation changes, the visibility of cells may change so
2360 * update the cells visibility.
2362 traverse_cells (gailview, NULL, FALSE, FALSE);
2366 gail_tree_view_set_scroll_adjustments (GtkWidget *widget,
2367 GtkAdjustment *hadj,
2368 GtkAdjustment *vadj)
2370 AtkObject *atk_obj = gtk_widget_get_accessible (widget);
2371 GailTreeView *gailview = GAIL_TREE_VIEW (atk_obj);
2374 g_object_get (widget, hadjustment, &adj, NULL);
2375 if (gailview->old_hadj != adj)
2377 g_signal_handlers_disconnect_by_func (gailview->old_hadj,
2378 (gpointer) adjustment_changed,
2380 gailview->old_hadj = adj;
2381 g_object_add_weak_pointer (G_OBJECT (gailview->old_hadj), (gpointer *)&gailview->old_hadj);
2382 g_signal_connect (adj,
2384 G_CALLBACK (adjustment_changed),
2387 g_object_get (widget, vadjustment, &adj, NULL);
2388 if (gailview->old_vadj != adj)
2390 g_signal_handlers_disconnect_by_func (gailview->old_vadj,
2391 (gpointer) adjustment_changed,
2393 gailview->old_vadj = adj;
2394 g_object_add_weak_pointer (G_OBJECT (gailview->old_vadj), (gpointer *)&gailview->old_vadj);
2395 g_signal_connect (adj,
2397 G_CALLBACK (adjustment_changed),
2403 gail_tree_view_changed_gtk (GtkTreeSelection *selection,
2406 GailTreeView *gailview;
2407 GtkTreeView *tree_view;
2411 GailTreeViewCellInfo *info;
2412 GtkTreeSelection *tree_selection;
2415 gailview = GAIL_TREE_VIEW (data);
2416 cell_list = gailview->cell_data;
2417 widget = GTK_ACCESSIBLE (gailview)->widget;
2420 * destroy signal emitted for widget
2423 tree_view = GTK_TREE_VIEW (widget);
2425 tree_selection = gtk_tree_view_get_selection (tree_view);
2427 clean_rows (gailview);
2429 for (l = cell_list; l; l = l->next)
2431 info = (GailTreeViewCellInfo *) (l->data);
2435 gail_cell_remove_state (info->cell, ATK_STATE_SELECTED, TRUE);
2437 path = gtk_tree_row_reference_get_path (info->cell_row_ref);
2438 if (path && gtk_tree_selection_path_is_selected (tree_selection, path))
2439 gail_cell_add_state (info->cell, ATK_STATE_SELECTED, TRUE);
2440 gtk_tree_path_free (path);
2443 if (GTK_WIDGET_REALIZED (widget))
2444 g_signal_emit_by_name (gailview, "selection_changed");
2448 columns_changed (GtkTreeView *tree_view)
2450 AtkObject *atk_obj = gtk_widget_get_accessible (GTK_WIDGET(tree_view));
2451 GailTreeView *gailview = GAIL_TREE_VIEW (atk_obj);
2452 GList *tv_cols, *tmp_list;
2453 gboolean column_found;
2454 gboolean move_found = FALSE;
2455 gboolean stale_set = FALSE;
2456 gint column_count = 0;
2460 * This function must determine if the change is an add, delete or
2461 * a move based upon its cache of TreeViewColumns in
2462 * gailview->col_data
2464 tv_cols = gtk_tree_view_get_columns (tree_view);
2466 /* check for adds or moves */
2467 for (tmp_list = tv_cols; tmp_list; tmp_list = tmp_list->next)
2469 column_found = FALSE;
2471 for (i = 0; i < gailview->col_data->len; i++)
2474 if ((GtkTreeViewColumn *)tmp_list->data ==
2475 (GtkTreeViewColumn *)g_array_index (gailview->col_data,
2476 GtkTreeViewColumn *, i))
2478 column_found = TRUE;
2480 /* If the column isn't in the same position, a move happened */
2481 if (!move_found && i != column_count)
2485 /* Set all rows to ATK_STATE_STALE */
2486 traverse_cells (gailview, NULL, TRUE, FALSE);
2490 /* Just emit one column reordered signal when a move happens */
2491 g_signal_emit_by_name (atk_obj, "column_reordered");
2500 * If column_found is FALSE, then an insert happened for column
2501 * number column_count
2505 gint n_cols, n_rows, row;
2509 /* Set all rows to ATK_STATE_STALE */
2510 traverse_cells (gailview, NULL, TRUE, FALSE);
2514 /* Generate column-inserted signal */
2515 g_signal_emit_by_name (atk_obj, "column_inserted", column_count, 1);
2517 /* Generate children-changed signals */
2518 n_rows = get_row_count (gtk_tree_view_get_model (tree_view));
2519 n_cols = get_n_actual_columns (tree_view);
2520 for (row = 0; row < n_rows; row++)
2523 * Pass NULL as the child object, i.e. 4th argument.
2525 g_signal_emit_by_name (atk_obj, "children_changed::add",
2526 ((row * n_cols) + column_count), NULL, NULL);
2533 /* check for deletes */
2534 for (i = 0; i < gailview->col_data->len; i++)
2536 column_found = FALSE;
2538 for (tmp_list = tv_cols; tmp_list; tmp_list = tmp_list->next)
2540 if ((GtkTreeViewColumn *)tmp_list->data ==
2541 (GtkTreeViewColumn *)g_array_index (gailview->col_data,
2542 GtkTreeViewColumn *, i))
2544 column_found = TRUE;
2550 * If column_found is FALSE, then a delete happened for column
2555 gint n_rows, n_cols, row;
2557 clean_cols (gailview,
2558 (GtkTreeViewColumn *)g_array_index (gailview->col_data,
2559 GtkTreeViewColumn *, i));
2563 /* Set all rows to ATK_STATE_STALE */
2564 traverse_cells (gailview, NULL, TRUE, FALSE);
2568 /* Generate column-deleted signal */
2569 g_signal_emit_by_name (atk_obj, "column_deleted", i, 1);
2571 /* Generate children-changed signals */
2572 n_rows = get_row_count (gtk_tree_view_get_model (tree_view));
2573 n_cols = get_n_actual_columns (tree_view);
2574 for (row = 0; row < n_rows; row++)
2577 * Pass NULL as the child object, 4th argument.
2579 g_signal_emit_by_name (atk_obj, "children_changed::remove",
2580 ((row * n_cols) + column_count), NULL, NULL);
2585 /* rebuild the array */
2587 g_array_free (gailview->col_data, TRUE);
2588 gailview->col_data = g_array_sized_new (FALSE, TRUE,
2589 sizeof(GtkTreeViewColumn *), 0);
2591 for (tmp_list = tv_cols; tmp_list; tmp_list = tmp_list->next)
2592 g_array_append_val (gailview->col_data, tmp_list->data);
2593 g_list_free (tv_cols);
2597 cursor_changed (GtkTreeView *tree_view)
2599 GailTreeView *gailview;
2601 gailview = GAIL_TREE_VIEW (gtk_widget_get_accessible (GTK_WIDGET (tree_view)));
2602 if (gailview->idle_cursor_changed_id != 0)
2606 * We notify the focus change in a idle handler so that the processing
2607 * of the cursor change is completed when the focus handler is called.
2608 * This will allow actions to be called in the focus handler
2610 gailview->idle_cursor_changed_id = gdk_threads_add_idle (idle_cursor_changed, gailview);
2614 idle_cursor_changed (gpointer data)
2616 GailTreeView *gail_tree_view = GAIL_TREE_VIEW (data);
2617 GtkTreeView *tree_view;
2621 gail_tree_view->idle_cursor_changed_id = 0;
2623 widget = GTK_ACCESSIBLE (gail_tree_view)->widget;
2625 * Widget has been deleted
2630 tree_view = GTK_TREE_VIEW (widget);
2632 cell = gail_tree_view_ref_focus_cell (tree_view);
2635 if (cell != gail_tree_view->focus_cell)
2637 if (gail_tree_view->focus_cell)
2639 gail_cell_remove_state (GAIL_CELL (gail_tree_view->focus_cell), ATK_STATE_ACTIVE, FALSE);
2640 gail_cell_remove_state (GAIL_CELL (gail_tree_view->focus_cell), ATK_STATE_FOCUSED, FALSE);
2641 g_object_unref (gail_tree_view->focus_cell);
2643 gail_tree_view->focus_cell = cell;
2645 if (GTK_WIDGET_HAS_FOCUS (widget))
2647 gail_cell_add_state (GAIL_CELL (cell), ATK_STATE_ACTIVE, FALSE);
2648 gail_cell_add_state (GAIL_CELL (cell), ATK_STATE_FOCUSED, FALSE);
2650 g_signal_emit_by_name (gail_tree_view,
2651 "active-descendant-changed",
2655 g_object_unref (cell);
2662 focus_in (GtkWidget *widget)
2664 GtkTreeView *tree_view;
2665 GailTreeView *gail_tree_view;
2666 AtkStateSet *state_set;
2669 tree_view = GTK_TREE_VIEW (widget);
2670 gail_tree_view = GAIL_TREE_VIEW (gtk_widget_get_accessible (widget));
2672 if (gail_tree_view->focus_cell == NULL)
2674 cell = gail_tree_view_ref_focus_cell (tree_view);
2677 state_set = atk_object_ref_state_set (cell);
2680 if (!atk_state_set_contains_state (state_set, ATK_STATE_FOCUSED))
2682 gail_cell_add_state (GAIL_CELL (cell), ATK_STATE_ACTIVE, FALSE);
2683 gail_tree_view->focus_cell = cell;
2684 gail_cell_add_state (GAIL_CELL (cell), ATK_STATE_FOCUSED, FALSE);
2685 g_signal_emit_by_name (gail_tree_view,
2686 "active-descendant-changed",
2689 g_object_unref (state_set);
2696 focus_out (GtkWidget *widget)
2698 GailTreeView *gail_tree_view;
2700 gail_tree_view = GAIL_TREE_VIEW (gtk_widget_get_accessible (widget));
2701 if (gail_tree_view->focus_cell)
2703 gail_cell_remove_state (GAIL_CELL (gail_tree_view->focus_cell), ATK_STATE_ACTIVE, FALSE);
2704 gail_cell_remove_state (GAIL_CELL (gail_tree_view->focus_cell), ATK_STATE_FOCUSED, FALSE);
2705 g_object_unref (gail_tree_view->focus_cell);
2706 gail_tree_view->focus_cell = NULL;
2711 model_row_changed (GtkTreeModel *tree_model,
2716 GtkTreeView *tree_view = GTK_TREE_VIEW(user_data);
2717 GailTreeView *gailview;
2718 GtkTreePath *cell_path;
2720 GailTreeViewCellInfo *cell_info;
2722 gailview = GAIL_TREE_VIEW (gtk_widget_get_accessible (GTK_WIDGET (tree_view)));
2724 /* Loop through our cached cells */
2725 /* Must loop through them all */
2726 for (l = gailview->cell_data; l; l = l->next)
2728 cell_info = (GailTreeViewCellInfo *) l->data;
2729 if (cell_info->in_use)
2731 cell_path = gtk_tree_row_reference_get_path (cell_info->cell_row_ref);
2733 if (cell_path != NULL)
2735 if (path && gtk_tree_path_compare (cell_path, path) == 0)
2737 if (GAIL_IS_RENDERER_CELL (cell_info->cell))
2739 update_cell_value (GAIL_RENDERER_CELL (cell_info->cell),
2743 gtk_tree_path_free (cell_path);
2747 g_signal_emit_by_name (gailview, "visible-data-changed");
2751 column_visibility_changed (GObject *object,
2755 if (strcmp (pspec->name, "visible") == 0)
2758 * A column has been made visible or invisible
2760 * We update our cache of cells and emit model_changed signal
2762 GtkTreeView *tree_view = (GtkTreeView *)user_data;
2763 GailTreeView *gailview;
2765 GailTreeViewCellInfo *cell_info;
2766 GtkTreeViewColumn *this_col = GTK_TREE_VIEW_COLUMN (object);
2767 GtkTreeViewColumn *tv_col;
2769 gailview = GAIL_TREE_VIEW (gtk_widget_get_accessible (GTK_WIDGET (tree_view))
2771 g_signal_emit_by_name (gailview, "model_changed");
2773 for (l = gailview->cell_data; l; l = l->next)
2775 cell_info = (GailTreeViewCellInfo *) l->data;
2776 if (cell_info->in_use)
2778 tv_col = cell_info->cell_col_ref;
2779 if (tv_col == this_col)
2781 GtkTreePath *row_path;
2782 row_path = gtk_tree_row_reference_get_path (cell_info->cell_row_ref);
2783 if (GAIL_IS_RENDERER_CELL (cell_info->cell))
2785 if (gtk_tree_view_column_get_visible (tv_col))
2786 set_cell_visibility (tree_view,
2788 tv_col, row_path, FALSE);
2791 gail_cell_remove_state (cell_info->cell,
2792 ATK_STATE_VISIBLE, TRUE);
2793 gail_cell_remove_state (cell_info->cell,
2794 ATK_STATE_SHOWING, TRUE);
2797 gtk_tree_path_free (row_path);
2805 * This is the signal handler for the "destroy" signal for a GtkTreeViewColumn
2807 * We check whether we have stored column description or column header
2808 * and if so we get rid of it.
2811 column_destroy (GtkObject *obj)
2813 GtkTreeViewColumn *tv_col = GTK_TREE_VIEW_COLUMN (obj);
2817 header = g_object_get_qdata (G_OBJECT (tv_col),
2818 quark_column_header_object);
2820 g_object_unref (header);
2821 desc = g_object_get_qdata (G_OBJECT (tv_col),
2822 quark_column_desc_object);
2827 model_row_inserted (GtkTreeModel *tree_model,
2832 GtkTreeView *tree_view = (GtkTreeView *)user_data;
2833 GtkTreePath *path_copy;
2834 AtkObject *atk_obj = gtk_widget_get_accessible (GTK_WIDGET (tree_view));
2835 GailTreeView *gailview = GAIL_TREE_VIEW (atk_obj);
2836 gint row, n_inserted, child_row;
2838 if (gailview->idle_expand_id)
2840 g_source_remove (gailview->idle_expand_id);
2841 gailview->idle_expand_id = 0;
2843 /* don't do this if the insertion precedes the idle path, since it will now be invalid */
2844 if (path && gailview->idle_expand_path &&
2845 (gtk_tree_path_compare (path, gailview->idle_expand_path) > 0))
2846 set_expand_state (tree_view, tree_model, gailview, gailview->idle_expand_path, FALSE);
2847 if (gailview->idle_expand_path)
2848 gtk_tree_path_free (gailview->idle_expand_path);
2850 /* Check to see if row is visible */
2851 row = get_row_from_tree_path (tree_view, path);
2854 * A row insert is not necessarily visible. For example,
2855 * a row can be draged & dropped into another row, which
2856 * causes an insert on the model that isn't visible in the
2857 * view. Only generate a signal if the inserted row is
2865 gtk_tree_model_get_iter (tree_model, &iter, path);
2867 /* Figure out number of visible children. */
2868 if (gtk_tree_model_iter_has_child (tree_model, &iter))
2871 * By passing path into this function, we find the number of
2872 * visible children of path.
2875 iterate_thru_children (tree_view, tree_model,
2876 path, NULL, &n_inserted, 0);
2878 /* Must add one to include the row that is being added */
2884 /* Set rows below the inserted row to ATK_STATE_STALE */
2885 traverse_cells (gailview, path, TRUE, TRUE);
2887 /* Generate row-inserted signal */
2888 g_signal_emit_by_name (atk_obj, "row_inserted", row, n_inserted);
2890 /* Generate children-changed signals */
2891 n_cols = gail_tree_view_get_n_columns (ATK_TABLE (atk_obj));
2892 for (child_row = row; child_row < (row + n_inserted); child_row++)
2894 for (col = 0; col < n_cols; col++)
2897 * Pass NULL as the child object, i.e. 4th argument
2899 g_signal_emit_by_name (atk_obj, "children_changed::add",
2900 ((row * n_cols) + col), NULL, NULL);
2907 * The row has been inserted inside another row. This can
2908 * cause a row that previously couldn't be expanded to now
2911 path_copy = gtk_tree_path_copy (path);
2912 gtk_tree_path_up (path_copy);
2913 set_expand_state (tree_view, tree_model, gailview, path_copy, TRUE);
2914 gtk_tree_path_free (path_copy);
2919 model_row_deleted (GtkTreeModel *tree_model,
2923 GtkTreeView *tree_view;
2924 GtkTreePath *path_copy;
2926 GailTreeView *gailview;
2927 gint row, col, n_cols;
2929 tree_view = (GtkTreeView *)user_data;
2930 atk_obj = gtk_widget_get_accessible (GTK_WIDGET (tree_view));
2931 gailview = GAIL_TREE_VIEW (atk_obj);
2933 if (gailview->idle_expand_id)
2935 g_source_remove (gailview->idle_expand_id);
2936 gtk_tree_path_free (gailview->idle_expand_path);
2937 gailview->idle_expand_id = 0;
2939 /* Check to see if row is visible */
2940 clean_rows (gailview);
2942 /* Set rows at or below the specified row to ATK_STATE_STALE */
2943 traverse_cells (gailview, path, TRUE, TRUE);
2946 * If deleting a row with a depth > 1, then this may affect the
2947 * expansion/contraction of its parent(s). Make sure this is
2950 if (gtk_tree_path_get_depth (path) > 1)
2952 path_copy = gtk_tree_path_copy (path);
2953 gtk_tree_path_up (path_copy);
2954 set_expand_state (tree_view, tree_model, gailview, path_copy, TRUE);
2955 gtk_tree_path_free (path_copy);
2957 row = get_row_from_tree_path (tree_view, path);
2959 * If the row which is deleted is not visible because it is a child of
2960 * a collapsed row then row will be -1
2963 g_signal_emit_by_name (atk_obj, "row_deleted", row,
2964 gailview->n_children_deleted + 1);
2965 gailview->n_children_deleted = 0;
2967 /* Generate children-changed signals */
2968 n_cols = get_n_actual_columns (tree_view);
2969 for (col = 0; col < n_cols; col++)
2972 * Pass NULL as the child object, 4th argument.
2974 g_signal_emit_by_name (atk_obj, "children_changed::remove",
2975 ((row * n_cols) + col), NULL, NULL);
2980 * This function gets called when a row is deleted or when rows are
2981 * removed from the view due to a collapse event. Note that the
2982 * count is the number of visible *children* of the deleted row,
2983 * so it does not include the row being deleted.
2985 * As this function is called before the rows are removed we just note the
2986 * number of rows and then deal with it when we get a notification that
2987 * rows were deleted or collapsed.
2990 destroy_count_func (GtkTreeView *tree_view,
2995 AtkObject *atk_obj = gtk_widget_get_accessible (GTK_WIDGET (tree_view));
2996 GailTreeView *gailview = GAIL_TREE_VIEW (atk_obj);
2998 gail_return_if_fail (gailview->n_children_deleted == 0);
2999 gailview->n_children_deleted = count;
3003 model_rows_reordered (GtkTreeModel *tree_model,
3009 GtkTreeView *tree_view = (GtkTreeView *)user_data;
3010 AtkObject *atk_obj = gtk_widget_get_accessible (GTK_WIDGET (tree_view));
3011 GailTreeView *gailview = GAIL_TREE_VIEW (atk_obj);
3013 if (gailview->idle_expand_id)
3015 g_source_remove (gailview->idle_expand_id);
3016 gtk_tree_path_free (gailview->idle_expand_path);
3017 gailview->idle_expand_id = 0;
3019 traverse_cells (gailview, NULL, TRUE, FALSE);
3021 g_signal_emit_by_name (atk_obj, "row_reordered");
3025 adjustment_changed (GtkAdjustment *adjustment,
3026 GtkTreeView *tree_view)
3032 * The scrollbars have changed
3034 atk_obj = gtk_widget_get_accessible (GTK_WIDGET (tree_view));
3035 obj = GAIL_TREE_VIEW (atk_obj);
3037 traverse_cells (obj, NULL, FALSE, FALSE);
3041 set_cell_visibility (GtkTreeView *tree_view,
3043 GtkTreeViewColumn *tv_col,
3044 GtkTreePath *tree_path,
3045 gboolean emit_signal)
3047 GdkRectangle cell_rect;
3049 /* Get these three values in tree coords */
3050 if (GTK_WIDGET_REALIZED (GTK_WIDGET (tree_view)))
3051 gtk_tree_view_get_cell_area (tree_view, tree_path, tv_col, &cell_rect);
3053 cell_rect.height = 0;
3055 if (cell_rect.height > 0)
3058 * The height will be zero for a cell for which an antecedent is not
3061 gail_cell_add_state (cell, ATK_STATE_VISIBLE, emit_signal);
3062 if (is_cell_showing (tree_view, &cell_rect))
3063 gail_cell_add_state (cell, ATK_STATE_SHOWING, emit_signal);
3065 gail_cell_remove_state (cell, ATK_STATE_SHOWING, emit_signal);
3069 gail_cell_remove_state (cell, ATK_STATE_VISIBLE, emit_signal);
3070 gail_cell_remove_state (cell, ATK_STATE_SHOWING, emit_signal);
3075 is_cell_showing (GtkTreeView *tree_view,
3076 GdkRectangle *cell_rect)
3078 GdkRectangle rect, *visible_rect;
3079 GdkRectangle rect1, *tree_cell_rect;
3081 gboolean is_showing;
3083 * A cell is considered "SHOWING" if any part of the cell is in the visible
3084 * area. Other ways we could do this is by a cell's midpoint or if the cell
3085 * is fully in the visible range. Since we have the cell_rect x,y,width,height
3086 * of the cell, any of these is easy to compute.
3088 * It is assumed that cell's rectangle is in widget coordinates so we
3089 * must transform to tree cordinates.
3091 visible_rect = ▭
3092 tree_cell_rect = &rect1;
3093 tree_cell_rect->x = cell_rect->x;
3094 tree_cell_rect->y = cell_rect->y;
3095 tree_cell_rect->width = cell_rect->width;
3096 tree_cell_rect->height = cell_rect->height;
3098 gtk_tree_view_get_visible_rect (tree_view, visible_rect);
3099 gtk_tree_view_convert_tree_to_bin_window_coords (tree_view, visible_rect->x,
3100 visible_rect->y, &bx, &by);
3102 if (((tree_cell_rect->x + tree_cell_rect->width) < bx) ||
3103 ((tree_cell_rect->y + tree_cell_rect->height) < by) ||
3104 (tree_cell_rect->x > (bx + visible_rect->width)) ||
3105 (tree_cell_rect->y > (by + visible_rect->height)))
3116 * This function is called when a cell's flyweight is created in
3117 * gail_tree_view_table_ref_at with emit_change_signal set to FALSE
3118 * and in model_row_changed() on receipt of "row-changed" signal when
3119 * emit_change_signal is set to TRUE
3122 update_cell_value (GailRendererCell *renderer_cell,
3123 GailTreeView *gailview,
3124 gboolean emit_change_signal)
3126 GailTreeViewCellInfo *cell_info;
3127 GtkTreeView *tree_view;
3128 GtkTreeModel *tree_model;
3131 GList *renderers, *cur_renderer;
3133 GailRendererCellClass *gail_renderer_cell_class;
3134 GtkCellRendererClass *gtk_cell_renderer_class;
3138 gboolean is_expander, is_expanded;
3140 gail_renderer_cell_class = GAIL_RENDERER_CELL_GET_CLASS (renderer_cell);
3141 if (renderer_cell->renderer)
3142 gtk_cell_renderer_class = GTK_CELL_RENDERER_GET_CLASS (renderer_cell->renderer);
3144 gtk_cell_renderer_class = NULL;
3146 prop_list = gail_renderer_cell_class->property_list;
3148 cell = GAIL_CELL (renderer_cell);
3149 cell_info = find_cell_info (gailview, cell, NULL, TRUE);
3150 gail_return_val_if_fail (cell_info, FALSE);
3151 gail_return_val_if_fail (cell_info->cell_col_ref, FALSE);
3152 gail_return_val_if_fail (cell_info->cell_row_ref, FALSE);
3154 if (emit_change_signal && cell_info->in_use)
3156 tree_view = GTK_TREE_VIEW (GTK_ACCESSIBLE (gailview)->widget);
3157 tree_model = gtk_tree_view_get_model (tree_view);
3158 path = gtk_tree_row_reference_get_path (cell_info->cell_row_ref);
3162 gtk_tree_model_get_iter (tree_model, &iter, path);
3163 is_expander = FALSE;
3164 is_expanded = FALSE;
3165 if (gtk_tree_model_iter_has_child (tree_model, &iter))
3167 GtkTreeViewColumn *expander_tv;
3169 expander_tv = gtk_tree_view_get_expander_column (tree_view);
3170 if (expander_tv == cell_info->cell_col_ref)
3173 is_expanded = gtk_tree_view_row_expanded (tree_view, path);
3176 gtk_tree_path_free (path);
3177 gtk_tree_view_column_cell_set_cell_data (cell_info->cell_col_ref,
3178 tree_model, &iter, is_expander, is_expanded);
3180 renderers = gtk_tree_view_column_get_cell_renderers (cell_info->cell_col_ref);
3181 gail_return_val_if_fail (renderers, FALSE);
3184 * If the cell is in a container, it's index is used to find the renderer
3189 * Otherwise, we assume that the cell is represented by the first renderer
3193 if (cell_info->in_use) {
3194 parent = atk_object_get_parent (ATK_OBJECT (cell));
3195 if (!ATK_IS_OBJECT (cell)) g_on_error_query (NULL);
3196 if (GAIL_IS_CONTAINER_CELL (parent))
3197 cur_renderer = g_list_nth (renderers, cell->index);
3199 cur_renderer = renderers;
3205 gail_return_val_if_fail (cur_renderer != NULL, FALSE);
3207 if (gtk_cell_renderer_class)
3211 spec = g_object_class_find_property
3212 (G_OBJECT_CLASS (gtk_cell_renderer_class), *prop_list);
3216 GValue value = { 0, };
3218 g_value_init (&value, spec->value_type);
3219 g_object_get_property (cur_renderer->data, *prop_list, &value);
3220 g_object_set_property (G_OBJECT (renderer_cell->renderer),
3221 *prop_list, &value);
3222 g_value_unset(&value);
3225 g_warning ("Invalid property: %s\n", *prop_list);
3229 g_list_free (renderers);
3230 return gail_renderer_cell_update_cache (renderer_cell, emit_change_signal);
3234 set_iter_nth_row (GtkTreeView *tree_view,
3238 GtkTreeModel *tree_model;
3240 tree_model = gtk_tree_view_get_model (tree_view);
3241 gtk_tree_model_get_iter_first (tree_model, iter);
3242 iter = return_iter_nth_row (tree_view, tree_model, iter, 0 , row);
3246 get_row_from_tree_path (GtkTreeView *tree_view,
3249 GtkTreeModel *tree_model;
3250 GtkTreePath *root_tree;
3253 tree_model = gtk_tree_view_get_model (tree_view);
3255 if (gtk_tree_model_get_flags (tree_model) & GTK_TREE_MODEL_LIST_ONLY)
3256 row = gtk_tree_path_get_indices (path)[0];
3259 root_tree = gtk_tree_path_new_first ();
3261 iterate_thru_children (tree_view, tree_model, root_tree, path, &row, 0);
3262 gtk_tree_path_free (root_tree);
3271 * Get the specified GtkTreeViewColumn in the GtkTreeView.
3272 * Only visible columns are considered.
3274 static GtkTreeViewColumn*
3275 get_column (GtkTreeView *tree_view,
3278 GtkTreeViewColumn *tv_col;
3284 g_warning ("Request for invalid column %d\n", in_col);
3288 tv_col = gtk_tree_view_get_column (tree_view, i);
3290 while (tv_col != NULL)
3292 if (gtk_tree_view_column_get_visible (tv_col))
3294 if (in_col == n_cols)
3296 tv_col = gtk_tree_view_get_column (tree_view, ++i);
3299 if (in_col != n_cols)
3301 g_warning ("Request for invalid column %d\n", in_col);
3308 get_actual_column_number (GtkTreeView *tree_view,
3309 gint visible_column)
3311 GtkTreeViewColumn *tv_col;
3312 gint actual_column = 0;
3313 gint visible_columns = -1;
3315 * This function calculates the column number which corresponds to the
3316 * specified visible column number
3318 tv_col = gtk_tree_view_get_column (tree_view, actual_column);
3320 while (tv_col != NULL)
3322 if (gtk_tree_view_column_get_visible (tv_col))
3324 if (visible_columns == visible_column)
3325 return actual_column;
3326 tv_col = gtk_tree_view_get_column (tree_view, ++actual_column);
3328 g_warning ("get_actual_column_number failed for %d\n", visible_column);
3333 get_visible_column_number (GtkTreeView *tree_view,
3336 GtkTreeViewColumn *tv_col;
3338 gint visible_columns = -1;
3340 * This function calculates the visible column number which corresponds to the
3341 * specified actual column number
3343 tv_col = gtk_tree_view_get_column (tree_view, column);
3345 while (tv_col != NULL)
3347 if (gtk_tree_view_column_get_visible (tv_col))
3350 if (actual_column == column)
3351 return visible_columns;
3354 if (actual_column == column)
3356 tv_col = gtk_tree_view_get_column (tree_view, ++column);
3358 g_warning ("get_visible_column_number failed for %d\n", actual_column);
3363 * Helper recursive function that returns GtkTreeIter pointer to nth row.
3366 return_iter_nth_row(GtkTreeView *tree_view,
3367 GtkTreeModel *tree_model,
3372 GtkTreePath *current_path = gtk_tree_model_get_path (tree_model, iter);
3373 GtkTreeIter new_iter;
3374 gboolean row_expanded;
3376 if (increment == row) {
3377 gtk_tree_path_free (current_path);
3381 row_expanded = gtk_tree_view_row_expanded (tree_view, current_path);
3382 gtk_tree_path_free (current_path);
3385 if ((row_expanded && gtk_tree_model_iter_children (tree_model, iter, &new_iter)) ||
3386 (gtk_tree_model_iter_next (tree_model, iter)) ||
3387 (gtk_tree_model_iter_parent (tree_model, iter, &new_iter) &&
3388 (gtk_tree_model_iter_next (tree_model, iter))))
3389 return return_iter_nth_row (tree_view, tree_model, iter,
3396 * Recursively called until the row specified by orig is found.
3398 * *count will be set to the visible row number of the child
3399 * relative to the row that was initially passed in as tree_path.
3401 * *count will be -1 if orig is not found as a child (a row that is
3402 * not visible will not be found, e.g. if the row is inside a
3403 * collapsed row). If NULL is passed in as orig, *count will
3404 * be a count of the visible children.
3406 * NOTE: the value for depth must be 0 when this recursive function
3407 * is initially called, or it may not function as expected.
3410 iterate_thru_children(GtkTreeView *tree_view,
3411 GtkTreeModel *tree_model,
3412 GtkTreePath *tree_path,
3419 if (!gtk_tree_model_get_iter (tree_model, &iter, tree_path))
3422 if (tree_path && orig && !gtk_tree_path_compare (tree_path, orig))
3426 if (tree_path && orig && gtk_tree_path_compare (tree_path, orig) > 0)
3428 /* Past it, so return -1 */
3432 else if (gtk_tree_view_row_expanded (tree_view, tree_path) &&
3433 gtk_tree_model_iter_has_child (tree_model, &iter))
3436 gtk_tree_path_append_index (tree_path, 0);
3437 iterate_thru_children (tree_view, tree_model, tree_path,
3438 orig, count, (depth + 1));
3441 else if (gtk_tree_model_iter_next (tree_model, &iter))
3444 tree_path = gtk_tree_model_get_path (tree_model, &iter);
3447 iterate_thru_children (tree_view, tree_model, tree_path,
3448 orig, count, depth);
3449 gtk_tree_path_free (tree_path);
3453 else if (gtk_tree_path_up (tree_path))
3455 GtkTreeIter temp_iter;
3456 gboolean exit_loop = FALSE;
3457 gint new_depth = depth - 1;
3462 * Make sure that we back up until we find a row
3463 * where gtk_tree_path_next does not return NULL.
3467 if (gtk_tree_path_get_depth (tree_path) == 0)
3468 /* depth is now zero so */
3470 gtk_tree_path_next (tree_path);
3472 /* Verify that the next row is a valid row! */
3473 exit_loop = gtk_tree_model_get_iter (tree_model, &temp_iter, tree_path);
3477 /* Keep going up until we find a row that has a valid next */
3478 if (gtk_tree_path_get_depth(tree_path) > 1)
3481 gtk_tree_path_up (tree_path);
3486 * If depth is 1 and gtk_tree_model_get_iter returns FALSE,
3487 * then we are at the last row, so just return.
3498 * This guarantees that we will stop when we hit the end of the
3504 iterate_thru_children (tree_view, tree_model, tree_path,
3505 orig, count, new_depth);
3510 * If it gets here, then the path wasn't found. Situations
3511 * that would cause this would be if the path passed in is
3512 * invalid or contained within the last row, but not visible
3513 * because the last row is not expanded. If NULL was passed
3514 * in then a row count is desired, so only set count to -1
3515 * if orig is not NULL.
3524 clean_cell_info (GailTreeView *gailview,
3527 GailTreeViewCellInfo *cell_info;
3530 g_assert (GAIL_IS_TREE_VIEW (gailview));
3532 cell_info = list->data;
3534 if (cell_info->in_use) {
3535 obj = G_OBJECT (cell_info->cell);
3537 gail_cell_add_state (cell_info->cell, ATK_STATE_DEFUNCT, FALSE);
3538 g_object_weak_unref (obj, (GWeakNotify) cell_destroyed, cell_info);
3539 cell_info->in_use = FALSE;
3540 if (!gailview->garbage_collection_pending) {
3541 gailview->garbage_collection_pending = TRUE;
3542 g_assert (gailview->idle_garbage_collect_id == 0);
3543 gailview->idle_garbage_collect_id =
3544 gdk_threads_add_idle (idle_garbage_collect_cell_data, gailview);
3550 clean_rows (GailTreeView *gailview)
3554 /* Clean GailTreeViewRowInfo data */
3556 array = gailview->row_data;
3559 GailTreeViewRowInfo *row_info;
3560 GtkTreePath *row_path;
3564 * Loop backwards so that calls to free_row_info
3565 * do not affect the index numbers
3567 for (i = (array->len - 1); i >= 0; i --)
3569 row_info = g_array_index (array, GailTreeViewRowInfo*, i);
3570 row_path = gtk_tree_row_reference_get_path (row_info->row_ref);
3572 /* Remove any rows that have become invalid */
3573 if (row_path == NULL)
3574 free_row_info (array, i, TRUE);
3576 gtk_tree_path_free (row_path);
3580 /* Clean GailTreeViewCellInfo data */
3582 if (gailview->cell_data != NULL)
3584 GailTreeViewCellInfo *cell_info;
3585 GtkTreePath *row_path;
3589 temp_list = gailview->cell_data;
3591 /* Must loop through them all */
3592 while (temp_list != NULL)
3594 cur_list = temp_list;
3595 cell_info = temp_list->data;
3596 temp_list = temp_list->next;
3597 row_path = gtk_tree_row_reference_get_path (cell_info->cell_row_ref);
3600 * If the cell has become invalid because the row has been removed,
3601 * then set the cell's state to ATK_STATE_DEFUNCT and remove the cell
3602 * from gailview->cell_data. If row_path is NULL then the row has
3605 if (row_path == NULL)
3607 clean_cell_info (gailview, cur_list);
3611 gtk_tree_path_free (row_path);
3618 clean_cols (GailTreeView *gailview,
3619 GtkTreeViewColumn *tv_col)
3621 /* Clean GailTreeViewCellInfo data */
3623 if (gailview->cell_data != NULL)
3625 GailTreeViewCellInfo *cell_info;
3626 GList *cur_list, *temp_list;
3628 temp_list = gailview->cell_data;
3630 while (temp_list != NULL)
3632 cur_list = temp_list;
3633 cell_info = temp_list->data;
3634 temp_list = temp_list->next;
3637 * If the cell has become invalid because the column tv_col
3638 * has been removed, then set the cell's state to ATK_STATE_DEFUNCT
3639 * and remove the cell from gailview->cell_data.
3641 if (cell_info->cell_col_ref == tv_col)
3643 clean_cell_info (gailview, cur_list);
3650 idle_garbage_collect_cell_data (gpointer data)
3652 GailTreeView *tree_view;
3654 g_assert (GAIL_IS_TREE_VIEW (data));
3655 tree_view = (GailTreeView *)data;
3657 /* this is the idle handler (only one instance allowed), so
3658 * we can safely delete it.
3660 tree_view->garbage_collection_pending = FALSE;
3661 tree_view->idle_garbage_collect_id = 0;
3663 tree_view->garbage_collection_pending = garbage_collect_cell_data (data);
3665 /* N.B.: if for some reason another handler has re-enterantly been queued
3666 * while this handler was being serviced, it has its own gsource, therefore this handler
3667 * should always return FALSE.
3673 garbage_collect_cell_data (gpointer data)
3675 GailTreeView *tree_view;
3676 GList *temp_list, *list;
3677 GailTreeViewCellInfo *cell_info;
3679 g_assert (GAIL_IS_TREE_VIEW (data));
3680 tree_view = (GailTreeView *)data;
3681 list = g_list_copy (tree_view->cell_data);
3683 tree_view->garbage_collection_pending = FALSE;
3684 if (tree_view->idle_garbage_collect_id != 0)
3686 g_source_remove (tree_view->idle_garbage_collect_id);
3687 tree_view->idle_garbage_collect_id = 0;
3690 /* Must loop through them all */
3692 while (temp_list != NULL)
3694 cell_info = temp_list->data;
3695 if (!cell_info->in_use)
3697 /* g_object_unref (cell_info->cell); */
3698 tree_view->cell_data = g_list_remove (tree_view->cell_data,
3700 if (cell_info->cell_row_ref)
3701 gtk_tree_row_reference_free (cell_info->cell_row_ref);
3704 temp_list = temp_list->next;
3708 return tree_view->garbage_collection_pending;
3712 * If tree_path is passed in as NULL, then all cells are acted on.
3713 * Otherwise, just act on those cells that are on a row greater than
3714 * the specified tree_path. If inc_row is passed in as TRUE, then rows
3715 * greater and equal to the specified tree_path are acted on.
3717 * if set_stale is set the ATK_STATE_STALE is set on cells which are to be
3720 * The function set_cell_visibility() is called on all cells to be
3721 * acted on to update the visibility of the cell.
3724 traverse_cells (GailTreeView *tree_view,
3725 GtkTreePath *tree_path,
3729 if (tree_view->cell_data != NULL)
3731 GailTreeViewCellInfo *cell_info;
3732 GtkTreeView *gtk_tree_view;
3736 g_assert (GTK_IS_ACCESSIBLE (tree_view));
3738 widget = GTK_ACCESSIBLE (tree_view)->widget;
3740 /* Widget is being deleted */
3743 gtk_tree_view = GTK_TREE_VIEW (widget);
3744 temp_list = tree_view->cell_data;
3746 /* Must loop through them all */
3747 while (temp_list != NULL)
3749 GtkTreePath *row_path;
3750 gboolean act_on_cell;
3752 cell_info = temp_list->data;
3753 temp_list = temp_list->next;
3755 if (cell_info->in_use)
3757 row_path = gtk_tree_row_reference_get_path (cell_info->cell_row_ref);
3758 g_return_if_fail (row_path != NULL);
3759 if (tree_path == NULL)
3765 comparison = gtk_tree_path_compare (row_path, tree_path);
3766 if ((comparison > 0) ||
3767 (comparison == 0 && inc_row))
3770 act_on_cell = FALSE;
3772 if (!cell_info->in_use) g_warning ("warning: cell info destroyed during traversal");
3773 if (act_on_cell && cell_info->in_use)
3776 gail_cell_add_state (cell_info->cell, ATK_STATE_STALE, TRUE);
3777 set_cell_visibility (gtk_tree_view,
3779 cell_info->cell_col_ref,
3782 gtk_tree_path_free (row_path);
3786 g_signal_emit_by_name (tree_view, "visible-data-changed");
3790 free_row_info (GArray *array,
3794 GailTreeViewRowInfo* obj;
3796 obj = g_array_index (array, GailTreeViewRowInfo*, array_idx);
3798 g_free (obj->description);
3799 if (obj->row_ref != NULL)
3800 gtk_tree_row_reference_free (obj->row_ref);
3802 g_object_unref (obj->header);
3806 g_array_remove_index (array, array_idx);
3810 * If the tree_path passed in has children, then
3811 * ATK_STATE_EXPANDABLE is set. If the row is expanded
3812 * ATK_STATE_EXPANDED is turned on. If the row is
3813 * collapsed, then ATK_STATE_EXPANDED is removed.
3815 * If the tree_path passed in has no children, then
3816 * ATK_STATE_EXPANDABLE and ATK_STATE_EXPANDED are removed.
3818 * If set_on_ancestor is TRUE, then this function will also
3819 * update all cells that are ancestors of the tree_path.
3822 set_expand_state (GtkTreeView *tree_view,
3823 GtkTreeModel *tree_model,
3824 GailTreeView *gailview,
3825 GtkTreePath *tree_path,
3826 gboolean set_on_ancestor)
3828 if (gailview->cell_data != NULL)
3830 GtkTreeViewColumn *expander_tv;
3831 GailTreeViewCellInfo *cell_info;
3833 GtkTreePath *cell_path;
3837 temp_list = gailview->cell_data;
3839 while (temp_list != NULL)
3841 cell_info = temp_list->data;
3842 temp_list = temp_list->next;
3843 if (cell_info->in_use)
3845 cell_path = gtk_tree_row_reference_get_path (cell_info->cell_row_ref);
3848 if (cell_path != NULL)
3850 GailCell *cell = GAIL_CELL (cell_info->cell);
3852 expander_tv = gtk_tree_view_get_expander_column (tree_view);
3855 * Only set state for the cell that is in the column with the
3858 if (expander_tv == cell_info->cell_col_ref)
3860 if (tree_path && gtk_tree_path_compare (cell_path, tree_path) == 0)
3862 else if (set_on_ancestor &&
3863 gtk_tree_path_get_depth (cell_path) <
3864 gtk_tree_path_get_depth (tree_path) &&
3865 gtk_tree_path_is_ancestor (cell_path, tree_path) == 1)
3866 /* Only set if set_on_ancestor was passed in as TRUE */
3871 * Set ATK_STATE_EXPANDABLE and ATK_STATE_EXPANDED
3872 * for ancestors and found cells.
3877 * Must check against cell_path since cell_path
3878 * can be equal to or an ancestor of tree_path.
3880 gtk_tree_model_get_iter (tree_model, &iter, cell_path);
3882 /* Set or unset ATK_STATE_EXPANDABLE as appropriate */
3883 if (gtk_tree_model_iter_has_child (tree_model, &iter))
3885 set_cell_expandable (cell);
3887 if (gtk_tree_view_row_expanded (tree_view, cell_path))
3888 gail_cell_add_state (cell, ATK_STATE_EXPANDED, TRUE);
3890 gail_cell_remove_state (cell,
3891 ATK_STATE_EXPANDED, TRUE);
3895 gail_cell_remove_state (cell,
3896 ATK_STATE_EXPANDED, TRUE);
3897 if (gail_cell_remove_state (cell,
3898 ATK_STATE_EXPANDABLE, TRUE))
3899 /* The state may have been propagated to the container cell */
3900 if (!GAIL_IS_CONTAINER_CELL (cell))
3901 gail_cell_remove_action_by_name (cell,
3902 "expand or contract");
3906 * We assume that each cell in the cache once and
3907 * a container cell is before its child cells so we are
3908 * finished if set_on_ancestor is not set to TRUE.
3910 if (!set_on_ancestor)
3914 gtk_tree_path_free (cell_path);
3922 add_cell_actions (GailCell *cell,
3925 if (GAIL_IS_BOOLEAN_CELL (cell))
3926 gail_cell_add_action (cell,
3928 "toggles the cell", /* action description */
3930 toggle_cell_toggled);
3932 gail_cell_add_action (cell,
3934 "creates a widget in which the contents of the cell can be edited",
3937 gail_cell_add_action (cell,
3939 "activate the cell",
3945 toggle_cell_expanded (GailCell *cell)
3947 GailTreeViewCellInfo *cell_info;
3948 GtkTreeView *tree_view;
3951 AtkStateSet *stateset;
3953 parent = atk_object_get_parent (ATK_OBJECT (cell));
3954 if (GAIL_IS_CONTAINER_CELL (parent))
3955 parent = atk_object_get_parent (parent);
3957 cell_info = find_cell_info (GAIL_TREE_VIEW (parent), cell, NULL, TRUE);
3958 gail_return_if_fail (cell_info);
3959 gail_return_if_fail (cell_info->cell_col_ref);
3960 gail_return_if_fail (cell_info->cell_row_ref);
3962 tree_view = GTK_TREE_VIEW (GTK_ACCESSIBLE (parent)->widget);
3963 path = gtk_tree_row_reference_get_path (cell_info->cell_row_ref);
3964 gail_return_if_fail (path);
3966 stateset = atk_object_ref_state_set (ATK_OBJECT (cell));
3967 if (atk_state_set_contains_state (stateset, ATK_STATE_EXPANDED))
3968 gtk_tree_view_collapse_row (tree_view, path);
3970 gtk_tree_view_expand_row (tree_view, path, TRUE);
3971 g_object_unref (stateset);
3972 gtk_tree_path_free (path);
3977 toggle_cell_toggled (GailCell *cell)
3979 GailTreeViewCellInfo *cell_info;
3980 GtkTreeView *tree_view;
3983 GList *renderers, *cur_renderer;
3985 gboolean is_container_cell = FALSE;
3987 parent = atk_object_get_parent (ATK_OBJECT (cell));
3988 if (GAIL_IS_CONTAINER_CELL (parent))
3990 is_container_cell = TRUE;
3991 parent = atk_object_get_parent (parent);
3994 cell_info = find_cell_info (GAIL_TREE_VIEW (parent), cell, NULL, TRUE);
3995 gail_return_if_fail (cell_info);
3996 gail_return_if_fail (cell_info->cell_col_ref);
3997 gail_return_if_fail (cell_info->cell_row_ref);
3999 tree_view = GTK_TREE_VIEW (GTK_ACCESSIBLE (parent)->widget);
4000 path = gtk_tree_row_reference_get_path (cell_info->cell_row_ref);
4001 gail_return_if_fail (path);
4002 pathstring = gtk_tree_path_to_string (path);
4004 renderers = gtk_tree_view_column_get_cell_renderers (cell_info->cell_col_ref);
4005 gail_return_if_fail (renderers);
4008 * if the cell is in a container, it's index is used to find the
4009 * renderer in the list
4012 if (is_container_cell)
4013 cur_renderer = g_list_nth (renderers, cell->index);
4016 * Otherwise, we assume that the cell is represented by the first
4017 * renderer in the list
4019 cur_renderer = renderers;
4021 gail_return_if_fail (cur_renderer);
4023 g_signal_emit_by_name (cur_renderer->data, "toggled", pathstring);
4024 g_list_free (renderers);
4025 g_free (pathstring);
4026 gtk_tree_path_free (path);
4031 edit_cell (GailCell *cell)
4033 GailTreeViewCellInfo *cell_info;
4034 GtkTreeView *tree_view;
4037 gboolean is_container_cell = FALSE;
4040 parent = atk_object_get_parent (ATK_OBJECT (cell));
4041 if (GAIL_IS_CONTAINER_CELL (parent))
4043 is_container_cell = TRUE;
4044 parent = atk_object_get_parent (parent);
4047 cell_info = find_cell_info (GAIL_TREE_VIEW (parent), cell, NULL, TRUE);
4048 gail_return_if_fail (cell_info);
4049 gail_return_if_fail (cell_info->cell_col_ref);
4050 gail_return_if_fail (cell_info->cell_row_ref);
4052 tree_view = GTK_TREE_VIEW (GTK_ACCESSIBLE (parent)->widget);
4053 path = gtk_tree_row_reference_get_path (cell_info->cell_row_ref);
4054 gail_return_if_fail (path);
4055 gtk_tree_view_set_cursor (tree_view, path, cell_info->cell_col_ref, TRUE);
4056 gtk_tree_path_free (path);
4061 activate_cell (GailCell *cell)
4063 GailTreeViewCellInfo *cell_info;
4064 GtkTreeView *tree_view;
4067 gboolean is_container_cell = FALSE;
4070 parent = atk_object_get_parent (ATK_OBJECT (cell));
4071 if (GAIL_IS_CONTAINER_CELL (parent))
4073 is_container_cell = TRUE;
4074 parent = atk_object_get_parent (parent);
4077 cell_info = find_cell_info (GAIL_TREE_VIEW (parent), cell, NULL, TRUE);
4078 gail_return_if_fail (cell_info);
4079 gail_return_if_fail (cell_info->cell_col_ref);
4080 gail_return_if_fail (cell_info->cell_row_ref);
4082 tree_view = GTK_TREE_VIEW (GTK_ACCESSIBLE (parent)->widget);
4083 path = gtk_tree_row_reference_get_path (cell_info->cell_row_ref);
4084 gail_return_if_fail (path);
4085 gtk_tree_view_row_activated (tree_view, path, cell_info->cell_col_ref);
4086 gtk_tree_path_free (path);
4091 cell_destroyed (gpointer data)
4093 GailTreeViewCellInfo *cell_info = data;
4095 gail_return_if_fail (cell_info);
4096 if (cell_info->in_use) {
4097 cell_info->in_use = FALSE;
4099 g_assert (GAIL_IS_TREE_VIEW (cell_info->view));
4100 if (!cell_info->view->garbage_collection_pending) {
4101 cell_info->view->garbage_collection_pending = TRUE;
4102 cell_info->view->idle_garbage_collect_id =
4103 gdk_threads_add_idle (idle_garbage_collect_cell_data, cell_info->view);
4110 cell_info_remove (GailTreeView *tree_view,
4113 GailTreeViewCellInfo *info;
4116 info = find_cell_info (tree_view, cell, &temp_list, FALSE);
4119 info->in_use = FALSE;
4122 g_warning ("No cell removed in cell_info_remove\n");
4127 cell_info_get_index (GtkTreeView *tree_view,
4128 GailTreeViewCellInfo *info,
4134 path = gtk_tree_row_reference_get_path (info->cell_row_ref);
4135 gail_return_if_fail (path);
4137 column_number = get_column_number (tree_view, info->cell_col_ref, FALSE);
4138 *index = get_index (tree_view, path, column_number);
4139 gtk_tree_path_free (path);
4143 cell_info_new (GailTreeView *gailview,
4144 GtkTreeModel *tree_model,
4146 GtkTreeViewColumn *tv_col,
4149 GailTreeViewCellInfo *cell_info;
4151 g_assert (GAIL_IS_TREE_VIEW (gailview));
4153 cell_info = g_new (GailTreeViewCellInfo, 1);
4154 cell_info->cell_row_ref = gtk_tree_row_reference_new (tree_model, path);
4156 cell_info->cell_col_ref = tv_col;
4157 cell_info->cell = cell;
4158 cell_info->in_use = TRUE; /* if we've created it, assume it's in use */
4159 cell_info->view = gailview;
4160 gailview->cell_data = g_list_append (gailview->cell_data, cell_info);
4162 /* Setup weak reference notification */
4164 g_object_weak_ref (G_OBJECT (cell),
4165 (GWeakNotify) cell_destroyed,
4170 find_cell (GailTreeView *gailview,
4173 GailTreeViewCellInfo *info;
4174 GtkTreeView *tree_view;
4178 gboolean needs_cleaning = FALSE;
4179 GailCell *retval = NULL;
4181 tree_view = GTK_TREE_VIEW (GTK_ACCESSIBLE (gailview)->widget);
4182 cell_list = gailview->cell_data;
4184 for (l = cell_list; l; l = l->next)
4186 info = (GailTreeViewCellInfo *) (l->data);
4189 cell_info_get_index (tree_view, info, &real_index);
4190 if (index == real_index)
4192 retval = info->cell;
4198 needs_cleaning = TRUE;
4202 garbage_collect_cell_data (gailview);
4208 refresh_cell_index (GailCell *cell)
4210 GailTreeViewCellInfo *info;
4212 GtkTreeView *tree_view;
4215 parent = atk_object_get_parent (ATK_OBJECT (cell));
4216 gail_return_if_fail (GAIL_IS_TREE_VIEW (parent));
4218 tree_view = GTK_TREE_VIEW (GTK_ACCESSIBLE (parent)->widget);
4220 /* Find this cell in the GailTreeView's cache */
4222 info = find_cell_info (GAIL_TREE_VIEW (parent), cell, NULL, TRUE);
4223 gail_return_if_fail (info);
4225 cell_info_get_index (tree_view, info, &index);
4226 cell->index = index;
4230 get_selected_rows (GtkTreeModel *model,
4235 GPtrArray *array = (GPtrArray *)data;
4237 g_ptr_array_add (array, gtk_tree_path_copy (path));
4241 connect_model_signals (GtkTreeView *view,
4242 GailTreeView *gailview)
4246 obj = G_OBJECT (gailview->tree_model);
4247 g_signal_connect_data (obj, "row-changed",
4248 (GCallback) model_row_changed, view, NULL, 0);
4249 g_signal_connect_data (obj, "row-inserted",
4250 (GCallback) model_row_inserted, view, NULL,
4252 g_signal_connect_data (obj, "row-deleted",
4253 (GCallback) model_row_deleted, view, NULL,
4255 g_signal_connect_data (obj, "rows-reordered",
4256 (GCallback) model_rows_reordered, view, NULL,
4261 disconnect_model_signals (GailTreeView *view)
4266 obj = G_OBJECT (view->tree_model);
4267 widget = GTK_ACCESSIBLE (view)->widget;
4268 g_signal_handlers_disconnect_by_func (obj, (gpointer) model_row_changed, widget);
4269 g_signal_handlers_disconnect_by_func (obj, (gpointer) model_row_inserted, widget);
4270 g_signal_handlers_disconnect_by_func (obj, (gpointer) model_row_deleted, widget);
4271 g_signal_handlers_disconnect_by_func (obj, (gpointer) model_rows_reordered, widget);
4275 clear_cached_data (GailTreeView *view)
4281 GArray *array = view->row_data;
4285 * Since the third argument to free_row_info is FALSE, we don't remove
4286 * the element. Therefore it is safe to loop forward.
4288 for (i = 0; i < array->len; i++)
4289 free_row_info (array, i, FALSE);
4291 g_array_free (array, TRUE);
4293 view->row_data = NULL;
4296 if (view->cell_data)
4298 /* Must loop through them all */
4299 for (temp_list = view->cell_data; temp_list; temp_list = temp_list->next)
4301 clean_cell_info (view, temp_list);
4304 garbage_collect_cell_data (view);
4305 if (view->cell_data)
4306 g_list_free (view->cell_data);
4308 view->cell_data = NULL;
4312 * Returns the column number of the specified GtkTreeViewColumn
4314 * If visible is set, the value returned will be the visible column number,
4315 * i.e. suitable for use in AtkTable function. If visible is not set, the
4316 * value returned is the actual column number, which is suitable for use in
4317 * getting an index value.
4320 get_column_number (GtkTreeView *tree_view,
4321 GtkTreeViewColumn *column,
4324 GList *temp_list, *column_list;
4325 GtkTreeViewColumn *tv_column;
4328 column_list = gtk_tree_view_get_columns (tree_view);
4330 for (temp_list = column_list; temp_list; temp_list = temp_list->next)
4332 tv_column = GTK_TREE_VIEW_COLUMN (temp_list->data);
4333 if (tv_column == column)
4335 if (!visible || gtk_tree_view_column_get_visible (tv_column))
4338 if (temp_list == NULL)
4342 g_list_free (column_list);
4347 get_index (GtkTreeView *tree_view,
4353 gint *indices = NULL;
4358 depth = gtk_tree_path_get_depth (path);
4359 indices = gtk_tree_path_get_indices (path);
4364 GtkTreePath *copy_path;
4365 GtkTreeModel *model;
4367 model = gtk_tree_view_get_model (tree_view);
4368 copy_path = gtk_tree_path_copy (path);
4369 gtk_tree_path_up (copy_path);
4370 count_rows (model, NULL, copy_path, &index, 0, depth);
4371 gtk_tree_path_free (copy_path);
4375 index += indices[depth-1];
4376 index *= get_n_actual_columns (tree_view);
4377 index += actual_column;
4382 * The function count_rows counts the number of rows starting at iter and ending
4383 * at end_path. The value of level is the depth of iter and the value of depth
4384 * is the depth of end_path. Rows at depth before end_path are counted.
4385 * This functions counts rows which are not visible because an ancestor is
4389 count_rows (GtkTreeModel *model,
4391 GtkTreePath *end_path,
4396 GtkTreeIter child_iter;
4402 *count += gtk_tree_model_iter_n_children (model, iter);
4405 g_print ("count_rows : %d level: %d depth: %d\n", *count, level, depth);
4407 g_print ("path: %s\n",
4408 gtk_tree_path_to_string (gtk_tree_model_get_path (model, iter)));
4414 if (gtk_tree_model_iter_children (model, &child_iter, iter))
4416 gboolean ret_val = TRUE;
4420 if (level == depth - 1)
4422 GtkTreePath *iter_path;
4423 gboolean finished = FALSE;
4425 iter_path = gtk_tree_model_get_path (model, &child_iter);
4426 if (end_path && gtk_tree_path_compare (iter_path, end_path) >= 0)
4428 gtk_tree_path_free (iter_path);
4432 if (gtk_tree_model_iter_has_child (model, &child_iter))
4433 count_rows (model, &child_iter, end_path, count, level, depth);
4434 ret_val = gtk_tree_model_iter_next (model, &child_iter);
4440 * Find the next node, which has children, at the specified depth below
4441 * the specified iter. The level is the depth of the current iter.
4442 * The position of the node is returned in path and the return value of TRUE
4443 * means that a node was found.
4446 gboolean get_next_node_with_child_at_depth (GtkTreeModel *model,
4452 GtkTreeIter child_iter;
4456 if (gtk_tree_model_iter_children (model, &child_iter, iter))
4462 while (!gtk_tree_model_iter_has_child (model, &child_iter))
4464 if (!gtk_tree_model_iter_next (model, &child_iter))
4469 /* We have found what we were looking for */
4471 *path = gtk_tree_model_get_path (model, &child_iter);
4475 if (get_next_node_with_child_at_depth (model, &child_iter, path,
4479 if (!gtk_tree_model_iter_next (model, &child_iter))
4487 * Find the next node, which has children, at the same depth as
4488 * the specified GtkTreePath.
4491 get_next_node_with_child (GtkTreeModel *model,
4493 GtkTreePath **return_path)
4498 gtk_tree_model_get_iter (model, &iter, path);
4500 while (gtk_tree_model_iter_next (model, &iter))
4502 if (gtk_tree_model_iter_has_child (model, &iter))
4504 *return_path = gtk_tree_model_get_path (model, &iter);
4508 depth = gtk_tree_path_get_depth (path);
4509 while (gtk_tree_path_up (path))
4511 if (gtk_tree_path_get_depth (path) == 0)
4514 gtk_tree_model_get_iter (model, &iter, path);
4515 while (gtk_tree_model_iter_next (model, &iter))
4516 if (get_next_node_with_child_at_depth (model, &iter, return_path,
4517 gtk_tree_path_get_depth (path), depth))
4520 *return_path = NULL;
4525 get_tree_path_from_row_index (GtkTreeModel *model,
4527 GtkTreePath **tree_path)
4533 count = gtk_tree_model_iter_n_children (model, NULL);
4534 if (count > row_index)
4536 if (gtk_tree_model_iter_nth_child (model, &iter, NULL, row_index))
4538 *tree_path = gtk_tree_model_get_path (model, &iter);
4552 if (get_next_node_with_child_at_depth (model, NULL, tree_path, 0, depth))
4554 GtkTreePath *next_path;
4558 gtk_tree_model_get_iter (model, &iter, *tree_path);
4559 count = gtk_tree_model_iter_n_children (model, &iter);
4560 if (count > row_index)
4562 gtk_tree_path_append_index (*tree_path, row_index);
4568 if (!get_next_node_with_child (model, *tree_path, &next_path))
4571 gtk_tree_path_free (*tree_path);
4572 *tree_path = next_path;
4577 g_warning ("Index value is too large\n");
4578 gtk_tree_path_free (*tree_path);
4586 * This function returns the number of rows, including those which are collapsed
4589 get_row_count (GtkTreeModel *model)
4593 count_rows (model, NULL, NULL, &n_rows, 0, G_MAXINT);
4599 get_path_column_from_index (GtkTreeView *tree_view,
4602 GtkTreeViewColumn **column)
4604 GtkTreeModel *tree_model;
4607 tree_model = gtk_tree_view_get_model (tree_view);
4608 n_columns = get_n_actual_columns (tree_view);
4611 /* First row is the column headers */
4621 row_index = index / n_columns;
4622 retval = get_tree_path_from_row_index (tree_model, row_index, path);
4623 gail_return_val_if_fail (retval, FALSE);
4630 *column = gtk_tree_view_get_column (tree_view, index % n_columns);
4631 if (*column == NULL)
4634 gtk_tree_path_free (*path);
4642 set_cell_expandable (GailCell *cell)
4644 if (gail_cell_add_state (cell,
4645 ATK_STATE_EXPANDABLE,
4647 gail_cell_add_action (cell,
4648 "expand or contract", /* action name */
4649 "expands or contracts the row in the tree view "
4650 "containing this cell", /* description */
4651 NULL, /* Keybinding */
4652 toggle_cell_expanded);
4655 static GailTreeViewCellInfo*
4656 find_cell_info (GailTreeView *view,
4662 GailTreeViewCellInfo *cell_info;
4664 for (temp_list = view->cell_data; temp_list; temp_list = temp_list->next)
4666 cell_info = (GailTreeViewCellInfo *) temp_list->data;
4667 if (cell_info->cell == cell && (!live_only || cell_info->in_use))
4678 get_header_from_column (GtkTreeViewColumn *tv_col)
4681 GtkWidget *header_widget;
4686 /* If the user has set a header object, use that */
4688 rc = g_object_get_qdata (G_OBJECT (tv_col), quark_column_header_object);
4692 /* If the user has not set a header object, grab the column */
4693 /* header object defined by the GtkTreeView */
4695 header_widget = tv_col->button;
4699 rc = gtk_widget_get_accessible (header_widget);