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_tree_view_column_get_cell_renderers (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;
1079 widget = GTK_ACCESSIBLE (component)->widget;
1081 /* State is defunct */
1084 tree_view = GTK_TREE_VIEW (widget);
1086 atk_component_get_extents (component, &x_pos, &y_pos, NULL, NULL, coord_type);
1087 ret_val = gtk_tree_view_get_path_at_pos (tree_view,
1088 x - x_pos, y - y_pos,
1089 &path, &tv_column, NULL, NULL);
1094 column = get_column_number (tree_view, tv_column, FALSE);
1095 index = get_index (tree_view, path, column);
1096 gtk_tree_path_free (path);
1098 return gail_tree_view_ref_child (ATK_OBJECT (component), index);
1102 g_warning ("gail_tree_view_ref_accessible_at_point: gtk_tree_view_get_path_at_pos () failed\n");
1110 atk_table_interface_init (AtkTableIface *iface)
1112 iface->ref_at = gail_tree_view_table_ref_at;
1113 iface->get_n_rows = gail_tree_view_get_n_rows;
1114 iface->get_n_columns = gail_tree_view_get_n_columns;
1115 iface->get_index_at = gail_tree_view_get_index_at;
1116 iface->get_column_at_index = gail_tree_view_get_column_at_index;
1117 iface->get_row_at_index = gail_tree_view_get_row_at_index;
1118 iface->is_row_selected = gail_tree_view_is_row_selected;
1119 iface->is_selected = gail_tree_view_is_selected;
1120 iface->get_selected_rows = gail_tree_view_get_selected_rows;
1121 iface->add_row_selection = gail_tree_view_add_row_selection;
1122 iface->remove_row_selection = gail_tree_view_remove_row_selection;
1123 iface->get_column_extent_at = NULL;
1124 iface->get_row_extent_at = NULL;
1125 iface->get_row_header = gail_tree_view_get_row_header;
1126 iface->set_row_header = gail_tree_view_set_row_header;
1127 iface->get_column_header = gail_tree_view_get_column_header;
1128 iface->set_column_header = gail_tree_view_set_column_header;
1129 iface->get_caption = gail_tree_view_get_caption;
1130 iface->set_caption = gail_tree_view_set_caption;
1131 iface->get_summary = gail_tree_view_get_summary;
1132 iface->set_summary = gail_tree_view_set_summary;
1133 iface->get_row_description = gail_tree_view_get_row_description;
1134 iface->set_row_description = gail_tree_view_set_row_description;
1135 iface->get_column_description = gail_tree_view_get_column_description;
1136 iface->set_column_description = gail_tree_view_set_column_description;
1140 gail_tree_view_get_index_at (AtkTable *table,
1145 GtkTreeView *tree_view;
1147 gint n_cols, n_rows;
1152 n_cols = atk_table_get_n_columns (table);
1153 n_rows = atk_table_get_n_rows (table);
1155 if (row >= n_rows ||
1159 widget = GTK_ACCESSIBLE (table)->widget;
1161 /* State is defunct */
1164 tree_view = GTK_TREE_VIEW (widget);
1165 actual_column = get_actual_column_number (tree_view, column);
1167 set_iter_nth_row (tree_view, &iter, row);
1168 path = gtk_tree_model_get_path (gtk_tree_view_get_model (tree_view), &iter);
1170 index = get_index (tree_view, path, actual_column);
1171 gtk_tree_path_free (path);
1177 gail_tree_view_get_column_at_index (AtkTable *table,
1181 GtkTreeView *tree_view;
1184 widget = GTK_ACCESSIBLE (table)->widget;
1186 /* State is defunct */
1189 tree_view = GTK_TREE_VIEW (widget);
1190 n_columns = get_n_actual_columns (tree_view);
1194 index = index % n_columns;
1196 return get_visible_column_number (tree_view, index);
1200 gail_tree_view_get_row_at_index (AtkTable *table,
1204 GtkTreeView *tree_view;
1207 widget = GTK_ACCESSIBLE (table)->widget;
1209 /* State is defunct */
1212 tree_view = GTK_TREE_VIEW (widget);
1213 if (get_path_column_from_index (tree_view, index, &path, NULL))
1215 gint row = get_row_from_tree_path (tree_view, path);
1216 gtk_tree_path_free (path);
1224 gail_tree_view_table_ref_at (AtkTable *table,
1230 index = gail_tree_view_get_index_at (table, row, column);
1234 return gail_tree_view_ref_child (ATK_OBJECT (table), index);
1238 gail_tree_view_get_n_rows (AtkTable *table)
1241 GtkTreeView *tree_view;
1242 GtkTreeModel *tree_model;
1245 widget = GTK_ACCESSIBLE (table)->widget;
1247 /* State is defunct */
1250 tree_view = GTK_TREE_VIEW (widget);
1251 tree_model = gtk_tree_view_get_model (tree_view);
1253 if (gtk_tree_model_get_flags (tree_model) & GTK_TREE_MODEL_LIST_ONLY)
1255 * If working with a LIST store, then this is a faster way
1256 * to get the number of rows.
1258 n_rows = gtk_tree_model_iter_n_children (tree_model, NULL);
1261 GtkTreePath *root_tree;
1264 root_tree = gtk_tree_path_new_first ();
1265 iterate_thru_children (tree_view, tree_model,
1266 root_tree, NULL, &n_rows, 0);
1267 gtk_tree_path_free (root_tree);
1274 * The function get_n_actual_columns returns the number of columns in the
1275 * GtkTreeView. i.e. it include both visible and non-visible columns.
1278 get_n_actual_columns (GtkTreeView *tree_view)
1283 columns = gtk_tree_view_get_columns (tree_view);
1284 n_cols = g_list_length (columns);
1285 g_list_free (columns);
1290 gail_tree_view_get_n_columns (AtkTable *table)
1293 GtkTreeView *tree_view;
1294 GtkTreeViewColumn *tv_col;
1298 widget = GTK_ACCESSIBLE (table)->widget;
1300 /* State is defunct */
1303 tree_view = GTK_TREE_VIEW (widget);
1304 tv_col = gtk_tree_view_get_column (tree_view, i);
1306 while (tv_col != NULL)
1308 if (gtk_tree_view_column_get_visible (tv_col))
1312 tv_col = gtk_tree_view_get_column (tree_view, i);
1319 gail_tree_view_is_row_selected (AtkTable *table,
1323 GtkTreeView *tree_view;
1324 GtkTreeSelection *selection;
1327 widget = GTK_ACCESSIBLE (table)->widget;
1329 /* State is defunct */
1335 tree_view = GTK_TREE_VIEW (widget);
1337 selection = gtk_tree_view_get_selection (tree_view);
1339 set_iter_nth_row (tree_view, &iter, row);
1341 return gtk_tree_selection_iter_is_selected (selection, &iter);
1345 gail_tree_view_is_selected (AtkTable *table,
1349 return gail_tree_view_is_row_selected (table, row);
1353 gail_tree_view_get_selected_rows (AtkTable *table,
1354 gint **rows_selected)
1357 GtkTreeView *tree_view;
1358 GtkTreeModel *tree_model;
1360 GtkTreeSelection *selection;
1361 GtkTreePath *tree_path;
1364 widget = GTK_ACCESSIBLE (table)->widget;
1366 /* State is defunct */
1369 tree_view = GTK_TREE_VIEW (widget);
1371 selection = gtk_tree_view_get_selection (tree_view);
1373 switch (selection->type)
1375 case GTK_SELECTION_SINGLE:
1376 case GTK_SELECTION_BROWSE:
1377 if (gtk_tree_selection_get_selected (selection, &tree_model, &iter))
1383 *rows_selected = (gint *)g_malloc (sizeof(gint));
1384 tree_path = gtk_tree_model_get_path (tree_model, &iter);
1385 row = get_row_from_tree_path (tree_view, tree_path);
1386 gtk_tree_path_free (tree_path);
1388 /* shouldn't ever happen */
1389 g_return_val_if_fail (row != -1, 0);
1391 *rows_selected[0] = row;
1396 case GTK_SELECTION_MULTIPLE:
1398 GPtrArray *array = g_ptr_array_new();
1400 gtk_tree_selection_selected_foreach (selection,
1403 ret_val = array->len;
1405 if (rows_selected && ret_val)
1408 *rows_selected = (gint *) g_malloc (ret_val * sizeof (gint));
1410 for (i = 0; i < ret_val; i++)
1414 tree_path = (GtkTreePath *) g_ptr_array_index (array, i);
1415 row = get_row_from_tree_path (tree_view, tree_path);
1416 gtk_tree_path_free (tree_path);
1417 (*rows_selected)[i] = row;
1420 g_ptr_array_free (array, FALSE);
1423 case GTK_SELECTION_NONE:
1430 gail_tree_view_add_row_selection (AtkTable *table,
1434 GtkTreeView *tree_view;
1435 GtkTreeModel *tree_model;
1436 GtkTreeSelection *selection;
1437 GtkTreePath *tree_path;
1438 GtkTreeIter iter_to_row;
1440 widget = GTK_ACCESSIBLE (table)->widget;
1442 /* State is defunct */
1445 if (!gail_tree_view_is_row_selected (table, row))
1447 tree_view = GTK_TREE_VIEW (widget);
1448 tree_model = gtk_tree_view_get_model (tree_view);
1449 selection = gtk_tree_view_get_selection (tree_view);
1451 if (gtk_tree_model_get_flags (tree_model) & GTK_TREE_MODEL_LIST_ONLY)
1453 tree_path = gtk_tree_path_new ();
1454 gtk_tree_path_append_index (tree_path, row);
1455 gtk_tree_selection_select_path (selection,tree_path);
1456 gtk_tree_path_free (tree_path);
1460 set_iter_nth_row (tree_view, &iter_to_row, row);
1461 if (&iter_to_row != NULL)
1462 gtk_tree_selection_select_iter (selection, &iter_to_row);
1468 return gail_tree_view_is_row_selected (table, row);
1472 gail_tree_view_remove_row_selection (AtkTable *table,
1476 GtkTreeView *tree_view;
1477 GtkTreeSelection *selection;
1479 widget = GTK_ACCESSIBLE (table)->widget;
1481 /* State is defunct */
1484 tree_view = GTK_TREE_VIEW (widget);
1486 selection = gtk_tree_view_get_selection (tree_view);
1488 if (gail_tree_view_is_row_selected (table, row))
1490 gtk_tree_selection_unselect_all (selection);
1497 gail_tree_view_get_row_header (AtkTable *table,
1500 GailTreeViewRowInfo *row_info;
1502 row_info = get_row_info (table, row);
1504 return row_info->header;
1510 gail_tree_view_set_row_header (AtkTable *table,
1514 set_row_data (table, row, header, NULL, TRUE);
1518 gail_tree_view_get_column_header (AtkTable *table,
1522 GtkTreeView *tree_view;
1523 GtkTreeViewColumn *tv_col;
1525 widget = GTK_ACCESSIBLE (table)->widget;
1527 /* State is defunct */
1530 tree_view = GTK_TREE_VIEW (widget);
1531 tv_col = get_column (tree_view, in_col);
1532 return get_header_from_column (tv_col);
1536 gail_tree_view_set_column_header (AtkTable *table,
1541 GtkTreeView *tree_view;
1542 GtkTreeViewColumn *tv_col;
1544 AtkPropertyValues values = { NULL };
1546 widget = GTK_ACCESSIBLE (table)->widget;
1548 /* State is defunct */
1551 tree_view = GTK_TREE_VIEW (widget);
1552 tv_col = get_column (tree_view, in_col);
1556 rc = g_object_get_qdata (G_OBJECT (tv_col),
1557 quark_column_header_object);
1559 g_object_unref (rc);
1561 g_object_set_qdata (G_OBJECT (tv_col),
1562 quark_column_header_object,
1565 g_object_ref (header);
1566 g_value_init (&values.new_value, G_TYPE_INT);
1567 g_value_set_int (&values.new_value, in_col);
1569 values.property_name = "accessible-table-column-header";
1570 g_signal_emit_by_name (table,
1571 "property_change::accessible-table-column-header",
1576 gail_tree_view_get_caption (AtkTable *table)
1578 GailTreeView* obj = GAIL_TREE_VIEW (table);
1580 return obj->caption;
1584 gail_tree_view_set_caption (AtkTable *table,
1587 GailTreeView* obj = GAIL_TREE_VIEW (table);
1588 AtkPropertyValues values = { NULL };
1589 AtkObject *old_caption;
1591 old_caption = obj->caption;
1592 obj->caption = caption;
1594 g_object_ref (obj->caption);
1595 g_value_init (&values.old_value, G_TYPE_POINTER);
1596 g_value_set_pointer (&values.old_value, old_caption);
1597 g_value_init (&values.new_value, G_TYPE_POINTER);
1598 g_value_set_pointer (&values.new_value, obj->caption);
1600 values.property_name = "accessible-table-caption-object";
1601 g_signal_emit_by_name (table,
1602 "property_change::accessible-table-caption-object",
1605 g_object_unref (old_caption);
1608 static G_CONST_RETURN gchar*
1609 gail_tree_view_get_column_description (AtkTable *table,
1613 GtkTreeView *tree_view;
1614 GtkTreeViewColumn *tv_col;
1617 widget = GTK_ACCESSIBLE (table)->widget;
1619 /* State is defunct */
1622 tree_view = GTK_TREE_VIEW (widget);
1623 tv_col = get_column (tree_view, in_col);
1627 rc = g_object_get_qdata (G_OBJECT (tv_col),
1628 quark_column_desc_object);
1636 g_object_get (tv_col, "title", &title_text, NULL);
1642 gail_tree_view_set_column_description (AtkTable *table,
1644 const gchar *description)
1647 GtkTreeView *tree_view;
1648 GtkTreeViewColumn *tv_col;
1649 AtkPropertyValues values = { NULL };
1651 widget = GTK_ACCESSIBLE (table)->widget;
1653 /* State is defunct */
1656 tree_view = GTK_TREE_VIEW (widget);
1657 tv_col = get_column (tree_view, in_col);
1661 g_object_set_qdata (G_OBJECT (tv_col),
1662 quark_column_desc_object,
1663 g_strdup (description));
1664 g_value_init (&values.new_value, G_TYPE_INT);
1665 g_value_set_int (&values.new_value, in_col);
1667 values.property_name = "accessible-table-column-description";
1668 g_signal_emit_by_name (table,
1669 "property_change::accessible-table-column-description",
1673 static G_CONST_RETURN gchar*
1674 gail_tree_view_get_row_description (AtkTable *table,
1677 GailTreeViewRowInfo *row_info;
1679 row_info = get_row_info (table, row);
1681 return row_info->description;
1687 gail_tree_view_set_row_description (AtkTable *table,
1689 const gchar *description)
1691 set_row_data (table, row, NULL, description, FALSE);
1695 gail_tree_view_get_summary (AtkTable *table)
1697 GailTreeView* obj = GAIL_TREE_VIEW (table);
1699 return obj->summary;
1703 gail_tree_view_set_summary (AtkTable *table,
1704 AtkObject *accessible)
1706 GailTreeView* obj = GAIL_TREE_VIEW (table);
1707 AtkPropertyValues values = { NULL };
1708 AtkObject *old_summary;
1710 old_summary = obj->summary;
1711 obj->summary = accessible;
1713 g_object_ref (obj->summary);
1714 g_value_init (&values.old_value, G_TYPE_POINTER);
1715 g_value_set_pointer (&values.old_value, old_summary);
1716 g_value_init (&values.new_value, G_TYPE_POINTER);
1717 g_value_set_pointer (&values.new_value, obj->summary);
1719 values.property_name = "accessible-table-summary";
1720 g_signal_emit_by_name (table,
1721 "property_change::accessible-table-ummary",
1724 g_object_unref (old_summary);
1728 set_row_data (AtkTable *table,
1731 const gchar *description,
1735 GtkTreeView *tree_view;
1736 GtkTreeModel *tree_model;
1737 GailTreeView* obj = GAIL_TREE_VIEW (table);
1738 GailTreeViewRowInfo* row_info;
1742 gboolean found = FALSE;
1744 AtkPropertyValues values = { NULL };
1747 widget = GTK_ACCESSIBLE (table)->widget;
1749 /* State is defunct */
1752 tree_view = GTK_TREE_VIEW (widget);
1753 tree_model = gtk_tree_view_get_model (tree_view);
1755 set_iter_nth_row (tree_view, &iter, row);
1756 path = gtk_tree_model_get_path (tree_model, &iter);
1758 if (obj->row_data == NULL)
1759 obj->row_data = g_array_sized_new (FALSE, TRUE,
1760 sizeof(GailTreeViewRowInfo *), 0);
1762 array = obj->row_data;
1764 for (i = 0; i < array->len; i++)
1766 GtkTreePath *row_path;
1768 row_info = g_array_index (array, GailTreeViewRowInfo*, i);
1769 row_path = gtk_tree_row_reference_get_path (row_info->row_ref);
1771 if (row_path != NULL)
1773 if (path && gtk_tree_path_compare (row_path, path) == 0)
1776 gtk_tree_path_free (row_path);
1782 if (row_info->header)
1783 g_object_unref (row_info->header);
1784 row_info->header = header;
1785 if (row_info->header)
1786 g_object_ref (row_info->header);
1790 g_free (row_info->description);
1791 row_info->description = g_strdup (description);
1801 row_info = g_malloc (sizeof(GailTreeViewRowInfo));
1802 row_info->row_ref = gtk_tree_row_reference_new (tree_model, path);
1805 row_info->header = header;
1806 if (row_info->header)
1807 g_object_ref (row_info->header);
1808 row_info->description = NULL;
1812 row_info->header = NULL;
1813 row_info->description = g_strdup (description);
1815 g_array_append_val (array, row_info);
1817 g_value_init (&values.new_value, G_TYPE_INT);
1818 g_value_set_int (&values.new_value, row);
1822 values.property_name = "accessible-table-row-header";
1823 signal_name = "property_change::accessible-table-row-header";
1827 values.property_name = "accessible-table-row-description";
1828 signal_name = "property-change::accessible-table-row-description";
1830 g_signal_emit_by_name (table,
1834 gtk_tree_path_free (path);
1838 static GailTreeViewRowInfo*
1839 get_row_info (AtkTable *table,
1843 GtkTreeView *tree_view;
1844 GtkTreeModel *tree_model;
1845 GailTreeView* obj = GAIL_TREE_VIEW (table);
1849 GailTreeViewRowInfo *rc = NULL;
1851 widget = GTK_ACCESSIBLE (table)->widget;
1853 /* State is defunct */
1856 tree_view = GTK_TREE_VIEW (widget);
1857 tree_model = gtk_tree_view_get_model (tree_view);
1859 set_iter_nth_row (tree_view, &iter, row);
1860 path = gtk_tree_model_get_path (tree_model, &iter);
1861 array = obj->row_data;
1865 GailTreeViewRowInfo *row_info;
1866 GtkTreePath *row_path;
1869 for (i = 0; i < array->len; i++)
1871 row_info = g_array_index (array, GailTreeViewRowInfo*, i);
1872 row_path = gtk_tree_row_reference_get_path (row_info->row_ref);
1873 if (row_path != NULL)
1875 if (path && gtk_tree_path_compare (row_path, path) == 0)
1878 gtk_tree_path_free (row_path);
1886 gtk_tree_path_free (path);
1889 /* atkselection.h */
1891 static void atk_selection_interface_init (AtkSelectionIface *iface)
1893 iface->add_selection = gail_tree_view_add_selection;
1894 iface->clear_selection = gail_tree_view_clear_selection;
1895 iface->ref_selection = gail_tree_view_ref_selection;
1896 iface->get_selection_count = gail_tree_view_get_selection_count;
1897 iface->is_child_selected = gail_tree_view_is_child_selected;
1901 gail_tree_view_add_selection (AtkSelection *selection,
1908 table = ATK_TABLE (selection);
1909 n_columns = gail_tree_view_get_n_columns (table);
1913 row = gail_tree_view_get_row_at_index (table, i);
1914 return gail_tree_view_add_row_selection (table, row);
1918 gail_tree_view_clear_selection (AtkSelection *selection)
1921 GtkTreeView *tree_view;
1922 GtkTreeSelection *tree_selection;
1924 widget = GTK_ACCESSIBLE (selection)->widget;
1926 /* State is defunct */
1929 tree_view = GTK_TREE_VIEW (widget);
1931 tree_selection = gtk_tree_view_get_selection (tree_view);
1932 gtk_tree_selection_unselect_all (tree_selection);
1938 gail_tree_view_ref_selection (AtkSelection *selection,
1947 table = ATK_TABLE (selection);
1948 n_columns = gail_tree_view_get_n_columns (table);
1949 n_selected = gail_tree_view_get_selected_rows (table, &selected);
1950 if (i >= n_columns * n_selected)
1953 row = selected[i / n_columns];
1956 return gail_tree_view_table_ref_at (table, row, i % n_columns);
1960 gail_tree_view_get_selection_count (AtkSelection *selection)
1965 table = ATK_TABLE (selection);
1966 n_selected = gail_tree_view_get_selected_rows (table, NULL);
1968 n_selected *= gail_tree_view_get_n_columns (table);
1973 gail_tree_view_is_child_selected (AtkSelection *selection,
1979 widget = GTK_ACCESSIBLE (selection)->widget;
1981 /* State is defunct */
1984 row = atk_table_get_row_at_index (ATK_TABLE (selection), i);
1986 return gail_tree_view_is_row_selected (ATK_TABLE (selection), row);
1990 static void gail_cell_parent_interface_init (GailCellParentIface *iface)
1992 iface->get_cell_extents = gail_tree_view_get_cell_extents;
1993 iface->get_cell_area = gail_tree_view_get_cell_area;
1994 iface->grab_focus = gail_tree_view_grab_cell_focus;
1998 gail_tree_view_get_cell_extents (GailCellParent *parent,
2004 AtkCoordType coord_type)
2007 GtkTreeView *tree_view;
2008 GdkWindow *bin_window;
2009 GdkRectangle cell_rect;
2012 widget = GTK_ACCESSIBLE (parent)->widget;
2014 /* State is defunct */
2017 tree_view = GTK_TREE_VIEW (widget);
2018 gail_tree_view_get_cell_area (parent, cell, &cell_rect);
2019 bin_window = gtk_tree_view_get_bin_window (tree_view);
2020 gdk_window_get_origin (bin_window, &w_x, &w_y);
2022 if (coord_type == ATK_XY_WINDOW)
2025 gint x_toplevel, y_toplevel;
2027 window = gdk_window_get_toplevel (bin_window);
2028 gdk_window_get_origin (window, &x_toplevel, &y_toplevel);
2034 *width = cell_rect.width;
2035 *height = cell_rect.height;
2036 if (is_cell_showing (tree_view, &cell_rect))
2038 *x = cell_rect.x + w_x;
2039 *y = cell_rect.y + w_y;
2048 #define EXTRA_EXPANDER_PADDING 4
2051 gail_tree_view_get_cell_area (GailCellParent *parent,
2053 GdkRectangle *cell_rect)
2056 GtkTreeView *tree_view;
2057 GtkTreeViewColumn *tv_col;
2059 AtkObject *parent_cell;
2060 GailTreeViewCellInfo *cell_info;
2063 widget = GTK_ACCESSIBLE (parent)->widget;
2065 /* State is defunct */
2068 tree_view = GTK_TREE_VIEW (widget);
2069 parent_cell = atk_object_get_parent (ATK_OBJECT (cell));
2070 if (parent_cell != ATK_OBJECT (parent))
2073 * GailCell is in a GailContainerCell
2075 top_cell = GAIL_CELL (parent_cell);
2081 cell_info = find_cell_info (GAIL_TREE_VIEW (parent), top_cell, NULL, TRUE);
2082 gail_return_if_fail (cell_info);
2083 gail_return_if_fail (cell_info->cell_col_ref);
2084 gail_return_if_fail (cell_info->cell_row_ref);
2085 path = gtk_tree_row_reference_get_path (cell_info->cell_row_ref);
2086 tv_col = cell_info->cell_col_ref;
2087 if (path && cell_info->in_use)
2089 GtkTreeViewColumn *expander_column;
2090 gint focus_line_width;
2092 gtk_tree_view_get_cell_area (tree_view, path, tv_col, cell_rect);
2093 expander_column = gtk_tree_view_get_expander_column (tree_view);
2094 if (expander_column == tv_col)
2098 gtk_widget_style_get (widget,
2099 "expander_size", &expander_size,
2102 cell_rect->x += expander_size + EXTRA_EXPANDER_PADDING;
2103 cell_rect->width -= expander_size + EXTRA_EXPANDER_PADDING;
2105 gtk_widget_style_get (widget,
2106 "focus-line-width", &focus_line_width,
2109 cell_rect->x += focus_line_width;
2110 cell_rect->width -= 2 * focus_line_width;
2112 gtk_tree_path_free (path);
2115 * A column has more than one renderer so we find the position and width
2118 if (top_cell != cell)
2125 GtkCellRenderer *renderer;
2127 cell_index = atk_object_get_index_in_parent (ATK_OBJECT (cell));
2128 renderers = gtk_tree_view_column_get_cell_renderers (tv_col);
2129 renderer = g_list_nth_data (renderers, cell_index);
2131 found = gtk_tree_view_column_cell_get_position (tv_col, renderer, &cell_start, &cell_width);
2134 cell_rect->x += cell_start;
2135 cell_rect->width = cell_width;
2137 g_list_free (renderers);
2144 gail_tree_view_grab_cell_focus (GailCellParent *parent,
2148 GtkTreeView *tree_view;
2149 GtkTreeViewColumn *tv_col;
2151 AtkObject *parent_cell;
2152 AtkObject *cell_object;
2153 GailTreeViewCellInfo *cell_info;
2154 GtkCellRenderer *renderer = NULL;
2155 GtkWidget *toplevel;
2158 widget = GTK_ACCESSIBLE (parent)->widget;
2160 /* State is defunct */
2163 tree_view = GTK_TREE_VIEW (widget);
2165 cell_info = find_cell_info (GAIL_TREE_VIEW (parent), cell, NULL, TRUE);
2166 gail_return_val_if_fail (cell_info, FALSE);
2167 gail_return_val_if_fail (cell_info->cell_col_ref, FALSE);
2168 gail_return_val_if_fail (cell_info->cell_row_ref, FALSE);
2169 cell_object = ATK_OBJECT (cell);
2170 parent_cell = atk_object_get_parent (cell_object);
2171 tv_col = cell_info->cell_col_ref;
2172 if (parent_cell != ATK_OBJECT (parent))
2175 * GailCell is in a GailContainerCell.
2176 * The GtkTreeViewColumn has multiple renderers;
2177 * find the corresponding one.
2181 renderers = gtk_tree_view_column_get_cell_renderers (tv_col);
2182 if (cell_info->in_use) {
2183 index = atk_object_get_index_in_parent (cell_object);
2184 renderer = g_list_nth_data (renderers, index);
2186 g_list_free (renderers);
2188 path = gtk_tree_row_reference_get_path (cell_info->cell_row_ref);
2189 if (path && cell_info->in_use)
2192 gtk_tree_view_set_cursor_on_cell (tree_view, path, tv_col, renderer, FALSE);
2194 gtk_tree_view_set_cursor (tree_view, path, tv_col, FALSE);
2196 gtk_tree_path_free (path);
2197 gtk_widget_grab_focus (widget);
2198 toplevel = gtk_widget_get_toplevel (widget);
2199 if (GTK_WIDGET_TOPLEVEL (toplevel))
2201 #ifdef GDK_WINDOWING_X11
2202 gtk_window_present_with_time (GTK_WINDOW (toplevel), gdk_x11_get_server_time (widget->window));
2204 gtk_window_present (GTK_WINDOW (toplevel));
2214 /* signal handling */
2217 gail_tree_view_expand_row_gtk (GtkTreeView *tree_view,
2222 GailTreeView *gailview;
2224 g_assert (GTK_IS_TREE_VIEW (tree_view));
2226 atk_obj = gtk_widget_get_accessible (GTK_WIDGET (tree_view));
2228 g_assert (GAIL_IS_TREE_VIEW (atk_obj));
2230 gailview = GAIL_TREE_VIEW (atk_obj);
2233 * The visible rectangle has not been updated when this signal is emitted
2234 * so we process the signal when the GTK processing is completed
2236 /* this seems wrong since it overwrites any other pending expand handlers... */
2237 gailview->idle_expand_path = gtk_tree_path_copy (path);
2238 if (gailview->idle_expand_id)
2239 g_source_remove (gailview->idle_expand_id);
2240 gailview->idle_expand_id = gdk_threads_add_idle (idle_expand_row, gailview);
2245 idle_expand_row (gpointer data)
2247 GailTreeView *gailview = data;
2249 GtkTreeView *tree_view;
2251 GtkTreeModel *tree_model;
2252 gint n_inserted, row;
2254 gailview->idle_expand_id = 0;
2256 path = gailview->idle_expand_path;
2257 tree_view = GTK_TREE_VIEW (GTK_ACCESSIBLE (gailview)->widget);
2259 g_assert (GTK_IS_TREE_VIEW (tree_view));
2261 tree_model = gtk_tree_view_get_model(tree_view);
2265 if (!path || !gtk_tree_model_get_iter (tree_model, &iter, path))
2269 * Update visibility of cells below expansion row
2271 traverse_cells (gailview, path, FALSE, FALSE);
2273 * Figure out number of visible children, the following test
2276 if (gtk_tree_model_iter_has_child (tree_model, &iter))
2278 GtkTreePath *path_copy;
2281 * By passing path into this function, we find the number of
2282 * visible children of path.
2284 path_copy = gtk_tree_path_copy (path);
2285 gtk_tree_path_append_index(path_copy, 0);
2288 iterate_thru_children (tree_view, tree_model,
2289 path_copy, NULL, &n_inserted, 0);
2290 gtk_tree_path_free (path_copy);
2294 /* We can get here if the row expanded callback deleted the row */
2298 /* Set expand state */
2299 set_expand_state (tree_view, tree_model, gailview, path, TRUE);
2301 row = get_row_from_tree_path (tree_view, path);
2303 /* shouldn't ever happen */
2305 g_assert_not_reached ();
2307 /* Must add 1 because the "added rows" are below the row being expanded */
2310 g_signal_emit_by_name (gailview, "row_inserted", row, n_inserted);
2312 gailview->idle_expand_path = NULL;
2314 gtk_tree_path_free (path);
2320 gail_tree_view_collapse_row_gtk (GtkTreeView *tree_view,
2324 GtkTreeModel *tree_model;
2325 AtkObject *atk_obj = gtk_widget_get_accessible (GTK_WIDGET (tree_view));
2326 GailTreeView *gailview = GAIL_TREE_VIEW (atk_obj);
2329 tree_model = gtk_tree_view_get_model (tree_view);
2331 clean_rows (gailview);
2334 * Update visibility of cells below collapsed row
2336 traverse_cells (gailview, path, FALSE, FALSE);
2337 /* Set collapse state */
2338 set_expand_state (tree_view, tree_model, gailview, path, FALSE);
2340 gail_return_val_if_fail (gailview->n_children_deleted, FALSE);
2341 row = get_row_from_tree_path (tree_view, path);
2342 gail_return_val_if_fail (row != -1, FALSE);
2343 g_signal_emit_by_name (atk_obj, "row_deleted", row,
2344 gailview->n_children_deleted);
2345 gailview->n_children_deleted = 0;
2350 gail_tree_view_size_allocate_gtk (GtkWidget *widget,
2351 GtkAllocation *allocation)
2353 AtkObject *atk_obj = gtk_widget_get_accessible (widget);
2354 GailTreeView *gailview = GAIL_TREE_VIEW (atk_obj);
2357 * If the size allocation changes, the visibility of cells may change so
2358 * update the cells visibility.
2360 traverse_cells (gailview, NULL, FALSE, FALSE);
2364 gail_tree_view_set_scroll_adjustments (GtkWidget *widget,
2365 GtkAdjustment *hadj,
2366 GtkAdjustment *vadj)
2368 AtkObject *atk_obj = gtk_widget_get_accessible (widget);
2369 GailTreeView *gailview = GAIL_TREE_VIEW (atk_obj);
2372 g_object_get (widget, hadjustment, &adj, NULL);
2373 if (gailview->old_hadj != adj)
2375 g_signal_handlers_disconnect_by_func (gailview->old_hadj,
2376 (gpointer) adjustment_changed,
2378 gailview->old_hadj = adj;
2379 g_object_add_weak_pointer (G_OBJECT (gailview->old_hadj), (gpointer *)&gailview->old_hadj);
2380 g_signal_connect (adj,
2382 G_CALLBACK (adjustment_changed),
2385 g_object_get (widget, vadjustment, &adj, NULL);
2386 if (gailview->old_vadj != adj)
2388 g_signal_handlers_disconnect_by_func (gailview->old_vadj,
2389 (gpointer) adjustment_changed,
2391 gailview->old_vadj = adj;
2392 g_object_add_weak_pointer (G_OBJECT (gailview->old_vadj), (gpointer *)&gailview->old_vadj);
2393 g_signal_connect (adj,
2395 G_CALLBACK (adjustment_changed),
2401 gail_tree_view_changed_gtk (GtkTreeSelection *selection,
2404 GailTreeView *gailview;
2405 GtkTreeView *tree_view;
2409 GailTreeViewCellInfo *info;
2410 GtkTreeSelection *tree_selection;
2413 gailview = GAIL_TREE_VIEW (data);
2414 cell_list = gailview->cell_data;
2415 widget = GTK_ACCESSIBLE (gailview)->widget;
2418 * destroy signal emitted for widget
2421 tree_view = GTK_TREE_VIEW (widget);
2423 tree_selection = gtk_tree_view_get_selection (tree_view);
2425 for (l = cell_list; l; l = l->next)
2427 info = (GailTreeViewCellInfo *) (l->data);
2431 gail_cell_remove_state (info->cell, ATK_STATE_SELECTED, TRUE);
2433 path = gtk_tree_row_reference_get_path (info->cell_row_ref);
2434 if (path && gtk_tree_selection_path_is_selected (tree_selection, path))
2435 gail_cell_add_state (info->cell, ATK_STATE_SELECTED, TRUE);
2436 gtk_tree_path_free (path);
2439 if (GTK_WIDGET_REALIZED (widget))
2440 g_signal_emit_by_name (gailview, "selection_changed");
2444 columns_changed (GtkTreeView *tree_view)
2446 AtkObject *atk_obj = gtk_widget_get_accessible (GTK_WIDGET(tree_view));
2447 GailTreeView *gailview = GAIL_TREE_VIEW (atk_obj);
2448 GList *tv_cols, *tmp_list;
2449 gboolean column_found;
2450 gboolean move_found = FALSE;
2451 gboolean stale_set = FALSE;
2452 gint column_count = 0;
2456 * This function must determine if the change is an add, delete or
2457 * a move based upon its cache of TreeViewColumns in
2458 * gailview->col_data
2460 tv_cols = gtk_tree_view_get_columns (tree_view);
2462 /* check for adds or moves */
2463 for (tmp_list = tv_cols; tmp_list; tmp_list = tmp_list->next)
2465 column_found = FALSE;
2467 for (i = 0; i < gailview->col_data->len; i++)
2470 if ((GtkTreeViewColumn *)tmp_list->data ==
2471 (GtkTreeViewColumn *)g_array_index (gailview->col_data,
2472 GtkTreeViewColumn *, i))
2474 column_found = TRUE;
2476 /* If the column isn't in the same position, a move happened */
2477 if (!move_found && i != column_count)
2481 /* Set all rows to ATK_STATE_STALE */
2482 traverse_cells (gailview, NULL, TRUE, FALSE);
2486 /* Just emit one column reordered signal when a move happens */
2487 g_signal_emit_by_name (atk_obj, "column_reordered");
2496 * If column_found is FALSE, then an insert happened for column
2497 * number column_count
2501 gint n_cols, n_rows, row;
2505 /* Set all rows to ATK_STATE_STALE */
2506 traverse_cells (gailview, NULL, TRUE, FALSE);
2510 /* Generate column-inserted signal */
2511 g_signal_emit_by_name (atk_obj, "column_inserted", column_count, 1);
2513 /* Generate children-changed signals */
2514 n_rows = get_row_count (gtk_tree_view_get_model (tree_view));
2515 n_cols = get_n_actual_columns (tree_view);
2516 for (row = 0; row < n_rows; row++)
2519 * Pass NULL as the child object, i.e. 4th argument.
2521 g_signal_emit_by_name (atk_obj, "children_changed::add",
2522 ((row * n_cols) + column_count), NULL, NULL);
2529 /* check for deletes */
2530 for (i = 0; i < gailview->col_data->len; i++)
2532 column_found = FALSE;
2534 for (tmp_list = tv_cols; tmp_list; tmp_list = tmp_list->next)
2536 if ((GtkTreeViewColumn *)tmp_list->data ==
2537 (GtkTreeViewColumn *)g_array_index (gailview->col_data,
2538 GtkTreeViewColumn *, i))
2540 column_found = TRUE;
2546 * If column_found is FALSE, then a delete happened for column
2551 gint n_rows, n_cols, row;
2553 clean_cols (gailview,
2554 (GtkTreeViewColumn *)g_array_index (gailview->col_data,
2555 GtkTreeViewColumn *, i));
2559 /* Set all rows to ATK_STATE_STALE */
2560 traverse_cells (gailview, NULL, TRUE, FALSE);
2564 /* Generate column-deleted signal */
2565 g_signal_emit_by_name (atk_obj, "column_deleted", i, 1);
2567 /* Generate children-changed signals */
2568 n_rows = get_row_count (gtk_tree_view_get_model (tree_view));
2569 n_cols = get_n_actual_columns (tree_view);
2570 for (row = 0; row < n_rows; row++)
2573 * Pass NULL as the child object, 4th argument.
2575 g_signal_emit_by_name (atk_obj, "children_changed::remove",
2576 ((row * n_cols) + column_count), NULL, NULL);
2581 /* rebuild the array */
2583 g_array_free (gailview->col_data, TRUE);
2584 gailview->col_data = g_array_sized_new (FALSE, TRUE,
2585 sizeof(GtkTreeViewColumn *), 0);
2587 for (tmp_list = tv_cols; tmp_list; tmp_list = tmp_list->next)
2588 g_array_append_val (gailview->col_data, tmp_list->data);
2589 g_list_free (tv_cols);
2593 cursor_changed (GtkTreeView *tree_view)
2595 GailTreeView *gailview;
2597 gailview = GAIL_TREE_VIEW (gtk_widget_get_accessible (GTK_WIDGET (tree_view)));
2598 if (gailview->idle_cursor_changed_id != 0)
2602 * We notify the focus change in a idle handler so that the processing
2603 * of the cursor change is completed when the focus handler is called.
2604 * This will allow actions to be called in the focus handler
2606 gailview->idle_cursor_changed_id = gdk_threads_add_idle (idle_cursor_changed, gailview);
2610 idle_cursor_changed (gpointer data)
2612 GailTreeView *gail_tree_view = GAIL_TREE_VIEW (data);
2613 GtkTreeView *tree_view;
2617 gail_tree_view->idle_cursor_changed_id = 0;
2619 widget = GTK_ACCESSIBLE (gail_tree_view)->widget;
2621 * Widget has been deleted
2626 tree_view = GTK_TREE_VIEW (widget);
2628 cell = gail_tree_view_ref_focus_cell (tree_view);
2631 if (cell != gail_tree_view->focus_cell)
2633 if (gail_tree_view->focus_cell)
2635 gail_cell_remove_state (GAIL_CELL (gail_tree_view->focus_cell), ATK_STATE_ACTIVE, FALSE);
2636 gail_cell_remove_state (GAIL_CELL (gail_tree_view->focus_cell), ATK_STATE_FOCUSED, FALSE);
2637 g_object_unref (gail_tree_view->focus_cell);
2639 gail_tree_view->focus_cell = cell;
2641 if (GTK_WIDGET_HAS_FOCUS (widget))
2643 gail_cell_add_state (GAIL_CELL (cell), ATK_STATE_ACTIVE, FALSE);
2644 gail_cell_add_state (GAIL_CELL (cell), ATK_STATE_FOCUSED, FALSE);
2646 g_signal_emit_by_name (gail_tree_view,
2647 "active-descendant-changed",
2651 g_object_unref (cell);
2658 focus_in (GtkWidget *widget)
2660 GtkTreeView *tree_view;
2661 GailTreeView *gail_tree_view;
2662 AtkStateSet *state_set;
2665 tree_view = GTK_TREE_VIEW (widget);
2666 gail_tree_view = GAIL_TREE_VIEW (gtk_widget_get_accessible (widget));
2668 if (gail_tree_view->focus_cell == NULL)
2670 cell = gail_tree_view_ref_focus_cell (tree_view);
2673 state_set = atk_object_ref_state_set (cell);
2676 if (!atk_state_set_contains_state (state_set, ATK_STATE_FOCUSED))
2678 gail_cell_add_state (GAIL_CELL (cell), ATK_STATE_ACTIVE, FALSE);
2679 gail_tree_view->focus_cell = cell;
2680 gail_cell_add_state (GAIL_CELL (cell), ATK_STATE_FOCUSED, FALSE);
2681 g_signal_emit_by_name (gail_tree_view,
2682 "active-descendant-changed",
2685 g_object_unref (state_set);
2692 focus_out (GtkWidget *widget)
2694 GailTreeView *gail_tree_view;
2696 gail_tree_view = GAIL_TREE_VIEW (gtk_widget_get_accessible (widget));
2697 if (gail_tree_view->focus_cell)
2699 gail_cell_remove_state (GAIL_CELL (gail_tree_view->focus_cell), ATK_STATE_ACTIVE, FALSE);
2700 gail_cell_remove_state (GAIL_CELL (gail_tree_view->focus_cell), ATK_STATE_FOCUSED, FALSE);
2701 g_object_unref (gail_tree_view->focus_cell);
2702 gail_tree_view->focus_cell = NULL;
2707 model_row_changed (GtkTreeModel *tree_model,
2712 GtkTreeView *tree_view = GTK_TREE_VIEW(user_data);
2713 GailTreeView *gailview;
2714 GtkTreePath *cell_path;
2716 GailTreeViewCellInfo *cell_info;
2718 gailview = GAIL_TREE_VIEW (gtk_widget_get_accessible (GTK_WIDGET (tree_view)));
2720 /* Loop through our cached cells */
2721 /* Must loop through them all */
2722 for (l = gailview->cell_data; l; l = l->next)
2724 cell_info = (GailTreeViewCellInfo *) l->data;
2725 if (cell_info->in_use)
2727 cell_path = gtk_tree_row_reference_get_path (cell_info->cell_row_ref);
2729 if (cell_path != NULL)
2731 if (path && gtk_tree_path_compare (cell_path, path) == 0)
2733 if (GAIL_IS_RENDERER_CELL (cell_info->cell))
2735 update_cell_value (GAIL_RENDERER_CELL (cell_info->cell),
2739 gtk_tree_path_free (cell_path);
2743 g_signal_emit_by_name (gailview, "visible-data-changed");
2747 column_visibility_changed (GObject *object,
2751 if (strcmp (pspec->name, "visible") == 0)
2754 * A column has been made visible or invisible
2756 * We update our cache of cells and emit model_changed signal
2758 GtkTreeView *tree_view = (GtkTreeView *)user_data;
2759 GailTreeView *gailview;
2761 GailTreeViewCellInfo *cell_info;
2762 GtkTreeViewColumn *this_col = GTK_TREE_VIEW_COLUMN (object);
2763 GtkTreeViewColumn *tv_col;
2765 gailview = GAIL_TREE_VIEW (gtk_widget_get_accessible (GTK_WIDGET (tree_view))
2767 g_signal_emit_by_name (gailview, "model_changed");
2769 for (l = gailview->cell_data; l; l = l->next)
2771 cell_info = (GailTreeViewCellInfo *) l->data;
2772 if (cell_info->in_use)
2774 tv_col = cell_info->cell_col_ref;
2775 if (tv_col == this_col)
2777 GtkTreePath *row_path;
2778 row_path = gtk_tree_row_reference_get_path (cell_info->cell_row_ref);
2779 if (GAIL_IS_RENDERER_CELL (cell_info->cell))
2781 if (gtk_tree_view_column_get_visible (tv_col))
2782 set_cell_visibility (tree_view,
2784 tv_col, row_path, FALSE);
2787 gail_cell_remove_state (cell_info->cell,
2788 ATK_STATE_VISIBLE, TRUE);
2789 gail_cell_remove_state (cell_info->cell,
2790 ATK_STATE_SHOWING, TRUE);
2793 gtk_tree_path_free (row_path);
2801 * This is the signal handler for the "destroy" signal for a GtkTreeViewColumn
2803 * We check whether we have stored column description or column header
2804 * and if so we get rid of it.
2807 column_destroy (GtkObject *obj)
2809 GtkTreeViewColumn *tv_col = GTK_TREE_VIEW_COLUMN (obj);
2813 header = g_object_get_qdata (G_OBJECT (tv_col),
2814 quark_column_header_object);
2816 g_object_unref (header);
2817 desc = g_object_get_qdata (G_OBJECT (tv_col),
2818 quark_column_desc_object);
2823 model_row_inserted (GtkTreeModel *tree_model,
2828 GtkTreeView *tree_view = (GtkTreeView *)user_data;
2829 GtkTreePath *path_copy;
2830 AtkObject *atk_obj = gtk_widget_get_accessible (GTK_WIDGET (tree_view));
2831 GailTreeView *gailview = GAIL_TREE_VIEW (atk_obj);
2832 gint row, n_inserted, child_row;
2834 if (gailview->idle_expand_id)
2836 g_source_remove (gailview->idle_expand_id);
2837 gailview->idle_expand_id = 0;
2839 /* don't do this if the insertion precedes the idle path, since it will now be invalid */
2840 if (path && gailview->idle_expand_path &&
2841 (gtk_tree_path_compare (path, gailview->idle_expand_path) > 0))
2842 set_expand_state (tree_view, tree_model, gailview, gailview->idle_expand_path, FALSE);
2843 if (gailview->idle_expand_path)
2844 gtk_tree_path_free (gailview->idle_expand_path);
2846 /* Check to see if row is visible */
2847 row = get_row_from_tree_path (tree_view, path);
2850 * A row insert is not necessarily visible. For example,
2851 * a row can be draged & dropped into another row, which
2852 * causes an insert on the model that isn't visible in the
2853 * view. Only generate a signal if the inserted row is
2861 gtk_tree_model_get_iter (tree_model, &iter, path);
2863 /* Figure out number of visible children. */
2864 if (gtk_tree_model_iter_has_child (tree_model, &iter))
2867 * By passing path into this function, we find the number of
2868 * visible children of path.
2871 iterate_thru_children (tree_view, tree_model,
2872 path, NULL, &n_inserted, 0);
2874 /* Must add one to include the row that is being added */
2880 /* Set rows below the inserted row to ATK_STATE_STALE */
2881 traverse_cells (gailview, path, TRUE, TRUE);
2883 /* Generate row-inserted signal */
2884 g_signal_emit_by_name (atk_obj, "row_inserted", row, n_inserted);
2886 /* Generate children-changed signals */
2887 n_cols = gail_tree_view_get_n_columns (ATK_TABLE (atk_obj));
2888 for (child_row = row; child_row < (row + n_inserted); child_row++)
2890 for (col = 0; col < n_cols; col++)
2893 * Pass NULL as the child object, i.e. 4th argument
2895 g_signal_emit_by_name (atk_obj, "children_changed::add",
2896 ((row * n_cols) + col), NULL, NULL);
2903 * The row has been inserted inside another row. This can
2904 * cause a row that previously couldn't be expanded to now
2907 path_copy = gtk_tree_path_copy (path);
2908 gtk_tree_path_up (path_copy);
2909 set_expand_state (tree_view, tree_model, gailview, path_copy, TRUE);
2910 gtk_tree_path_free (path_copy);
2915 model_row_deleted (GtkTreeModel *tree_model,
2919 GtkTreeView *tree_view;
2920 GtkTreePath *path_copy;
2922 GailTreeView *gailview;
2923 gint row, col, n_cols;
2925 tree_view = (GtkTreeView *)user_data;
2926 atk_obj = gtk_widget_get_accessible (GTK_WIDGET (tree_view));
2927 gailview = GAIL_TREE_VIEW (atk_obj);
2929 if (gailview->idle_expand_id)
2931 g_source_remove (gailview->idle_expand_id);
2932 gtk_tree_path_free (gailview->idle_expand_path);
2933 gailview->idle_expand_id = 0;
2935 /* Check to see if row is visible */
2936 clean_rows (gailview);
2938 /* Set rows at or below the specified row to ATK_STATE_STALE */
2939 traverse_cells (gailview, path, TRUE, TRUE);
2942 * If deleting a row with a depth > 1, then this may affect the
2943 * expansion/contraction of its parent(s). Make sure this is
2946 if (gtk_tree_path_get_depth (path) > 1)
2948 path_copy = gtk_tree_path_copy (path);
2949 gtk_tree_path_up (path_copy);
2950 set_expand_state (tree_view, tree_model, gailview, path_copy, TRUE);
2951 gtk_tree_path_free (path_copy);
2953 row = get_row_from_tree_path (tree_view, path);
2955 * If the row which is deleted is not visible because it is a child of
2956 * a collapsed row then row will be -1
2959 g_signal_emit_by_name (atk_obj, "row_deleted", row,
2960 gailview->n_children_deleted + 1);
2961 gailview->n_children_deleted = 0;
2963 /* Generate children-changed signals */
2964 n_cols = get_n_actual_columns (tree_view);
2965 for (col = 0; col < n_cols; col++)
2968 * Pass NULL as the child object, 4th argument.
2970 g_signal_emit_by_name (atk_obj, "children_changed::remove",
2971 ((row * n_cols) + col), NULL, NULL);
2976 * This function gets called when a row is deleted or when rows are
2977 * removed from the view due to a collapse event. Note that the
2978 * count is the number of visible *children* of the deleted row,
2979 * so it does not include the row being deleted.
2981 * As this function is called before the rows are removed we just note the
2982 * number of rows and then deal with it when we get a notification that
2983 * rows were deleted or collapsed.
2986 destroy_count_func (GtkTreeView *tree_view,
2991 AtkObject *atk_obj = gtk_widget_get_accessible (GTK_WIDGET (tree_view));
2992 GailTreeView *gailview = GAIL_TREE_VIEW (atk_obj);
2994 gail_return_if_fail (gailview->n_children_deleted == 0);
2995 gailview->n_children_deleted = count;
2999 model_rows_reordered (GtkTreeModel *tree_model,
3005 GtkTreeView *tree_view = (GtkTreeView *)user_data;
3006 AtkObject *atk_obj = gtk_widget_get_accessible (GTK_WIDGET (tree_view));
3007 GailTreeView *gailview = GAIL_TREE_VIEW (atk_obj);
3009 if (gailview->idle_expand_id)
3011 g_source_remove (gailview->idle_expand_id);
3012 gtk_tree_path_free (gailview->idle_expand_path);
3013 gailview->idle_expand_id = 0;
3015 traverse_cells (gailview, NULL, TRUE, FALSE);
3017 g_signal_emit_by_name (atk_obj, "row_reordered");
3021 adjustment_changed (GtkAdjustment *adjustment,
3022 GtkTreeView *tree_view)
3028 * The scrollbars have changed
3030 atk_obj = gtk_widget_get_accessible (GTK_WIDGET (tree_view));
3031 obj = GAIL_TREE_VIEW (atk_obj);
3033 traverse_cells (obj, NULL, FALSE, FALSE);
3037 set_cell_visibility (GtkTreeView *tree_view,
3039 GtkTreeViewColumn *tv_col,
3040 GtkTreePath *tree_path,
3041 gboolean emit_signal)
3043 GdkRectangle cell_rect;
3045 /* Get these three values in tree coords */
3046 if (GTK_WIDGET_REALIZED (GTK_WIDGET (tree_view)))
3047 gtk_tree_view_get_cell_area (tree_view, tree_path, tv_col, &cell_rect);
3049 cell_rect.height = 0;
3051 if (cell_rect.height > 0)
3054 * The height will be zero for a cell for which an antecedent is not
3057 gail_cell_add_state (cell, ATK_STATE_VISIBLE, emit_signal);
3058 if (is_cell_showing (tree_view, &cell_rect))
3059 gail_cell_add_state (cell, ATK_STATE_SHOWING, emit_signal);
3061 gail_cell_remove_state (cell, ATK_STATE_SHOWING, emit_signal);
3065 gail_cell_remove_state (cell, ATK_STATE_VISIBLE, emit_signal);
3066 gail_cell_remove_state (cell, ATK_STATE_SHOWING, emit_signal);
3071 is_cell_showing (GtkTreeView *tree_view,
3072 GdkRectangle *cell_rect)
3074 GdkRectangle rect, *visible_rect;
3075 GdkRectangle rect1, *tree_cell_rect;
3076 gboolean is_showing;
3078 * A cell is considered "SHOWING" if any part of the cell is in the visible
3079 * area. Other ways we could do this is by a cell's midpoint or if the cell
3080 * is fully in the visible range. Since we have the cell_rect x,y,width,height
3081 * of the cell, any of these is easy to compute.
3083 * It is assumed that cell's rectangle is in widget coordinates so we
3084 * must transform to tree cordinates.
3086 visible_rect = ▭
3087 tree_cell_rect = &rect1;
3088 tree_cell_rect->x = cell_rect->x;
3089 tree_cell_rect->width = cell_rect->width;
3090 tree_cell_rect->height = cell_rect->height;
3092 gtk_tree_view_get_visible_rect (tree_view, visible_rect);
3093 gtk_tree_view_convert_widget_to_bin_window_coords (tree_view,
3094 cell_rect->x, cell_rect->y,
3097 if (((tree_cell_rect->x + tree_cell_rect->width) < visible_rect->x) ||
3098 ((tree_cell_rect->y + tree_cell_rect->height) < (visible_rect->y)) ||
3099 (tree_cell_rect->x > (visible_rect->x + visible_rect->width)) ||
3100 (tree_cell_rect->y > (visible_rect->y + visible_rect->height)))
3111 * This function is called when a cell's flyweight is created in
3112 * gail_tree_view_table_ref_at with emit_change_signal set to FALSE
3113 * and in model_row_changed() on receipt of "row-changed" signal when
3114 * emit_change_signal is set to TRUE
3117 update_cell_value (GailRendererCell *renderer_cell,
3118 GailTreeView *gailview,
3119 gboolean emit_change_signal)
3121 GailTreeViewCellInfo *cell_info;
3122 GtkTreeView *tree_view;
3123 GtkTreeModel *tree_model;
3126 GList *renderers, *cur_renderer;
3128 GailRendererCellClass *gail_renderer_cell_class;
3129 GtkCellRendererClass *gtk_cell_renderer_class;
3133 gboolean is_expander, is_expanded;
3135 gail_renderer_cell_class = GAIL_RENDERER_CELL_GET_CLASS (renderer_cell);
3136 if (renderer_cell->renderer)
3137 gtk_cell_renderer_class = GTK_CELL_RENDERER_GET_CLASS (renderer_cell->renderer);
3139 gtk_cell_renderer_class = NULL;
3141 prop_list = gail_renderer_cell_class->property_list;
3143 cell = GAIL_CELL (renderer_cell);
3144 cell_info = find_cell_info (gailview, cell, NULL, TRUE);
3145 gail_return_val_if_fail (cell_info, FALSE);
3146 gail_return_val_if_fail (cell_info->cell_col_ref, FALSE);
3147 gail_return_val_if_fail (cell_info->cell_row_ref, FALSE);
3149 if (emit_change_signal && cell_info->in_use)
3151 tree_view = GTK_TREE_VIEW (GTK_ACCESSIBLE (gailview)->widget);
3152 tree_model = gtk_tree_view_get_model (tree_view);
3153 path = gtk_tree_row_reference_get_path (cell_info->cell_row_ref);
3157 gtk_tree_model_get_iter (tree_model, &iter, path);
3158 is_expander = FALSE;
3159 is_expanded = FALSE;
3160 if (gtk_tree_model_iter_has_child (tree_model, &iter))
3162 GtkTreeViewColumn *expander_tv;
3164 expander_tv = gtk_tree_view_get_expander_column (tree_view);
3165 if (expander_tv == cell_info->cell_col_ref)
3168 is_expanded = gtk_tree_view_row_expanded (tree_view, path);
3171 gtk_tree_path_free (path);
3172 gtk_tree_view_column_cell_set_cell_data (cell_info->cell_col_ref,
3173 tree_model, &iter, is_expander, is_expanded);
3175 renderers = gtk_tree_view_column_get_cell_renderers (cell_info->cell_col_ref);
3176 gail_return_val_if_fail (renderers, FALSE);
3179 * If the cell is in a container, it's index is used to find the renderer
3184 * Otherwise, we assume that the cell is represented by the first renderer
3188 if (cell_info->in_use) {
3189 parent = atk_object_get_parent (ATK_OBJECT (cell));
3190 if (!ATK_IS_OBJECT (cell)) g_on_error_query (NULL);
3191 if (GAIL_IS_CONTAINER_CELL (parent))
3192 cur_renderer = g_list_nth (renderers, cell->index);
3194 cur_renderer = renderers;
3200 gail_return_val_if_fail (cur_renderer != NULL, FALSE);
3202 if (gtk_cell_renderer_class)
3206 spec = g_object_class_find_property
3207 (G_OBJECT_CLASS (gtk_cell_renderer_class), *prop_list);
3211 GValue value = { 0, };
3213 g_value_init (&value, spec->value_type);
3214 g_object_get_property (cur_renderer->data, *prop_list, &value);
3215 g_object_set_property (G_OBJECT (renderer_cell->renderer),
3216 *prop_list, &value);
3217 g_value_unset(&value);
3220 g_warning ("Invalid property: %s\n", *prop_list);
3224 g_list_free (renderers);
3225 return gail_renderer_cell_update_cache (renderer_cell, emit_change_signal);
3229 set_iter_nth_row (GtkTreeView *tree_view,
3233 GtkTreeModel *tree_model;
3235 tree_model = gtk_tree_view_get_model (tree_view);
3236 gtk_tree_model_get_iter_first (tree_model, iter);
3237 iter = return_iter_nth_row (tree_view, tree_model, iter, 0 , row);
3241 get_row_from_tree_path (GtkTreeView *tree_view,
3244 GtkTreeModel *tree_model;
3245 GtkTreePath *root_tree;
3248 tree_model = gtk_tree_view_get_model (tree_view);
3250 if (gtk_tree_model_get_flags (tree_model) & GTK_TREE_MODEL_LIST_ONLY)
3251 row = gtk_tree_path_get_indices (path)[0];
3254 root_tree = gtk_tree_path_new_first ();
3256 iterate_thru_children (tree_view, tree_model, root_tree, path, &row, 0);
3257 gtk_tree_path_free (root_tree);
3266 * Get the specified GtkTreeViewColumn in the GtkTreeView.
3267 * Only visible columns are considered.
3269 static GtkTreeViewColumn*
3270 get_column (GtkTreeView *tree_view,
3273 GtkTreeViewColumn *tv_col;
3279 g_warning ("Request for invalid column %d\n", in_col);
3283 tv_col = gtk_tree_view_get_column (tree_view, i);
3285 while (tv_col != NULL)
3287 if (gtk_tree_view_column_get_visible (tv_col))
3289 if (in_col == n_cols)
3291 tv_col = gtk_tree_view_get_column (tree_view, ++i);
3294 if (in_col != n_cols)
3296 g_warning ("Request for invalid column %d\n", in_col);
3303 get_actual_column_number (GtkTreeView *tree_view,
3304 gint visible_column)
3306 GtkTreeViewColumn *tv_col;
3307 gint actual_column = 0;
3308 gint visible_columns = -1;
3310 * This function calculates the column number which corresponds to the
3311 * specified visible column number
3313 tv_col = gtk_tree_view_get_column (tree_view, actual_column);
3315 while (tv_col != NULL)
3317 if (gtk_tree_view_column_get_visible (tv_col))
3319 if (visible_columns == visible_column)
3320 return actual_column;
3321 tv_col = gtk_tree_view_get_column (tree_view, ++actual_column);
3323 g_warning ("get_actual_column_number failed for %d\n", visible_column);
3328 get_visible_column_number (GtkTreeView *tree_view,
3331 GtkTreeViewColumn *tv_col;
3333 gint visible_columns = -1;
3335 * This function calculates the visible column number which corresponds to the
3336 * specified actual column number
3338 tv_col = gtk_tree_view_get_column (tree_view, column);
3340 while (tv_col != NULL)
3342 if (gtk_tree_view_column_get_visible (tv_col))
3345 if (actual_column == column)
3346 return visible_columns;
3349 if (actual_column == column)
3351 tv_col = gtk_tree_view_get_column (tree_view, ++column);
3353 g_warning ("get_visible_column_number failed for %d\n", actual_column);
3358 * Helper recursive function that returns GtkTreeIter pointer to nth row.
3361 return_iter_nth_row(GtkTreeView *tree_view,
3362 GtkTreeModel *tree_model,
3367 GtkTreePath *current_path = gtk_tree_model_get_path (tree_model, iter);
3368 GtkTreeIter new_iter;
3369 gboolean row_expanded;
3371 if (increment == row) {
3372 gtk_tree_path_free (current_path);
3376 row_expanded = gtk_tree_view_row_expanded (tree_view, current_path);
3377 gtk_tree_path_free (current_path);
3380 if ((row_expanded && gtk_tree_model_iter_children (tree_model, iter, &new_iter)) ||
3381 (gtk_tree_model_iter_next (tree_model, iter)) ||
3382 (gtk_tree_model_iter_parent (tree_model, iter, &new_iter) &&
3383 (gtk_tree_model_iter_next (tree_model, iter))))
3384 return return_iter_nth_row (tree_view, tree_model, iter,
3391 * Recursively called until the row specified by orig is found.
3393 * *count will be set to the visible row number of the child
3394 * relative to the row that was initially passed in as tree_path.
3396 * *count will be -1 if orig is not found as a child (a row that is
3397 * not visible will not be found, e.g. if the row is inside a
3398 * collapsed row). If NULL is passed in as orig, *count will
3399 * be a count of the visible children.
3401 * NOTE: the value for depth must be 0 when this recursive function
3402 * is initially called, or it may not function as expected.
3405 iterate_thru_children(GtkTreeView *tree_view,
3406 GtkTreeModel *tree_model,
3407 GtkTreePath *tree_path,
3414 if (!gtk_tree_model_get_iter (tree_model, &iter, tree_path))
3417 if (tree_path && orig && !gtk_tree_path_compare (tree_path, orig))
3421 if (tree_path && orig && gtk_tree_path_compare (tree_path, orig) > 0)
3423 /* Past it, so return -1 */
3427 else if (gtk_tree_view_row_expanded (tree_view, tree_path) &&
3428 gtk_tree_model_iter_has_child (tree_model, &iter))
3431 gtk_tree_path_append_index (tree_path, 0);
3432 iterate_thru_children (tree_view, tree_model, tree_path,
3433 orig, count, (depth + 1));
3436 else if (gtk_tree_model_iter_next (tree_model, &iter))
3439 tree_path = gtk_tree_model_get_path (tree_model, &iter);
3442 iterate_thru_children (tree_view, tree_model, tree_path,
3443 orig, count, depth);
3444 gtk_tree_path_free (tree_path);
3448 else if (gtk_tree_path_up (tree_path))
3450 GtkTreeIter temp_iter;
3451 gboolean exit_loop = FALSE;
3452 gint new_depth = depth - 1;
3457 * Make sure that we back up until we find a row
3458 * where gtk_tree_path_next does not return NULL.
3462 if (gtk_tree_path_get_depth (tree_path) == 0)
3463 /* depth is now zero so */
3465 gtk_tree_path_next (tree_path);
3467 /* Verify that the next row is a valid row! */
3468 exit_loop = gtk_tree_model_get_iter (tree_model, &temp_iter, tree_path);
3472 /* Keep going up until we find a row that has a valid next */
3473 if (gtk_tree_path_get_depth(tree_path) > 1)
3476 gtk_tree_path_up (tree_path);
3481 * If depth is 1 and gtk_tree_model_get_iter returns FALSE,
3482 * then we are at the last row, so just return.
3493 * This guarantees that we will stop when we hit the end of the
3499 iterate_thru_children (tree_view, tree_model, tree_path,
3500 orig, count, new_depth);
3505 * If it gets here, then the path wasn't found. Situations
3506 * that would cause this would be if the path passed in is
3507 * invalid or contained within the last row, but not visible
3508 * because the last row is not expanded. If NULL was passed
3509 * in then a row count is desired, so only set count to -1
3510 * if orig is not NULL.
3519 clean_cell_info (GailTreeView *gailview,
3522 GailTreeViewCellInfo *cell_info;
3525 g_assert (GAIL_IS_TREE_VIEW (gailview));
3527 cell_info = list->data;
3529 if (cell_info->in_use) {
3530 obj = G_OBJECT (cell_info->cell);
3532 gail_cell_add_state (cell_info->cell, ATK_STATE_DEFUNCT, TRUE);
3533 g_object_weak_unref (obj, (GWeakNotify) cell_destroyed, cell_info);
3534 cell_info->in_use = FALSE;
3535 if (!gailview->garbage_collection_pending) {
3536 gailview->garbage_collection_pending = TRUE;
3537 g_assert (gailview->idle_garbage_collect_id == 0);
3538 gailview->idle_garbage_collect_id =
3539 gdk_threads_add_idle (idle_garbage_collect_cell_data, gailview);
3545 clean_rows (GailTreeView *gailview)
3549 /* Clean GailTreeViewRowInfo data */
3551 array = gailview->row_data;
3554 GailTreeViewRowInfo *row_info;
3555 GtkTreePath *row_path;
3559 * Loop backwards so that calls to free_row_info
3560 * do not affect the index numbers
3562 for (i = (array->len - 1); i >= 0; i --)
3564 row_info = g_array_index (array, GailTreeViewRowInfo*, i);
3565 row_path = gtk_tree_row_reference_get_path (row_info->row_ref);
3567 /* Remove any rows that have become invalid */
3568 if (row_path == NULL)
3569 free_row_info (array, i, TRUE);
3571 gtk_tree_path_free (row_path);
3575 /* Clean GailTreeViewCellInfo data */
3577 if (gailview->cell_data != NULL)
3579 GailTreeViewCellInfo *cell_info;
3580 GtkTreePath *row_path;
3584 temp_list = gailview->cell_data;
3586 /* Must loop through them all */
3587 while (temp_list != NULL)
3589 cur_list = temp_list;
3590 cell_info = temp_list->data;
3591 temp_list = temp_list->next;
3592 row_path = gtk_tree_row_reference_get_path (cell_info->cell_row_ref);
3595 * If the cell has become invalid because the row has been removed,
3596 * then set the cell's state to ATK_STATE_DEFUNCT and remove the cell
3597 * from gailview->cell_data. If row_path is NULL then the row has
3600 if (row_path == NULL)
3602 clean_cell_info (gailview, cur_list);
3606 gtk_tree_path_free (row_path);
3613 clean_cols (GailTreeView *gailview,
3614 GtkTreeViewColumn *tv_col)
3616 /* Clean GailTreeViewCellInfo data */
3618 if (gailview->cell_data != NULL)
3620 GailTreeViewCellInfo *cell_info;
3621 GList *cur_list, *temp_list;
3623 temp_list = gailview->cell_data;
3625 while (temp_list != NULL)
3627 cur_list = temp_list;
3628 cell_info = temp_list->data;
3629 temp_list = temp_list->next;
3632 * If the cell has become invalid because the column tv_col
3633 * has been removed, then set the cell's state to ATK_STATE_DEFUNCT
3634 * and remove the cell from gailview->cell_data.
3636 if (cell_info->cell_col_ref == tv_col)
3638 clean_cell_info (gailview, cur_list);
3645 idle_garbage_collect_cell_data (gpointer data)
3647 GailTreeView *tree_view;
3649 g_assert (GAIL_IS_TREE_VIEW (data));
3650 tree_view = (GailTreeView *)data;
3652 /* this is the idle handler (only one instance allowed), so
3653 * we can safely delete it.
3655 tree_view->garbage_collection_pending = FALSE;
3656 tree_view->idle_garbage_collect_id = 0;
3658 tree_view->garbage_collection_pending = garbage_collect_cell_data (data);
3660 /* N.B.: if for some reason another handler has re-enterantly been queued
3661 * while this handler was being serviced, it has its own gsource, therefore this handler
3662 * should always return FALSE.
3668 garbage_collect_cell_data (gpointer data)
3670 GailTreeView *tree_view;
3671 GList *temp_list, *list;
3672 GailTreeViewCellInfo *cell_info;
3674 g_assert (GAIL_IS_TREE_VIEW (data));
3675 tree_view = (GailTreeView *)data;
3676 list = g_list_copy (tree_view->cell_data);
3678 tree_view->garbage_collection_pending = FALSE;
3679 if (tree_view->idle_garbage_collect_id != 0)
3681 g_source_remove (tree_view->idle_garbage_collect_id);
3682 tree_view->idle_garbage_collect_id = 0;
3685 /* Must loop through them all */
3687 while (temp_list != NULL)
3689 cell_info = temp_list->data;
3690 if (!cell_info->in_use)
3692 /* g_object_unref (cell_info->cell); */
3693 tree_view->cell_data = g_list_remove (tree_view->cell_data,
3695 if (cell_info->cell_row_ref)
3696 gtk_tree_row_reference_free (cell_info->cell_row_ref);
3699 temp_list = temp_list->next;
3703 return tree_view->garbage_collection_pending;
3707 * If tree_path is passed in as NULL, then all cells are acted on.
3708 * Otherwise, just act on those cells that are on a row greater than
3709 * the specified tree_path. If inc_row is passed in as TRUE, then rows
3710 * greater and equal to the specified tree_path are acted on.
3712 * if set_stale is set the ATK_STATE_STALE is set on cells which are to be
3715 * The function set_cell_visibility() is called on all cells to be
3716 * acted on to update the visibility of the cell.
3719 traverse_cells (GailTreeView *tree_view,
3720 GtkTreePath *tree_path,
3724 if (tree_view->cell_data != NULL)
3726 GailTreeViewCellInfo *cell_info;
3727 GtkTreeView *gtk_tree_view;
3731 g_assert (GTK_IS_ACCESSIBLE (tree_view));
3733 widget = GTK_ACCESSIBLE (tree_view)->widget;
3735 /* Widget is being deleted */
3738 gtk_tree_view = GTK_TREE_VIEW (widget);
3739 temp_list = tree_view->cell_data;
3741 /* Must loop through them all */
3742 while (temp_list != NULL)
3744 GtkTreePath *row_path;
3745 gboolean act_on_cell;
3747 cell_info = temp_list->data;
3748 temp_list = temp_list->next;
3750 if (cell_info->in_use)
3752 row_path = gtk_tree_row_reference_get_path (cell_info->cell_row_ref);
3753 g_return_if_fail (row_path != NULL);
3754 if (tree_path == NULL)
3760 comparison = gtk_tree_path_compare (row_path, tree_path);
3761 if ((comparison > 0) ||
3762 (comparison == 0 && inc_row))
3765 act_on_cell = FALSE;
3767 if (!cell_info->in_use) g_warning ("warning: cell info destroyed during traversal");
3768 if (act_on_cell && cell_info->in_use)
3771 gail_cell_add_state (cell_info->cell, ATK_STATE_STALE, TRUE);
3772 set_cell_visibility (gtk_tree_view,
3774 cell_info->cell_col_ref,
3777 gtk_tree_path_free (row_path);
3781 g_signal_emit_by_name (tree_view, "visible-data-changed");
3785 free_row_info (GArray *array,
3789 GailTreeViewRowInfo* obj;
3791 obj = g_array_index (array, GailTreeViewRowInfo*, array_idx);
3793 g_free (obj->description);
3794 if (obj->row_ref != NULL)
3795 gtk_tree_row_reference_free (obj->row_ref);
3797 g_object_unref (obj->header);
3801 g_array_remove_index (array, array_idx);
3805 * If the tree_path passed in has children, then
3806 * ATK_STATE_EXPANDABLE is set. If the row is expanded
3807 * ATK_STATE_EXPANDED is turned on. If the row is
3808 * collapsed, then ATK_STATE_EXPANDED is removed.
3810 * If the tree_path passed in has no children, then
3811 * ATK_STATE_EXPANDABLE and ATK_STATE_EXPANDED are removed.
3813 * If set_on_ancestor is TRUE, then this function will also
3814 * update all cells that are ancestors of the tree_path.
3817 set_expand_state (GtkTreeView *tree_view,
3818 GtkTreeModel *tree_model,
3819 GailTreeView *gailview,
3820 GtkTreePath *tree_path,
3821 gboolean set_on_ancestor)
3823 if (gailview->cell_data != NULL)
3825 GtkTreeViewColumn *expander_tv;
3826 GailTreeViewCellInfo *cell_info;
3828 GtkTreePath *cell_path;
3832 temp_list = gailview->cell_data;
3834 while (temp_list != NULL)
3836 cell_info = temp_list->data;
3837 temp_list = temp_list->next;
3838 if (cell_info->in_use)
3840 cell_path = gtk_tree_row_reference_get_path (cell_info->cell_row_ref);
3843 if (cell_path != NULL)
3845 GailCell *cell = GAIL_CELL (cell_info->cell);
3847 expander_tv = gtk_tree_view_get_expander_column (tree_view);
3850 * Only set state for the cell that is in the column with the
3853 if (expander_tv == cell_info->cell_col_ref)
3855 if (tree_path && gtk_tree_path_compare (cell_path, tree_path) == 0)
3857 else if (set_on_ancestor &&
3858 gtk_tree_path_get_depth (cell_path) <
3859 gtk_tree_path_get_depth (tree_path) &&
3860 gtk_tree_path_is_ancestor (cell_path, tree_path) == 1)
3861 /* Only set if set_on_ancestor was passed in as TRUE */
3866 * Set ATK_STATE_EXPANDABLE and ATK_STATE_EXPANDED
3867 * for ancestors and found cells.
3872 * Must check against cell_path since cell_path
3873 * can be equal to or an ancestor of tree_path.
3875 gtk_tree_model_get_iter (tree_model, &iter, cell_path);
3877 /* Set or unset ATK_STATE_EXPANDABLE as appropriate */
3878 if (gtk_tree_model_iter_has_child (tree_model, &iter))
3880 set_cell_expandable (cell);
3882 if (gtk_tree_view_row_expanded (tree_view, cell_path))
3883 gail_cell_add_state (cell, ATK_STATE_EXPANDED, TRUE);
3885 gail_cell_remove_state (cell,
3886 ATK_STATE_EXPANDED, TRUE);
3890 gail_cell_remove_state (cell,
3891 ATK_STATE_EXPANDED, TRUE);
3892 if (gail_cell_remove_state (cell,
3893 ATK_STATE_EXPANDABLE, TRUE))
3894 /* The state may have been propagated to the container cell */
3895 if (!GAIL_IS_CONTAINER_CELL (cell))
3896 gail_cell_remove_action_by_name (cell,
3897 "expand or contract");
3901 * We assume that each cell in the cache once and
3902 * a container cell is before its child cells so we are
3903 * finished if set_on_ancestor is not set to TRUE.
3905 if (!set_on_ancestor)
3909 gtk_tree_path_free (cell_path);
3917 add_cell_actions (GailCell *cell,
3920 if (GAIL_IS_BOOLEAN_CELL (cell))
3921 gail_cell_add_action (cell,
3923 "toggles the cell", /* action description */
3925 toggle_cell_toggled);
3927 gail_cell_add_action (cell,
3929 "creates a widget in which the contents of the cell can be edited",
3932 gail_cell_add_action (cell,
3934 "activate the cell",
3940 toggle_cell_expanded (GailCell *cell)
3942 GailTreeViewCellInfo *cell_info;
3943 GtkTreeView *tree_view;
3946 AtkStateSet *stateset;
3948 parent = atk_object_get_parent (ATK_OBJECT (cell));
3949 if (GAIL_IS_CONTAINER_CELL (parent))
3950 parent = atk_object_get_parent (parent);
3952 cell_info = find_cell_info (GAIL_TREE_VIEW (parent), cell, NULL, TRUE);
3953 gail_return_if_fail (cell_info);
3954 gail_return_if_fail (cell_info->cell_col_ref);
3955 gail_return_if_fail (cell_info->cell_row_ref);
3957 tree_view = GTK_TREE_VIEW (GTK_ACCESSIBLE (parent)->widget);
3958 path = gtk_tree_row_reference_get_path (cell_info->cell_row_ref);
3959 gail_return_if_fail (path);
3961 stateset = atk_object_ref_state_set (ATK_OBJECT (cell));
3962 if (atk_state_set_contains_state (stateset, ATK_STATE_EXPANDED))
3963 gtk_tree_view_collapse_row (tree_view, path);
3965 gtk_tree_view_expand_row (tree_view, path, TRUE);
3966 g_object_unref (stateset);
3967 gtk_tree_path_free (path);
3972 toggle_cell_toggled (GailCell *cell)
3974 GailTreeViewCellInfo *cell_info;
3975 GtkTreeView *tree_view;
3978 GList *renderers, *cur_renderer;
3980 gboolean is_container_cell = FALSE;
3982 parent = atk_object_get_parent (ATK_OBJECT (cell));
3983 if (GAIL_IS_CONTAINER_CELL (parent))
3985 is_container_cell = TRUE;
3986 parent = atk_object_get_parent (parent);
3989 cell_info = find_cell_info (GAIL_TREE_VIEW (parent), cell, NULL, TRUE);
3990 gail_return_if_fail (cell_info);
3991 gail_return_if_fail (cell_info->cell_col_ref);
3992 gail_return_if_fail (cell_info->cell_row_ref);
3994 tree_view = GTK_TREE_VIEW (GTK_ACCESSIBLE (parent)->widget);
3995 path = gtk_tree_row_reference_get_path (cell_info->cell_row_ref);
3996 gail_return_if_fail (path);
3997 pathstring = gtk_tree_path_to_string (path);
3999 renderers = gtk_tree_view_column_get_cell_renderers (cell_info->cell_col_ref);
4000 gail_return_if_fail (renderers);
4003 * if the cell is in a container, it's index is used to find the
4004 * renderer in the list
4007 if (is_container_cell)
4008 cur_renderer = g_list_nth (renderers, cell->index);
4011 * Otherwise, we assume that the cell is represented by the first
4012 * renderer in the list
4014 cur_renderer = renderers;
4016 gail_return_if_fail (cur_renderer);
4018 g_signal_emit_by_name (cur_renderer->data, "toggled", pathstring);
4019 g_list_free (renderers);
4020 g_free (pathstring);
4021 gtk_tree_path_free (path);
4026 edit_cell (GailCell *cell)
4028 GailTreeViewCellInfo *cell_info;
4029 GtkTreeView *tree_view;
4032 gboolean is_container_cell = FALSE;
4035 parent = atk_object_get_parent (ATK_OBJECT (cell));
4036 if (GAIL_IS_CONTAINER_CELL (parent))
4038 is_container_cell = TRUE;
4039 parent = atk_object_get_parent (parent);
4042 cell_info = find_cell_info (GAIL_TREE_VIEW (parent), cell, NULL, TRUE);
4043 gail_return_if_fail (cell_info);
4044 gail_return_if_fail (cell_info->cell_col_ref);
4045 gail_return_if_fail (cell_info->cell_row_ref);
4047 tree_view = GTK_TREE_VIEW (GTK_ACCESSIBLE (parent)->widget);
4048 path = gtk_tree_row_reference_get_path (cell_info->cell_row_ref);
4049 gail_return_if_fail (path);
4050 gtk_tree_view_set_cursor (tree_view, path, cell_info->cell_col_ref, TRUE);
4051 gtk_tree_path_free (path);
4056 activate_cell (GailCell *cell)
4058 GailTreeViewCellInfo *cell_info;
4059 GtkTreeView *tree_view;
4062 gboolean is_container_cell = FALSE;
4065 parent = atk_object_get_parent (ATK_OBJECT (cell));
4066 if (GAIL_IS_CONTAINER_CELL (parent))
4068 is_container_cell = TRUE;
4069 parent = atk_object_get_parent (parent);
4072 cell_info = find_cell_info (GAIL_TREE_VIEW (parent), cell, NULL, TRUE);
4073 gail_return_if_fail (cell_info);
4074 gail_return_if_fail (cell_info->cell_col_ref);
4075 gail_return_if_fail (cell_info->cell_row_ref);
4077 tree_view = GTK_TREE_VIEW (GTK_ACCESSIBLE (parent)->widget);
4078 path = gtk_tree_row_reference_get_path (cell_info->cell_row_ref);
4079 gail_return_if_fail (path);
4080 gtk_tree_view_row_activated (tree_view, path, cell_info->cell_col_ref);
4081 gtk_tree_path_free (path);
4086 cell_destroyed (gpointer data)
4088 GailTreeViewCellInfo *cell_info = data;
4090 gail_return_if_fail (cell_info);
4091 if (cell_info->in_use) {
4092 cell_info->in_use = FALSE;
4094 g_assert (GAIL_IS_TREE_VIEW (cell_info->view));
4095 if (!cell_info->view->garbage_collection_pending) {
4096 cell_info->view->garbage_collection_pending = TRUE;
4097 cell_info->view->idle_garbage_collect_id =
4098 gdk_threads_add_idle (idle_garbage_collect_cell_data, cell_info->view);
4105 cell_info_remove (GailTreeView *tree_view,
4108 GailTreeViewCellInfo *info;
4111 info = find_cell_info (tree_view, cell, &temp_list, FALSE);
4114 info->in_use = FALSE;
4117 g_warning ("No cell removed in cell_info_remove\n");
4122 cell_info_get_index (GtkTreeView *tree_view,
4123 GailTreeViewCellInfo *info,
4129 path = gtk_tree_row_reference_get_path (info->cell_row_ref);
4130 gail_return_if_fail (path);
4132 column_number = get_column_number (tree_view, info->cell_col_ref, FALSE);
4133 *index = get_index (tree_view, path, column_number);
4134 gtk_tree_path_free (path);
4138 cell_info_new (GailTreeView *gailview,
4139 GtkTreeModel *tree_model,
4141 GtkTreeViewColumn *tv_col,
4144 GailTreeViewCellInfo *cell_info;
4146 g_assert (GAIL_IS_TREE_VIEW (gailview));
4148 cell_info = g_new (GailTreeViewCellInfo, 1);
4149 cell_info->cell_row_ref = gtk_tree_row_reference_new (tree_model, path);
4151 cell_info->cell_col_ref = tv_col;
4152 cell_info->cell = cell;
4153 cell_info->in_use = TRUE; /* if we've created it, assume it's in use */
4154 cell_info->view = gailview;
4155 gailview->cell_data = g_list_append (gailview->cell_data, cell_info);
4157 /* Setup weak reference notification */
4159 g_object_weak_ref (G_OBJECT (cell),
4160 (GWeakNotify) cell_destroyed,
4165 find_cell (GailTreeView *gailview,
4168 GailTreeViewCellInfo *info;
4169 GtkTreeView *tree_view;
4173 gboolean needs_cleaning = FALSE;
4174 GailCell *retval = NULL;
4176 tree_view = GTK_TREE_VIEW (GTK_ACCESSIBLE (gailview)->widget);
4177 cell_list = gailview->cell_data;
4179 for (l = cell_list; l; l = l->next)
4181 info = (GailTreeViewCellInfo *) (l->data);
4184 cell_info_get_index (tree_view, info, &real_index);
4185 if (index == real_index)
4187 retval = info->cell;
4193 needs_cleaning = TRUE;
4197 garbage_collect_cell_data (gailview);
4203 refresh_cell_index (GailCell *cell)
4205 GailTreeViewCellInfo *info;
4207 GtkTreeView *tree_view;
4210 parent = atk_object_get_parent (ATK_OBJECT (cell));
4211 gail_return_if_fail (GAIL_IS_TREE_VIEW (parent));
4213 tree_view = GTK_TREE_VIEW (GTK_ACCESSIBLE (parent)->widget);
4215 /* Find this cell in the GailTreeView's cache */
4217 info = find_cell_info (GAIL_TREE_VIEW (parent), cell, NULL, TRUE);
4218 gail_return_if_fail (info);
4220 cell_info_get_index (tree_view, info, &index);
4221 cell->index = index;
4225 get_selected_rows (GtkTreeModel *model,
4230 GPtrArray *array = (GPtrArray *)data;
4232 g_ptr_array_add (array, gtk_tree_path_copy (path));
4236 connect_model_signals (GtkTreeView *view,
4237 GailTreeView *gailview)
4241 obj = G_OBJECT (gailview->tree_model);
4242 g_signal_connect_data (obj, "row-changed",
4243 (GCallback) model_row_changed, view, NULL, 0);
4244 g_signal_connect_data (obj, "row-inserted",
4245 (GCallback) model_row_inserted, view, NULL,
4247 g_signal_connect_data (obj, "row-deleted",
4248 (GCallback) model_row_deleted, view, NULL,
4250 g_signal_connect_data (obj, "rows-reordered",
4251 (GCallback) model_rows_reordered, view, NULL,
4256 disconnect_model_signals (GailTreeView *view)
4261 obj = G_OBJECT (view->tree_model);
4262 widget = GTK_ACCESSIBLE (view)->widget;
4263 g_signal_handlers_disconnect_by_func (obj, (gpointer) model_row_changed, widget);
4264 g_signal_handlers_disconnect_by_func (obj, (gpointer) model_row_inserted, widget);
4265 g_signal_handlers_disconnect_by_func (obj, (gpointer) model_row_deleted, widget);
4266 g_signal_handlers_disconnect_by_func (obj, (gpointer) model_rows_reordered, widget);
4270 clear_cached_data (GailTreeView *view)
4276 GArray *array = view->row_data;
4280 * Since the third argument to free_row_info is FALSE, we don't remove
4281 * the element. Therefore it is safe to loop forward.
4283 for (i = 0; i < array->len; i++)
4284 free_row_info (array, i, FALSE);
4286 g_array_free (array, TRUE);
4288 view->row_data = NULL;
4291 if (view->cell_data)
4293 /* Must loop through them all */
4294 for (temp_list = view->cell_data; temp_list; temp_list = temp_list->next)
4296 clean_cell_info (view, temp_list);
4299 garbage_collect_cell_data (view);
4300 if (view->cell_data)
4301 g_list_free (view->cell_data);
4303 view->cell_data = NULL;
4307 * Returns the column number of the specified GtkTreeViewColumn
4309 * If visible is set, the value returned will be the visible column number,
4310 * i.e. suitable for use in AtkTable function. If visible is not set, the
4311 * value returned is the actual column number, which is suitable for use in
4312 * getting an index value.
4315 get_column_number (GtkTreeView *tree_view,
4316 GtkTreeViewColumn *column,
4319 GList *temp_list, *column_list;
4320 GtkTreeViewColumn *tv_column;
4323 column_list = gtk_tree_view_get_columns (tree_view);
4325 for (temp_list = column_list; temp_list; temp_list = temp_list->next)
4327 tv_column = GTK_TREE_VIEW_COLUMN (temp_list->data);
4328 if (tv_column == column)
4330 if (!visible || gtk_tree_view_column_get_visible (tv_column))
4333 if (temp_list == NULL)
4337 g_list_free (column_list);
4342 get_index (GtkTreeView *tree_view,
4348 gint *indices = NULL;
4353 depth = gtk_tree_path_get_depth (path);
4354 indices = gtk_tree_path_get_indices (path);
4359 GtkTreePath *copy_path;
4360 GtkTreeModel *model;
4362 model = gtk_tree_view_get_model (tree_view);
4363 copy_path = gtk_tree_path_copy (path);
4364 gtk_tree_path_up (copy_path);
4365 count_rows (model, NULL, copy_path, &index, 0, depth);
4366 gtk_tree_path_free (copy_path);
4370 index += indices[depth-1];
4371 index *= get_n_actual_columns (tree_view);
4372 index += actual_column;
4377 * The function count_rows counts the number of rows starting at iter and ending
4378 * at end_path. The value of level is the depth of iter and the value of depth
4379 * is the depth of end_path. Rows at depth before end_path are counted.
4380 * This functions counts rows which are not visible because an ancestor is
4384 count_rows (GtkTreeModel *model,
4386 GtkTreePath *end_path,
4391 GtkTreeIter child_iter;
4397 *count += gtk_tree_model_iter_n_children (model, iter);
4400 g_print ("count_rows : %d level: %d depth: %d\n", *count, level, depth);
4402 g_print ("path: %s\n",
4403 gtk_tree_path_to_string (gtk_tree_model_get_path (model, iter)));
4409 if (gtk_tree_model_iter_children (model, &child_iter, iter))
4411 gboolean ret_val = TRUE;
4415 if (level == depth - 1)
4417 GtkTreePath *iter_path;
4418 gboolean finished = FALSE;
4420 iter_path = gtk_tree_model_get_path (model, &child_iter);
4421 if (end_path && gtk_tree_path_compare (iter_path, end_path) >= 0)
4423 gtk_tree_path_free (iter_path);
4427 if (gtk_tree_model_iter_has_child (model, &child_iter))
4428 count_rows (model, &child_iter, end_path, count, level, depth);
4429 ret_val = gtk_tree_model_iter_next (model, &child_iter);
4435 * Find the next node, which has children, at the specified depth below
4436 * the specified iter. The level is the depth of the current iter.
4437 * The position of the node is returned in path and the return value of TRUE
4438 * means that a node was found.
4441 gboolean get_next_node_with_child_at_depth (GtkTreeModel *model,
4447 GtkTreeIter child_iter;
4451 if (gtk_tree_model_iter_children (model, &child_iter, iter))
4457 while (!gtk_tree_model_iter_has_child (model, &child_iter))
4459 if (!gtk_tree_model_iter_next (model, &child_iter))
4464 /* We have found what we were looking for */
4466 *path = gtk_tree_model_get_path (model, &child_iter);
4470 if (get_next_node_with_child_at_depth (model, &child_iter, path,
4474 if (!gtk_tree_model_iter_next (model, &child_iter))
4482 * Find the next node, which has children, at the same depth as
4483 * the specified GtkTreePath.
4486 get_next_node_with_child (GtkTreeModel *model,
4488 GtkTreePath **return_path)
4493 gtk_tree_model_get_iter (model, &iter, path);
4495 while (gtk_tree_model_iter_next (model, &iter))
4497 if (gtk_tree_model_iter_has_child (model, &iter))
4499 *return_path = gtk_tree_model_get_path (model, &iter);
4503 depth = gtk_tree_path_get_depth (path);
4504 while (gtk_tree_path_up (path))
4506 if (gtk_tree_path_get_depth (path) == 0)
4509 gtk_tree_model_get_iter (model, &iter, path);
4510 while (gtk_tree_model_iter_next (model, &iter))
4511 if (get_next_node_with_child_at_depth (model, &iter, return_path,
4512 gtk_tree_path_get_depth (path), depth))
4515 *return_path = NULL;
4520 get_tree_path_from_row_index (GtkTreeModel *model,
4522 GtkTreePath **tree_path)
4528 count = gtk_tree_model_iter_n_children (model, NULL);
4529 if (count > row_index)
4531 if (gtk_tree_model_iter_nth_child (model, &iter, NULL, row_index))
4533 *tree_path = gtk_tree_model_get_path (model, &iter);
4547 if (get_next_node_with_child_at_depth (model, NULL, tree_path, 0, depth))
4549 GtkTreePath *next_path;
4553 gtk_tree_model_get_iter (model, &iter, *tree_path);
4554 count = gtk_tree_model_iter_n_children (model, &iter);
4555 if (count > row_index)
4557 gtk_tree_path_append_index (*tree_path, row_index);
4563 if (!get_next_node_with_child (model, *tree_path, &next_path))
4566 gtk_tree_path_free (*tree_path);
4567 *tree_path = next_path;
4572 g_warning ("Index value is too large\n");
4573 gtk_tree_path_free (*tree_path);
4581 * This function returns the number of rows, including those which are collapsed
4584 get_row_count (GtkTreeModel *model)
4588 count_rows (model, NULL, NULL, &n_rows, 0, G_MAXINT);
4594 get_path_column_from_index (GtkTreeView *tree_view,
4597 GtkTreeViewColumn **column)
4599 GtkTreeModel *tree_model;
4602 tree_model = gtk_tree_view_get_model (tree_view);
4603 n_columns = get_n_actual_columns (tree_view);
4606 /* First row is the column headers */
4616 row_index = index / n_columns;
4617 retval = get_tree_path_from_row_index (tree_model, row_index, path);
4618 gail_return_val_if_fail (retval, FALSE);
4625 *column = gtk_tree_view_get_column (tree_view, index % n_columns);
4626 if (*column == NULL)
4629 gtk_tree_path_free (*path);
4637 set_cell_expandable (GailCell *cell)
4639 if (gail_cell_add_state (cell,
4640 ATK_STATE_EXPANDABLE,
4642 gail_cell_add_action (cell,
4643 "expand or contract", /* action name */
4644 "expands or contracts the row in the tree view "
4645 "containing this cell", /* description */
4646 NULL, /* Keybinding */
4647 toggle_cell_expanded);
4650 static GailTreeViewCellInfo*
4651 find_cell_info (GailTreeView *view,
4657 GailTreeViewCellInfo *cell_info;
4659 for (temp_list = view->cell_data; temp_list; temp_list = temp_list->next)
4661 cell_info = (GailTreeViewCellInfo *) temp_list->data;
4662 if (cell_info->cell == cell && (!live_only || cell_info->in_use))
4673 get_header_from_column (GtkTreeViewColumn *tv_col)
4676 GtkWidget *header_widget;
4681 /* If the user has set a header object, use that */
4683 rc = g_object_get_qdata (G_OBJECT (tv_col), quark_column_header_object);
4687 /* If the user has not set a header object, grab the column */
4688 /* header object defined by the GtkTreeView */
4690 header_widget = tv_col->button;
4694 rc = gtk_widget_get_accessible (header_widget);