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 <gtk/gtktreeviewcolumn.h>
28 #include "gailtreeview.h"
29 #include "gailrenderercell.h"
30 #include "gailbooleancell.h"
31 #include "gailcontainercell.h"
32 #include "gailtextcell.h"
33 #include "gailcellparent.h"
34 #include "gail-private-macros.h"
36 typedef struct _GailTreeViewRowInfo GailTreeViewRowInfo;
37 typedef struct _GailTreeViewCellInfo GailTreeViewCellInfo;
39 static void gail_tree_view_class_init (GailTreeViewClass *klass);
40 static void gail_tree_view_init (GailTreeView *view);
41 static void gail_tree_view_real_initialize (AtkObject *obj,
43 static void gail_tree_view_real_notify_gtk (GObject *obj,
45 static void gail_tree_view_finalize (GObject *object);
47 static void gail_tree_view_connect_widget_destroyed
48 (GtkAccessible *accessible);
49 static void gail_tree_view_destroyed (GtkWidget *widget,
50 GtkAccessible *accessible);
53 static gint gail_tree_view_get_n_children (AtkObject *obj);
54 static AtkObject* gail_tree_view_ref_child (AtkObject *obj,
56 static AtkStateSet* gail_tree_view_ref_state_set (AtkObject *obj);
60 static void atk_component_interface_init (AtkComponentIface *iface);
62 static AtkObject* gail_tree_view_ref_accessible_at_point
63 (AtkComponent *component,
66 AtkCoordType coord_type);
70 static void atk_table_interface_init (AtkTableIface *iface);
72 static gint gail_tree_view_get_index_at (AtkTable *table,
75 static gint gail_tree_view_get_column_at_index
78 static gint gail_tree_view_get_row_at_index (AtkTable *table,
81 static AtkObject* gail_tree_view_table_ref_at (AtkTable *table,
84 static gint gail_tree_view_get_n_rows (AtkTable *table);
85 static gint gail_tree_view_get_n_columns (AtkTable *table);
86 static gint get_n_actual_columns (GtkTreeView *tree_view);
87 static gboolean gail_tree_view_is_row_selected (AtkTable *table,
89 static gboolean gail_tree_view_is_selected (AtkTable *table,
92 static gint gail_tree_view_get_selected_rows
95 static gboolean gail_tree_view_add_row_selection
98 static gboolean gail_tree_view_remove_row_selection
101 static AtkObject* gail_tree_view_get_row_header (AtkTable *table,
103 static AtkObject* gail_tree_view_get_column_header
106 static void gail_tree_view_set_row_header (AtkTable *table,
109 static void gail_tree_view_set_column_header
114 gail_tree_view_get_caption (AtkTable *table);
115 static void gail_tree_view_set_caption (AtkTable *table,
117 static AtkObject* gail_tree_view_get_summary (AtkTable *table);
118 static void gail_tree_view_set_summary (AtkTable *table,
119 AtkObject *accessible);
120 static G_CONST_RETURN gchar*
121 gail_tree_view_get_row_description
124 static void gail_tree_view_set_row_description
127 const gchar *description);
128 static G_CONST_RETURN gchar*
129 gail_tree_view_get_column_description
132 static void gail_tree_view_set_column_description
135 const gchar *description);
137 static void set_row_data (AtkTable *table,
140 const gchar *description,
142 static GailTreeViewRowInfo*
143 get_row_info (AtkTable *table,
148 static void atk_selection_interface_init (AtkSelectionIface *iface);
149 static gboolean gail_tree_view_add_selection (AtkSelection *selection,
151 static gboolean gail_tree_view_clear_selection (AtkSelection *selection);
152 static AtkObject* gail_tree_view_ref_selection (AtkSelection *selection,
154 static gint gail_tree_view_get_selection_count
155 (AtkSelection *selection);
156 static gboolean gail_tree_view_is_child_selected
157 (AtkSelection *selection,
160 /* gailcellparent.h */
162 static void gail_cell_parent_interface_init (GailCellParentIface *iface);
163 static void gail_tree_view_get_cell_extents (GailCellParent *parent,
169 AtkCoordType coord_type);
170 static void gail_tree_view_get_cell_area (GailCellParent *parent,
172 GdkRectangle *cell_rect);
173 static gboolean gail_tree_view_grab_cell_focus (GailCellParent *parent,
176 /* signal handling */
178 static gboolean gail_tree_view_expand_row_gtk (GtkTreeView *tree_view,
181 static gint idle_expand_row (gpointer data);
182 static gboolean gail_tree_view_collapse_row_gtk (GtkTreeView *tree_view,
185 static void gail_tree_view_size_allocate_gtk (GtkWidget *widget,
186 GtkAllocation *allocation);
187 static void gail_tree_view_set_scroll_adjustments
190 GtkAdjustment *vadj);
191 static void gail_tree_view_changed_gtk (GtkTreeSelection *selection,
194 static void columns_changed (GtkTreeView *tree_view);
195 static void cursor_changed (GtkTreeView *tree_view);
196 static gint idle_cursor_changed (gpointer data);
197 static void focus_in (GtkWidget *widget);
198 static void focus_out (GtkWidget *widget);
200 static void model_row_changed (GtkTreeModel *tree_model,
204 static void column_visibility_changed (GObject *object,
207 static void column_destroy (GtkObject *obj);
208 static void model_row_inserted (GtkTreeModel *tree_model,
212 static void model_row_deleted (GtkTreeModel *tree_model,
215 static void destroy_count_func (GtkTreeView *tree_view,
219 static void model_rows_reordered (GtkTreeModel *tree_model,
224 static void adjustment_changed (GtkAdjustment *adjustment,
225 GtkTreeView *tree_view);
229 static void set_iter_nth_row (GtkTreeView *tree_view,
232 static gint get_row_from_tree_path (GtkTreeView *tree_view,
234 static GtkTreeViewColumn* get_column (GtkTreeView *tree_view,
236 static gint get_actual_column_number (GtkTreeView *tree_view,
237 gint visible_column);
238 static gint get_visible_column_number (GtkTreeView *tree_view,
240 static void iterate_thru_children (GtkTreeView *tree_view,
241 GtkTreeModel *tree_model,
242 GtkTreePath *tree_path,
246 static GtkTreeIter* return_iter_nth_row (GtkTreeView *tree_view,
247 GtkTreeModel *tree_model,
251 static void free_row_info (GArray *array,
254 static void clean_cell_info (GailTreeView *tree_view,
256 static void clean_rows (GailTreeView *tree_view);
257 static void clean_cols (GailTreeView *tree_view,
258 GtkTreeViewColumn *tv_col);
259 static void traverse_cells (GailTreeView *tree_view,
260 GtkTreePath *tree_path,
263 static gboolean update_cell_value (GailRendererCell *renderer_cell,
264 GailTreeView *gailview,
265 gboolean emit_change_signal);
266 static void set_cell_visibility (GtkTreeView *tree_view,
268 GtkTreeViewColumn *tv_col,
269 GtkTreePath *tree_path,
270 gboolean emit_signal);
271 static gboolean is_cell_showing (GtkTreeView *tree_view,
272 GdkRectangle *cell_rect);
273 static void set_expand_state (GtkTreeView *tree_view,
274 GtkTreeModel *tree_model,
275 GailTreeView *gailview,
276 GtkTreePath *tree_path,
277 gboolean set_on_ancestor);
278 static void add_cell_actions (GailCell *cell,
281 static void toggle_cell_expanded (GailCell *cell);
282 static void toggle_cell_toggled (GailCell *cell);
283 static void edit_cell (GailCell *cell);
284 static void activate_cell (GailCell *cell);
285 static void cell_destroyed (gpointer data);
287 static void cell_info_remove (GailTreeView *tree_view,
290 static void cell_info_get_index (GtkTreeView *tree_view,
291 GailTreeViewCellInfo *info,
293 static void cell_info_new (GailTreeView *gailview,
294 GtkTreeModel *tree_model,
296 GtkTreeViewColumn *tv_col,
298 static GailCell* find_cell (GailTreeView *gailview,
300 static void refresh_cell_index (GailCell *cell);
301 static void get_selected_rows (GtkTreeModel *model,
305 static void connect_model_signals (GtkTreeView *view,
306 GailTreeView *gailview);
307 static void disconnect_model_signals (GailTreeView *gailview);
308 static void clear_cached_data (GailTreeView *view);
309 static gint get_column_number (GtkTreeView *tree_view,
310 GtkTreeViewColumn *column,
312 static gint get_focus_index (GtkTreeView *tree_view);
313 static gint get_index (GtkTreeView *tree_view,
316 static void count_rows (GtkTreeModel *model,
318 GtkTreePath *end_path,
323 static gboolean get_next_node_with_child_at_depth
324 (GtkTreeModel *model,
329 static gboolean get_next_node_with_child (GtkTreeModel *model,
331 GtkTreePath **return_path);
332 static gboolean get_tree_path_from_row_index (GtkTreeModel *model,
334 GtkTreePath **tree_path);
335 static gint get_row_count (GtkTreeModel *model);
336 static gboolean get_path_column_from_index (GtkTreeView *tree_view,
339 GtkTreeViewColumn **column);
340 static void set_cell_expandable (GailCell *cell);
342 static GailTreeViewCellInfo* find_cell_info (GailTreeView *view,
346 static AtkObject * get_header_from_column (GtkTreeViewColumn *tv_col);
347 static gboolean idle_garbage_collect_cell_data (gpointer data);
348 static gboolean garbage_collect_cell_data (gpointer data);
350 static GQuark quark_column_desc_object = 0;
351 static GQuark quark_column_header_object = 0;
352 static gboolean editing = FALSE;
353 static const gchar* hadjustment = "hadjustment";
354 static const gchar* vadjustment = "vadjustment";
356 struct _GailTreeViewRowInfo
358 GtkTreeRowReference *row_ref;
363 struct _GailTreeViewCellInfo
366 GtkTreeRowReference *cell_row_ref;
367 GtkTreeViewColumn *cell_col_ref;
372 G_DEFINE_TYPE_WITH_CODE (GailTreeView, gail_tree_view, GAIL_TYPE_CONTAINER,
373 G_IMPLEMENT_INTERFACE (ATK_TYPE_TABLE, atk_table_interface_init)
374 G_IMPLEMENT_INTERFACE (ATK_TYPE_SELECTION, atk_selection_interface_init)
375 G_IMPLEMENT_INTERFACE (ATK_TYPE_COMPONENT, atk_component_interface_init)
376 G_IMPLEMENT_INTERFACE (GAIL_TYPE_CELL_PARENT, gail_cell_parent_interface_init))
379 gail_tree_view_class_init (GailTreeViewClass *klass)
381 AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
382 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
383 GtkAccessibleClass *accessible_class;
384 GailWidgetClass *widget_class;
385 GailContainerClass *container_class;
387 accessible_class = (GtkAccessibleClass*)klass;
388 widget_class = (GailWidgetClass*)klass;
389 container_class = (GailContainerClass*)klass;
391 class->get_n_children = gail_tree_view_get_n_children;
392 class->ref_child = gail_tree_view_ref_child;
393 class->ref_state_set = gail_tree_view_ref_state_set;
394 class->initialize = gail_tree_view_real_initialize;
396 widget_class->notify_gtk = gail_tree_view_real_notify_gtk;
398 accessible_class->connect_widget_destroyed = gail_tree_view_connect_widget_destroyed;
401 * The children of a GtkTreeView are the buttons at the top of the columns
402 * we do not represent these as children so we do not want to report
403 * children added or deleted when these changed.
405 container_class->add_gtk = NULL;
406 container_class->remove_gtk = NULL;
408 gobject_class->finalize = gail_tree_view_finalize;
410 quark_column_desc_object = g_quark_from_static_string ("gtk-column-object");
411 quark_column_header_object = g_quark_from_static_string ("gtk-header-object");
415 gail_tree_view_init (GailTreeView *view)
420 gail_tree_view_real_initialize (AtkObject *obj,
424 GtkTreeView *tree_view;
425 GtkTreeModel *tree_model;
427 GList *tv_cols, *tmp_list;
430 ATK_OBJECT_CLASS (gail_tree_view_parent_class)->initialize (obj, data);
432 view = GAIL_TREE_VIEW (obj);
433 view->caption = NULL;
434 view->summary = NULL;
435 view->row_data = NULL;
436 view->col_data = NULL;
437 view->cell_data = NULL;
438 view->focus_cell = NULL;
439 view->old_hadj = NULL;
440 view->old_vadj = NULL;
441 view->idle_expand_id = 0;
442 view->idle_expand_path = NULL;
444 view->n_children_deleted = 0;
446 widget = GTK_WIDGET (data);
447 g_signal_connect_after (widget,
449 G_CALLBACK (gail_tree_view_collapse_row_gtk),
451 g_signal_connect (widget,
453 G_CALLBACK (gail_tree_view_expand_row_gtk),
455 g_signal_connect (widget,
457 G_CALLBACK (gail_tree_view_size_allocate_gtk),
460 tree_view = GTK_TREE_VIEW (widget);
461 tree_model = gtk_tree_view_get_model (tree_view);
463 /* Set up signal handling */
465 g_signal_connect_data (gtk_tree_view_get_selection (tree_view),
467 (GCallback) gail_tree_view_changed_gtk,
470 g_signal_connect_data (tree_view, "columns-changed",
471 (GCallback) columns_changed, NULL, NULL, 0);
472 g_signal_connect_data (tree_view, "cursor-changed",
473 (GCallback) cursor_changed, NULL, NULL, 0);
474 g_signal_connect_data (GTK_WIDGET (tree_view), "focus-in-event",
475 (GCallback) focus_in, NULL, NULL, 0);
476 g_signal_connect_data (GTK_WIDGET (tree_view), "focus-out-event",
477 (GCallback) focus_out, NULL, NULL, 0);
479 view->tree_model = tree_model;
482 g_object_add_weak_pointer (G_OBJECT (view->tree_model), (gpointer *)&view->tree_model);
483 connect_model_signals (tree_view, view);
485 if (GTK_IS_TREE_STORE (tree_model))
486 obj->role = ATK_ROLE_TREE_TABLE;
488 obj->role = ATK_ROLE_TABLE;
492 obj->role = ATK_ROLE_UNKNOWN;
495 /* adjustment callbacks */
497 g_object_get (tree_view, hadjustment, &adj, NULL);
498 view->old_hadj = adj;
499 g_object_add_weak_pointer (G_OBJECT (view->old_hadj), (gpointer *)&view->old_hadj);
500 g_signal_connect (adj,
502 G_CALLBACK (adjustment_changed),
505 g_object_get (tree_view, vadjustment, &adj, NULL);
506 view->old_vadj = adj;
507 g_object_add_weak_pointer (G_OBJECT (view->old_vadj), (gpointer *)&view->old_vadj);
508 g_signal_connect (adj,
510 G_CALLBACK (adjustment_changed),
512 g_signal_connect_after (widget,
513 "set_scroll_adjustments",
514 G_CALLBACK (gail_tree_view_set_scroll_adjustments),
517 view->col_data = g_array_sized_new (FALSE, TRUE,
518 sizeof(GtkTreeViewColumn *), 0);
520 tv_cols = gtk_tree_view_get_columns (tree_view);
522 for (tmp_list = tv_cols; tmp_list; tmp_list = tmp_list->next)
524 g_signal_connect_data (tmp_list->data, "notify::visible",
525 (GCallback)column_visibility_changed,
526 tree_view, NULL, FALSE);
527 g_signal_connect_data (tmp_list->data, "destroy",
528 (GCallback)column_destroy,
530 g_array_append_val (view->col_data, tmp_list->data);
533 gtk_tree_view_set_destroy_count_func (tree_view,
536 g_list_free (tv_cols);
540 gail_tree_view_real_notify_gtk (GObject *obj,
545 GtkTreeView *tree_view;
546 GailTreeView *gailview;
549 widget = GTK_WIDGET (obj);
550 atk_obj = gtk_widget_get_accessible (widget);
551 tree_view = GTK_TREE_VIEW (widget);
552 gailview = GAIL_TREE_VIEW (atk_obj);
554 if (strcmp (pspec->name, "model") == 0)
556 GtkTreeModel *tree_model;
559 tree_model = gtk_tree_view_get_model (tree_view);
560 if (gailview->tree_model)
561 disconnect_model_signals (gailview);
562 clear_cached_data (gailview);
563 gailview->tree_model = tree_model;
565 * if there is no model the GtkTreeView is probably being destroyed
569 g_object_add_weak_pointer (G_OBJECT (gailview->tree_model), (gpointer *)&gailview->tree_model);
570 connect_model_signals (tree_view, gailview);
572 if (GTK_IS_TREE_STORE (tree_model))
573 role = ATK_ROLE_TREE_TABLE;
575 role = ATK_ROLE_TABLE;
579 role = ATK_ROLE_UNKNOWN;
581 atk_object_set_role (atk_obj, role);
582 g_object_freeze_notify (G_OBJECT (atk_obj));
583 g_signal_emit_by_name (atk_obj, "model_changed");
584 g_signal_emit_by_name (atk_obj, "visible_data_changed");
585 g_object_thaw_notify (G_OBJECT (atk_obj));
587 else if (strcmp (pspec->name, hadjustment) == 0)
589 g_object_get (tree_view, hadjustment, &adj, NULL);
590 g_signal_handlers_disconnect_by_func (gailview->old_hadj,
591 (gpointer) adjustment_changed,
593 gailview->old_hadj = adj;
594 g_object_add_weak_pointer (G_OBJECT (gailview->old_hadj), (gpointer *)&gailview->old_hadj);
595 g_signal_connect (adj,
597 G_CALLBACK (adjustment_changed),
600 else if (strcmp (pspec->name, vadjustment) == 0)
602 g_object_get (tree_view, vadjustment, &adj, NULL);
603 g_signal_handlers_disconnect_by_func (gailview->old_vadj,
604 (gpointer) adjustment_changed,
606 gailview->old_vadj = adj;
607 g_object_add_weak_pointer (G_OBJECT (gailview->old_hadj), (gpointer *)&gailview->old_vadj);
608 g_signal_connect (adj,
610 G_CALLBACK (adjustment_changed),
614 GAIL_WIDGET_CLASS (gail_tree_view_parent_class)->notify_gtk (obj, pspec);
618 gail_tree_view_finalize (GObject *object)
620 GailTreeView *view = GAIL_TREE_VIEW (object);
622 clear_cached_data (view);
624 /* remove any idle handlers still pending */
625 if (view->idle_garbage_collect_id)
626 g_source_remove (view->idle_garbage_collect_id);
627 if (view->idle_cursor_changed_id)
628 g_source_remove (view->idle_cursor_changed_id);
629 if (view->idle_expand_id)
630 g_source_remove (view->idle_expand_id);
633 g_object_unref (view->caption);
635 g_object_unref (view->summary);
637 if (view->tree_model)
638 disconnect_model_signals (view);
642 GArray *array = view->col_data;
645 * No need to free the contents of the array since it
646 * just contains pointers to the GtkTreeViewColumn
647 * objects that are in the GtkTreeView.
649 g_array_free (array, TRUE);
652 G_OBJECT_CLASS (gail_tree_view_parent_class)->finalize (object);
656 gail_tree_view_connect_widget_destroyed (GtkAccessible *accessible)
658 if (accessible->widget)
660 g_signal_connect_after (accessible->widget,
662 G_CALLBACK (gail_tree_view_destroyed),
665 GTK_ACCESSIBLE_CLASS (gail_tree_view_parent_class)->connect_widget_destroyed (accessible);
669 gail_tree_view_destroyed (GtkWidget *widget,
670 GtkAccessible *accessible)
673 GailTreeView *gailview;
675 gail_return_if_fail (GTK_IS_TREE_VIEW (widget));
677 gailview = GAIL_TREE_VIEW (accessible);
678 adj = gailview->old_hadj;
680 g_signal_handlers_disconnect_by_func (adj,
681 (gpointer) adjustment_changed,
683 adj = gailview->old_vadj;
685 g_signal_handlers_disconnect_by_func (adj,
686 (gpointer) adjustment_changed,
688 if (gailview->tree_model)
690 disconnect_model_signals (gailview);
691 gailview->tree_model = NULL;
693 if (gailview->focus_cell)
695 g_object_unref (gailview->focus_cell);
696 gailview->focus_cell = NULL;
698 if (gailview->idle_expand_id)
700 g_source_remove (gailview->idle_expand_id);
701 gailview->idle_expand_id = 0;
706 get_focus_index (GtkTreeView *tree_view)
708 GtkTreePath *focus_path;
709 GtkTreeViewColumn *focus_column;
712 gtk_tree_view_get_cursor (tree_view, &focus_path, &focus_column);
713 if (focus_path && focus_column)
716 index = get_index (tree_view, focus_path,
717 get_column_number (tree_view, focus_column, FALSE));
723 gtk_tree_path_free (focus_path);
729 gail_tree_view_ref_focus_cell (GtkTreeView *tree_view)
732 * This function returns a reference to the accessible object for the cell
733 * in the treeview which has focus, if a cell has focus.
735 AtkObject *focus_cell = NULL;
739 focus_index = get_focus_index (tree_view);
740 if (focus_index >= 0)
742 atk_obj = gtk_widget_get_accessible (GTK_WIDGET (tree_view));
743 focus_cell = atk_object_ref_accessible_child (atk_obj, focus_index);
752 gail_tree_view_get_n_children (AtkObject *obj)
755 GtkTreeView *tree_view;
756 GtkTreeModel *tree_model;
759 gail_return_val_if_fail (GAIL_IS_TREE_VIEW (obj), 0);
761 widget = GTK_ACCESSIBLE (obj)->widget;
768 tree_view = GTK_TREE_VIEW (widget);
769 tree_model = gtk_tree_view_get_model (tree_view);
772 * We get the total number of rows including those which are collapsed
774 n_rows = get_row_count (tree_model);
776 * We get the total number of columns including those which are not visible
778 n_cols = get_n_actual_columns (tree_view);
779 return (n_rows * n_cols);
783 gail_tree_view_ref_child (AtkObject *obj,
787 GailTreeView *gailview;
789 GtkTreeView *tree_view;
790 GtkTreeModel *tree_model;
791 GtkCellRenderer *renderer;
793 GtkTreeViewColumn *tv_col;
794 GtkTreeSelection *selection;
796 AtkRegistry *default_registry;
797 AtkObjectFactory *factory;
800 GtkTreeViewColumn *expander_tv;
801 GList *renderer_list;
803 GailContainerCell *container = NULL;
804 GailRendererCell *renderer_cell;
805 gboolean is_expander, is_expanded, retval;
806 gboolean editable = FALSE;
809 g_return_val_if_fail (GAIL_IS_TREE_VIEW (obj), NULL);
810 g_return_val_if_fail (i >= 0, NULL);
812 widget = GTK_ACCESSIBLE (obj)->widget;
819 if (i >= gail_tree_view_get_n_children (obj))
822 tree_view = GTK_TREE_VIEW (widget);
823 if (i < get_n_actual_columns (tree_view))
825 tv_col = gtk_tree_view_get_column (tree_view, i);
826 child = get_header_from_column (tv_col);
828 g_object_ref (child);
832 gailview = GAIL_TREE_VIEW (obj);
834 * Check whether the child is cached
836 cell = find_cell (gailview, i);
840 return ATK_OBJECT (cell);
843 if (gailview->focus_cell == NULL)
844 focus_index = get_focus_index (tree_view);
848 * Find the TreePath and GtkTreeViewColumn for the index
850 if (!get_path_column_from_index (tree_view, i, &path, &tv_col))
853 tree_model = gtk_tree_view_get_model (tree_view);
854 retval = gtk_tree_model_get_iter (tree_model, &iter, path);
855 gail_return_val_if_fail (retval, NULL);
857 expander_tv = gtk_tree_view_get_expander_column (tree_view);
860 if (gtk_tree_model_iter_has_child (tree_model, &iter))
862 if (expander_tv == tv_col)
865 is_expanded = gtk_tree_view_row_expanded (tree_view, path);
868 gtk_tree_view_column_cell_set_cell_data (tv_col, tree_model, &iter,
869 is_expander, is_expanded);
871 renderer_list = gtk_tree_view_column_get_cell_renderers (tv_col);
873 /* If there are more than one renderer in the list, make a container */
875 if (renderer_list && renderer_list->next)
877 GailCell *container_cell;
879 container = gail_container_cell_new ();
880 gail_return_val_if_fail (container, NULL);
882 container_cell = GAIL_CELL (container);
883 gail_cell_initialise (container_cell,
884 widget, ATK_OBJECT (gailview),
887 * The GailTreeViewCellInfo structure for the container will be before
888 * the ones for the cells so that the first one we find for a position
889 * will be for the container
891 cell_info_new (gailview, tree_model, path, tv_col, container_cell);
892 container_cell->refresh_index = refresh_cell_index;
893 parent = ATK_OBJECT (container);
896 parent = ATK_OBJECT (gailview);
901 * Now we make a fake cell_renderer if there is no cell in renderer_list
904 if (renderer_list == NULL)
906 GtkCellRenderer *fake_renderer;
907 fake_renderer = g_object_new (GTK_TYPE_CELL_RENDERER_TEXT, NULL);
908 default_registry = atk_get_default_registry ();
909 factory = atk_registry_get_factory (default_registry,
910 GTK_OBJECT_TYPE (fake_renderer));
911 child = atk_object_factory_create_accessible (factory,
912 G_OBJECT (fake_renderer));
913 gail_return_val_if_fail (GAIL_IS_RENDERER_CELL (child), NULL);
914 cell = GAIL_CELL (child);
915 renderer_cell = GAIL_RENDERER_CELL (child);
916 renderer_cell->renderer = fake_renderer;
918 /* Create the GailTreeViewCellInfo structure for this cell */
919 cell_info_new (gailview, tree_model, path, tv_col, cell);
921 gail_cell_initialise (cell,
925 cell->refresh_index = refresh_cell_index;
927 /* set state if it is expandable */
930 set_cell_expandable (cell);
932 gail_cell_add_state (cell,
937 for (l = renderer_list; l; l = l->next)
939 renderer = GTK_CELL_RENDERER (l->data);
941 if (GTK_IS_CELL_RENDERER_TEXT (renderer))
942 g_object_get (G_OBJECT (renderer), "editable", &editable, NULL);
944 default_registry = atk_get_default_registry ();
945 factory = atk_registry_get_factory (default_registry,
946 GTK_OBJECT_TYPE (renderer));
947 child = atk_object_factory_create_accessible (factory,
948 G_OBJECT (renderer));
949 gail_return_val_if_fail (GAIL_IS_RENDERER_CELL (child), NULL);
950 cell = GAIL_CELL (child);
951 renderer_cell = GAIL_RENDERER_CELL (child);
953 /* Create the GailTreeViewCellInfo structure for this cell */
954 cell_info_new (gailview, tree_model, path, tv_col, cell);
956 gail_cell_initialise (cell,
961 gail_container_cell_add_child (container, cell);
963 cell->refresh_index = refresh_cell_index;
965 update_cell_value (renderer_cell, gailview, FALSE);
966 /* Add the actions appropriate for this cell */
967 add_cell_actions (cell, editable);
969 /* set state if it is expandable */
972 set_cell_expandable (cell);
974 gail_cell_add_state (cell,
979 * If the column is visible, sets the cell's state
981 if (gtk_tree_view_column_get_visible (tv_col))
982 set_cell_visibility (tree_view, cell, tv_col, path, FALSE);
984 * If the row is selected, all cells on the row are selected
986 selection = gtk_tree_view_get_selection (tree_view);
988 if (gtk_tree_selection_path_is_selected (selection, path))
989 gail_cell_add_state (cell, ATK_STATE_SELECTED, FALSE);
991 gail_cell_add_state (cell, ATK_STATE_FOCUSABLE, FALSE);
992 if (focus_index == i)
994 gailview->focus_cell = g_object_ref (cell);
995 gail_cell_add_state (cell, ATK_STATE_FOCUSED, FALSE);
996 g_signal_emit_by_name (gailview,
997 "active-descendant-changed",
1001 g_list_free (renderer_list);
1003 child = ATK_OBJECT (container);
1006 if (expander_tv == tv_col)
1008 AtkRelationSet *relation_set;
1009 AtkObject *accessible_array[1];
1010 AtkRelation* relation;
1011 AtkObject *parent_node;
1013 relation_set = atk_object_ref_relation_set (ATK_OBJECT (child));
1015 gtk_tree_path_up (path);
1016 if (gtk_tree_path_get_depth (path) == 0)
1023 n_columns = get_n_actual_columns (tree_view);
1024 parent_index = get_index (tree_view, path, i % n_columns);
1025 parent_node = atk_object_ref_accessible_child (obj, parent_index);
1027 accessible_array[0] = parent_node;
1028 relation = atk_relation_new (accessible_array, 1,
1029 ATK_RELATION_NODE_CHILD_OF);
1030 atk_relation_set_add (relation_set, relation);
1031 g_object_unref (relation);
1032 g_object_unref (relation_set);
1034 gtk_tree_path_free (path);
1037 * We do not increase the reference count here; when g_object_unref() is
1038 * called for the cell then cell_destroyed() is called and
1039 * this removes the cell from the cache.
1045 gail_tree_view_ref_state_set (AtkObject *obj)
1047 AtkStateSet *state_set;
1050 state_set = ATK_OBJECT_CLASS (gail_tree_view_parent_class)->ref_state_set (obj);
1051 widget = GTK_ACCESSIBLE (obj)->widget;
1054 atk_state_set_add_state (state_set, ATK_STATE_MANAGES_DESCENDANTS);
1059 /* atkcomponent.h */
1062 atk_component_interface_init (AtkComponentIface *iface)
1064 iface->ref_accessible_at_point = gail_tree_view_ref_accessible_at_point;
1068 gail_tree_view_ref_accessible_at_point (AtkComponent *component,
1071 AtkCoordType coord_type)
1074 GtkTreeView *tree_view;
1076 GtkTreeViewColumn *tv_column;
1080 widget = GTK_ACCESSIBLE (component)->widget;
1082 /* State is defunct */
1085 tree_view = GTK_TREE_VIEW (widget);
1087 atk_component_get_extents (component, &x_pos, &y_pos, NULL, NULL, coord_type);
1088 ret_val = gtk_tree_view_get_path_at_pos (tree_view,
1089 x - x_pos, y - y_pos,
1090 &path, &tv_column, NULL, NULL);
1095 column = get_column_number (tree_view, tv_column, FALSE);
1096 index = get_index (tree_view, path, column);
1097 gtk_tree_path_free (path);
1099 return gail_tree_view_ref_child (ATK_OBJECT (component), index);
1103 g_warning ("gail_tree_view_ref_accessible_at_point: gtk_tree_view_get_path_at_pos () failed\n");
1111 atk_table_interface_init (AtkTableIface *iface)
1113 iface->ref_at = gail_tree_view_table_ref_at;
1114 iface->get_n_rows = gail_tree_view_get_n_rows;
1115 iface->get_n_columns = gail_tree_view_get_n_columns;
1116 iface->get_index_at = gail_tree_view_get_index_at;
1117 iface->get_column_at_index = gail_tree_view_get_column_at_index;
1118 iface->get_row_at_index = gail_tree_view_get_row_at_index;
1119 iface->is_row_selected = gail_tree_view_is_row_selected;
1120 iface->is_selected = gail_tree_view_is_selected;
1121 iface->get_selected_rows = gail_tree_view_get_selected_rows;
1122 iface->add_row_selection = gail_tree_view_add_row_selection;
1123 iface->remove_row_selection = gail_tree_view_remove_row_selection;
1124 iface->get_column_extent_at = NULL;
1125 iface->get_row_extent_at = NULL;
1126 iface->get_row_header = gail_tree_view_get_row_header;
1127 iface->set_row_header = gail_tree_view_set_row_header;
1128 iface->get_column_header = gail_tree_view_get_column_header;
1129 iface->set_column_header = gail_tree_view_set_column_header;
1130 iface->get_caption = gail_tree_view_get_caption;
1131 iface->set_caption = gail_tree_view_set_caption;
1132 iface->get_summary = gail_tree_view_get_summary;
1133 iface->set_summary = gail_tree_view_set_summary;
1134 iface->get_row_description = gail_tree_view_get_row_description;
1135 iface->set_row_description = gail_tree_view_set_row_description;
1136 iface->get_column_description = gail_tree_view_get_column_description;
1137 iface->set_column_description = gail_tree_view_set_column_description;
1141 gail_tree_view_get_index_at (AtkTable *table,
1146 GtkTreeView *tree_view;
1148 gint n_cols, n_rows;
1153 n_cols = atk_table_get_n_columns (table);
1154 n_rows = atk_table_get_n_rows (table);
1156 if (row >= n_rows ||
1160 widget = GTK_ACCESSIBLE (table)->widget;
1162 /* State is defunct */
1165 tree_view = GTK_TREE_VIEW (widget);
1166 actual_column = get_actual_column_number (tree_view, column);
1168 set_iter_nth_row (tree_view, &iter, row);
1169 path = gtk_tree_model_get_path (gtk_tree_view_get_model (tree_view), &iter);
1171 index = get_index (tree_view, path, actual_column);
1172 gtk_tree_path_free (path);
1178 gail_tree_view_get_column_at_index (AtkTable *table,
1182 GtkTreeView *tree_view;
1185 widget = GTK_ACCESSIBLE (table)->widget;
1187 /* State is defunct */
1190 tree_view = GTK_TREE_VIEW (widget);
1191 n_columns = get_n_actual_columns (tree_view);
1195 index = index % n_columns;
1197 return get_visible_column_number (tree_view, index);
1201 gail_tree_view_get_row_at_index (AtkTable *table,
1205 GtkTreeView *tree_view;
1208 widget = GTK_ACCESSIBLE (table)->widget;
1210 /* State is defunct */
1213 tree_view = GTK_TREE_VIEW (widget);
1214 if (get_path_column_from_index (tree_view, index, &path, NULL))
1216 gint row = get_row_from_tree_path (tree_view, path);
1217 gtk_tree_path_free (path);
1225 gail_tree_view_table_ref_at (AtkTable *table,
1231 index = gail_tree_view_get_index_at (table, row, column);
1235 return gail_tree_view_ref_child (ATK_OBJECT (table), index);
1239 gail_tree_view_get_n_rows (AtkTable *table)
1242 GtkTreeView *tree_view;
1243 GtkTreeModel *tree_model;
1246 widget = GTK_ACCESSIBLE (table)->widget;
1248 /* State is defunct */
1251 tree_view = GTK_TREE_VIEW (widget);
1252 tree_model = gtk_tree_view_get_model (tree_view);
1254 if (gtk_tree_model_get_flags (tree_model) & GTK_TREE_MODEL_LIST_ONLY)
1256 * If working with a LIST store, then this is a faster way
1257 * to get the number of rows.
1259 n_rows = gtk_tree_model_iter_n_children (tree_model, NULL);
1262 GtkTreePath *root_tree;
1265 root_tree = gtk_tree_path_new_root ();
1266 iterate_thru_children (tree_view, tree_model,
1267 root_tree, NULL, &n_rows, 0);
1268 gtk_tree_path_free (root_tree);
1275 * The function get_n_actual_columns returns the number of columns in the
1276 * GtkTreeView. i.e. it include both visible and non-visible columns.
1279 get_n_actual_columns (GtkTreeView *tree_view)
1284 columns = gtk_tree_view_get_columns (tree_view);
1285 n_cols = g_list_length (columns);
1286 g_list_free (columns);
1291 gail_tree_view_get_n_columns (AtkTable *table)
1294 GtkTreeView *tree_view;
1295 GtkTreeViewColumn *tv_col;
1299 widget = GTK_ACCESSIBLE (table)->widget;
1301 /* State is defunct */
1304 tree_view = GTK_TREE_VIEW (widget);
1305 tv_col = gtk_tree_view_get_column (tree_view, i);
1307 while (tv_col != NULL)
1309 if (gtk_tree_view_column_get_visible (tv_col))
1313 tv_col = gtk_tree_view_get_column (tree_view, i);
1320 gail_tree_view_is_row_selected (AtkTable *table,
1324 GtkTreeView *tree_view;
1325 GtkTreeSelection *selection;
1328 widget = GTK_ACCESSIBLE (table)->widget;
1330 /* State is defunct */
1336 tree_view = GTK_TREE_VIEW (widget);
1338 selection = gtk_tree_view_get_selection (tree_view);
1340 set_iter_nth_row (tree_view, &iter, row);
1342 return gtk_tree_selection_iter_is_selected (selection, &iter);
1346 gail_tree_view_is_selected (AtkTable *table,
1350 return gail_tree_view_is_row_selected (table, row);
1354 gail_tree_view_get_selected_rows (AtkTable *table,
1355 gint **rows_selected)
1358 GtkTreeView *tree_view;
1359 GtkTreeModel *tree_model;
1361 GtkTreeSelection *selection;
1362 GtkTreePath *tree_path;
1365 widget = GTK_ACCESSIBLE (table)->widget;
1367 /* State is defunct */
1370 tree_view = GTK_TREE_VIEW (widget);
1372 selection = gtk_tree_view_get_selection (tree_view);
1374 switch (selection->type)
1376 case GTK_SELECTION_SINGLE:
1377 case GTK_SELECTION_BROWSE:
1378 if (gtk_tree_selection_get_selected (selection, &tree_model, &iter))
1384 *rows_selected = (gint *)g_malloc (sizeof(gint));
1385 tree_path = gtk_tree_model_get_path (tree_model, &iter);
1386 row = get_row_from_tree_path (tree_view, tree_path);
1387 gtk_tree_path_free (tree_path);
1389 /* shouldn't ever happen */
1390 g_return_val_if_fail (row != -1, 0);
1392 *rows_selected[0] = row;
1397 case GTK_SELECTION_MULTIPLE:
1399 GPtrArray *array = g_ptr_array_new();
1401 gtk_tree_selection_selected_foreach (selection,
1404 ret_val = array->len;
1406 if (rows_selected && ret_val)
1409 *rows_selected = (gint *) g_malloc (ret_val * sizeof (gint));
1411 for (i = 0; i < ret_val; i++)
1415 tree_path = (GtkTreePath *) g_ptr_array_index (array, i);
1416 row = get_row_from_tree_path (tree_view, tree_path);
1417 gtk_tree_path_free (tree_path);
1418 (*rows_selected)[i] = row;
1421 g_ptr_array_free (array, FALSE);
1424 case GTK_SELECTION_NONE:
1431 gail_tree_view_add_row_selection (AtkTable *table,
1435 GtkTreeView *tree_view;
1436 GtkTreeModel *tree_model;
1437 GtkTreeSelection *selection;
1438 GtkTreePath *tree_path;
1439 GtkTreeIter iter_to_row;
1441 widget = GTK_ACCESSIBLE (table)->widget;
1443 /* State is defunct */
1446 if (!gail_tree_view_is_row_selected (table, row))
1448 tree_view = GTK_TREE_VIEW (widget);
1449 tree_model = gtk_tree_view_get_model (tree_view);
1450 selection = gtk_tree_view_get_selection (tree_view);
1452 if (gtk_tree_model_get_flags (tree_model) & GTK_TREE_MODEL_LIST_ONLY)
1454 tree_path = gtk_tree_path_new ();
1455 gtk_tree_path_append_index (tree_path, row);
1456 gtk_tree_selection_select_path (selection,tree_path);
1457 gtk_tree_path_free (tree_path);
1461 set_iter_nth_row (tree_view, &iter_to_row, row);
1462 if (&iter_to_row != NULL)
1463 gtk_tree_selection_select_iter (selection, &iter_to_row);
1469 return gail_tree_view_is_row_selected (table, row);
1473 gail_tree_view_remove_row_selection (AtkTable *table,
1477 GtkTreeView *tree_view;
1478 GtkTreeSelection *selection;
1480 widget = GTK_ACCESSIBLE (table)->widget;
1482 /* State is defunct */
1485 tree_view = GTK_TREE_VIEW (widget);
1487 selection = gtk_tree_view_get_selection (tree_view);
1489 if (gail_tree_view_is_row_selected (table, row))
1491 gtk_tree_selection_unselect_all (selection);
1498 gail_tree_view_get_row_header (AtkTable *table,
1501 GailTreeViewRowInfo *row_info;
1503 row_info = get_row_info (table, row);
1505 return row_info->header;
1511 gail_tree_view_set_row_header (AtkTable *table,
1515 set_row_data (table, row, header, NULL, TRUE);
1519 gail_tree_view_get_column_header (AtkTable *table,
1523 GtkTreeView *tree_view;
1524 GtkTreeViewColumn *tv_col;
1526 widget = GTK_ACCESSIBLE (table)->widget;
1528 /* State is defunct */
1531 tree_view = GTK_TREE_VIEW (widget);
1532 tv_col = get_column (tree_view, in_col);
1533 return get_header_from_column (tv_col);
1537 gail_tree_view_set_column_header (AtkTable *table,
1542 GtkTreeView *tree_view;
1543 GtkTreeViewColumn *tv_col;
1545 AtkPropertyValues values = { NULL };
1547 widget = GTK_ACCESSIBLE (table)->widget;
1549 /* State is defunct */
1552 tree_view = GTK_TREE_VIEW (widget);
1553 tv_col = get_column (tree_view, in_col);
1557 rc = g_object_get_qdata (G_OBJECT (tv_col),
1558 quark_column_header_object);
1560 g_object_unref (rc);
1562 g_object_set_qdata (G_OBJECT (tv_col),
1563 quark_column_header_object,
1566 g_object_ref (header);
1567 g_value_init (&values.new_value, G_TYPE_INT);
1568 g_value_set_int (&values.new_value, in_col);
1570 values.property_name = "accessible-table-column-header";
1571 g_signal_emit_by_name (table,
1572 "property_change::accessible-table-column-header",
1577 gail_tree_view_get_caption (AtkTable *table)
1579 GailTreeView* obj = GAIL_TREE_VIEW (table);
1581 return obj->caption;
1585 gail_tree_view_set_caption (AtkTable *table,
1588 GailTreeView* obj = GAIL_TREE_VIEW (table);
1589 AtkPropertyValues values = { NULL };
1590 AtkObject *old_caption;
1592 old_caption = obj->caption;
1593 obj->caption = caption;
1595 g_object_ref (obj->caption);
1596 g_value_init (&values.old_value, G_TYPE_POINTER);
1597 g_value_set_pointer (&values.old_value, old_caption);
1598 g_value_init (&values.new_value, G_TYPE_POINTER);
1599 g_value_set_pointer (&values.new_value, obj->caption);
1601 values.property_name = "accessible-table-caption-object";
1602 g_signal_emit_by_name (table,
1603 "property_change::accessible-table-caption-object",
1606 g_object_unref (old_caption);
1609 static G_CONST_RETURN gchar*
1610 gail_tree_view_get_column_description (AtkTable *table,
1614 GtkTreeView *tree_view;
1615 GtkTreeViewColumn *tv_col;
1618 widget = GTK_ACCESSIBLE (table)->widget;
1620 /* State is defunct */
1623 tree_view = GTK_TREE_VIEW (widget);
1624 tv_col = get_column (tree_view, in_col);
1628 rc = g_object_get_qdata (G_OBJECT (tv_col),
1629 quark_column_desc_object);
1637 g_object_get (tv_col, "title", &title_text, NULL);
1643 gail_tree_view_set_column_description (AtkTable *table,
1645 const gchar *description)
1648 GtkTreeView *tree_view;
1649 GtkTreeViewColumn *tv_col;
1650 AtkPropertyValues values = { NULL };
1652 widget = GTK_ACCESSIBLE (table)->widget;
1654 /* State is defunct */
1657 tree_view = GTK_TREE_VIEW (widget);
1658 tv_col = get_column (tree_view, in_col);
1662 g_object_set_qdata (G_OBJECT (tv_col),
1663 quark_column_desc_object,
1664 g_strdup (description));
1665 g_value_init (&values.new_value, G_TYPE_INT);
1666 g_value_set_int (&values.new_value, in_col);
1668 values.property_name = "accessible-table-column-description";
1669 g_signal_emit_by_name (table,
1670 "property_change::accessible-table-column-description",
1674 static G_CONST_RETURN gchar*
1675 gail_tree_view_get_row_description (AtkTable *table,
1678 GailTreeViewRowInfo *row_info;
1680 row_info = get_row_info (table, row);
1682 return row_info->description;
1688 gail_tree_view_set_row_description (AtkTable *table,
1690 const gchar *description)
1692 set_row_data (table, row, NULL, description, FALSE);
1696 gail_tree_view_get_summary (AtkTable *table)
1698 GailTreeView* obj = GAIL_TREE_VIEW (table);
1700 return obj->summary;
1704 gail_tree_view_set_summary (AtkTable *table,
1705 AtkObject *accessible)
1707 GailTreeView* obj = GAIL_TREE_VIEW (table);
1708 AtkPropertyValues values = { NULL };
1709 AtkObject *old_summary;
1711 old_summary = obj->summary;
1712 obj->summary = accessible;
1714 g_object_ref (obj->summary);
1715 g_value_init (&values.old_value, G_TYPE_POINTER);
1716 g_value_set_pointer (&values.old_value, old_summary);
1717 g_value_init (&values.new_value, G_TYPE_POINTER);
1718 g_value_set_pointer (&values.new_value, obj->summary);
1720 values.property_name = "accessible-table-summary";
1721 g_signal_emit_by_name (table,
1722 "property_change::accessible-table-ummary",
1725 g_object_unref (old_summary);
1729 set_row_data (AtkTable *table,
1732 const gchar *description,
1736 GtkTreeView *tree_view;
1737 GtkTreeModel *tree_model;
1738 GailTreeView* obj = GAIL_TREE_VIEW (table);
1739 GailTreeViewRowInfo* row_info;
1743 gboolean found = FALSE;
1745 AtkPropertyValues values = { NULL };
1748 widget = GTK_ACCESSIBLE (table)->widget;
1750 /* State is defunct */
1753 tree_view = GTK_TREE_VIEW (widget);
1754 tree_model = gtk_tree_view_get_model (tree_view);
1756 set_iter_nth_row (tree_view, &iter, row);
1757 path = gtk_tree_model_get_path (tree_model, &iter);
1759 if (obj->row_data == NULL)
1760 obj->row_data = g_array_sized_new (FALSE, TRUE,
1761 sizeof(GailTreeViewRowInfo *), 0);
1763 array = obj->row_data;
1765 for (i = 0; i < array->len; i++)
1767 GtkTreePath *row_path;
1769 row_info = g_array_index (array, GailTreeViewRowInfo*, i);
1770 row_path = gtk_tree_row_reference_get_path (row_info->row_ref);
1772 if (row_path != NULL)
1774 if (path && gtk_tree_path_compare (row_path, path) == 0)
1777 gtk_tree_path_free (row_path);
1783 if (row_info->header)
1784 g_object_unref (row_info->header);
1785 row_info->header = header;
1786 if (row_info->header)
1787 g_object_ref (row_info->header);
1791 g_free (row_info->description);
1792 row_info->description = g_strdup (description);
1802 row_info = g_malloc (sizeof(GailTreeViewRowInfo));
1803 row_info->row_ref = gtk_tree_row_reference_new (tree_model, path);
1806 row_info->header = header;
1807 if (row_info->header)
1808 g_object_ref (row_info->header);
1809 row_info->description = NULL;
1813 row_info->header = NULL;
1814 row_info->description = g_strdup (description);
1816 g_array_append_val (array, row_info);
1818 g_value_init (&values.new_value, G_TYPE_INT);
1819 g_value_set_int (&values.new_value, row);
1823 values.property_name = "accessible-table-row-header";
1824 signal_name = "property_change::accessible-table-row-header";
1828 values.property_name = "accessible-table-row-description";
1829 signal_name = "property-change::accessible-table-row-description";
1831 g_signal_emit_by_name (table,
1835 gtk_tree_path_free (path);
1839 static GailTreeViewRowInfo*
1840 get_row_info (AtkTable *table,
1844 GtkTreeView *tree_view;
1845 GtkTreeModel *tree_model;
1846 GailTreeView* obj = GAIL_TREE_VIEW (table);
1850 GailTreeViewRowInfo *rc = NULL;
1852 widget = GTK_ACCESSIBLE (table)->widget;
1854 /* State is defunct */
1857 tree_view = GTK_TREE_VIEW (widget);
1858 tree_model = gtk_tree_view_get_model (tree_view);
1860 set_iter_nth_row (tree_view, &iter, row);
1861 path = gtk_tree_model_get_path (tree_model, &iter);
1862 array = obj->row_data;
1866 GailTreeViewRowInfo *row_info;
1867 GtkTreePath *row_path;
1870 for (i = 0; i < array->len; i++)
1872 row_info = g_array_index (array, GailTreeViewRowInfo*, i);
1873 row_path = gtk_tree_row_reference_get_path (row_info->row_ref);
1874 if (row_path != NULL)
1876 if (path && gtk_tree_path_compare (row_path, path) == 0)
1879 gtk_tree_path_free (row_path);
1887 gtk_tree_path_free (path);
1890 /* atkselection.h */
1892 static void atk_selection_interface_init (AtkSelectionIface *iface)
1894 iface->add_selection = gail_tree_view_add_selection;
1895 iface->clear_selection = gail_tree_view_clear_selection;
1896 iface->ref_selection = gail_tree_view_ref_selection;
1897 iface->get_selection_count = gail_tree_view_get_selection_count;
1898 iface->is_child_selected = gail_tree_view_is_child_selected;
1902 gail_tree_view_add_selection (AtkSelection *selection,
1909 table = ATK_TABLE (selection);
1910 n_columns = gail_tree_view_get_n_columns (table);
1914 row = gail_tree_view_get_row_at_index (table, i);
1915 return gail_tree_view_add_row_selection (table, row);
1919 gail_tree_view_clear_selection (AtkSelection *selection)
1922 GtkTreeView *tree_view;
1923 GtkTreeSelection *tree_selection;
1925 widget = GTK_ACCESSIBLE (selection)->widget;
1927 /* State is defunct */
1930 tree_view = GTK_TREE_VIEW (widget);
1932 tree_selection = gtk_tree_view_get_selection (tree_view);
1933 gtk_tree_selection_unselect_all (tree_selection);
1939 gail_tree_view_ref_selection (AtkSelection *selection,
1948 table = ATK_TABLE (selection);
1949 n_columns = gail_tree_view_get_n_columns (table);
1950 n_selected = gail_tree_view_get_selected_rows (table, &selected);
1951 if (i >= n_columns * n_selected)
1954 row = selected[i / n_columns];
1957 return gail_tree_view_table_ref_at (table, row, i % n_columns);
1961 gail_tree_view_get_selection_count (AtkSelection *selection)
1966 table = ATK_TABLE (selection);
1967 n_selected = gail_tree_view_get_selected_rows (table, NULL);
1969 n_selected *= gail_tree_view_get_n_columns (table);
1974 gail_tree_view_is_child_selected (AtkSelection *selection,
1980 widget = GTK_ACCESSIBLE (selection)->widget;
1982 /* State is defunct */
1985 row = atk_table_get_row_at_index (ATK_TABLE (selection), i);
1987 return gail_tree_view_is_row_selected (ATK_TABLE (selection), row);
1991 static void gail_cell_parent_interface_init (GailCellParentIface *iface)
1993 iface->get_cell_extents = gail_tree_view_get_cell_extents;
1994 iface->get_cell_area = gail_tree_view_get_cell_area;
1995 iface->grab_focus = gail_tree_view_grab_cell_focus;
1999 gail_tree_view_get_cell_extents (GailCellParent *parent,
2005 AtkCoordType coord_type)
2008 GtkTreeView *tree_view;
2009 GdkWindow *bin_window;
2010 GdkRectangle cell_rect;
2013 widget = GTK_ACCESSIBLE (parent)->widget;
2015 /* State is defunct */
2018 tree_view = GTK_TREE_VIEW (widget);
2019 gail_tree_view_get_cell_area (parent, cell, &cell_rect);
2020 bin_window = gtk_tree_view_get_bin_window (tree_view);
2021 gdk_window_get_origin (bin_window, &w_x, &w_y);
2023 if (coord_type == ATK_XY_WINDOW)
2026 gint x_toplevel, y_toplevel;
2028 window = gdk_window_get_toplevel (bin_window);
2029 gdk_window_get_origin (window, &x_toplevel, &y_toplevel);
2035 *width = cell_rect.width;
2036 *height = cell_rect.height;
2037 if (is_cell_showing (tree_view, &cell_rect))
2039 *x = cell_rect.x + w_x;
2040 *y = cell_rect.y + w_y;
2049 #define EXTRA_EXPANDER_PADDING 4
2052 gail_tree_view_get_cell_area (GailCellParent *parent,
2054 GdkRectangle *cell_rect)
2057 GtkTreeView *tree_view;
2058 GtkTreeViewColumn *tv_col;
2060 AtkObject *parent_cell;
2061 GailTreeViewCellInfo *cell_info;
2064 widget = GTK_ACCESSIBLE (parent)->widget;
2066 /* State is defunct */
2069 tree_view = GTK_TREE_VIEW (widget);
2070 parent_cell = atk_object_get_parent (ATK_OBJECT (cell));
2071 if (parent_cell != ATK_OBJECT (parent))
2074 * GailCell is in a GailContainerCell
2076 top_cell = GAIL_CELL (parent_cell);
2082 cell_info = find_cell_info (GAIL_TREE_VIEW (parent), top_cell, NULL, TRUE);
2083 gail_return_if_fail (cell_info);
2084 gail_return_if_fail (cell_info->cell_col_ref);
2085 gail_return_if_fail (cell_info->cell_row_ref);
2086 path = gtk_tree_row_reference_get_path (cell_info->cell_row_ref);
2087 tv_col = cell_info->cell_col_ref;
2088 if (path && cell_info->in_use)
2090 GtkTreeViewColumn *expander_column;
2091 gint focus_line_width;
2093 gtk_tree_view_get_cell_area (tree_view, path, tv_col, cell_rect);
2094 expander_column = gtk_tree_view_get_expander_column (tree_view);
2095 if (expander_column == tv_col)
2099 gtk_widget_style_get (widget,
2100 "expander_size", &expander_size,
2103 cell_rect->x += expander_size + EXTRA_EXPANDER_PADDING;
2104 cell_rect->width -= expander_size + EXTRA_EXPANDER_PADDING;
2106 gtk_widget_style_get (widget,
2107 "focus-line-width", &focus_line_width,
2110 cell_rect->x += focus_line_width;
2111 cell_rect->width -= 2 * focus_line_width;
2113 gtk_tree_path_free (path);
2116 * A column has more than one renderer so we find the position and width
2119 if (top_cell != cell)
2126 GtkCellRenderer *renderer;
2128 cell_index = atk_object_get_index_in_parent (ATK_OBJECT (cell));
2129 renderers = gtk_tree_view_column_get_cell_renderers (tv_col);
2130 renderer = g_list_nth_data (renderers, cell_index);
2132 found = gtk_tree_view_column_cell_get_position (tv_col, renderer, &cell_start, &cell_width);
2135 cell_rect->x += cell_start;
2136 cell_rect->width = cell_width;
2138 g_list_free (renderers);
2145 gail_tree_view_grab_cell_focus (GailCellParent *parent,
2149 GtkTreeView *tree_view;
2150 GtkTreeViewColumn *tv_col;
2152 AtkObject *parent_cell;
2153 AtkObject *cell_object;
2154 GailTreeViewCellInfo *cell_info;
2155 GtkCellRenderer *renderer = NULL;
2156 GtkWidget *toplevel;
2159 widget = GTK_ACCESSIBLE (parent)->widget;
2161 /* State is defunct */
2164 tree_view = GTK_TREE_VIEW (widget);
2166 cell_info = find_cell_info (GAIL_TREE_VIEW (parent), cell, NULL, TRUE);
2167 gail_return_val_if_fail (cell_info, FALSE);
2168 gail_return_val_if_fail (cell_info->cell_col_ref, FALSE);
2169 gail_return_val_if_fail (cell_info->cell_row_ref, FALSE);
2170 cell_object = ATK_OBJECT (cell);
2171 parent_cell = atk_object_get_parent (cell_object);
2172 tv_col = cell_info->cell_col_ref;
2173 if (parent_cell != ATK_OBJECT (parent))
2176 * GailCell is in a GailContainerCell.
2177 * The GtkTreeViewColumn has multiple renderers;
2178 * find the corresponding one.
2182 renderers = gtk_tree_view_column_get_cell_renderers (tv_col);
2183 if (cell_info->in_use) {
2184 index = atk_object_get_index_in_parent (cell_object);
2185 renderer = g_list_nth_data (renderers, index);
2187 g_list_free (renderers);
2189 path = gtk_tree_row_reference_get_path (cell_info->cell_row_ref);
2190 if (path && cell_info->in_use)
2193 gtk_tree_view_set_cursor_on_cell (tree_view, path, tv_col, renderer, FALSE);
2195 gtk_tree_view_set_cursor (tree_view, path, tv_col, FALSE);
2197 gtk_tree_path_free (path);
2198 gtk_widget_grab_focus (widget);
2199 toplevel = gtk_widget_get_toplevel (widget);
2200 if (GTK_WIDGET_TOPLEVEL (toplevel))
2202 #ifdef GDK_WINDOWING_X11
2203 gtk_window_present_with_time (GTK_WINDOW (toplevel), gdk_x11_get_server_time (widget->window));
2205 gtk_window_present (GTK_WINDOW (toplevel));
2215 /* signal handling */
2218 gail_tree_view_expand_row_gtk (GtkTreeView *tree_view,
2223 GailTreeView *gailview;
2225 g_assert (GTK_IS_TREE_VIEW (tree_view));
2227 atk_obj = gtk_widget_get_accessible (GTK_WIDGET (tree_view));
2229 g_assert (GAIL_IS_TREE_VIEW (atk_obj));
2231 gailview = GAIL_TREE_VIEW (atk_obj);
2234 * The visible rectangle has not been updated when this signal is emitted
2235 * so we process the signal when the GTK processing is completed
2237 /* this seems wrong since it overwrites any other pending expand handlers... */
2238 gailview->idle_expand_path = gtk_tree_path_copy (path);
2239 if (gailview->idle_expand_id)
2240 g_source_remove (gailview->idle_expand_id);
2241 gailview->idle_expand_id = gdk_threads_add_idle (idle_expand_row, gailview);
2246 idle_expand_row (gpointer data)
2248 GailTreeView *gailview = data;
2250 GtkTreeView *tree_view;
2252 GtkTreeModel *tree_model;
2253 gint n_inserted, row;
2255 gailview->idle_expand_id = 0;
2257 path = gailview->idle_expand_path;
2258 tree_view = GTK_TREE_VIEW (GTK_ACCESSIBLE (gailview)->widget);
2260 g_assert (GTK_IS_TREE_VIEW (tree_view));
2262 tree_model = gtk_tree_view_get_model(tree_view);
2266 if (!path || !gtk_tree_model_get_iter (tree_model, &iter, path))
2270 * Update visibility of cells below expansion row
2272 traverse_cells (gailview, path, FALSE, FALSE);
2274 * Figure out number of visible children, the following test
2277 if (gtk_tree_model_iter_has_child (tree_model, &iter))
2279 GtkTreePath *path_copy;
2282 * By passing path into this function, we find the number of
2283 * visible children of path.
2285 path_copy = gtk_tree_path_copy (path);
2286 gtk_tree_path_append_index(path_copy, 0);
2289 iterate_thru_children (tree_view, tree_model,
2290 path_copy, NULL, &n_inserted, 0);
2291 gtk_tree_path_free (path_copy);
2295 /* We can get here if the row expanded callback deleted the row */
2299 /* Set expand state */
2300 set_expand_state (tree_view, tree_model, gailview, path, TRUE);
2302 row = get_row_from_tree_path (tree_view, path);
2304 /* shouldn't ever happen */
2306 g_assert_not_reached ();
2308 /* Must add 1 because the "added rows" are below the row being expanded */
2311 g_signal_emit_by_name (gailview, "row_inserted", row, n_inserted);
2313 gailview->idle_expand_path = NULL;
2315 gtk_tree_path_free (path);
2321 gail_tree_view_collapse_row_gtk (GtkTreeView *tree_view,
2325 GtkTreeModel *tree_model;
2326 AtkObject *atk_obj = gtk_widget_get_accessible (GTK_WIDGET (tree_view));
2327 GailTreeView *gailview = GAIL_TREE_VIEW (atk_obj);
2330 tree_model = gtk_tree_view_get_model (tree_view);
2332 clean_rows (gailview);
2335 * Update visibility of cells below collapsed row
2337 traverse_cells (gailview, path, FALSE, FALSE);
2338 /* Set collapse state */
2339 set_expand_state (tree_view, tree_model, gailview, path, FALSE);
2341 gail_return_val_if_fail (gailview->n_children_deleted, FALSE);
2342 row = get_row_from_tree_path (tree_view, path);
2343 gail_return_val_if_fail (row != -1, FALSE);
2344 g_signal_emit_by_name (atk_obj, "row_deleted", row,
2345 gailview->n_children_deleted);
2346 gailview->n_children_deleted = 0;
2351 gail_tree_view_size_allocate_gtk (GtkWidget *widget,
2352 GtkAllocation *allocation)
2354 AtkObject *atk_obj = gtk_widget_get_accessible (widget);
2355 GailTreeView *gailview = GAIL_TREE_VIEW (atk_obj);
2358 * If the size allocation changes, the visibility of cells may change so
2359 * update the cells visibility.
2361 traverse_cells (gailview, NULL, FALSE, FALSE);
2365 gail_tree_view_set_scroll_adjustments (GtkWidget *widget,
2366 GtkAdjustment *hadj,
2367 GtkAdjustment *vadj)
2369 AtkObject *atk_obj = gtk_widget_get_accessible (widget);
2370 GailTreeView *gailview = GAIL_TREE_VIEW (atk_obj);
2373 g_object_get (widget, hadjustment, &adj, NULL);
2374 if (gailview->old_hadj != adj)
2376 g_signal_handlers_disconnect_by_func (gailview->old_hadj,
2377 (gpointer) adjustment_changed,
2379 gailview->old_hadj = adj;
2380 g_object_add_weak_pointer (G_OBJECT (gailview->old_hadj), (gpointer *)&gailview->old_hadj);
2381 g_signal_connect (adj,
2383 G_CALLBACK (adjustment_changed),
2386 g_object_get (widget, vadjustment, &adj, NULL);
2387 if (gailview->old_vadj != adj)
2389 g_signal_handlers_disconnect_by_func (gailview->old_vadj,
2390 (gpointer) adjustment_changed,
2392 gailview->old_vadj = adj;
2393 g_object_add_weak_pointer (G_OBJECT (gailview->old_vadj), (gpointer *)&gailview->old_vadj);
2394 g_signal_connect (adj,
2396 G_CALLBACK (adjustment_changed),
2402 gail_tree_view_changed_gtk (GtkTreeSelection *selection,
2405 GailTreeView *gailview;
2406 GtkTreeView *tree_view;
2410 GailTreeViewCellInfo *info;
2411 GtkTreeSelection *tree_selection;
2414 gailview = GAIL_TREE_VIEW (data);
2415 cell_list = gailview->cell_data;
2416 widget = GTK_ACCESSIBLE (gailview)->widget;
2419 * destroy signal emitted for widget
2422 tree_view = GTK_TREE_VIEW (widget);
2424 tree_selection = gtk_tree_view_get_selection (tree_view);
2426 for (l = cell_list; l; l = l->next)
2428 info = (GailTreeViewCellInfo *) (l->data);
2432 gail_cell_remove_state (info->cell, ATK_STATE_SELECTED, TRUE);
2434 path = gtk_tree_row_reference_get_path (info->cell_row_ref);
2435 if (path && gtk_tree_selection_path_is_selected (tree_selection, path))
2436 gail_cell_add_state (info->cell, ATK_STATE_SELECTED, TRUE);
2437 gtk_tree_path_free (path);
2440 if (GTK_WIDGET_REALIZED (widget))
2441 g_signal_emit_by_name (gailview, "selection_changed");
2445 columns_changed (GtkTreeView *tree_view)
2447 AtkObject *atk_obj = gtk_widget_get_accessible (GTK_WIDGET(tree_view));
2448 GailTreeView *gailview = GAIL_TREE_VIEW (atk_obj);
2449 GList *tv_cols, *tmp_list;
2450 gboolean column_found;
2451 gboolean move_found = FALSE;
2452 gboolean stale_set = FALSE;
2453 gint column_count = 0;
2457 * This function must determine if the change is an add, delete or
2458 * a move based upon its cache of TreeViewColumns in
2459 * gailview->col_data
2461 tv_cols = gtk_tree_view_get_columns (tree_view);
2463 /* check for adds or moves */
2464 for (tmp_list = tv_cols; tmp_list; tmp_list = tmp_list->next)
2466 column_found = FALSE;
2468 for (i = 0; i < gailview->col_data->len; i++)
2471 if ((GtkTreeViewColumn *)tmp_list->data ==
2472 (GtkTreeViewColumn *)g_array_index (gailview->col_data,
2473 GtkTreeViewColumn *, i))
2475 column_found = TRUE;
2477 /* If the column isn't in the same position, a move happened */
2478 if (!move_found && i != column_count)
2482 /* Set all rows to ATK_STATE_STALE */
2483 traverse_cells (gailview, NULL, TRUE, FALSE);
2487 /* Just emit one column reordered signal when a move happens */
2488 g_signal_emit_by_name (atk_obj, "column_reordered");
2497 * If column_found is FALSE, then an insert happened for column
2498 * number column_count
2502 gint n_cols, n_rows, row;
2506 /* Set all rows to ATK_STATE_STALE */
2507 traverse_cells (gailview, NULL, TRUE, FALSE);
2511 /* Generate column-inserted signal */
2512 g_signal_emit_by_name (atk_obj, "column_inserted", column_count, 1);
2514 /* Generate children-changed signals */
2515 n_rows = get_row_count (gtk_tree_view_get_model (tree_view));
2516 n_cols = get_n_actual_columns (tree_view);
2517 for (row = 0; row < n_rows; row++)
2520 * Pass NULL as the child object, i.e. 4th argument.
2522 g_signal_emit_by_name (atk_obj, "children_changed::add",
2523 ((row * n_cols) + column_count), NULL, NULL);
2530 /* check for deletes */
2531 for (i = 0; i < gailview->col_data->len; i++)
2533 column_found = FALSE;
2535 for (tmp_list = tv_cols; tmp_list; tmp_list = tmp_list->next)
2537 if ((GtkTreeViewColumn *)tmp_list->data ==
2538 (GtkTreeViewColumn *)g_array_index (gailview->col_data,
2539 GtkTreeViewColumn *, i))
2541 column_found = TRUE;
2547 * If column_found is FALSE, then a delete happened for column
2552 gint n_rows, n_cols, row;
2554 clean_cols (gailview,
2555 (GtkTreeViewColumn *)g_array_index (gailview->col_data,
2556 GtkTreeViewColumn *, i));
2560 /* Set all rows to ATK_STATE_STALE */
2561 traverse_cells (gailview, NULL, TRUE, FALSE);
2565 /* Generate column-deleted signal */
2566 g_signal_emit_by_name (atk_obj, "column_deleted", i, 1);
2568 /* Generate children-changed signals */
2569 n_rows = get_row_count (gtk_tree_view_get_model (tree_view));
2570 n_cols = get_n_actual_columns (tree_view);
2571 for (row = 0; row < n_rows; row++)
2574 * Pass NULL as the child object, 4th argument.
2576 g_signal_emit_by_name (atk_obj, "children_changed::remove",
2577 ((row * n_cols) + column_count), NULL, NULL);
2582 /* rebuild the array */
2584 g_array_free (gailview->col_data, TRUE);
2585 gailview->col_data = g_array_sized_new (FALSE, TRUE,
2586 sizeof(GtkTreeViewColumn *), 0);
2588 for (tmp_list = tv_cols; tmp_list; tmp_list = tmp_list->next)
2589 g_array_append_val (gailview->col_data, tmp_list->data);
2590 g_list_free (tv_cols);
2594 cursor_changed (GtkTreeView *tree_view)
2596 GailTreeView *gailview;
2598 gailview = GAIL_TREE_VIEW (gtk_widget_get_accessible (GTK_WIDGET (tree_view)));
2599 if (gailview->idle_cursor_changed_id != 0)
2603 * We notify the focus change in a idle handler so that the processing
2604 * of the cursor change is completed when the focus handler is called.
2605 * This will allow actions to be called in the focus handler
2607 gailview->idle_cursor_changed_id = gdk_threads_add_idle (idle_cursor_changed, gailview);
2611 idle_cursor_changed (gpointer data)
2613 GailTreeView *gail_tree_view = GAIL_TREE_VIEW (data);
2614 GtkTreeView *tree_view;
2618 gail_tree_view->idle_cursor_changed_id = 0;
2620 widget = GTK_ACCESSIBLE (gail_tree_view)->widget;
2622 * Widget has been deleted
2627 tree_view = GTK_TREE_VIEW (widget);
2629 cell = gail_tree_view_ref_focus_cell (tree_view);
2632 if (cell != gail_tree_view->focus_cell)
2634 if (gail_tree_view->focus_cell)
2636 gail_cell_remove_state (GAIL_CELL (gail_tree_view->focus_cell), ATK_STATE_ACTIVE, FALSE);
2637 gail_cell_remove_state (GAIL_CELL (gail_tree_view->focus_cell), ATK_STATE_FOCUSED, FALSE);
2638 g_object_unref (gail_tree_view->focus_cell);
2640 gail_tree_view->focus_cell = cell;
2642 if (GTK_WIDGET_HAS_FOCUS (widget))
2644 gail_cell_add_state (GAIL_CELL (cell), ATK_STATE_ACTIVE, FALSE);
2645 gail_cell_add_state (GAIL_CELL (cell), ATK_STATE_FOCUSED, FALSE);
2647 g_signal_emit_by_name (gail_tree_view,
2648 "active-descendant-changed",
2652 g_object_unref (cell);
2659 focus_in (GtkWidget *widget)
2661 GtkTreeView *tree_view;
2662 GailTreeView *gail_tree_view;
2663 AtkStateSet *state_set;
2666 tree_view = GTK_TREE_VIEW (widget);
2667 gail_tree_view = GAIL_TREE_VIEW (gtk_widget_get_accessible (widget));
2669 if (gail_tree_view->focus_cell == NULL)
2671 cell = gail_tree_view_ref_focus_cell (tree_view);
2674 state_set = atk_object_ref_state_set (cell);
2677 if (!atk_state_set_contains_state (state_set, ATK_STATE_FOCUSED))
2679 gail_cell_add_state (GAIL_CELL (cell), ATK_STATE_ACTIVE, FALSE);
2680 gail_tree_view->focus_cell = cell;
2681 gail_cell_add_state (GAIL_CELL (cell), ATK_STATE_FOCUSED, FALSE);
2682 g_signal_emit_by_name (gail_tree_view,
2683 "active-descendant-changed",
2686 g_object_unref (state_set);
2693 focus_out (GtkWidget *widget)
2695 GailTreeView *gail_tree_view;
2697 gail_tree_view = GAIL_TREE_VIEW (gtk_widget_get_accessible (widget));
2698 if (gail_tree_view->focus_cell)
2700 gail_cell_remove_state (GAIL_CELL (gail_tree_view->focus_cell), ATK_STATE_ACTIVE, FALSE);
2701 gail_cell_remove_state (GAIL_CELL (gail_tree_view->focus_cell), ATK_STATE_FOCUSED, FALSE);
2702 g_object_unref (gail_tree_view->focus_cell);
2703 gail_tree_view->focus_cell = NULL;
2708 model_row_changed (GtkTreeModel *tree_model,
2713 GtkTreeView *tree_view = GTK_TREE_VIEW(user_data);
2714 GailTreeView *gailview;
2715 GtkTreePath *cell_path;
2717 GailTreeViewCellInfo *cell_info;
2719 gailview = GAIL_TREE_VIEW (gtk_widget_get_accessible (GTK_WIDGET (tree_view)));
2721 /* Loop through our cached cells */
2722 /* Must loop through them all */
2723 for (l = gailview->cell_data; l; l = l->next)
2725 cell_info = (GailTreeViewCellInfo *) l->data;
2726 if (cell_info->in_use)
2728 cell_path = gtk_tree_row_reference_get_path (cell_info->cell_row_ref);
2730 if (cell_path != NULL)
2732 if (path && gtk_tree_path_compare (cell_path, path) == 0)
2734 if (GAIL_IS_RENDERER_CELL (cell_info->cell))
2736 update_cell_value (GAIL_RENDERER_CELL (cell_info->cell),
2740 gtk_tree_path_free (cell_path);
2744 g_signal_emit_by_name (gailview, "visible-data-changed");
2748 column_visibility_changed (GObject *object,
2752 if (strcmp (pspec->name, "visible") == 0)
2755 * A column has been made visible or invisible
2757 * We update our cache of cells and emit model_changed signal
2759 GtkTreeView *tree_view = (GtkTreeView *)user_data;
2760 GailTreeView *gailview;
2762 GailTreeViewCellInfo *cell_info;
2763 GtkTreeViewColumn *this_col = GTK_TREE_VIEW_COLUMN (object);
2764 GtkTreeViewColumn *tv_col;
2766 gailview = GAIL_TREE_VIEW (gtk_widget_get_accessible (GTK_WIDGET (tree_view))
2768 g_signal_emit_by_name (gailview, "model_changed");
2770 for (l = gailview->cell_data; l; l = l->next)
2772 cell_info = (GailTreeViewCellInfo *) l->data;
2773 if (cell_info->in_use)
2775 tv_col = cell_info->cell_col_ref;
2776 if (tv_col == this_col)
2778 GtkTreePath *row_path;
2779 row_path = gtk_tree_row_reference_get_path (cell_info->cell_row_ref);
2780 if (GAIL_IS_RENDERER_CELL (cell_info->cell))
2782 if (gtk_tree_view_column_get_visible (tv_col))
2783 set_cell_visibility (tree_view,
2785 tv_col, row_path, FALSE);
2788 gail_cell_remove_state (cell_info->cell,
2789 ATK_STATE_VISIBLE, TRUE);
2790 gail_cell_remove_state (cell_info->cell,
2791 ATK_STATE_SHOWING, TRUE);
2794 gtk_tree_path_free (row_path);
2802 * This is the signal handler for the "destroy" signal for a GtkTreeViewColumn
2804 * We check whether we have stored column description or column header
2805 * and if so we get rid of it.
2808 column_destroy (GtkObject *obj)
2810 GtkTreeViewColumn *tv_col = GTK_TREE_VIEW_COLUMN (obj);
2814 header = g_object_get_qdata (G_OBJECT (tv_col),
2815 quark_column_header_object);
2817 g_object_unref (header);
2818 desc = g_object_get_qdata (G_OBJECT (tv_col),
2819 quark_column_desc_object);
2824 model_row_inserted (GtkTreeModel *tree_model,
2829 GtkTreeView *tree_view = (GtkTreeView *)user_data;
2830 GtkTreePath *path_copy;
2831 AtkObject *atk_obj = gtk_widget_get_accessible (GTK_WIDGET (tree_view));
2832 GailTreeView *gailview = GAIL_TREE_VIEW (atk_obj);
2833 gint row, n_inserted, child_row;
2835 if (gailview->idle_expand_id)
2837 g_source_remove (gailview->idle_expand_id);
2838 gailview->idle_expand_id = 0;
2840 /* don't do this if the insertion precedes the idle path, since it will now be invalid */
2841 if (path && gailview->idle_expand_path &&
2842 (gtk_tree_path_compare (path, gailview->idle_expand_path) > 0))
2843 set_expand_state (tree_view, tree_model, gailview, gailview->idle_expand_path, FALSE);
2844 if (gailview->idle_expand_path)
2845 gtk_tree_path_free (gailview->idle_expand_path);
2847 /* Check to see if row is visible */
2848 row = get_row_from_tree_path (tree_view, path);
2851 * A row insert is not necessarily visible. For example,
2852 * a row can be draged & dropped into another row, which
2853 * causes an insert on the model that isn't visible in the
2854 * view. Only generate a signal if the inserted row is
2862 gtk_tree_model_get_iter (tree_model, &iter, path);
2864 /* Figure out number of visible children. */
2865 if (gtk_tree_model_iter_has_child (tree_model, &iter))
2868 * By passing path into this function, we find the number of
2869 * visible children of path.
2872 iterate_thru_children (tree_view, tree_model,
2873 path, NULL, &n_inserted, 0);
2875 /* Must add one to include the row that is being added */
2881 /* Set rows below the inserted row to ATK_STATE_STALE */
2882 traverse_cells (gailview, path, TRUE, TRUE);
2884 /* Generate row-inserted signal */
2885 g_signal_emit_by_name (atk_obj, "row_inserted", row, n_inserted);
2887 /* Generate children-changed signals */
2888 n_cols = gail_tree_view_get_n_columns (ATK_TABLE (atk_obj));
2889 for (child_row = row; child_row < (row + n_inserted); child_row++)
2891 for (col = 0; col < n_cols; col++)
2894 * Pass NULL as the child object, i.e. 4th argument
2896 g_signal_emit_by_name (atk_obj, "children_changed::add",
2897 ((row * n_cols) + col), NULL, NULL);
2904 * The row has been inserted inside another row. This can
2905 * cause a row that previously couldn't be expanded to now
2908 path_copy = gtk_tree_path_copy (path);
2909 gtk_tree_path_up (path_copy);
2910 set_expand_state (tree_view, tree_model, gailview, path_copy, TRUE);
2911 gtk_tree_path_free (path_copy);
2916 model_row_deleted (GtkTreeModel *tree_model,
2920 GtkTreeView *tree_view;
2921 GtkTreePath *path_copy;
2923 GailTreeView *gailview;
2926 tree_view = (GtkTreeView *)user_data;
2927 atk_obj = gtk_widget_get_accessible (GTK_WIDGET (tree_view));
2928 gailview = GAIL_TREE_VIEW (atk_obj);
2930 if (gailview->idle_expand_id)
2932 g_source_remove (gailview->idle_expand_id);
2933 gtk_tree_path_free (gailview->idle_expand_path);
2934 gailview->idle_expand_id = 0;
2936 /* Check to see if row is visible */
2937 clean_rows (gailview);
2939 /* Set rows at or below the specified row to ATK_STATE_STALE */
2940 traverse_cells (gailview, path, TRUE, TRUE);
2943 * If deleting a row with a depth > 1, then this may affect the
2944 * expansion/contraction of its parent(s). Make sure this is
2947 if (gtk_tree_path_get_depth (path) > 1)
2949 path_copy = gtk_tree_path_copy (path);
2950 gtk_tree_path_up (path_copy);
2951 set_expand_state (tree_view, tree_model, gailview, path_copy, TRUE);
2952 gtk_tree_path_free (path_copy);
2954 row = get_row_from_tree_path (tree_view, path);
2956 * If the row which is deleted is not visible because it is a child of
2957 * a collapsed row then row will be -1
2960 g_signal_emit_by_name (atk_obj, "row_deleted", row,
2961 gailview->n_children_deleted + 1);
2962 gailview->n_children_deleted = 0;
2966 * This function gets called when a row is deleted or when rows are
2967 * removed from the view due to a collapse event. Note that the
2968 * count is the number of visible *children* of the deleted row,
2969 * so it does not include the row being deleted.
2971 * As this function is called before the rows are removed we just note the
2972 * number of rows and then deal with it when we get a notification that
2973 * rows were deleted or collapsed.
2976 destroy_count_func (GtkTreeView *tree_view,
2981 AtkObject *atk_obj = gtk_widget_get_accessible (GTK_WIDGET (tree_view));
2982 GailTreeView *gailview = GAIL_TREE_VIEW (atk_obj);
2984 gail_return_if_fail (gailview->n_children_deleted == 0);
2985 gailview->n_children_deleted = count;
2989 model_rows_reordered (GtkTreeModel *tree_model,
2995 GtkTreeView *tree_view = (GtkTreeView *)user_data;
2996 AtkObject *atk_obj = gtk_widget_get_accessible (GTK_WIDGET (tree_view));
2997 GailTreeView *gailview = GAIL_TREE_VIEW (atk_obj);
2999 if (gailview->idle_expand_id)
3001 g_source_remove (gailview->idle_expand_id);
3002 gtk_tree_path_free (gailview->idle_expand_path);
3003 gailview->idle_expand_id = 0;
3005 traverse_cells (gailview, NULL, TRUE, FALSE);
3007 g_signal_emit_by_name (atk_obj, "row_reordered");
3011 adjustment_changed (GtkAdjustment *adjustment,
3012 GtkTreeView *tree_view)
3018 * The scrollbars have changed
3020 atk_obj = gtk_widget_get_accessible (GTK_WIDGET (tree_view));
3021 obj = GAIL_TREE_VIEW (atk_obj);
3023 traverse_cells (obj, NULL, FALSE, FALSE);
3027 set_cell_visibility (GtkTreeView *tree_view,
3029 GtkTreeViewColumn *tv_col,
3030 GtkTreePath *tree_path,
3031 gboolean emit_signal)
3033 GdkRectangle cell_rect;
3035 /* Get these three values in tree coords */
3036 if (GTK_WIDGET_REALIZED (GTK_WIDGET (tree_view)))
3037 gtk_tree_view_get_cell_area (tree_view, tree_path, tv_col, &cell_rect);
3039 cell_rect.height = 0;
3041 if (cell_rect.height > 0)
3044 * The height will be zero for a cell for which an antecedent is not
3047 gail_cell_add_state (cell, ATK_STATE_VISIBLE, emit_signal);
3048 if (is_cell_showing (tree_view, &cell_rect))
3049 gail_cell_add_state (cell, ATK_STATE_SHOWING, emit_signal);
3051 gail_cell_remove_state (cell, ATK_STATE_SHOWING, emit_signal);
3055 gail_cell_remove_state (cell, ATK_STATE_VISIBLE, emit_signal);
3056 gail_cell_remove_state (cell, ATK_STATE_SHOWING, emit_signal);
3061 is_cell_showing (GtkTreeView *tree_view,
3062 GdkRectangle *cell_rect)
3064 GdkRectangle rect, *visible_rect;
3065 GdkRectangle rect1, *tree_cell_rect;
3066 gboolean is_showing;
3068 * A cell is considered "SHOWING" if any part of the cell is in the visible
3069 * area. Other ways we could do this is by a cell's midpoint or if the cell
3070 * is fully in the visible range. Since we have the cell_rect x,y,width,height
3071 * of the cell, any of these is easy to compute.
3073 * It is assumed that cell's rectangle is in widget coordinates so we
3074 * must transform to tree cordinates.
3076 visible_rect = ▭
3077 tree_cell_rect = &rect1;
3078 tree_cell_rect->x = cell_rect->x;
3079 tree_cell_rect->width = cell_rect->width;
3080 tree_cell_rect->height = cell_rect->height;
3082 gtk_tree_view_get_visible_rect (tree_view, visible_rect);
3083 gtk_tree_view_widget_to_tree_coords (tree_view, cell_rect->x, cell_rect->y,
3086 if (((tree_cell_rect->x + tree_cell_rect->width) < visible_rect->x) ||
3087 ((tree_cell_rect->y + tree_cell_rect->height) < (visible_rect->y)) ||
3088 (tree_cell_rect->x > (visible_rect->x + visible_rect->width)) ||
3089 (tree_cell_rect->y > (visible_rect->y + visible_rect->height)))
3100 * This function is called when a cell's flyweight is created in
3101 * gail_tree_view_table_ref_at with emit_change_signal set to FALSE
3102 * and in model_row_changed() on receipt of "row-changed" signal when
3103 * emit_change_signal is set to TRUE
3106 update_cell_value (GailRendererCell *renderer_cell,
3107 GailTreeView *gailview,
3108 gboolean emit_change_signal)
3110 GailTreeViewCellInfo *cell_info;
3111 GtkTreeView *tree_view;
3112 GtkTreeModel *tree_model;
3115 GList *renderers, *cur_renderer;
3117 GailRendererCellClass *gail_renderer_cell_class;
3118 GtkCellRendererClass *gtk_cell_renderer_class;
3122 gboolean is_expander, is_expanded;
3124 gail_renderer_cell_class = GAIL_RENDERER_CELL_GET_CLASS (renderer_cell);
3125 if (renderer_cell->renderer)
3126 gtk_cell_renderer_class = GTK_CELL_RENDERER_GET_CLASS (renderer_cell->renderer);
3128 gtk_cell_renderer_class = NULL;
3130 prop_list = gail_renderer_cell_class->property_list;
3132 cell = GAIL_CELL (renderer_cell);
3133 cell_info = find_cell_info (gailview, cell, NULL, TRUE);
3134 gail_return_val_if_fail (cell_info, FALSE);
3135 gail_return_val_if_fail (cell_info->cell_col_ref, FALSE);
3136 gail_return_val_if_fail (cell_info->cell_row_ref, FALSE);
3138 if (emit_change_signal && cell_info->in_use)
3140 tree_view = GTK_TREE_VIEW (GTK_ACCESSIBLE (gailview)->widget);
3141 tree_model = gtk_tree_view_get_model (tree_view);
3142 path = gtk_tree_row_reference_get_path (cell_info->cell_row_ref);
3146 gtk_tree_model_get_iter (tree_model, &iter, path);
3147 is_expander = FALSE;
3148 is_expanded = FALSE;
3149 if (gtk_tree_model_iter_has_child (tree_model, &iter))
3151 GtkTreeViewColumn *expander_tv;
3153 expander_tv = gtk_tree_view_get_expander_column (tree_view);
3154 if (expander_tv == cell_info->cell_col_ref)
3157 is_expanded = gtk_tree_view_row_expanded (tree_view, path);
3160 gtk_tree_path_free (path);
3161 gtk_tree_view_column_cell_set_cell_data (cell_info->cell_col_ref,
3162 tree_model, &iter, is_expander, is_expanded);
3164 renderers = gtk_tree_view_column_get_cell_renderers (cell_info->cell_col_ref);
3165 gail_return_val_if_fail (renderers, FALSE);
3168 * If the cell is in a container, it's index is used to find the renderer
3173 * Otherwise, we assume that the cell is represented by the first renderer
3177 if (cell_info->in_use) {
3178 parent = atk_object_get_parent (ATK_OBJECT (cell));
3179 if (!ATK_IS_OBJECT (cell)) g_on_error_query (NULL);
3180 if (GAIL_IS_CONTAINER_CELL (parent))
3181 cur_renderer = g_list_nth (renderers, cell->index);
3183 cur_renderer = renderers;
3189 gail_return_val_if_fail (cur_renderer != NULL, FALSE);
3191 if (gtk_cell_renderer_class)
3195 spec = g_object_class_find_property
3196 (G_OBJECT_CLASS (gtk_cell_renderer_class), *prop_list);
3200 GValue value = { 0, };
3202 g_value_init (&value, spec->value_type);
3203 g_object_get_property (cur_renderer->data, *prop_list, &value);
3204 g_object_set_property (G_OBJECT (renderer_cell->renderer),
3205 *prop_list, &value);
3206 g_value_unset(&value);
3209 g_warning ("Invalid property: %s\n", *prop_list);
3213 g_list_free (renderers);
3214 return gail_renderer_cell_update_cache (renderer_cell, emit_change_signal);
3218 set_iter_nth_row (GtkTreeView *tree_view,
3222 GtkTreeModel *tree_model;
3224 tree_model = gtk_tree_view_get_model (tree_view);
3225 gtk_tree_model_get_iter_root (tree_model, iter);
3226 iter = return_iter_nth_row (tree_view, tree_model, iter, 0 , row);
3230 get_row_from_tree_path (GtkTreeView *tree_view,
3233 GtkTreeModel *tree_model;
3234 GtkTreePath *root_tree;
3237 tree_model = gtk_tree_view_get_model (tree_view);
3239 if (gtk_tree_model_get_flags (tree_model) & GTK_TREE_MODEL_LIST_ONLY)
3240 row = gtk_tree_path_get_indices (path)[0];
3243 root_tree = gtk_tree_path_new_root ();
3245 iterate_thru_children (tree_view, tree_model, root_tree, path, &row, 0);
3246 gtk_tree_path_free (root_tree);
3255 * Get the specified GtkTreeViewColumn in the GtkTreeView.
3256 * Only visible columns are considered.
3258 static GtkTreeViewColumn*
3259 get_column (GtkTreeView *tree_view,
3262 GtkTreeViewColumn *tv_col;
3268 g_warning ("Request for invalid column %d\n", in_col);
3272 tv_col = gtk_tree_view_get_column (tree_view, i);
3274 while (tv_col != NULL)
3276 if (gtk_tree_view_column_get_visible (tv_col))
3278 if (in_col == n_cols)
3280 tv_col = gtk_tree_view_get_column (tree_view, ++i);
3283 if (in_col != n_cols)
3285 g_warning ("Request for invalid column %d\n", in_col);
3292 get_actual_column_number (GtkTreeView *tree_view,
3293 gint visible_column)
3295 GtkTreeViewColumn *tv_col;
3296 gint actual_column = 0;
3297 gint visible_columns = -1;
3299 * This function calculates the column number which corresponds to the
3300 * specified visible column number
3302 tv_col = gtk_tree_view_get_column (tree_view, actual_column);
3304 while (tv_col != NULL)
3306 if (gtk_tree_view_column_get_visible (tv_col))
3308 if (visible_columns == visible_column)
3309 return actual_column;
3310 tv_col = gtk_tree_view_get_column (tree_view, ++actual_column);
3312 g_warning ("get_actual_column_number failed for %d\n", visible_column);
3317 get_visible_column_number (GtkTreeView *tree_view,
3320 GtkTreeViewColumn *tv_col;
3322 gint visible_columns = -1;
3324 * This function calculates the visible column number which corresponds to the
3325 * specified actual column number
3327 tv_col = gtk_tree_view_get_column (tree_view, column);
3329 while (tv_col != NULL)
3331 if (gtk_tree_view_column_get_visible (tv_col))
3334 if (actual_column == column)
3335 return visible_columns;
3338 if (actual_column == column)
3340 tv_col = gtk_tree_view_get_column (tree_view, ++column);
3342 g_warning ("get_visible_column_number failed for %d\n", actual_column);
3347 * Helper recursive function that returns GtkTreeIter pointer to nth row.
3350 return_iter_nth_row(GtkTreeView *tree_view,
3351 GtkTreeModel *tree_model,
3356 GtkTreePath *current_path = gtk_tree_model_get_path (tree_model, iter);
3357 GtkTreeIter new_iter;
3358 gboolean row_expanded;
3360 if (increment == row) {
3361 gtk_tree_path_free (current_path);
3365 row_expanded = gtk_tree_view_row_expanded (tree_view, current_path);
3366 gtk_tree_path_free (current_path);
3369 if ((row_expanded && gtk_tree_model_iter_children (tree_model, iter, &new_iter)) ||
3370 (gtk_tree_model_iter_next (tree_model, iter)) ||
3371 (gtk_tree_model_iter_parent (tree_model, iter, &new_iter) &&
3372 (gtk_tree_model_iter_next (tree_model, iter))))
3373 return return_iter_nth_row (tree_view, tree_model, iter,
3380 * Recursively called until the row specified by orig is found.
3382 * *count will be set to the visible row number of the child
3383 * relative to the row that was initially passed in as tree_path.
3385 * *count will be -1 if orig is not found as a child (a row that is
3386 * not visible will not be found, e.g. if the row is inside a
3387 * collapsed row). If NULL is passed in as orig, *count will
3388 * be a count of the visible children.
3390 * NOTE: the value for depth must be 0 when this recursive function
3391 * is initially called, or it may not function as expected.
3394 iterate_thru_children(GtkTreeView *tree_view,
3395 GtkTreeModel *tree_model,
3396 GtkTreePath *tree_path,
3403 if (!gtk_tree_model_get_iter (tree_model, &iter, tree_path))
3406 if (tree_path && orig && !gtk_tree_path_compare (tree_path, orig))
3410 if (tree_path && orig && gtk_tree_path_compare (tree_path, orig) > 0)
3412 /* Past it, so return -1 */
3416 else if (gtk_tree_view_row_expanded (tree_view, tree_path) &&
3417 gtk_tree_model_iter_has_child (tree_model, &iter))
3420 gtk_tree_path_append_index (tree_path, 0);
3421 iterate_thru_children (tree_view, tree_model, tree_path,
3422 orig, count, (depth + 1));
3425 else if (gtk_tree_model_iter_next (tree_model, &iter))
3428 tree_path = gtk_tree_model_get_path (tree_model, &iter);
3431 iterate_thru_children (tree_view, tree_model, tree_path,
3432 orig, count, depth);
3433 gtk_tree_path_free (tree_path);
3437 else if (gtk_tree_path_up (tree_path))
3439 GtkTreeIter temp_iter;
3440 gboolean exit_loop = FALSE;
3441 gint new_depth = depth - 1;
3446 * Make sure that we back up until we find a row
3447 * where gtk_tree_path_next does not return NULL.
3451 if (gtk_tree_path_get_depth (tree_path) == 0)
3452 /* depth is now zero so */
3454 gtk_tree_path_next (tree_path);
3456 /* Verify that the next row is a valid row! */
3457 exit_loop = gtk_tree_model_get_iter (tree_model, &temp_iter, tree_path);
3461 /* Keep going up until we find a row that has a valid next */
3462 if (gtk_tree_path_get_depth(tree_path) > 1)
3465 gtk_tree_path_up (tree_path);
3470 * If depth is 1 and gtk_tree_model_get_iter returns FALSE,
3471 * then we are at the last row, so just return.
3482 * This guarantees that we will stop when we hit the end of the
3488 iterate_thru_children (tree_view, tree_model, tree_path,
3489 orig, count, new_depth);
3494 * If it gets here, then the path wasn't found. Situations
3495 * that would cause this would be if the path passed in is
3496 * invalid or contained within the last row, but not visible
3497 * because the last row is not expanded. If NULL was passed
3498 * in then a row count is desired, so only set count to -1
3499 * if orig is not NULL.
3508 clean_cell_info (GailTreeView *gailview,
3511 GailTreeViewCellInfo *cell_info;
3514 g_assert (GAIL_IS_TREE_VIEW (gailview));
3516 cell_info = list->data;
3518 if (cell_info->in_use) {
3519 obj = G_OBJECT (cell_info->cell);
3521 gail_cell_add_state (cell_info->cell, ATK_STATE_DEFUNCT, TRUE);
3522 g_object_weak_unref (obj, (GWeakNotify) cell_destroyed, cell_info);
3523 cell_info->in_use = FALSE;
3524 if (!gailview->garbage_collection_pending) {
3525 gailview->garbage_collection_pending = TRUE;
3526 g_assert (gailview->idle_garbage_collect_id == 0);
3527 gailview->idle_garbage_collect_id =
3528 gdk_threads_add_idle (idle_garbage_collect_cell_data, gailview);
3534 clean_rows (GailTreeView *gailview)
3538 /* Clean GailTreeViewRowInfo data */
3540 array = gailview->row_data;
3543 GailTreeViewRowInfo *row_info;
3544 GtkTreePath *row_path;
3548 * Loop backwards so that calls to free_row_info
3549 * do not affect the index numbers
3551 for (i = (array->len - 1); i >= 0; i --)
3553 row_info = g_array_index (array, GailTreeViewRowInfo*, i);
3554 row_path = gtk_tree_row_reference_get_path (row_info->row_ref);
3556 /* Remove any rows that have become invalid */
3557 if (row_path == NULL)
3558 free_row_info (array, i, TRUE);
3560 gtk_tree_path_free (row_path);
3564 /* Clean GailTreeViewCellInfo data */
3566 if (gailview->cell_data != NULL)
3568 GailTreeViewCellInfo *cell_info;
3569 GtkTreePath *row_path;
3573 temp_list = gailview->cell_data;
3575 /* Must loop through them all */
3576 while (temp_list != NULL)
3578 cur_list = temp_list;
3579 cell_info = temp_list->data;
3580 temp_list = temp_list->next;
3581 row_path = gtk_tree_row_reference_get_path (cell_info->cell_row_ref);
3584 * If the cell has become invalid because the row has been removed,
3585 * then set the cell's state to ATK_STATE_DEFUNCT and remove the cell
3586 * from gailview->cell_data. If row_path is NULL then the row has
3589 if (row_path == NULL)
3591 clean_cell_info (gailview, cur_list);
3595 gtk_tree_path_free (row_path);
3602 clean_cols (GailTreeView *gailview,
3603 GtkTreeViewColumn *tv_col)
3605 /* Clean GailTreeViewCellInfo data */
3607 if (gailview->cell_data != NULL)
3609 GailTreeViewCellInfo *cell_info;
3610 GList *cur_list, *temp_list;
3612 temp_list = gailview->cell_data;
3614 while (temp_list != NULL)
3616 cur_list = temp_list;
3617 cell_info = temp_list->data;
3618 temp_list = temp_list->next;
3621 * If the cell has become invalid because the column tv_col
3622 * has been removed, then set the cell's state to ATK_STATE_DEFUNCT
3623 * and remove the cell from gailview->cell_data.
3625 if (cell_info->cell_col_ref == tv_col)
3627 clean_cell_info (gailview, cur_list);
3634 idle_garbage_collect_cell_data (gpointer data)
3636 GailTreeView *tree_view;
3638 g_assert (GAIL_IS_TREE_VIEW (data));
3639 tree_view = (GailTreeView *)data;
3641 /* this is the idle handler (only one instance allowed), so
3642 * we can safely delete it.
3644 tree_view->garbage_collection_pending = FALSE;
3645 tree_view->idle_garbage_collect_id = 0;
3647 tree_view->garbage_collection_pending = garbage_collect_cell_data (data);
3649 /* N.B.: if for some reason another handler has re-enterantly been queued
3650 * while this handler was being serviced, it has its own gsource, therefore this handler
3651 * should always return FALSE.
3657 garbage_collect_cell_data (gpointer data)
3659 GailTreeView *tree_view;
3661 GailTreeViewCellInfo *cell_info;
3663 g_assert (GAIL_IS_TREE_VIEW (data));
3664 tree_view = (GailTreeView *)data;
3665 temp_list = g_list_copy (tree_view->cell_data);
3667 tree_view->garbage_collection_pending = FALSE;
3668 if (tree_view->idle_garbage_collect_id != 0)
3670 g_source_remove (tree_view->idle_garbage_collect_id);
3671 tree_view->idle_garbage_collect_id = 0;
3674 /* Must loop through them all */
3675 while (temp_list != NULL)
3677 cell_info = temp_list->data;
3678 if (!cell_info->in_use)
3680 /* g_object_unref (cell_info->cell); */
3681 tree_view->cell_data = g_list_remove (tree_view->cell_data,
3683 if (cell_info->cell_row_ref)
3684 gtk_tree_row_reference_free (cell_info->cell_row_ref);
3687 temp_list = temp_list->next;
3689 g_list_free (temp_list);
3691 return tree_view->garbage_collection_pending;
3695 * If tree_path is passed in as NULL, then all cells are acted on.
3696 * Otherwise, just act on those cells that are on a row greater than
3697 * the specified tree_path. If inc_row is passed in as TRUE, then rows
3698 * greater and equal to the specified tree_path are acted on.
3700 * if set_stale is set the ATK_STATE_STALE is set on cells which are to be
3703 * The function set_cell_visibility() is called on all cells to be
3704 * acted on to update the visibility of the cell.
3707 traverse_cells (GailTreeView *tree_view,
3708 GtkTreePath *tree_path,
3712 if (tree_view->cell_data != NULL)
3714 GailTreeViewCellInfo *cell_info;
3715 GtkTreeView *gtk_tree_view;
3719 g_assert (GTK_IS_ACCESSIBLE (tree_view));
3721 widget = GTK_ACCESSIBLE (tree_view)->widget;
3723 /* Widget is being deleted */
3726 gtk_tree_view = GTK_TREE_VIEW (widget);
3727 temp_list = tree_view->cell_data;
3729 /* Must loop through them all */
3730 while (temp_list != NULL)
3732 GtkTreePath *row_path;
3733 gboolean act_on_cell;
3735 cell_info = temp_list->data;
3736 temp_list = temp_list->next;
3738 if (cell_info->in_use)
3740 row_path = gtk_tree_row_reference_get_path (cell_info->cell_row_ref);
3741 g_assert (row_path != NULL);
3742 if (tree_path == NULL)
3748 comparison = gtk_tree_path_compare (row_path, tree_path);
3749 if ((comparison > 0) ||
3750 (comparison == 0 && inc_row))
3753 act_on_cell = FALSE;
3755 if (!cell_info->in_use) g_warning ("warning: cell info destroyed during traversal");
3756 if (act_on_cell && cell_info->in_use)
3759 gail_cell_add_state (cell_info->cell, ATK_STATE_STALE, TRUE);
3760 set_cell_visibility (gtk_tree_view,
3762 cell_info->cell_col_ref,
3765 gtk_tree_path_free (row_path);
3769 g_signal_emit_by_name (tree_view, "visible-data-changed");
3773 free_row_info (GArray *array,
3777 GailTreeViewRowInfo* obj;
3779 obj = g_array_index (array, GailTreeViewRowInfo*, array_idx);
3781 g_free (obj->description);
3782 if (obj->row_ref != NULL)
3783 gtk_tree_row_reference_free (obj->row_ref);
3785 g_object_unref (obj->header);
3789 g_array_remove_index (array, array_idx);
3793 * If the tree_path passed in has children, then
3794 * ATK_STATE_EXPANDABLE is set. If the row is expanded
3795 * ATK_STATE_EXPANDED is turned on. If the row is
3796 * collapsed, then ATK_STATE_EXPANDED is removed.
3798 * If the tree_path passed in has no children, then
3799 * ATK_STATE_EXPANDABLE and ATK_STATE_EXPANDED are removed.
3801 * If set_on_ancestor is TRUE, then this function will also
3802 * update all cells that are ancestors of the tree_path.
3805 set_expand_state (GtkTreeView *tree_view,
3806 GtkTreeModel *tree_model,
3807 GailTreeView *gailview,
3808 GtkTreePath *tree_path,
3809 gboolean set_on_ancestor)
3811 if (gailview->cell_data != NULL)
3813 GtkTreeViewColumn *expander_tv;
3814 GailTreeViewCellInfo *cell_info;
3816 GtkTreePath *cell_path;
3820 temp_list = gailview->cell_data;
3822 while (temp_list != NULL)
3824 cell_info = temp_list->data;
3825 temp_list = temp_list->next;
3826 if (cell_info->in_use)
3828 cell_path = gtk_tree_row_reference_get_path (cell_info->cell_row_ref);
3831 if (cell_path != NULL)
3833 GailCell *cell = GAIL_CELL (cell_info->cell);
3835 expander_tv = gtk_tree_view_get_expander_column (tree_view);
3838 * Only set state for the cell that is in the column with the
3841 if (expander_tv == cell_info->cell_col_ref)
3843 if (tree_path && gtk_tree_path_compare (cell_path, tree_path) == 0)
3845 else if (set_on_ancestor &&
3846 gtk_tree_path_get_depth (cell_path) <
3847 gtk_tree_path_get_depth (tree_path) &&
3848 gtk_tree_path_is_ancestor (cell_path, tree_path) == 1)
3849 /* Only set if set_on_ancestor was passed in as TRUE */
3854 * Set ATK_STATE_EXPANDABLE and ATK_STATE_EXPANDED
3855 * for ancestors and found cells.
3860 * Must check against cell_path since cell_path
3861 * can be equal to or an ancestor of tree_path.
3863 gtk_tree_model_get_iter (tree_model, &iter, cell_path);
3865 /* Set or unset ATK_STATE_EXPANDABLE as appropriate */
3866 if (gtk_tree_model_iter_has_child (tree_model, &iter))
3868 set_cell_expandable (cell);
3870 if (gtk_tree_view_row_expanded (tree_view, cell_path))
3871 gail_cell_add_state (cell, ATK_STATE_EXPANDED, TRUE);
3873 gail_cell_remove_state (cell,
3874 ATK_STATE_EXPANDED, TRUE);
3878 gail_cell_remove_state (cell,
3879 ATK_STATE_EXPANDED, TRUE);
3880 if (gail_cell_remove_state (cell,
3881 ATK_STATE_EXPANDABLE, TRUE))
3882 /* The state may have been propagated to the container cell */
3883 if (!GAIL_IS_CONTAINER_CELL (cell))
3884 gail_cell_remove_action_by_name (cell,
3885 "expand or contract");
3889 * We assume that each cell in the cache once and
3890 * a container cell is before its child cells so we are
3891 * finished if set_on_ancestor is not set to TRUE.
3893 if (!set_on_ancestor)
3897 gtk_tree_path_free (cell_path);
3905 add_cell_actions (GailCell *cell,
3908 if (GAIL_IS_BOOLEAN_CELL (cell))
3909 gail_cell_add_action (cell,
3911 "toggles the cell", /* action description */
3913 toggle_cell_toggled);
3915 gail_cell_add_action (cell,
3917 "creates a widget in which the contents of the cell can be edited",
3920 gail_cell_add_action (cell,
3922 "activate the cell",
3928 toggle_cell_expanded (GailCell *cell)
3930 GailTreeViewCellInfo *cell_info;
3931 GtkTreeView *tree_view;
3934 AtkStateSet *stateset;
3936 parent = atk_object_get_parent (ATK_OBJECT (cell));
3937 if (GAIL_IS_CONTAINER_CELL (parent))
3938 parent = atk_object_get_parent (parent);
3940 cell_info = find_cell_info (GAIL_TREE_VIEW (parent), cell, NULL, TRUE);
3941 gail_return_if_fail (cell_info);
3942 gail_return_if_fail (cell_info->cell_col_ref);
3943 gail_return_if_fail (cell_info->cell_row_ref);
3945 tree_view = GTK_TREE_VIEW (GTK_ACCESSIBLE (parent)->widget);
3946 path = gtk_tree_row_reference_get_path (cell_info->cell_row_ref);
3947 gail_return_if_fail (path);
3949 stateset = atk_object_ref_state_set (ATK_OBJECT (cell));
3950 if (atk_state_set_contains_state (stateset, ATK_STATE_EXPANDED))
3951 gtk_tree_view_collapse_row (tree_view, path);
3953 gtk_tree_view_expand_row (tree_view, path, TRUE);
3954 g_object_unref (stateset);
3955 gtk_tree_path_free (path);
3960 toggle_cell_toggled (GailCell *cell)
3962 GailTreeViewCellInfo *cell_info;
3963 GtkTreeView *tree_view;
3966 GList *renderers, *cur_renderer;
3968 gboolean is_container_cell = FALSE;
3970 parent = atk_object_get_parent (ATK_OBJECT (cell));
3971 if (GAIL_IS_CONTAINER_CELL (parent))
3973 is_container_cell = TRUE;
3974 parent = atk_object_get_parent (parent);
3977 cell_info = find_cell_info (GAIL_TREE_VIEW (parent), cell, NULL, TRUE);
3978 gail_return_if_fail (cell_info);
3979 gail_return_if_fail (cell_info->cell_col_ref);
3980 gail_return_if_fail (cell_info->cell_row_ref);
3982 tree_view = GTK_TREE_VIEW (GTK_ACCESSIBLE (parent)->widget);
3983 path = gtk_tree_row_reference_get_path (cell_info->cell_row_ref);
3984 gail_return_if_fail (path);
3985 pathstring = gtk_tree_path_to_string (path);
3987 renderers = gtk_tree_view_column_get_cell_renderers (cell_info->cell_col_ref);
3988 gail_return_if_fail (renderers);
3991 * if the cell is in a container, it's index is used to find the
3992 * renderer in the list
3995 if (is_container_cell)
3996 cur_renderer = g_list_nth (renderers, cell->index);
3999 * Otherwise, we assume that the cell is represented by the first
4000 * renderer in the list
4002 cur_renderer = renderers;
4004 gail_return_if_fail (cur_renderer);
4006 g_signal_emit_by_name (cur_renderer->data, "toggled", pathstring);
4007 g_list_free (renderers);
4008 g_free (pathstring);
4009 gtk_tree_path_free (path);
4014 edit_cell (GailCell *cell)
4016 GailTreeViewCellInfo *cell_info;
4017 GtkTreeView *tree_view;
4020 gboolean is_container_cell = FALSE;
4023 parent = atk_object_get_parent (ATK_OBJECT (cell));
4024 if (GAIL_IS_CONTAINER_CELL (parent))
4026 is_container_cell = TRUE;
4027 parent = atk_object_get_parent (parent);
4030 cell_info = find_cell_info (GAIL_TREE_VIEW (parent), cell, NULL, TRUE);
4031 gail_return_if_fail (cell_info);
4032 gail_return_if_fail (cell_info->cell_col_ref);
4033 gail_return_if_fail (cell_info->cell_row_ref);
4035 tree_view = GTK_TREE_VIEW (GTK_ACCESSIBLE (parent)->widget);
4036 path = gtk_tree_row_reference_get_path (cell_info->cell_row_ref);
4037 gail_return_if_fail (path);
4038 gtk_tree_view_set_cursor (tree_view, path, cell_info->cell_col_ref, TRUE);
4039 gtk_tree_path_free (path);
4044 activate_cell (GailCell *cell)
4046 GailTreeViewCellInfo *cell_info;
4047 GtkTreeView *tree_view;
4050 gboolean is_container_cell = FALSE;
4053 parent = atk_object_get_parent (ATK_OBJECT (cell));
4054 if (GAIL_IS_CONTAINER_CELL (parent))
4056 is_container_cell = TRUE;
4057 parent = atk_object_get_parent (parent);
4060 cell_info = find_cell_info (GAIL_TREE_VIEW (parent), cell, NULL, TRUE);
4061 gail_return_if_fail (cell_info);
4062 gail_return_if_fail (cell_info->cell_col_ref);
4063 gail_return_if_fail (cell_info->cell_row_ref);
4065 tree_view = GTK_TREE_VIEW (GTK_ACCESSIBLE (parent)->widget);
4066 path = gtk_tree_row_reference_get_path (cell_info->cell_row_ref);
4067 gail_return_if_fail (path);
4068 gtk_tree_view_row_activated (tree_view, path, cell_info->cell_col_ref);
4069 gtk_tree_path_free (path);
4074 cell_destroyed (gpointer data)
4076 GailTreeViewCellInfo *cell_info = data;
4078 gail_return_if_fail (cell_info);
4079 if (cell_info->in_use) {
4080 cell_info->in_use = FALSE;
4082 g_assert (GAIL_IS_TREE_VIEW (cell_info->view));
4083 if (!cell_info->view->garbage_collection_pending) {
4084 cell_info->view->garbage_collection_pending = TRUE;
4085 cell_info->view->idle_garbage_collect_id =
4086 gdk_threads_add_idle (idle_garbage_collect_cell_data, cell_info->view);
4093 cell_info_remove (GailTreeView *tree_view,
4096 GailTreeViewCellInfo *info;
4099 info = find_cell_info (tree_view, cell, &temp_list, FALSE);
4102 info->in_use = FALSE;
4105 g_warning ("No cell removed in cell_info_remove\n");
4110 cell_info_get_index (GtkTreeView *tree_view,
4111 GailTreeViewCellInfo *info,
4117 path = gtk_tree_row_reference_get_path (info->cell_row_ref);
4118 gail_return_if_fail (path);
4120 column_number = get_column_number (tree_view, info->cell_col_ref, FALSE);
4121 *index = get_index (tree_view, path, column_number);
4122 gtk_tree_path_free (path);
4126 cell_info_new (GailTreeView *gailview,
4127 GtkTreeModel *tree_model,
4129 GtkTreeViewColumn *tv_col,
4132 GailTreeViewCellInfo *cell_info;
4134 g_assert (GAIL_IS_TREE_VIEW (gailview));
4136 cell_info = g_new (GailTreeViewCellInfo, 1);
4137 cell_info->cell_row_ref = gtk_tree_row_reference_new (tree_model, path);
4139 cell_info->cell_col_ref = tv_col;
4140 cell_info->cell = cell;
4141 cell_info->in_use = TRUE; /* if we've created it, assume it's in use */
4142 cell_info->view = gailview;
4143 gailview->cell_data = g_list_append (gailview->cell_data, cell_info);
4145 /* Setup weak reference notification */
4147 g_object_weak_ref (G_OBJECT (cell),
4148 (GWeakNotify) cell_destroyed,
4153 find_cell (GailTreeView *gailview,
4156 GailTreeViewCellInfo *info;
4157 GtkTreeView *tree_view;
4161 gboolean needs_cleaning = FALSE;
4162 GailCell *retval = NULL;
4164 tree_view = GTK_TREE_VIEW (GTK_ACCESSIBLE (gailview)->widget);
4165 cell_list = gailview->cell_data;
4167 for (l = cell_list; l; l = l->next)
4169 info = (GailTreeViewCellInfo *) (l->data);
4172 cell_info_get_index (tree_view, info, &real_index);
4173 if (index == real_index)
4175 retval = info->cell;
4181 needs_cleaning = TRUE;
4185 garbage_collect_cell_data (gailview);
4191 refresh_cell_index (GailCell *cell)
4193 GailTreeViewCellInfo *info;
4195 GtkTreeView *tree_view;
4198 parent = atk_object_get_parent (ATK_OBJECT (cell));
4199 gail_return_if_fail (GAIL_IS_TREE_VIEW (parent));
4201 tree_view = GTK_TREE_VIEW (GTK_ACCESSIBLE (parent)->widget);
4203 /* Find this cell in the GailTreeView's cache */
4205 info = find_cell_info (GAIL_TREE_VIEW (parent), cell, NULL, TRUE);
4206 gail_return_if_fail (info);
4208 cell_info_get_index (tree_view, info, &index);
4209 cell->index = index;
4213 get_selected_rows (GtkTreeModel *model,
4218 GPtrArray *array = (GPtrArray *)data;
4220 g_ptr_array_add (array, gtk_tree_path_copy (path));
4224 connect_model_signals (GtkTreeView *view,
4225 GailTreeView *gailview)
4229 obj = G_OBJECT (gailview->tree_model);
4230 g_signal_connect_data (obj, "row-changed",
4231 (GCallback) model_row_changed, view, NULL, 0);
4232 g_signal_connect_data (obj, "row-inserted",
4233 (GCallback) model_row_inserted, view, NULL,
4235 g_signal_connect_data (obj, "row-deleted",
4236 (GCallback) model_row_deleted, view, NULL,
4238 g_signal_connect_data (obj, "rows-reordered",
4239 (GCallback) model_rows_reordered, view, NULL,
4244 disconnect_model_signals (GailTreeView *view)
4249 obj = G_OBJECT (view->tree_model);
4250 widget = GTK_ACCESSIBLE (view)->widget;
4251 g_signal_handlers_disconnect_by_func (obj, (gpointer) model_row_changed, widget);
4252 g_signal_handlers_disconnect_by_func (obj, (gpointer) model_row_inserted, widget);
4253 g_signal_handlers_disconnect_by_func (obj, (gpointer) model_row_deleted, widget);
4254 g_signal_handlers_disconnect_by_func (obj, (gpointer) model_rows_reordered, widget);
4258 clear_cached_data (GailTreeView *view)
4264 GArray *array = view->row_data;
4268 * Since the third argument to free_row_info is FALSE, we don't remove
4269 * the element. Therefore it is safe to loop forward.
4271 for (i = 0; i < array->len; i++)
4272 free_row_info (array, i, FALSE);
4274 g_array_free (array, TRUE);
4276 view->row_data = NULL;
4279 if (view->cell_data)
4281 /* Must loop through them all */
4282 for (temp_list = view->cell_data; temp_list; temp_list = temp_list->next)
4284 clean_cell_info (view, temp_list);
4287 garbage_collect_cell_data (view);
4288 if (view->cell_data)
4289 g_list_free (view->cell_data);
4291 view->cell_data = NULL;
4295 * Returns the column number of the specified GtkTreeViewColumn
4297 * If visible is set, the value returned will be the visible column number,
4298 * i.e. suitable for use in AtkTable function. If visible is not set, the
4299 * value returned is the actual column number, which is suitable for use in
4300 * getting an index value.
4303 get_column_number (GtkTreeView *tree_view,
4304 GtkTreeViewColumn *column,
4307 GList *temp_list, *column_list;
4308 GtkTreeViewColumn *tv_column;
4311 column_list = gtk_tree_view_get_columns (tree_view);
4313 for (temp_list = column_list; temp_list; temp_list = temp_list->next)
4315 tv_column = GTK_TREE_VIEW_COLUMN (temp_list->data);
4316 if (tv_column == column)
4318 if (!visible || gtk_tree_view_column_get_visible (tv_column))
4321 if (temp_list == NULL)
4325 g_list_free (column_list);
4330 get_index (GtkTreeView *tree_view,
4336 gint *indices = NULL;
4341 depth = gtk_tree_path_get_depth (path);
4342 indices = gtk_tree_path_get_indices (path);
4347 GtkTreePath *copy_path;
4348 GtkTreeModel *model;
4350 model = gtk_tree_view_get_model (tree_view);
4351 copy_path = gtk_tree_path_copy (path);
4352 gtk_tree_path_up (copy_path);
4353 count_rows (model, NULL, copy_path, &index, 0, depth);
4354 gtk_tree_path_free (copy_path);
4358 index += indices[depth-1];
4359 index *= get_n_actual_columns (tree_view);
4360 index += actual_column;
4365 * The function count_rows counts the number of rows starting at iter and ending
4366 * at end_path. The value of level is the depth of iter and the value of depth
4367 * is the depth of end_path. Rows at depth before end_path are counted.
4368 * This functions counts rows which are not visible because an ancestor is
4372 count_rows (GtkTreeModel *model,
4374 GtkTreePath *end_path,
4379 GtkTreeIter child_iter;
4385 *count += gtk_tree_model_iter_n_children (model, iter);
4388 g_print ("count_rows : %d level: %d depth: %d\n", *count, level, depth);
4390 g_print ("path: %s\n",
4391 gtk_tree_path_to_string (gtk_tree_model_get_path (model, iter)));
4397 if (gtk_tree_model_iter_children (model, &child_iter, iter))
4399 gboolean ret_val = TRUE;
4403 if (level == depth - 1)
4405 GtkTreePath *iter_path;
4406 gboolean finished = FALSE;
4408 iter_path = gtk_tree_model_get_path (model, &child_iter);
4409 if (end_path && gtk_tree_path_compare (iter_path, end_path) >= 0)
4411 gtk_tree_path_free (iter_path);
4415 if (gtk_tree_model_iter_has_child (model, &child_iter))
4416 count_rows (model, &child_iter, end_path, count, level, depth);
4417 ret_val = gtk_tree_model_iter_next (model, &child_iter);
4423 * Find the next node, which has children, at the specified depth below
4424 * the specified iter. The level is the depth of the current iter.
4425 * The position of the node is returned in path and the return value of TRUE
4426 * means that a node was found.
4429 gboolean get_next_node_with_child_at_depth (GtkTreeModel *model,
4435 GtkTreeIter child_iter;
4439 if (gtk_tree_model_iter_children (model, &child_iter, iter))
4445 while (!gtk_tree_model_iter_has_child (model, &child_iter))
4447 if (!gtk_tree_model_iter_next (model, &child_iter))
4452 /* We have found what we were looking for */
4454 *path = gtk_tree_model_get_path (model, &child_iter);
4458 if (get_next_node_with_child_at_depth (model, &child_iter, path,
4462 if (!gtk_tree_model_iter_next (model, &child_iter))
4470 * Find the next node, which has children, at the same depth as
4471 * the specified GtkTreePath.
4474 get_next_node_with_child (GtkTreeModel *model,
4476 GtkTreePath **return_path)
4481 gtk_tree_model_get_iter (model, &iter, path);
4483 while (gtk_tree_model_iter_next (model, &iter))
4485 if (gtk_tree_model_iter_has_child (model, &iter))
4487 *return_path = gtk_tree_model_get_path (model, &iter);
4491 depth = gtk_tree_path_get_depth (path);
4492 while (gtk_tree_path_up (path))
4494 if (gtk_tree_path_get_depth (path) == 0)
4497 gtk_tree_model_get_iter (model, &iter, path);
4498 while (gtk_tree_model_iter_next (model, &iter))
4499 if (get_next_node_with_child_at_depth (model, &iter, return_path,
4500 gtk_tree_path_get_depth (path), depth))
4503 *return_path = NULL;
4508 get_tree_path_from_row_index (GtkTreeModel *model,
4510 GtkTreePath **tree_path)
4516 count = gtk_tree_model_iter_n_children (model, NULL);
4517 if (count > row_index)
4519 if (gtk_tree_model_iter_nth_child (model, &iter, NULL, row_index))
4521 *tree_path = gtk_tree_model_get_path (model, &iter);
4535 if (get_next_node_with_child_at_depth (model, NULL, tree_path, 0, depth))
4537 GtkTreePath *next_path;
4541 gtk_tree_model_get_iter (model, &iter, *tree_path);
4542 count = gtk_tree_model_iter_n_children (model, &iter);
4543 if (count > row_index)
4545 gtk_tree_path_append_index (*tree_path, row_index);
4551 if (!get_next_node_with_child (model, *tree_path, &next_path))
4554 gtk_tree_path_free (*tree_path);
4555 *tree_path = next_path;
4560 g_warning ("Index value is too large\n");
4561 gtk_tree_path_free (*tree_path);
4569 * This function returns the number of rows, including those which are collapsed
4572 get_row_count (GtkTreeModel *model)
4576 count_rows (model, NULL, NULL, &n_rows, 0, G_MAXINT);
4582 get_path_column_from_index (GtkTreeView *tree_view,
4585 GtkTreeViewColumn **column)
4587 GtkTreeModel *tree_model;
4590 tree_model = gtk_tree_view_get_model (tree_view);
4591 n_columns = get_n_actual_columns (tree_view);
4594 /* First row is the column headers */
4604 row_index = index / n_columns;
4605 retval = get_tree_path_from_row_index (tree_model, row_index, path);
4606 gail_return_val_if_fail (retval, FALSE);
4613 *column = gtk_tree_view_get_column (tree_view, index % n_columns);
4614 if (*column == NULL)
4617 gtk_tree_path_free (*path);
4625 set_cell_expandable (GailCell *cell)
4627 if (gail_cell_add_state (cell,
4628 ATK_STATE_EXPANDABLE,
4630 gail_cell_add_action (cell,
4631 "expand or contract", /* action name */
4632 "expands or contracts the row in the tree view "
4633 "containing this cell", /* description */
4634 NULL, /* Keybinding */
4635 toggle_cell_expanded);
4638 static GailTreeViewCellInfo*
4639 find_cell_info (GailTreeView *view,
4645 GailTreeViewCellInfo *cell_info;
4647 for (temp_list = view->cell_data; temp_list; temp_list = temp_list->next)
4649 cell_info = (GailTreeViewCellInfo *) temp_list->data;
4650 if (cell_info->cell == cell && (!live_only || cell_info->in_use))
4661 get_header_from_column (GtkTreeViewColumn *tv_col)
4664 GtkWidget *header_widget;
4669 /* If the user has set a header object, use that */
4671 rc = g_object_get_qdata (G_OBJECT (tv_col), quark_column_header_object);
4675 /* If the user has not set a header object, grab the column */
4676 /* header object defined by the GtkTreeView */
4678 header_widget = tv_col->button;
4682 rc = gtk_widget_get_accessible (header_widget);