[gtk+/a11y] Convert GailTreeView to GtkTreeViewAccessible
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/a11y] Convert GailTreeView to GtkTreeViewAccessible
- Date: Thu, 30 Jun 2011 03:04:14 +0000 (UTC)
commit 7d96338feaedda5e24da76b4cd934d78de8b85c9
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Jun 29 20:50:50 2011 -0400
Convert GailTreeView to GtkTreeViewAccessible
Mostly code rearrangement and cleanup, but also a memory
leak fix in gtk_tree_view_accessible_get_column_description().
gtk/a11y/Makefile.am | 4 +-
gtk/a11y/gail.c | 3 -
gtk/a11y/gailtreeview.h | 70 -
.../{gailtreeview.c => gtktreeviewaccessible.c} | 2955 +++++++++-----------
gtk/a11y/gtktreeviewaccessible.h | 69 +
gtk/gtktreeview.c | 3 +
tests/a11y/appchooser.txt | 8 +-
7 files changed, 1381 insertions(+), 1731 deletions(-)
---
diff --git a/gtk/a11y/Makefile.am b/gtk/a11y/Makefile.am
index 51a6810..6d2269d 100644
--- a/gtk/a11y/Makefile.am
+++ b/gtk/a11y/Makefile.am
@@ -46,7 +46,7 @@ gail_c_sources = \
gtktextviewaccessible.c \
gtktogglebuttonaccessible.c \
gailtoplevel.c \
- gailtreeview.c \
+ gtktreeviewaccessible.c \
gailutil.c \
gailwidget.c \
gailwindow.c
@@ -97,7 +97,7 @@ gail_private_h_sources = \
gtktextviewaccessible.h \
gtktogglebuttonaccessible.h \
gailtoplevel.h \
- gailtreeview.h \
+ gtktreeviewaccessible.h \
gailutil.h \
gailwindow.h
diff --git a/gtk/a11y/gail.c b/gtk/a11y/gail.c
index 3a4e1ca..0bea4e2 100644
--- a/gtk/a11y/gail.c
+++ b/gtk/a11y/gail.c
@@ -40,7 +40,6 @@
#include "gailstatusbar.h"
#include "gailtextcell.h"
#include "gailtoplevel.h"
-#include "gailtreeview.h"
#include "gailutil.h"
#include "gailwidget.h"
#include "gailwindow.h"
@@ -100,7 +99,6 @@ GAIL_IMPLEMENT_FACTORY (GAIL_TYPE_MENU, GailMenu, gail_menu, GTK_TYPE_MENU)
GAIL_IMPLEMENT_FACTORY (GAIL_TYPE_WINDOW, GailWindow, gail_window, GTK_TYPE_BIN)
GAIL_IMPLEMENT_FACTORY (GAIL_TYPE_STATUSBAR, GailStatusbar, gail_statusbar, GTK_TYPE_STATUSBAR)
GAIL_IMPLEMENT_FACTORY (GAIL_TYPE_NOTEBOOK, GailNotebook, gail_notebook, GTK_TYPE_NOTEBOOK)
-GAIL_IMPLEMENT_FACTORY (GAIL_TYPE_TREE_VIEW, GailTreeView, gail_tree_view, GTK_TYPE_TREE_VIEW)
GAIL_IMPLEMENT_FACTORY_WITH_FUNC (GAIL_TYPE_CHECK_MENU_ITEM, GailCheckMenuItem, gail_check_menu_item, gail_check_menu_item_new)
GAIL_IMPLEMENT_FACTORY_WITH_FUNC (GAIL_TYPE_RADIO_MENU_ITEM, GailRadioMenuItem, gail_radio_menu_item, gail_radio_menu_item_new)
GAIL_IMPLEMENT_FACTORY (GAIL_TYPE_EXPANDER, GailExpander, gail_expander, GTK_TYPE_EXPANDER)
@@ -857,7 +855,6 @@ gail_accessibility_module_init (void)
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_WINDOW, gail_window);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_STATUSBAR, gail_statusbar);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_NOTEBOOK, gail_notebook);
- GAIL_WIDGET_SET_FACTORY (GTK_TYPE_TREE_VIEW, gail_tree_view);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_CELL_RENDERER_TEXT, gail_text_cell);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_CELL_RENDERER_TOGGLE, gail_boolean_cell);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_CELL_RENDERER_PIXBUF, gail_image_cell);
diff --git a/gtk/a11y/gailtreeview.c b/gtk/a11y/gtktreeviewaccessible.c
similarity index 51%
rename from gtk/a11y/gailtreeview.c
rename to gtk/a11y/gtktreeviewaccessible.c
index ccf93da..09e3e57 100644
--- a/gtk/a11y/gailtreeview.c
+++ b/gtk/a11y/gtktreeviewaccessible.c
@@ -24,159 +24,49 @@
#ifdef GDK_WINDOWING_X11
#include <gdk/x11/gdkx.h>
#endif
-#include "gailtreeview.h"
+#include "gtktreeviewaccessible.h"
#include "gailrenderercell.h"
#include "gailbooleancell.h"
#include "gailcontainercell.h"
#include "gailtextcell.h"
#include "gailcellparent.h"
-typedef struct _GailTreeViewCellInfo GailTreeViewCellInfo;
-
-static void gail_tree_view_class_init (GailTreeViewClass *klass);
-static void gail_tree_view_init (GailTreeView *view);
-static void gail_tree_view_real_initialize (AtkObject *obj,
- gpointer data);
-static void gail_tree_view_real_notify_gtk (GObject *obj,
- GParamSpec *pspec);
-static void gail_tree_view_finalize (GObject *object);
-
-static void gail_tree_view_connect_widget_destroyed
- (GtkAccessible *accessible);
-static void gail_tree_view_destroyed (GtkWidget *widget,
- GtkAccessible *accessible);
-/* atkobject.h */
-
-static gint gail_tree_view_get_n_children (AtkObject *obj);
-static AtkObject* gail_tree_view_ref_child (AtkObject *obj,
- gint i);
-static AtkStateSet* gail_tree_view_ref_state_set (AtkObject *obj);
-
-/* atkcomponent.h */
-
-static void atk_component_interface_init (AtkComponentIface *iface);
-
-static AtkObject* gail_tree_view_ref_accessible_at_point
- (AtkComponent *component,
- gint x,
- gint y,
- AtkCoordType coord_type);
-
-/* atktable.h */
-
-static void atk_table_interface_init (AtkTableIface *iface);
-
-static gint gail_tree_view_get_index_at (AtkTable *table,
- gint row,
- gint column);
-static gint gail_tree_view_get_column_at_index
- (AtkTable *table,
- gint index);
-static gint gail_tree_view_get_row_at_index (AtkTable *table,
- gint index);
-
-static AtkObject* gail_tree_view_table_ref_at (AtkTable *table,
- gint row,
- gint column);
-static gint gail_tree_view_get_n_rows (AtkTable *table);
-static gint gail_tree_view_get_n_columns (AtkTable *table);
-static gboolean gail_tree_view_is_row_selected (AtkTable *table,
- gint row);
-static gboolean gail_tree_view_is_selected (AtkTable *table,
- gint row,
- gint column);
-static gint gail_tree_view_get_selected_rows
- (AtkTable *table,
- gint **selected);
-static gboolean gail_tree_view_add_row_selection
- (AtkTable *table,
- gint row);
-static gboolean gail_tree_view_remove_row_selection
- (AtkTable *table,
- gint row);
-static AtkObject* gail_tree_view_get_column_header
- (AtkTable *table,
- gint column);
-static const gchar*
- gail_tree_view_get_column_description
- (AtkTable *table,
- gint column);
-
-/* atkselection.h */
-
-static void atk_selection_interface_init (AtkSelectionIface *iface);
-static gboolean gail_tree_view_add_selection (AtkSelection *selection,
- gint i);
-static gboolean gail_tree_view_clear_selection (AtkSelection *selection);
-static AtkObject* gail_tree_view_ref_selection (AtkSelection *selection,
- gint i);
-static gint gail_tree_view_get_selection_count
- (AtkSelection *selection);
-static gboolean gail_tree_view_is_child_selected
- (AtkSelection *selection,
- gint i);
-
-/* gailcellparent.h */
-
-static void gail_cell_parent_interface_init (GailCellParentIface *iface);
-static void gail_tree_view_get_cell_extents (GailCellParent *parent,
- GailCell *cell,
- gint *x,
- gint *y,
- gint *width,
- gint *height,
- AtkCoordType coord_type);
-static void gail_tree_view_get_cell_area (GailCellParent *parent,
- GailCell *cell,
- GdkRectangle *cell_rect);
-static gboolean gail_tree_view_grab_cell_focus (GailCellParent *parent,
- GailCell *cell);
+typedef struct _GtkTreeViewAccessibleCellInfo GtkTreeViewAccessibleCellInfo;
+struct _GtkTreeViewAccessibleCellInfo
+{
+ GailCell *cell;
+ GtkTreeRowReference *cell_row_ref;
+ GtkTreeViewColumn *cell_col_ref;
+ GtkTreeViewAccessible *view;
+ gboolean in_use;
+};
/* signal handling */
-static gboolean gail_tree_view_expand_row_gtk (GtkTreeView *tree_view,
- GtkTreeIter *iter,
- GtkTreePath *path);
-static gint idle_expand_row (gpointer data);
-static gboolean gail_tree_view_collapse_row_gtk (GtkTreeView *tree_view,
- GtkTreeIter *iter,
- GtkTreePath *path);
-static void gail_tree_view_size_allocate_gtk (GtkWidget *widget,
- GtkAllocation *allocation);
-static void gail_tree_view_changed_gtk (GtkTreeSelection *selection,
- gpointer data);
-
-static void columns_changed (GtkTreeView *tree_view);
-static void cursor_changed (GtkTreeView *tree_view);
-static gint idle_cursor_changed (gpointer data);
-static gboolean focus_in (GtkWidget *widget);
-static gboolean focus_out (GtkWidget *widget);
-
-static void model_row_changed (GtkTreeModel *tree_model,
- GtkTreePath *path,
- GtkTreeIter *iter,
- gpointer user_data);
-static void column_visibility_changed (GObject *object,
- GParamSpec *param,
- gpointer user_data);
-static void model_row_inserted (GtkTreeModel *tree_model,
- GtkTreePath *path,
- GtkTreeIter *iter,
- gpointer user_data);
-static void model_row_deleted (GtkTreeModel *tree_model,
- GtkTreePath *path,
- gpointer user_data);
-static void destroy_count_func (GtkTreeView *tree_view,
- GtkTreePath *path,
- gint count,
- gpointer user_data);
-static void model_rows_reordered (GtkTreeModel *tree_model,
- GtkTreePath *path,
- GtkTreeIter *iter,
- gint *new_order,
- gpointer user_data);
-static void adjustment_changed (GtkAdjustment *adjustment,
- GtkTreeView *tree_view);
+static gboolean row_expanded_cb (GtkTreeView *tree_view,
+ GtkTreeIter *iter,
+ GtkTreePath *path);
+static gboolean row_collapsed_cb (GtkTreeView *tree_view,
+ GtkTreeIter *iter,
+ GtkTreePath *path);
+static void size_allocate_cb (GtkWidget *widget,
+ GtkAllocation *allocation);
+static void selection_changed_cb (GtkTreeSelection *selection,
+ gpointer data);
+
+static void columns_changed (GtkTreeView *tree_view);
+static void cursor_changed (GtkTreeView *tree_view);
+static gboolean focus_in (GtkWidget *widget);
+static gboolean focus_out (GtkWidget *widget);
+
+static void column_visibility_changed
+ (GObject *object,
+ GParamSpec *param,
+ gpointer user_data);
+static void destroy_count_func (GtkTreeView *tree_view,
+ GtkTreePath *path,
+ gint count,
+ gpointer user_data);
/* Misc */
@@ -191,26 +81,21 @@ static gint get_actual_column_number (GtkTreeView
gint visible_column);
static gint get_visible_column_number (GtkTreeView *tree_view,
gint actual_column);
-static void iterate_thru_children (GtkTreeView *tree_view,
+static void iterate_thru_children (GtkTreeView *tree_view,
GtkTreeModel *tree_model,
GtkTreePath *tree_path,
GtkTreePath *orig,
gint *count,
gint depth);
-static GtkTreeIter* return_iter_nth_row (GtkTreeView *tree_view,
- GtkTreeModel *tree_model,
- GtkTreeIter *iter,
- gint increment,
- gint row);
-static void clean_rows (GailTreeView *tree_view);
-static void clean_cols (GailTreeView *tree_view,
+static void clean_rows (GtkTreeViewAccessible *tree_view);
+static void clean_cols (GtkTreeViewAccessible *tree_view,
GtkTreeViewColumn *tv_col);
-static void traverse_cells (GailTreeView *tree_view,
+static void traverse_cells (GtkTreeViewAccessible *tree_view,
GtkTreePath *tree_path,
gboolean set_stale,
gboolean inc_row);
static gboolean update_cell_value (GailRendererCell *renderer_cell,
- GailTreeView *gailview,
+ GtkTreeViewAccessible *accessible,
gboolean emit_change_signal);
static void set_cell_visibility (GtkTreeView *tree_view,
GailCell *cell,
@@ -221,43 +106,32 @@ static gboolean is_cell_showing (GtkTreeView
GdkRectangle *cell_rect);
static void set_expand_state (GtkTreeView *tree_view,
GtkTreeModel *tree_model,
- GailTreeView *gailview,
+ GtkTreeViewAccessible *accessible,
GtkTreePath *tree_path,
gboolean set_on_ancestor);
+static void set_cell_expandable (GailCell *cell);
static void add_cell_actions (GailCell *cell,
gboolean editable);
-static void toggle_cell_expanded (GailCell *cell);
static void toggle_cell_toggled (GailCell *cell);
static void edit_cell (GailCell *cell);
static void activate_cell (GailCell *cell);
static void cell_destroyed (gpointer data);
-#if 0
-static void cell_info_remove (GailTreeView *tree_view,
- GailCell *cell);
-#endif
-static void cell_info_get_index (GtkTreeView *tree_view,
- GailTreeViewCellInfo *info,
- gint *index);
-static void cell_info_new (GailTreeView *gailview,
+static void cell_info_new (GtkTreeViewAccessible *accessible,
GtkTreeModel *tree_model,
GtkTreePath *path,
GtkTreeViewColumn *tv_col,
GailCell *cell);
-static GailCell* find_cell (GailTreeView *gailview,
+static GailCell* find_cell (GtkTreeViewAccessible *accessible,
gint index);
static void refresh_cell_index (GailCell *cell);
-static void get_selected_rows (GtkTreeModel *model,
- GtkTreePath *path,
- GtkTreeIter *iter,
- gpointer data);
static void connect_model_signals (GtkTreeView *view,
- GailTreeView *gailview);
-static void disconnect_model_signals (GailTreeView *gailview);
-static void clear_cached_data (GailTreeView *view);
+ GtkTreeViewAccessible *accessible);
+static void disconnect_model_signals (GtkTreeViewAccessible *accessible);
+static void clear_cached_data (GtkTreeViewAccessible *view);
static gint get_column_number (GtkTreeView *tree_view,
GtkTreeViewColumn *column,
- gboolean visible);
+ gboolean visible);
static gint get_focus_index (GtkTreeView *tree_view);
static gint get_index (GtkTreeView *tree_view,
GtkTreePath *path,
@@ -269,243 +143,203 @@ static void count_rows (GtkTreeModel
gint level,
gint depth);
-static gboolean get_next_node_with_child_at_depth
- (GtkTreeModel *model,
- GtkTreeIter *iter,
- GtkTreePath **path,
- gint level,
- gint depth);
-static gboolean get_next_node_with_child (GtkTreeModel *model,
- GtkTreePath *path,
- GtkTreePath **return_path);
-static gboolean get_tree_path_from_row_index (GtkTreeModel *model,
- gint row_index,
- GtkTreePath **tree_path);
static gboolean get_path_column_from_index (GtkTreeView *tree_view,
gint index,
GtkTreePath **path,
GtkTreeViewColumn **column);
-static void set_cell_expandable (GailCell *cell);
-static GailTreeViewCellInfo* find_cell_info (GailTreeView *view,
+static GtkTreeViewAccessibleCellInfo* find_cell_info (GtkTreeViewAccessible *view,
GailCell *cell,
- gboolean live_only);
+ gboolean live_only);
static AtkObject * get_header_from_column (GtkTreeViewColumn *tv_col);
static gboolean idle_garbage_collect_cell_data (gpointer data);
-static gboolean garbage_collect_cell_data (gpointer data);
-static gboolean editing = FALSE;
-struct _GailTreeViewCellInfo
-{
- GailCell *cell;
- GtkTreeRowReference *cell_row_ref;
- GtkTreeViewColumn *cell_col_ref;
- GailTreeView *view;
- gboolean in_use;
-};
+static void atk_table_interface_init (AtkTableIface *iface);
+static void atk_selection_interface_init (AtkSelectionIface *iface);
+static void atk_component_interface_init (AtkComponentIface *iface);
+static void gail_cell_parent_interface_init (GailCellParentIface *iface);
-G_DEFINE_TYPE_WITH_CODE (GailTreeView, gail_tree_view, GAIL_TYPE_CONTAINER,
+G_DEFINE_TYPE_WITH_CODE (GtkTreeViewAccessible, gtk_tree_view_accessible, GAIL_TYPE_CONTAINER,
G_IMPLEMENT_INTERFACE (ATK_TYPE_TABLE, atk_table_interface_init)
G_IMPLEMENT_INTERFACE (ATK_TYPE_SELECTION, atk_selection_interface_init)
G_IMPLEMENT_INTERFACE (ATK_TYPE_COMPONENT, atk_component_interface_init)
G_IMPLEMENT_INTERFACE (GAIL_TYPE_CELL_PARENT, gail_cell_parent_interface_init))
-static void
-gail_tree_view_class_init (GailTreeViewClass *klass)
-{
- AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- GtkAccessibleClass *accessible_class;
- GailWidgetClass *widget_class;
- GailContainerClass *container_class;
-
- accessible_class = (GtkAccessibleClass*)klass;
- widget_class = (GailWidgetClass*)klass;
- container_class = (GailContainerClass*)klass;
-
- class->get_n_children = gail_tree_view_get_n_children;
- class->ref_child = gail_tree_view_ref_child;
- class->ref_state_set = gail_tree_view_ref_state_set;
- class->initialize = gail_tree_view_real_initialize;
-
- widget_class->notify_gtk = gail_tree_view_real_notify_gtk;
-
- accessible_class->connect_widget_destroyed = gail_tree_view_connect_widget_destroyed;
-
- /*
- * The children of a GtkTreeView are the buttons at the top of the columns
- * we do not represent these as children so we do not want to report
- * children added or deleted when these changed.
- */
- container_class->add_gtk = NULL;
- container_class->remove_gtk = NULL;
-
- gobject_class->finalize = gail_tree_view_finalize;
-}
static void
-gail_tree_view_init (GailTreeView *view)
+adjustment_changed (GtkAdjustment *adjustment,
+ GtkWidget *widget)
{
+ GtkTreeViewAccessible *accessible;
+
+ accessible = GTK_TREE_VIEW_ACCESSIBLE (gtk_widget_get_accessible (widget));
+ traverse_cells (accessible, NULL, FALSE, FALSE);
}
static void
-gail_tree_view_hadjustment_set (GObject *widget,
- GParamSpec *pspec,
- gpointer data)
+hadjustment_set_cb (GObject *widget,
+ GParamSpec *pspec,
+ gpointer data)
{
+ GtkTreeViewAccessible *accessible = data;
GtkAdjustment *adj;
- GailTreeView *view = data;
g_object_get (widget, "hadjustment", &adj, NULL);
- view->old_hadj = adj;
- g_object_add_weak_pointer (G_OBJECT (view->old_hadj), (gpointer *)&view->old_hadj);
- g_signal_connect (adj,
- "value-changed",
- G_CALLBACK (adjustment_changed),
- widget);
+ accessible->old_hadj = adj;
+ g_object_add_weak_pointer (G_OBJECT (accessible->old_hadj), (gpointer *)&accessible->old_hadj);
+ g_signal_connect (adj, "value-changed", G_CALLBACK (adjustment_changed), widget);
}
static void
-gail_tree_view_vadjustment_set (GObject *widget,
- GParamSpec *pspec,
- gpointer data)
+vadjustment_set_cb (GObject *widget,
+ GParamSpec *pspec,
+ gpointer data)
{
+ GtkTreeViewAccessible *accessible = data;
GtkAdjustment *adj;
- GailTreeView *view = data;
g_object_get (widget, "vadjustment", &adj, NULL);
- view->old_vadj = adj;
- g_object_add_weak_pointer (G_OBJECT (view->old_vadj), (gpointer *)&view->old_vadj);
- g_signal_connect (adj,
- "value-changed",
- G_CALLBACK (adjustment_changed),
- widget);
+ accessible->old_vadj = adj;
+ g_object_add_weak_pointer (G_OBJECT (accessible->old_vadj), (gpointer *)&accessible->old_vadj);
+ g_signal_connect (adj, "value-changed",
+ G_CALLBACK (adjustment_changed), widget);
}
static void
-gail_tree_view_real_initialize (AtkObject *obj,
- gpointer data)
+gtk_tree_view_accessible_initialize (AtkObject *obj,
+ gpointer data)
{
- GailTreeView *view;
+ GtkTreeViewAccessible *accessible;
GtkTreeView *tree_view;
GtkTreeModel *tree_model;
GList *tv_cols, *tmp_list;
GtkWidget *widget;
+ GtkTreeSelection *selection;
- ATK_OBJECT_CLASS (gail_tree_view_parent_class)->initialize (obj, data);
-
- view = GAIL_TREE_VIEW (obj);
- view->col_data = NULL;
- view->focus_cell = NULL;
- view->old_hadj = NULL;
- view->old_vadj = NULL;
- view->idle_expand_id = 0;
- view->idle_expand_path = NULL;
+ ATK_OBJECT_CLASS (gtk_tree_view_accessible_parent_class)->initialize (obj, data);
- view->n_children_deleted = 0;
+ accessible = GTK_TREE_VIEW_ACCESSIBLE (obj);
+ accessible->col_data = NULL;
+ accessible->focus_cell = NULL;
+ accessible->old_hadj = NULL;
+ accessible->old_vadj = NULL;
+ accessible->idle_expand_id = 0;
+ accessible->idle_expand_path = NULL;
+ accessible->n_children_deleted = 0;
- view->cell_info_by_index = g_hash_table_new (g_int_hash, g_int_equal);
+ accessible->cell_info_by_index = g_hash_table_new (g_int_hash, g_int_equal);
widget = GTK_WIDGET (data);
- g_signal_connect_after (widget,
- "row-collapsed",
- G_CALLBACK (gail_tree_view_collapse_row_gtk),
- NULL);
- g_signal_connect (widget,
- "row-expanded",
- G_CALLBACK (gail_tree_view_expand_row_gtk),
- NULL);
- g_signal_connect (widget,
- "size-allocate",
- G_CALLBACK (gail_tree_view_size_allocate_gtk),
- NULL);
-
tree_view = GTK_TREE_VIEW (widget);
tree_model = gtk_tree_view_get_model (tree_view);
+ selection = gtk_tree_view_get_selection (tree_view);
- /* Set up signal handling */
-
- g_signal_connect_data (gtk_tree_view_get_selection (tree_view),
- "changed",
- (GCallback) gail_tree_view_changed_gtk,
- obj, NULL, 0);
-
- g_signal_connect_data (tree_view, "columns-changed",
- (GCallback) columns_changed, NULL, NULL, 0);
- g_signal_connect_data (tree_view, "cursor-changed",
- (GCallback) cursor_changed, NULL, NULL, 0);
- g_signal_connect_data (GTK_WIDGET (tree_view), "focus-in-event",
- (GCallback) focus_in, NULL, NULL, 0);
- g_signal_connect_data (GTK_WIDGET (tree_view), "focus-out-event",
- (GCallback) focus_out, NULL, NULL, 0);
-
- view->tree_model = tree_model;
- view->n_rows = 0;
- view->n_cols = 0;
+ g_signal_connect_after (widget, "row-collapsed",
+ G_CALLBACK (row_collapsed_cb), NULL);
+ g_signal_connect (widget, "row-expanded",
+ G_CALLBACK (row_expanded_cb), NULL);
+ g_signal_connect (widget, "size-allocate",
+ G_CALLBACK (size_allocate_cb), NULL);
+ g_signal_connect (selection, "changed",
+ G_CALLBACK (selection_changed_cb), obj);
+
+ g_signal_connect (tree_view, "columns-changed",
+ G_CALLBACK (columns_changed), NULL);
+ g_signal_connect (tree_view, "cursor-changed",
+ G_CALLBACK (cursor_changed), NULL);
+ g_signal_connect (tree_view, "focus-in-event",
+ G_CALLBACK (focus_in), NULL);
+ g_signal_connect (tree_view, "focus-out-event",
+ G_CALLBACK (focus_out), NULL);
+
+ accessible->tree_model = tree_model;
+ accessible->n_rows = 0;
+ accessible->n_cols = 0;
if (tree_model)
{
- g_object_add_weak_pointer (G_OBJECT (view->tree_model), (gpointer *)&view->tree_model);
- count_rows (tree_model, NULL, NULL, &view->n_rows, 0, G_MAXINT);
- connect_model_signals (tree_view, view);
+ g_object_add_weak_pointer (G_OBJECT (accessible->tree_model), (gpointer *)&accessible->tree_model);
+ count_rows (tree_model, NULL, NULL, &accessible->n_rows, 0, G_MAXINT);
+ connect_model_signals (tree_view, accessible);
if (gtk_tree_model_get_flags (tree_model) & GTK_TREE_MODEL_LIST_ONLY)
obj->role = ATK_ROLE_TABLE;
else
obj->role = ATK_ROLE_TREE_TABLE;
}
- else
- {
- obj->role = ATK_ROLE_UNKNOWN;
- }
-
- /* adjustment callbacks */
- gail_tree_view_hadjustment_set (G_OBJECT (widget), NULL, view);
- gail_tree_view_vadjustment_set (G_OBJECT (widget), NULL, view);
- g_signal_connect (widget,
- "notify::hadjustment",
- G_CALLBACK (gail_tree_view_hadjustment_set),
- view);
- g_signal_connect (widget,
- "notify::vadjustment",
- G_CALLBACK (gail_tree_view_vadjustment_set),
- view);
+ hadjustment_set_cb (G_OBJECT (widget), NULL, accessible);
+ vadjustment_set_cb (G_OBJECT (widget), NULL, accessible);
+ g_signal_connect (widget, "notify::hadjustment",
+ G_CALLBACK (hadjustment_set_cb), accessible);
+ g_signal_connect (widget, "notify::vadjustment",
+ G_CALLBACK (vadjustment_set_cb), accessible);
- view->col_data = g_array_sized_new (FALSE, TRUE,
- sizeof(GtkTreeViewColumn *), 0);
+ accessible->col_data = g_array_sized_new (FALSE, TRUE,
+ sizeof (GtkTreeViewColumn *), 0);
tv_cols = gtk_tree_view_get_columns (tree_view);
-
for (tmp_list = tv_cols; tmp_list; tmp_list = tmp_list->next)
{
- view->n_cols++;
- g_signal_connect_data (tmp_list->data, "notify::visible",
- (GCallback)column_visibility_changed,
- tree_view, NULL, FALSE);
- g_array_append_val (view->col_data, tmp_list->data);
+ accessible->n_cols++;
+ g_signal_connect (tmp_list->data, "notify::visible",
+ G_CALLBACK (column_visibility_changed), tree_view);
+ g_array_append_val (accessible->col_data, tmp_list->data);
}
+ g_list_free (tv_cols);
- gtk_tree_view_set_destroy_count_func (tree_view,
+ gtk_tree_view_set_destroy_count_func (tree_view,
destroy_count_func,
NULL, NULL);
- g_list_free (tv_cols);
}
static void
-gail_tree_view_real_notify_gtk (GObject *obj,
- GParamSpec *pspec)
+gtk_tree_view_accessible_finalize (GObject *object)
+{
+ GtkTreeViewAccessible *accessible = GTK_TREE_VIEW_ACCESSIBLE (object);
+
+ clear_cached_data (accessible);
+
+ /* remove any idle handlers still pending */
+ if (accessible->idle_garbage_collect_id)
+ g_source_remove (accessible->idle_garbage_collect_id);
+ if (accessible->idle_cursor_changed_id)
+ g_source_remove (accessible->idle_cursor_changed_id);
+ if (accessible->idle_expand_id)
+ g_source_remove (accessible->idle_expand_id);
+
+ if (accessible->tree_model)
+ disconnect_model_signals (accessible);
+
+ if (accessible->cell_info_by_index)
+ g_hash_table_destroy (accessible->cell_info_by_index);
+
+ if (accessible->col_data)
+ {
+ GArray *array = accessible->col_data;
+
+ /* No need to free the contents of the array since it
+ * just contains pointers to the GtkTreeViewColumn
+ * objects that are in the GtkTreeView.
+ */
+ g_array_free (array, TRUE);
+ }
+
+ G_OBJECT_CLASS (gtk_tree_view_accessible_parent_class)->finalize (object);
+}
+
+static void
+gtk_tree_view_accessible_notify_gtk (GObject *obj,
+ GParamSpec *pspec)
{
GtkWidget *widget;
- AtkObject* atk_obj;
GtkTreeView *tree_view;
- GailTreeView *gailview;
+ GtkTreeViewAccessible *accessible;
GtkAdjustment *adj;
widget = GTK_WIDGET (obj);
- atk_obj = gtk_widget_get_accessible (widget);
+ accessible = GTK_TREE_VIEW_ACCESSIBLE (gtk_widget_get_accessible (widget));
tree_view = GTK_TREE_VIEW (widget);
- gailview = GAIL_TREE_VIEW (atk_obj);
if (strcmp (pspec->name, "model") == 0)
{
@@ -513,19 +347,17 @@ gail_tree_view_real_notify_gtk (GObject *obj,
AtkRole role;
tree_model = gtk_tree_view_get_model (tree_view);
- if (gailview->tree_model)
- disconnect_model_signals (gailview);
- clear_cached_data (gailview);
- gailview->tree_model = tree_model;
- gailview->n_rows = 0;
- /*
- * if there is no model the GtkTreeView is probably being destroyed
- */
+ if (accessible->tree_model)
+ disconnect_model_signals (accessible);
+ clear_cached_data (accessible);
+ accessible->tree_model = tree_model;
+ accessible->n_rows = 0;
+
if (tree_model)
{
- g_object_add_weak_pointer (G_OBJECT (gailview->tree_model), (gpointer *)&gailview->tree_model);
- count_rows (tree_model, NULL, NULL, &gailview->n_rows, 0, G_MAXINT);
- connect_model_signals (tree_view, gailview);
+ g_object_add_weak_pointer (G_OBJECT (accessible->tree_model), (gpointer *)&accessible->tree_model);
+ count_rows (tree_model, NULL, NULL, &accessible->n_rows, 0, G_MAXINT);
+ connect_model_signals (tree_view, accessible);
if (gtk_tree_model_get_flags (tree_model) & GTK_TREE_MODEL_LIST_ONLY)
role = ATK_ROLE_TABLE;
@@ -536,202 +368,110 @@ gail_tree_view_real_notify_gtk (GObject *obj,
{
role = ATK_ROLE_UNKNOWN;
}
- atk_object_set_role (atk_obj, role);
- g_object_freeze_notify (G_OBJECT (atk_obj));
- g_signal_emit_by_name (atk_obj, "model_changed");
- g_signal_emit_by_name (atk_obj, "visible_data_changed");
- g_object_thaw_notify (G_OBJECT (atk_obj));
+ atk_object_set_role (ATK_OBJECT (accessible), role);
+ g_object_freeze_notify (G_OBJECT (accessible));
+ g_signal_emit_by_name (accessible, "model_changed");
+ g_signal_emit_by_name (accessible, "visible_data_changed");
+ g_object_thaw_notify (G_OBJECT (accessible));
}
else if (strcmp (pspec->name, "hadjustment") == 0)
{
g_object_get (tree_view, "hadjustment", &adj, NULL);
- g_signal_handlers_disconnect_by_func (gailview->old_hadj,
- (gpointer) adjustment_changed,
- widget);
- gailview->old_hadj = adj;
- g_object_add_weak_pointer (G_OBJECT (gailview->old_hadj), (gpointer *)&gailview->old_hadj);
- g_signal_connect (adj,
- "value-changed",
- G_CALLBACK (adjustment_changed),
- tree_view);
+ g_signal_handlers_disconnect_by_func (accessible->old_hadj,
+ (gpointer) adjustment_changed,
+ widget);
+ accessible->old_hadj = adj;
+ g_object_add_weak_pointer (G_OBJECT (accessible->old_hadj), (gpointer *)&accessible->old_hadj);
+ g_signal_connect (adj, "value-changed", G_CALLBACK (adjustment_changed), tree_view);
}
else if (strcmp (pspec->name, "vadjustment") == 0)
{
g_object_get (tree_view, "vadjustment", &adj, NULL);
- g_signal_handlers_disconnect_by_func (gailview->old_vadj,
- (gpointer) adjustment_changed,
- widget);
- gailview->old_vadj = adj;
- g_object_add_weak_pointer (G_OBJECT (gailview->old_hadj), (gpointer *)&gailview->old_vadj);
- g_signal_connect (adj,
- "value-changed",
- G_CALLBACK (adjustment_changed),
- tree_view);
+ g_signal_handlers_disconnect_by_func (accessible->old_vadj,
+ (gpointer) adjustment_changed,
+ widget);
+ accessible->old_vadj = adj;
+ g_object_add_weak_pointer (G_OBJECT (accessible->old_hadj), (gpointer *)&accessible->old_vadj);
+ g_signal_connect (adj, "value-changed", G_CALLBACK (adjustment_changed), tree_view);
}
else
- GAIL_WIDGET_CLASS (gail_tree_view_parent_class)->notify_gtk (obj, pspec);
-}
-
-static void
-gail_tree_view_finalize (GObject *object)
-{
- GailTreeView *view = GAIL_TREE_VIEW (object);
-
- clear_cached_data (view);
-
- /* remove any idle handlers still pending */
- if (view->idle_garbage_collect_id)
- g_source_remove (view->idle_garbage_collect_id);
- if (view->idle_cursor_changed_id)
- g_source_remove (view->idle_cursor_changed_id);
- if (view->idle_expand_id)
- g_source_remove (view->idle_expand_id);
-
- if (view->tree_model)
- disconnect_model_signals (view);
-
- if (view->cell_info_by_index)
- g_hash_table_destroy (view->cell_info_by_index);
-
- if (view->col_data)
- {
- GArray *array = view->col_data;
-
- /*
- * No need to free the contents of the array since it
- * just contains pointers to the GtkTreeViewColumn
- * objects that are in the GtkTreeView.
- */
- g_array_free (array, TRUE);
- }
-
- G_OBJECT_CLASS (gail_tree_view_parent_class)->finalize (object);
-}
-
-static void
-gail_tree_view_connect_widget_destroyed (GtkAccessible *accessible)
-{
- GtkWidget *widget;
-
- widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible));
- if (widget)
- {
- g_signal_connect_after (widget,
- "destroy",
- G_CALLBACK (gail_tree_view_destroyed),
- accessible);
- }
- GTK_ACCESSIBLE_CLASS (gail_tree_view_parent_class)->connect_widget_destroyed (accessible);
+ GAIL_WIDGET_CLASS (gtk_tree_view_accessible_parent_class)->notify_gtk (obj, pspec);
}
static void
-gail_tree_view_destroyed (GtkWidget *widget,
- GtkAccessible *accessible)
+gtk_tree_view_accessible_destroyed (GtkWidget *widget,
+ GtkAccessible *gtk_accessible)
{
GtkAdjustment *adj;
- GailTreeView *gailview;
+ GtkTreeViewAccessible *accessible;
if (!GTK_IS_TREE_VIEW (widget))
return;
- gailview = GAIL_TREE_VIEW (accessible);
- adj = gailview->old_hadj;
+ accessible = GTK_TREE_VIEW_ACCESSIBLE (gtk_accessible);
+ adj = accessible->old_hadj;
if (adj)
- g_signal_handlers_disconnect_by_func (adj,
+ g_signal_handlers_disconnect_by_func (adj,
(gpointer) adjustment_changed,
widget);
- adj = gailview->old_vadj;
+ adj = accessible->old_vadj;
if (adj)
- g_signal_handlers_disconnect_by_func (adj,
+ g_signal_handlers_disconnect_by_func (adj,
(gpointer) adjustment_changed,
widget);
- if (gailview->tree_model)
+ if (accessible->tree_model)
{
- disconnect_model_signals (gailview);
- gailview->tree_model = NULL;
+ disconnect_model_signals (accessible);
+ accessible->tree_model = NULL;
}
- if (gailview->focus_cell)
+ if (accessible->focus_cell)
{
- g_object_unref (gailview->focus_cell);
- gailview->focus_cell = NULL;
+ g_object_unref (accessible->focus_cell);
+ accessible->focus_cell = NULL;
}
- if (gailview->idle_expand_id)
+ if (accessible->idle_expand_id)
{
- g_source_remove (gailview->idle_expand_id);
- gailview->idle_expand_id = 0;
+ g_source_remove (accessible->idle_expand_id);
+ accessible->idle_expand_id = 0;
}
}
-gint
-get_focus_index (GtkTreeView *tree_view)
-{
- GtkTreePath *focus_path;
- GtkTreeViewColumn *focus_column;
- gint index;
-
- gtk_tree_view_get_cursor (tree_view, &focus_path, &focus_column);
- if (focus_path && focus_column)
- {
-
- index = get_index (tree_view, focus_path,
- get_column_number (tree_view, focus_column, FALSE));
- }
- else
- index = -1;
-
- if (focus_path)
- gtk_tree_path_free (focus_path);
-
- return index;
-}
-
-AtkObject *
-gail_tree_view_ref_focus_cell (GtkTreeView *tree_view)
+static void
+gtk_tree_view_accessible_connect_widget_destroyed (GtkAccessible *accessible)
{
- /*
- * This function returns a reference to the accessible object for the cell
- * in the treeview which has focus, if a cell has focus.
- */
- AtkObject *focus_cell = NULL;
- AtkObject *atk_obj;
- gint focus_index;
+ GtkWidget *widget;
- focus_index = get_focus_index (tree_view);
- if (focus_index >= 0)
- {
- atk_obj = gtk_widget_get_accessible (GTK_WIDGET (tree_view));
- focus_cell = atk_object_ref_accessible_child (atk_obj, focus_index);
- }
+ widget = gtk_accessible_get_widget (accessible);
+ if (widget)
+ g_signal_connect_after (widget, "destroy",
+ G_CALLBACK (gtk_tree_view_accessible_destroyed), accessible);
- return focus_cell;
+ GTK_ACCESSIBLE_CLASS (gtk_tree_view_accessible_parent_class)->connect_widget_destroyed (accessible);
}
-/* atkobject.h */
-
static gint
-gail_tree_view_get_n_children (AtkObject *obj)
+gtk_tree_view_accessible_get_n_children (AtkObject *obj)
{
GtkWidget *widget;
-
- if (!GAIL_IS_TREE_VIEW (obj))
- return 0;
+ GtkTreeViewAccessible *accessible;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
if (widget == NULL)
return 0;
- return (GAIL_TREE_VIEW (obj)->n_rows + 1) * GAIL_TREE_VIEW (obj)->n_cols;
+ accessible = GTK_TREE_VIEW_ACCESSIBLE (obj);
+ return (accessible->n_rows + 1) * accessible->n_cols;
}
-static AtkObject*
-gail_tree_view_ref_child (AtkObject *obj,
- gint i)
+static AtkObject *
+gtk_tree_view_accessible_ref_child (AtkObject *obj,
+ gint i)
{
GtkWidget *widget;
- GailTreeView *gailview;
+ GtkTreeViewAccessible *accessible;
GailCell *cell;
GtkTreeView *tree_view;
- GtkTreeModel *tree_model;
+ GtkTreeModel *tree_model;
GtkCellRenderer *renderer;
GtkTreeIter iter;
GtkTreeViewColumn *tv_col;
@@ -750,22 +490,16 @@ gail_tree_view_ref_child (AtkObject *obj,
gboolean editable = FALSE;
gint focus_index;
- g_return_val_if_fail (GAIL_IS_TREE_VIEW (obj), NULL);
- g_return_val_if_fail (i >= 0, NULL);
-
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
if (widget == NULL)
- /*
- * State is defunct
- */
return NULL;
- if (i >= gail_tree_view_get_n_children (obj))
+ if (i >= gtk_tree_view_accessible_get_n_children (obj))
return NULL;
- gailview = GAIL_TREE_VIEW (obj);
+ accessible = GTK_TREE_VIEW_ACCESSIBLE (obj);
tree_view = GTK_TREE_VIEW (widget);
- if (i < gailview->n_cols)
+ if (i < accessible->n_cols)
{
tv_col = gtk_tree_view_get_column (tree_view, i);
child = get_header_from_column (tv_col);
@@ -774,26 +508,23 @@ gail_tree_view_ref_child (AtkObject *obj,
return child;
}
- /*
- * Check whether the child is cached
- */
- cell = find_cell (gailview, i);
+ /* Check whether the child is cached */
+ cell = find_cell (accessible, i);
if (cell)
{
g_object_ref (cell);
return ATK_OBJECT (cell);
}
- if (gailview->focus_cell == NULL)
+ if (accessible->focus_cell == NULL)
focus_index = get_focus_index (tree_view);
else
focus_index = -1;
- /*
- * Find the TreePath and GtkTreeViewColumn for the index
- */
+
+ /* Find the TreePath and GtkTreeViewColumn for the index */
if (!get_path_column_from_index (tree_view, i, &path, &tv_col))
return NULL;
-
+
tree_model = gtk_tree_view_get_model (tree_view);
retval = gtk_tree_model_get_iter (tree_model, &iter, path);
if (!retval)
@@ -809,14 +540,15 @@ gail_tree_view_ref_child (AtkObject *obj,
is_expander = TRUE;
is_expanded = gtk_tree_view_row_expanded (tree_view, path);
}
- }
- gtk_tree_view_column_cell_set_cell_data (tv_col, tree_model, &iter,
+ }
+ gtk_tree_view_column_cell_set_cell_data (tv_col, tree_model, &iter,
is_expander, is_expanded);
renderer_list = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (tv_col));
- /* If there are more than one renderer in the list, make a container */
-
+ /* If there are more than one renderer in the list,
+ * make a container
+ */
if (renderer_list && renderer_list->next)
{
GailCell *container_cell;
@@ -824,126 +556,115 @@ gail_tree_view_ref_child (AtkObject *obj,
container = gail_container_cell_new ();
container_cell = GAIL_CELL (container);
- gail_cell_initialise (container_cell,
- widget, ATK_OBJECT (gailview),
- i);
- /*
- * The GailTreeViewCellInfo structure for the container will be before
- * the ones for the cells so that the first one we find for a position
- * will be for the container
+ gail_cell_initialise (container_cell, widget, ATK_OBJECT (accessible), i);
+
+ /* The GtkTreeViewAccessibleCellInfo structure for the container will
+ * be before the ones for the cells so that the first one we find for
+ * a position will be for the container
*/
- cell_info_new (gailview, tree_model, path, tv_col, container_cell);
+ cell_info_new (accessible, tree_model, path, tv_col, container_cell);
container_cell->refresh_index = refresh_cell_index;
parent = ATK_OBJECT (container);
}
else
- parent = ATK_OBJECT (gailview);
+ parent = ATK_OBJECT (accessible);
child = NULL;
- /*
- * Now we make a fake cell_renderer if there is no cell in renderer_list
+ /* Now we make a fake cell_renderer if there is no cell
+ * in renderer_list
*/
-
if (renderer_list == NULL)
- {
- GtkCellRenderer *fake_renderer;
- fake_renderer = g_object_new (GTK_TYPE_CELL_RENDERER_TEXT, NULL);
- default_registry = atk_get_default_registry ();
- factory = atk_registry_get_factory (default_registry,
- G_OBJECT_TYPE (fake_renderer));
- child = atk_object_factory_create_accessible (factory,
- G_OBJECT (fake_renderer));
- cell = GAIL_CELL (child);
- renderer_cell = GAIL_RENDERER_CELL (child);
- renderer_cell->renderer = fake_renderer;
-
- /* Create the GailTreeViewCellInfo structure for this cell */
- cell_info_new (gailview, tree_model, path, tv_col, cell);
-
- gail_cell_initialise (cell,
- widget, parent,
- i);
-
- cell->refresh_index = refresh_cell_index;
-
- /* set state if it is expandable */
- if (is_expander)
- {
- set_cell_expandable (cell);
- if (is_expanded)
- gail_cell_add_state (cell,
- ATK_STATE_EXPANDED,
- FALSE);
- }
- } else {
- for (l = renderer_list; l; l = l->next)
- {
- renderer = GTK_CELL_RENDERER (l->data);
+ {
+ GtkCellRenderer *fake_renderer;
+
+ fake_renderer = g_object_new (GTK_TYPE_CELL_RENDERER_TEXT, NULL);
+ default_registry = atk_get_default_registry ();
+ factory = atk_registry_get_factory (default_registry,
+ G_OBJECT_TYPE (fake_renderer));
+ child = atk_object_factory_create_accessible (factory,
+ G_OBJECT (fake_renderer));
+ cell = GAIL_CELL (child);
+ renderer_cell = GAIL_RENDERER_CELL (child);
+ renderer_cell->renderer = fake_renderer;
+
+ /* Create the GtkTreeViewAccessibleCellInfo structure for this cell */
+ cell_info_new (accessible, tree_model, path, tv_col, cell);
+
+ gail_cell_initialise (cell, widget, parent, i);
- if (GTK_IS_CELL_RENDERER_TEXT (renderer))
- g_object_get (G_OBJECT (renderer), "editable", &editable, NULL);
+ cell->refresh_index = refresh_cell_index;
- default_registry = atk_get_default_registry ();
- factory = atk_registry_get_factory (default_registry,
- G_OBJECT_TYPE (renderer));
- child = atk_object_factory_create_accessible (factory,
- G_OBJECT (renderer));
- cell = GAIL_CELL (child);
- renderer_cell = GAIL_RENDERER_CELL (child);
+ /* Set state if it is expandable */
+ if (is_expander)
+ {
+ set_cell_expandable (cell);
+ if (is_expanded)
+ gail_cell_add_state (cell, ATK_STATE_EXPANDED, FALSE);
+ }
+ }
+ else
+ {
+ for (l = renderer_list; l; l = l->next)
+ {
+ renderer = GTK_CELL_RENDERER (l->data);
- /* Create the GailTreeViewCellInfo structure for this cell */
- cell_info_new (gailview, tree_model, path, tv_col, cell);
+ if (GTK_IS_CELL_RENDERER_TEXT (renderer))
+ g_object_get (G_OBJECT (renderer), "editable", &editable, NULL);
- gail_cell_initialise (cell,
- widget, parent,
- i);
+ default_registry = atk_get_default_registry ();
+ factory = atk_registry_get_factory (default_registry,
+ G_OBJECT_TYPE (renderer));
+ child = atk_object_factory_create_accessible (factory,
+ G_OBJECT (renderer));
+ cell = GAIL_CELL (child);
+ renderer_cell = GAIL_RENDERER_CELL (child);
- if (container)
- gail_container_cell_add_child (container, cell);
- else
- cell->refresh_index = refresh_cell_index;
+ /* Create the GtkTreeViewAccessibleCellInfo for this cell */
+ cell_info_new (accessible, tree_model, path, tv_col, cell);
- update_cell_value (renderer_cell, gailview, FALSE);
- /* Add the actions appropriate for this cell */
- add_cell_actions (cell, editable);
+ gail_cell_initialise (cell, widget, parent, i);
- /* set state if it is expandable */
- if (is_expander)
- {
- set_cell_expandable (cell);
- if (is_expanded)
- gail_cell_add_state (cell,
- ATK_STATE_EXPANDED,
- FALSE);
- }
- /*
- * If the column is visible, sets the cell's state
- */
- if (gtk_tree_view_column_get_visible (tv_col))
- set_cell_visibility (tree_view, cell, tv_col, path, FALSE);
- /*
- * If the row is selected, all cells on the row are selected
- */
- selection = gtk_tree_view_get_selection (tree_view);
-
- if (gtk_tree_selection_path_is_selected (selection, path))
- gail_cell_add_state (cell, ATK_STATE_SELECTED, FALSE);
-
- gail_cell_add_state (cell, ATK_STATE_FOCUSABLE, FALSE);
- if (focus_index == i)
- {
- gailview->focus_cell = g_object_ref (cell);
- gail_cell_add_state (cell, ATK_STATE_FOCUSED, FALSE);
- g_signal_emit_by_name (gailview,
- "active-descendant-changed",
- cell);
- }
- }
- g_list_free (renderer_list);
- if (container)
- child = ATK_OBJECT (container);
- }
+ if (container)
+ gail_container_cell_add_child (container, cell);
+ else
+ cell->refresh_index = refresh_cell_index;
+
+ update_cell_value (renderer_cell, accessible, FALSE);
+
+ /* Add the actions appropriate for this cell */
+ add_cell_actions (cell, editable);
+
+ /* Set state if it is expandable */
+ if (is_expander)
+ {
+ set_cell_expandable (cell);
+ if (is_expanded)
+ gail_cell_add_state (cell, ATK_STATE_EXPANDED, FALSE);
+ }
+
+ /* If the column is visible, sets the cell's state */
+ if (gtk_tree_view_column_get_visible (tv_col))
+ set_cell_visibility (tree_view, cell, tv_col, path, FALSE);
+
+ /* If the row is selected, all cells on the row are selected */
+ selection = gtk_tree_view_get_selection (tree_view);
+
+ if (gtk_tree_selection_path_is_selected (selection, path))
+ gail_cell_add_state (cell, ATK_STATE_SELECTED, FALSE);
+
+ gail_cell_add_state (cell, ATK_STATE_FOCUSABLE, FALSE);
+ if (focus_index == i)
+ {
+ accessible->focus_cell = g_object_ref (cell);
+ gail_cell_add_state (cell, ATK_STATE_FOCUSED, FALSE);
+ g_signal_emit_by_name (accessible, "active-descendant-changed", cell);
+ }
+ }
+ g_list_free (renderer_list);
+ if (container)
+ child = ATK_OBJECT (container);
+ }
if (expander_tv == tv_col)
{
@@ -961,35 +682,33 @@ gail_tree_view_ref_child (AtkObject *obj,
{
gint parent_index;
- parent_index = get_index (tree_view, path, i % gailview->n_cols);
+ parent_index = get_index (tree_view, path, i % accessible->n_cols);
parent_node = atk_object_ref_accessible_child (obj, parent_index);
}
accessible_array[0] = parent_node;
relation = atk_relation_new (accessible_array, 1,
ATK_RELATION_NODE_CHILD_OF);
atk_relation_set_add (relation_set, relation);
- atk_object_add_relationship (parent_node, ATK_RELATION_NODE_PARENT_OF,
- child);
+ atk_object_add_relationship (parent_node, ATK_RELATION_NODE_PARENT_OF, child);
g_object_unref (relation);
g_object_unref (relation_set);
}
gtk_tree_path_free (path);
- /*
- * We do not increase the reference count here; when g_object_unref() is
- * called for the cell then cell_destroyed() is called and
- * this removes the cell from the cache.
+ /* We do not increase the reference count here; when g_object_unref()
+ * is called for the cell then cell_destroyed() is called and this
+ * removes the cell from the cache.
*/
return child;
}
static AtkStateSet*
-gail_tree_view_ref_state_set (AtkObject *obj)
+gtk_tree_view_accessible_ref_state_set (AtkObject *obj)
{
AtkStateSet *state_set;
GtkWidget *widget;
- state_set = ATK_OBJECT_CLASS (gail_tree_view_parent_class)->ref_state_set (obj);
+ state_set = ATK_OBJECT_CLASS (gtk_tree_view_accessible_parent_class)->ref_state_set (obj);
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
if (widget != NULL)
@@ -998,19 +717,90 @@ gail_tree_view_ref_state_set (AtkObject *obj)
return state_set;
}
-/* atkcomponent.h */
+static void
+gtk_tree_view_accessible_class_init (GtkTreeViewAccessibleClass *klass)
+{
+ AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+ GtkAccessibleClass *accessible_class;
+ GailWidgetClass *widget_class;
+ GailContainerClass *container_class;
+
+ accessible_class = (GtkAccessibleClass*)klass;
+ widget_class = (GailWidgetClass*)klass;
+ container_class = (GailContainerClass*)klass;
+
+ class->get_n_children = gtk_tree_view_accessible_get_n_children;
+ class->ref_child = gtk_tree_view_accessible_ref_child;
+ class->ref_state_set = gtk_tree_view_accessible_ref_state_set;
+ class->initialize = gtk_tree_view_accessible_initialize;
+
+ widget_class->notify_gtk = gtk_tree_view_accessible_notify_gtk;
+
+ accessible_class->connect_widget_destroyed = gtk_tree_view_accessible_connect_widget_destroyed;
+
+ /* The children of a GtkTreeView are the buttons at the top of the columns
+ * we do not represent these as children so we do not want to report
+ * children added or deleted when these changed.
+ */
+ container_class->add_gtk = NULL;
+ container_class->remove_gtk = NULL;
+
+ gobject_class->finalize = gtk_tree_view_accessible_finalize;
+}
static void
-atk_component_interface_init (AtkComponentIface *iface)
+gtk_tree_view_accessible_init (GtkTreeViewAccessible *view)
+{
+}
+
+gint
+get_focus_index (GtkTreeView *tree_view)
{
- iface->ref_accessible_at_point = gail_tree_view_ref_accessible_at_point;
+ GtkTreePath *focus_path;
+ GtkTreeViewColumn *focus_column;
+ gint index;
+
+ gtk_tree_view_get_cursor (tree_view, &focus_path, &focus_column);
+ if (focus_path && focus_column)
+ index = get_index (tree_view, focus_path,
+ get_column_number (tree_view, focus_column, FALSE));
+ else
+ index = -1;
+
+ if (focus_path)
+ gtk_tree_path_free (focus_path);
+
+ return index;
}
-static AtkObject*
-gail_tree_view_ref_accessible_at_point (AtkComponent *component,
- gint x,
- gint y,
- AtkCoordType coord_type)
+/* This function returns a reference to the accessible object
+ * for the cell in the treeview which has focus, if any
+ */
+AtkObject *
+gtk_tree_view_accessible_ref_focus_cell (GtkTreeView *tree_view)
+{
+ AtkObject *focus_cell = NULL;
+ AtkObject *atk_obj;
+ gint focus_index;
+
+ focus_index = get_focus_index (tree_view);
+ if (focus_index >= 0)
+ {
+ atk_obj = gtk_widget_get_accessible (GTK_WIDGET (tree_view));
+ focus_cell = atk_object_ref_accessible_child (atk_obj, focus_index);
+ }
+
+ return focus_cell;
+}
+
+/* atkcomponent.h */
+
+static AtkObject *
+gtk_tree_view_accessible_ref_accessible_at_point (AtkComponent *component,
+ gint x,
+ gint y,
+ AtkCoordType coord_type)
{
GtkWidget *widget;
GtkTreeView *tree_view;
@@ -1022,15 +812,14 @@ gail_tree_view_ref_accessible_at_point (AtkComponent *component,
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (component));
if (widget == NULL)
- /* State is defunct */
return NULL;
tree_view = GTK_TREE_VIEW (widget);
atk_component_get_extents (component, &x_pos, &y_pos, NULL, NULL, coord_type);
gtk_tree_view_convert_widget_to_bin_window_coords (tree_view, x, y, &bx, &by);
- ret_val = gtk_tree_view_get_path_at_pos (tree_view,
- bx - x_pos, by - y_pos,
+ ret_val = gtk_tree_view_get_path_at_pos (tree_view,
+ bx - x_pos, by - y_pos,
&path, &tv_column, NULL, NULL);
if (ret_val)
{
@@ -1040,41 +829,27 @@ gail_tree_view_ref_accessible_at_point (AtkComponent *component,
index = get_index (tree_view, path, column);
gtk_tree_path_free (path);
- return gail_tree_view_ref_child (ATK_OBJECT (component), index);
- }
+ return gtk_tree_view_accessible_ref_child (ATK_OBJECT (component), index);
+ }
else
{
- g_warning ("gail_tree_view_ref_accessible_at_point: gtk_tree_view_get_path_at_pos () failed\n");
+ g_warning ("gtk_tree_view_accessible_ref_accessible_at_point: gtk_tree_view_get_path_at_pos () failed\n");
}
return NULL;
}
-
-/* atktable.h */
-static void
-atk_table_interface_init (AtkTableIface *iface)
+static void
+atk_component_interface_init (AtkComponentIface *iface)
{
- iface->ref_at = gail_tree_view_table_ref_at;
- iface->get_n_rows = gail_tree_view_get_n_rows;
- iface->get_n_columns = gail_tree_view_get_n_columns;
- iface->get_index_at = gail_tree_view_get_index_at;
- iface->get_column_at_index = gail_tree_view_get_column_at_index;
- iface->get_row_at_index = gail_tree_view_get_row_at_index;
- iface->is_row_selected = gail_tree_view_is_row_selected;
- iface->is_selected = gail_tree_view_is_selected;
- iface->get_selected_rows = gail_tree_view_get_selected_rows;
- iface->add_row_selection = gail_tree_view_add_row_selection;
- iface->remove_row_selection = gail_tree_view_remove_row_selection;
- iface->get_column_extent_at = NULL;
- iface->get_row_extent_at = NULL;
- iface->get_column_header = gail_tree_view_get_column_header;
- iface->get_column_description = gail_tree_view_get_column_description;
+ iface->ref_accessible_at_point = gtk_tree_view_accessible_ref_accessible_at_point;
}
+/* atktable.h */
+
static gint
-gail_tree_view_get_index_at (AtkTable *table,
- gint row,
- gint column)
+gtk_tree_view_accessible_get_index_at (AtkTable *table,
+ gint row,
+ gint column)
{
GtkWidget *widget;
GtkTreeView *tree_view;
@@ -1084,16 +859,14 @@ gail_tree_view_get_index_at (AtkTable *table,
GtkTreePath *path;
gint index;
+ widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (table));
+ if (widget == NULL)
+ return -1;
+
n_cols = atk_table_get_n_columns (table);
n_rows = atk_table_get_n_rows (table);
- if (row >= n_rows ||
- column >= n_cols)
- return -1;
-
- widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (table));
- if (widget == NULL)
- /* State is defunct */
+ if (row >= n_rows || column >= n_cols)
return -1;
tree_view = GTK_TREE_VIEW (widget);
@@ -1109,8 +882,8 @@ gail_tree_view_get_index_at (AtkTable *table,
}
static gint
-gail_tree_view_get_column_at_index (AtkTable *table,
- gint index)
+gtk_tree_view_accessible_get_column_at_index (AtkTable *table,
+ gint index)
{
GtkWidget *widget;
GtkTreeView *tree_view;
@@ -1118,22 +891,22 @@ gail_tree_view_get_column_at_index (AtkTable *table,
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (table));
if (widget == NULL)
- /* State is defunct */
return -1;
tree_view = GTK_TREE_VIEW (widget);
- n_columns = GAIL_TREE_VIEW (table)->n_cols;
+ n_columns = GTK_TREE_VIEW_ACCESSIBLE (table)->n_cols;
if (n_columns == 0)
return 0;
+
index = index % n_columns;
return get_visible_column_number (tree_view, index);
}
static gint
-gail_tree_view_get_row_at_index (AtkTable *table,
- gint index)
+gtk_tree_view_accessible_get_row_at_index (AtkTable *table,
+ gint index)
{
GtkWidget *widget;
GtkTreeView *tree_view;
@@ -1141,7 +914,6 @@ gail_tree_view_get_row_at_index (AtkTable *table,
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (table));
if (widget == NULL)
- /* State is defunct */
return -1;
tree_view = GTK_TREE_VIEW (widget);
@@ -1155,22 +927,22 @@ gail_tree_view_get_row_at_index (AtkTable *table,
return -1;
}
-static AtkObject*
-gail_tree_view_table_ref_at (AtkTable *table,
- gint row,
- gint column)
+static AtkObject *
+gtk_tree_view_accessible_table_ref_at (AtkTable *table,
+ gint row,
+ gint column)
{
gint index;
- index = gail_tree_view_get_index_at (table, row, column);
+ index = gtk_tree_view_accessible_get_index_at (table, row, column);
if (index == -1)
return NULL;
-
- return gail_tree_view_ref_child (ATK_OBJECT (table), index);
+
+ return gtk_tree_view_accessible_ref_child (ATK_OBJECT (table), index);
}
-static gint
-gail_tree_view_get_n_rows (AtkTable *table)
+static gint
+gtk_tree_view_accessible_get_n_rows (AtkTable *table)
{
GtkWidget *widget;
GtkTreeView *tree_view;
@@ -1179,7 +951,6 @@ gail_tree_view_get_n_rows (AtkTable *table)
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (table));
if (widget == NULL)
- /* State is defunct */
return 0;
tree_view = GTK_TREE_VIEW (widget);
@@ -1188,10 +959,8 @@ gail_tree_view_get_n_rows (AtkTable *table)
if (!tree_model)
n_rows = 0;
else if (gtk_tree_model_get_flags (tree_model) & GTK_TREE_MODEL_LIST_ONLY)
- /*
- * If working with a LIST store, then no rows are collapsed
- */
- n_rows = GAIL_TREE_VIEW (table)->n_rows;
+ /* No collapsed rows in a list store */
+ n_rows = GTK_TREE_VIEW_ACCESSIBLE (table)->n_rows;
else
{
GtkTreePath *root_tree;
@@ -1207,7 +976,7 @@ gail_tree_view_get_n_rows (AtkTable *table)
}
static gint
-gail_tree_view_get_n_columns (AtkTable *table)
+gtk_tree_view_accessible_get_n_columns (AtkTable *table)
{
GtkWidget *widget;
GtkTreeView *tree_view;
@@ -1217,15 +986,14 @@ gail_tree_view_get_n_columns (AtkTable *table)
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (table));
if (widget == NULL)
- /* State is defunct */
return 0;
tree_view = GTK_TREE_VIEW (widget);
tv_col = gtk_tree_view_get_column (tree_view, i);
- while (tv_col != NULL)
+ while (tv_col != NULL)
{
- if (gtk_tree_view_column_get_visible (tv_col))
+ if (gtk_tree_view_column_get_visible (tv_col))
n_cols++;
i++;
@@ -1235,9 +1003,9 @@ gail_tree_view_get_n_columns (AtkTable *table)
return n_cols;
}
-static gboolean
-gail_tree_view_is_row_selected (AtkTable *table,
- gint row)
+static gboolean
+gtk_tree_view_accessible_is_row_selected (AtkTable *table,
+ gint row)
{
GtkWidget *widget;
GtkTreeView *tree_view;
@@ -1246,32 +1014,40 @@ gail_tree_view_is_row_selected (AtkTable *table,
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (table));
if (widget == NULL)
- /* State is defunct */
return FALSE;
if (row < 0)
return FALSE;
tree_view = GTK_TREE_VIEW (widget);
-
selection = gtk_tree_view_get_selection (tree_view);
set_iter_nth_row (tree_view, &iter, row);
-
return gtk_tree_selection_iter_is_selected (selection, &iter);
}
-static gboolean
-gail_tree_view_is_selected (AtkTable *table,
- gint row,
- gint column)
+static gboolean
+gtk_tree_view_accessible_is_selected (AtkTable *table,
+ gint row,
+ gint column)
+{
+ return gtk_tree_view_accessible_is_row_selected (table, row);
+}
+
+static void
+get_selected_rows (GtkTreeModel *model,
+ GtkTreePath *path,
+ GtkTreeIter *iter,
+ gpointer data)
{
- return gail_tree_view_is_row_selected (table, row);
+ GPtrArray *array = (GPtrArray *)data;
+
+ g_ptr_array_add (array, gtk_tree_path_copy (path));
}
-static gint
-gail_tree_view_get_selected_rows (AtkTable *table,
- gint **rows_selected)
+static gint
+gtk_tree_view_accessible_get_selected_rows (AtkTable *table,
+ gint **rows_selected)
{
GtkWidget *widget;
GtkTreeView *tree_view;
@@ -1283,11 +1059,9 @@ gail_tree_view_get_selected_rows (AtkTable *table,
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (table));
if (widget == NULL)
- /* State is defunct */
return 0;
tree_view = GTK_TREE_VIEW (widget);
-
selection = gtk_tree_view_get_selection (tree_view);
switch (gtk_tree_selection_get_mode (selection))
@@ -1300,7 +1074,7 @@ gail_tree_view_get_selected_rows (AtkTable *table,
if (rows_selected)
{
- *rows_selected = (gint *)g_malloc (sizeof(gint));
+ *rows_selected = g_new (gint, 1);
tree_path = gtk_tree_model_get_path (tree_model, &iter);
row = get_row_from_tree_path (tree_view, tree_path);
gtk_tree_path_free (tree_path);
@@ -1317,16 +1091,14 @@ gail_tree_view_get_selected_rows (AtkTable *table,
{
GPtrArray *array = g_ptr_array_new();
- gtk_tree_selection_selected_foreach (selection,
- get_selected_rows,
- array);
+ gtk_tree_selection_selected_foreach (selection, get_selected_rows, array);
ret_val = array->len;
if (rows_selected && ret_val)
{
gint i;
- *rows_selected = (gint *) g_malloc (ret_val * sizeof (gint));
+ *rows_selected = g_new (gint, ret_val);
for (i = 0; i < ret_val; i++)
{
gint row;
@@ -1341,14 +1113,14 @@ gail_tree_view_get_selected_rows (AtkTable *table,
}
break;
case GTK_SELECTION_NONE:
- break;
+ break;
}
return ret_val;
}
-static gboolean
-gail_tree_view_add_row_selection (AtkTable *table,
- gint row)
+static gboolean
+gtk_tree_view_accessible_add_row_selection (AtkTable *table,
+ gint row)
{
GtkWidget *widget;
GtkTreeView *tree_view;
@@ -1359,10 +1131,9 @@ gail_tree_view_add_row_selection (AtkTable *table,
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (table));
if (widget == NULL)
- /* State is defunct */
return FALSE;
-
- if (!gail_tree_view_is_row_selected (table, row))
+
+ if (!gtk_tree_view_accessible_is_row_selected (table, row))
{
tree_view = GTK_TREE_VIEW (widget);
tree_model = gtk_tree_view_get_model (tree_view);
@@ -1376,18 +1147,18 @@ gail_tree_view_add_row_selection (AtkTable *table,
gtk_tree_path_free (tree_path);
}
else
- {
+ {
set_iter_nth_row (tree_view, &iter_to_row, row);
gtk_tree_selection_select_iter (selection, &iter_to_row);
}
}
- return gail_tree_view_is_row_selected (table, row);
+ return gtk_tree_view_accessible_is_row_selected (table, row);
}
-static gboolean
-gail_tree_view_remove_row_selection (AtkTable *table,
- gint row)
+static gboolean
+gtk_tree_view_accessible_remove_row_selection (AtkTable *table,
+ gint row)
{
GtkWidget *widget;
GtkTreeView *tree_view;
@@ -1395,24 +1166,23 @@ gail_tree_view_remove_row_selection (AtkTable *table,
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (table));
if (widget == NULL)
- /* State is defunct */
return FALSE;
tree_view = GTK_TREE_VIEW (widget);
-
selection = gtk_tree_view_get_selection (tree_view);
- if (gail_tree_view_is_row_selected (table, row))
+ if (gtk_tree_view_accessible_is_row_selected (table, row))
{
gtk_tree_selection_unselect_all (selection);
return TRUE;
}
- else return FALSE;
+
+ return FALSE;
}
-static AtkObject*
-gail_tree_view_get_column_header (AtkTable *table,
- gint in_col)
+static AtkObject *
+gtk_tree_view_accessible_get_column_header (AtkTable *table,
+ gint in_col)
{
GtkWidget *widget;
GtkTreeView *tree_view;
@@ -1420,7 +1190,6 @@ gail_tree_view_get_column_header (AtkTable *table,
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (table));
if (widget == NULL)
- /* State is defunct */
return NULL;
tree_view = GTK_TREE_VIEW (widget);
@@ -1428,18 +1197,16 @@ gail_tree_view_get_column_header (AtkTable *table,
return get_header_from_column (tv_col);
}
-static const gchar*
-gail_tree_view_get_column_description (AtkTable *table,
- gint in_col)
+static const gchar *
+gtk_tree_view_accessible_get_column_description (AtkTable *table,
+ gint in_col)
{
GtkWidget *widget;
GtkTreeView *tree_view;
GtkTreeViewColumn *tv_col;
- gchar *title_text;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (table));
if (widget == NULL)
- /* State is defunct */
return NULL;
tree_view = GTK_TREE_VIEW (widget);
@@ -1447,40 +1214,50 @@ gail_tree_view_get_column_description (AtkTable *table,
if (tv_col == NULL)
return NULL;
- g_object_get (tv_col, "title", &title_text, NULL);
- return title_text;
+ return gtk_tree_view_column_get_title (tv_col);
}
-/* atkselection.h */
-
-static void atk_selection_interface_init (AtkSelectionIface *iface)
+static void
+atk_table_interface_init (AtkTableIface *iface)
{
- iface->add_selection = gail_tree_view_add_selection;
- iface->clear_selection = gail_tree_view_clear_selection;
- iface->ref_selection = gail_tree_view_ref_selection;
- iface->get_selection_count = gail_tree_view_get_selection_count;
- iface->is_child_selected = gail_tree_view_is_child_selected;
+ iface->ref_at = gtk_tree_view_accessible_table_ref_at;
+ iface->get_n_rows = gtk_tree_view_accessible_get_n_rows;
+ iface->get_n_columns = gtk_tree_view_accessible_get_n_columns;
+ iface->get_index_at = gtk_tree_view_accessible_get_index_at;
+ iface->get_column_at_index = gtk_tree_view_accessible_get_column_at_index;
+ iface->get_row_at_index = gtk_tree_view_accessible_get_row_at_index;
+ iface->is_row_selected = gtk_tree_view_accessible_is_row_selected;
+ iface->is_selected = gtk_tree_view_accessible_is_selected;
+ iface->get_selected_rows = gtk_tree_view_accessible_get_selected_rows;
+ iface->add_row_selection = gtk_tree_view_accessible_add_row_selection;
+ iface->remove_row_selection = gtk_tree_view_accessible_remove_row_selection;
+ iface->get_column_extent_at = NULL;
+ iface->get_row_extent_at = NULL;
+ iface->get_column_header = gtk_tree_view_accessible_get_column_header;
+ iface->get_column_description = gtk_tree_view_accessible_get_column_description;
}
+/* atkselection.h */
+
static gboolean
-gail_tree_view_add_selection (AtkSelection *selection,
- gint i)
+gtk_tree_view_accessible_add_selection (AtkSelection *selection,
+ gint i)
{
AtkTable *table;
gint n_columns;
gint row;
table = ATK_TABLE (selection);
- n_columns = gail_tree_view_get_n_columns (table);
+ n_columns = gtk_tree_view_accessible_get_n_columns (table);
if (n_columns != 1)
return FALSE;
- row = gail_tree_view_get_row_at_index (table, i);
- return gail_tree_view_add_row_selection (table, row);
+ row = gtk_tree_view_accessible_get_row_at_index (table, i);
+ return gtk_tree_view_accessible_add_row_selection (table, row);
}
static gboolean
-gail_tree_view_clear_selection (AtkSelection *selection)
+gtk_tree_view_accessible_clear_selection (AtkSelection *selection)
{
GtkWidget *widget;
GtkTreeView *tree_view;
@@ -1488,20 +1265,18 @@ gail_tree_view_clear_selection (AtkSelection *selection)
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (selection));
if (widget == NULL)
- /* State is defunct */
return FALSE;
-
- tree_view = GTK_TREE_VIEW (widget);
+ tree_view = GTK_TREE_VIEW (widget);
tree_selection = gtk_tree_view_get_selection (tree_view);
- gtk_tree_selection_unselect_all (tree_selection);
+ gtk_tree_selection_unselect_all (tree_selection);
return TRUE;
}
-static AtkObject*
-gail_tree_view_ref_selection (AtkSelection *selection,
- gint i)
+static AtkObject *
+gtk_tree_view_accessible_ref_selection (AtkSelection *selection,
+ gint i)
{
AtkTable *table;
gint row;
@@ -1510,140 +1285,86 @@ gail_tree_view_ref_selection (AtkSelection *selection,
gint *selected;
table = ATK_TABLE (selection);
- n_columns = gail_tree_view_get_n_columns (table);
- n_selected = gail_tree_view_get_selected_rows (table, &selected);
+ n_columns = gtk_tree_view_accessible_get_n_columns (table);
+ n_selected = gtk_tree_view_accessible_get_selected_rows (table, &selected);
if (i >= n_columns * n_selected)
return NULL;
row = selected[i / n_columns];
g_free (selected);
- return gail_tree_view_table_ref_at (table, row, i % n_columns);
+ return gtk_tree_view_accessible_table_ref_at (table, row, i % n_columns);
}
static gint
-gail_tree_view_get_selection_count (AtkSelection *selection)
+gtk_tree_view_accessible_get_selection_count (AtkSelection *selection)
{
AtkTable *table;
gint n_selected;
table = ATK_TABLE (selection);
- n_selected = gail_tree_view_get_selected_rows (table, NULL);
+ n_selected = gtk_tree_view_accessible_get_selected_rows (table, NULL);
if (n_selected > 0)
- n_selected *= gail_tree_view_get_n_columns (table);
+ n_selected *= gtk_tree_view_accessible_get_n_columns (table);
return n_selected;
}
static gboolean
-gail_tree_view_is_child_selected (AtkSelection *selection,
- gint i)
+gtk_tree_view_accessible_is_child_selected (AtkSelection *selection,
+ gint i)
{
GtkWidget *widget;
gint row;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (selection));
if (widget == NULL)
- /* State is defunct */
return FALSE;
row = atk_table_get_row_at_index (ATK_TABLE (selection), i);
- return gail_tree_view_is_row_selected (ATK_TABLE (selection), row);
+ return gtk_tree_view_accessible_is_row_selected (ATK_TABLE (selection), row);
}
-
-static void gail_cell_parent_interface_init (GailCellParentIface *iface)
+static void atk_selection_interface_init (AtkSelectionIface *iface)
{
- iface->get_cell_extents = gail_tree_view_get_cell_extents;
- iface->get_cell_area = gail_tree_view_get_cell_area;
- iface->grab_focus = gail_tree_view_grab_cell_focus;
-}
-
-static void
-gail_tree_view_get_cell_extents (GailCellParent *parent,
- GailCell *cell,
- gint *x,
- gint *y,
- gint *width,
- gint *height,
- AtkCoordType coord_type)
-{
- GtkWidget *widget;
- GtkTreeView *tree_view;
- GdkWindow *bin_window;
- GdkRectangle cell_rect;
- gint w_x, w_y;
-
- widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (parent));
- if (widget == NULL)
- /* State is defunct */
- return;
-
- tree_view = GTK_TREE_VIEW (widget);
- gail_tree_view_get_cell_area (parent, cell, &cell_rect);
- bin_window = gtk_tree_view_get_bin_window (tree_view);
- gdk_window_get_origin (bin_window, &w_x, &w_y);
-
- if (coord_type == ATK_XY_WINDOW)
- {
- GdkWindow *window;
- gint x_toplevel, y_toplevel;
-
- window = gdk_window_get_toplevel (bin_window);
- gdk_window_get_origin (window, &x_toplevel, &y_toplevel);
-
- w_x -= x_toplevel;
- w_y -= y_toplevel;
- }
-
- *width = cell_rect.width;
- *height = cell_rect.height;
- if (is_cell_showing (tree_view, &cell_rect))
- {
- *x = cell_rect.x + w_x;
- *y = cell_rect.y + w_y;
- }
- else
- {
- *x = G_MININT;
- *y = G_MININT;
- }
+ iface->add_selection = gtk_tree_view_accessible_add_selection;
+ iface->clear_selection = gtk_tree_view_accessible_clear_selection;
+ iface->ref_selection = gtk_tree_view_accessible_ref_selection;
+ iface->get_selection_count = gtk_tree_view_accessible_get_selection_count;
+ iface->is_child_selected = gtk_tree_view_accessible_is_child_selected;
}
#define EXTRA_EXPANDER_PADDING 4
static void
-gail_tree_view_get_cell_area (GailCellParent *parent,
- GailCell *cell,
- GdkRectangle *cell_rect)
+gtk_tree_view_accessible_get_cell_area (GailCellParent *parent,
+ GailCell *cell,
+ GdkRectangle *cell_rect)
{
GtkWidget *widget;
GtkTreeView *tree_view;
GtkTreeViewColumn *tv_col;
GtkTreePath *path;
AtkObject *parent_cell;
- GailTreeViewCellInfo *cell_info;
+ GtkTreeViewAccessibleCellInfo *cell_info;
GailCell *top_cell;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (parent));
if (widget == NULL)
- /* State is defunct */
return;
tree_view = GTK_TREE_VIEW (widget);
parent_cell = atk_object_get_parent (ATK_OBJECT (cell));
if (parent_cell != ATK_OBJECT (parent))
{
- /*
- * GailCell is in a GailContainerCell
- */
+ /* GailCell is in a GailContainerCell */
top_cell = GAIL_CELL (parent_cell);
}
else
{
top_cell = cell;
}
- cell_info = find_cell_info (GAIL_TREE_VIEW (parent), top_cell, TRUE);
+ cell_info = find_cell_info (GTK_TREE_VIEW_ACCESSIBLE (parent), top_cell, TRUE);
if (!cell_info || !cell_info->cell_col_ref || !cell_info->cell_row_ref)
return;
path = gtk_tree_row_reference_get_path (cell_info->cell_row_ref);
@@ -1658,11 +1379,9 @@ gail_tree_view_get_cell_area (GailCellParent *parent,
if (expander_column == tv_col)
{
gint expander_size;
-
gtk_widget_style_get (widget,
"expander_size", &expander_size,
NULL);
-
cell_rect->x += expander_size + EXTRA_EXPANDER_PADDING;
cell_rect->width -= expander_size + EXTRA_EXPANDER_PADDING;
}
@@ -1671,13 +1390,12 @@ gail_tree_view_get_cell_area (GailCellParent *parent,
NULL);
cell_rect->x += focus_line_width;
- cell_rect->width -= 2 * focus_line_width;
+ cell_rect->width -= 2 * focus_line_width;
gtk_tree_path_free (path);
- /*
- * A column has more than one renderer so we find the position and width
- * of each.
+ /* A column has more than one renderer so we find the position
+ * and width of each
*/
if (top_cell != cell)
{
@@ -1688,25 +1406,75 @@ gail_tree_view_get_cell_area (GailCellParent *parent,
GList *renderers;
GtkCellRenderer *renderer;
- cell_index = atk_object_get_index_in_parent (ATK_OBJECT (cell));
- renderers = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (tv_col));
- renderer = g_list_nth_data (renderers, cell_index);
+ cell_index = atk_object_get_index_in_parent (ATK_OBJECT (cell));
+ renderers = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (tv_col));
+ renderer = g_list_nth_data (renderers, cell_index);
- found = gtk_tree_view_column_cell_get_position (tv_col, renderer, &cell_start, &cell_width);
+ found = gtk_tree_view_column_cell_get_position (tv_col, renderer, &cell_start, &cell_width);
if (found)
{
cell_rect->x += cell_start;
cell_rect->width = cell_width;
}
- g_list_free (renderers);
- }
+ g_list_free (renderers);
+ }
}
}
+static void
+gtk_tree_view_accessible_get_cell_extents (GailCellParent *parent,
+ GailCell *cell,
+ gint *x,
+ gint *y,
+ gint *width,
+ gint *height,
+ AtkCoordType coord_type)
+{
+ GtkWidget *widget;
+ GtkTreeView *tree_view;
+ GdkWindow *bin_window;
+ GdkRectangle cell_rect;
+ gint w_x, w_y;
+
+ widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (parent));
+ if (widget == NULL)
+ return;
+
+ tree_view = GTK_TREE_VIEW (widget);
+ gtk_tree_view_accessible_get_cell_area (parent, cell, &cell_rect);
+ bin_window = gtk_tree_view_get_bin_window (tree_view);
+ gdk_window_get_origin (bin_window, &w_x, &w_y);
+
+ if (coord_type == ATK_XY_WINDOW)
+ {
+ GdkWindow *window;
+ gint x_toplevel, y_toplevel;
+
+ window = gdk_window_get_toplevel (bin_window);
+ gdk_window_get_origin (window, &x_toplevel, &y_toplevel);
+
+ w_x -= x_toplevel;
+ w_y -= y_toplevel;
+ }
+
+ *width = cell_rect.width;
+ *height = cell_rect.height;
+ if (is_cell_showing (tree_view, &cell_rect))
+ {
+ *x = cell_rect.x + w_x;
+ *y = cell_rect.y + w_y;
+ }
+ else
+ {
+ *x = G_MININT;
+ *y = G_MININT;
+ }
+}
+
static gboolean
-gail_tree_view_grab_cell_focus (GailCellParent *parent,
- GailCell *cell)
+gtk_tree_view_accessible_grab_cell_focus (GailCellParent *parent,
+ GailCell *cell)
{
GtkWidget *widget;
GtkTreeView *tree_view;
@@ -1714,19 +1482,18 @@ gail_tree_view_grab_cell_focus (GailCellParent *parent,
GtkTreePath *path;
AtkObject *parent_cell;
AtkObject *cell_object;
- GailTreeViewCellInfo *cell_info;
+ GtkTreeViewAccessibleCellInfo *cell_info;
GtkCellRenderer *renderer = NULL;
GtkWidget *toplevel;
gint index;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (parent));
if (widget == NULL)
- /* State is defunct */
return FALSE;
tree_view = GTK_TREE_VIEW (widget);
- cell_info = find_cell_info (GAIL_TREE_VIEW (parent), cell, TRUE);
+ cell_info = find_cell_info (GTK_TREE_VIEW_ACCESSIBLE (parent), cell, TRUE);
if (!cell_info || !cell_info->cell_col_ref || !cell_info->cell_row_ref)
return FALSE;
cell_object = ATK_OBJECT (cell);
@@ -1734,18 +1501,18 @@ gail_tree_view_grab_cell_focus (GailCellParent *parent,
tv_col = cell_info->cell_col_ref;
if (parent_cell != ATK_OBJECT (parent))
{
- /*
- * GailCell is in a GailContainerCell.
- * The GtkTreeViewColumn has multiple renderers;
+ /* GailCell is in a GailContainerCell.
+ * The GtkTreeViewColumn has multiple renderers;
* find the corresponding one.
*/
GList *renderers;
renderers = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (tv_col));
- if (cell_info->in_use) {
- index = atk_object_get_index_in_parent (cell_object);
- renderer = g_list_nth_data (renderers, index);
- }
+ if (cell_info->in_use)
+ {
+ index = atk_object_get_index_in_parent (cell_object);
+ renderer = g_list_nth_data (renderers, index);
+ }
g_list_free (renderers);
}
path = gtk_tree_row_reference_get_path (cell_info->cell_row_ref);
@@ -1760,93 +1527,67 @@ gail_tree_view_grab_cell_focus (GailCellParent *parent,
gtk_widget_grab_focus (widget);
toplevel = gtk_widget_get_toplevel (widget);
if (gtk_widget_is_toplevel (toplevel))
- {
+ {
#ifdef GDK_WINDOWING_X11
- gtk_window_present_with_time (GTK_WINDOW (toplevel),
+ gtk_window_present_with_time (GTK_WINDOW (toplevel),
gdk_x11_get_server_time (gtk_widget_get_window (widget)));
#else
- gtk_window_present (GTK_WINDOW (toplevel));
+ gtk_window_present (GTK_WINDOW (toplevel));
#endif
- }
+ }
return TRUE;
}
else
- return FALSE;
+ return FALSE;
}
-/* signal handling */
-
-static gboolean
-gail_tree_view_expand_row_gtk (GtkTreeView *tree_view,
- GtkTreeIter *iter,
- GtkTreePath *path)
+static void gail_cell_parent_interface_init (GailCellParentIface *iface)
{
- AtkObject *atk_obj;
- GailTreeView *gailview;
-
- g_assert (GTK_IS_TREE_VIEW (tree_view));
-
- atk_obj = gtk_widget_get_accessible (GTK_WIDGET (tree_view));
-
- g_assert (GAIL_IS_TREE_VIEW (atk_obj));
-
- gailview = GAIL_TREE_VIEW (atk_obj);
-
- /*
- * The visible rectangle has not been updated when this signal is emitted
- * so we process the signal when the GTK processing is completed
- */
- /* this seems wrong since it overwrites any other pending expand handlers... */
- gailview->idle_expand_path = gtk_tree_path_copy (path);
- if (gailview->idle_expand_id)
- g_source_remove (gailview->idle_expand_id);
- gailview->idle_expand_id = gdk_threads_add_idle (idle_expand_row, gailview);
- return FALSE;
+ iface->get_cell_extents = gtk_tree_view_accessible_get_cell_extents;
+ iface->get_cell_area = gtk_tree_view_accessible_get_cell_area;
+ iface->grab_focus = gtk_tree_view_accessible_grab_cell_focus;
}
-static gint
+/* signal handling */
+
+static gboolean
idle_expand_row (gpointer data)
{
- GailTreeView *gailview = data;
+ GtkTreeViewAccessible *accessible = data;
GtkTreePath *path;
GtkTreeView *tree_view;
GtkTreeIter iter;
GtkTreeModel *tree_model;
gint n_inserted, row;
- gailview->idle_expand_id = 0;
-
- path = gailview->idle_expand_path;
- tree_view = GTK_TREE_VIEW (gtk_accessible_get_widget (GTK_ACCESSIBLE (gailview)));
+ accessible->idle_expand_id = 0;
- g_assert (GTK_IS_TREE_VIEW (tree_view));
+ path = accessible->idle_expand_path;
+ tree_view = GTK_TREE_VIEW (gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible)));
- tree_model = gtk_tree_view_get_model(tree_view);
+ tree_model = gtk_tree_view_get_model (tree_view);
if (!tree_model)
return FALSE;
if (!path || !gtk_tree_model_get_iter (tree_model, &iter, path))
return FALSE;
- /*
- * Update visibility of cells below expansion row
- */
- traverse_cells (gailview, path, FALSE, FALSE);
- /*
- * Figure out number of visible children, the following test
+ /* Update visibility of cells below expansion row */
+ traverse_cells (accessible, path, FALSE, FALSE);
+
+ /* Figure out number of visible children, the following test
* should not fail
*/
if (gtk_tree_model_iter_has_child (tree_model, &iter))
{
GtkTreePath *path_copy;
- /*
- * By passing path into this function, we find the number of
- * visible children of path.
- */
+ /* By passing path into this function, we find the number of
+ * visible children of path.
+ */
path_copy = gtk_tree_path_copy (path);
- gtk_tree_path_append_index(path_copy, 0);
+ gtk_tree_path_append_index (path_copy, 0);
n_inserted = 0;
iterate_thru_children (tree_view, tree_model,
@@ -1860,7 +1601,7 @@ idle_expand_row (gpointer data)
}
/* Set expand state */
- set_expand_state (tree_view, tree_model, gailview, path, TRUE);
+ set_expand_state (tree_view, tree_model, accessible, path, TRUE);
row = get_row_from_tree_path (tree_view, path);
@@ -1870,10 +1611,10 @@ idle_expand_row (gpointer data)
/* Must add 1 because the "added rows" are below the row being expanded */
row += 1;
-
- g_signal_emit_by_name (gailview, "row_inserted", row, n_inserted);
- gailview->idle_expand_path = NULL;
+ g_signal_emit_by_name (accessible, "row_inserted", row, n_inserted);
+
+ accessible->idle_expand_path = NULL;
gtk_tree_path_free (path);
@@ -1881,98 +1622,122 @@ idle_expand_row (gpointer data)
}
static gboolean
-gail_tree_view_collapse_row_gtk (GtkTreeView *tree_view,
- GtkTreeIter *iter,
- GtkTreePath *path)
+row_expanded_cb (GtkTreeView *tree_view,
+ GtkTreeIter *iter,
+ GtkTreePath *path)
+{
+ AtkObject *atk_obj;
+ GtkTreeViewAccessible *accessible;
+
+ atk_obj = gtk_widget_get_accessible (GTK_WIDGET (tree_view));
+ accessible = GTK_TREE_VIEW_ACCESSIBLE (atk_obj);
+
+ /*
+ * The visible rectangle has not been updated when this signal is emitted
+ * so we process the signal when the GTK processing is completed
+ */
+ /* this seems wrong since it overwrites any other pending expand handlers... */
+ accessible->idle_expand_path = gtk_tree_path_copy (path);
+ if (accessible->idle_expand_id)
+ g_source_remove (accessible->idle_expand_id);
+ accessible->idle_expand_id = gdk_threads_add_idle (idle_expand_row, accessible);
+
+ return FALSE;
+}
+
+static gboolean
+row_collapsed_cb (GtkTreeView *tree_view,
+ GtkTreeIter *iter,
+ GtkTreePath *path)
{
GtkTreeModel *tree_model;
- AtkObject *atk_obj = gtk_widget_get_accessible (GTK_WIDGET (tree_view));
- GailTreeView *gailview = GAIL_TREE_VIEW (atk_obj);
+ AtkObject *atk_obj;
+ GtkTreeViewAccessible *accessible;
gint row;
+ atk_obj = gtk_widget_get_accessible (GTK_WIDGET (tree_view));
+ accessible = GTK_TREE_VIEW_ACCESSIBLE (atk_obj);
tree_model = gtk_tree_view_get_model (tree_view);
- clean_rows (gailview);
+ clean_rows (accessible);
+
+ /* Update visibility of cells below collapsed row */
+ traverse_cells (accessible, path, FALSE, FALSE);
- /*
- * Update visibility of cells below collapsed row
- */
- traverse_cells (gailview, path, FALSE, FALSE);
/* Set collapse state */
- set_expand_state (tree_view, tree_model, gailview, path, FALSE);
- if (gailview->n_children_deleted == 0)
+ set_expand_state (tree_view, tree_model, accessible, path, FALSE);
+ if (accessible->n_children_deleted == 0)
return FALSE;
row = get_row_from_tree_path (tree_view, path);
if (row == -1)
return FALSE;
- g_signal_emit_by_name (atk_obj, "row_deleted", row,
- gailview->n_children_deleted);
- gailview->n_children_deleted = 0;
+ g_signal_emit_by_name (atk_obj, "row_deleted", row,
+ accessible->n_children_deleted);
+ accessible->n_children_deleted = 0;
return FALSE;
}
static void
-gail_tree_view_size_allocate_gtk (GtkWidget *widget,
- GtkAllocation *allocation)
+size_allocate_cb (GtkWidget *widget,
+ GtkAllocation *allocation)
{
- AtkObject *atk_obj = gtk_widget_get_accessible (widget);
- GailTreeView *gailview = GAIL_TREE_VIEW (atk_obj);
+ AtkObject *atk_obj;
+ GtkTreeViewAccessible *accessible;
- /*
- * If the size allocation changes, the visibility of cells may change so
- * update the cells visibility.
+ atk_obj = gtk_widget_get_accessible (widget);
+ accessible = GTK_TREE_VIEW_ACCESSIBLE (atk_obj);
+
+ /* If the size allocation changes, the visibility of cells
+ * may change so update the cells visibility.
*/
- traverse_cells (gailview, NULL, FALSE, FALSE);
+ traverse_cells (accessible, NULL, FALSE, FALSE);
}
static void
-gail_tree_view_changed_gtk (GtkTreeSelection *selection,
- gpointer data)
+selection_changed_cb (GtkTreeSelection *selection,
+ gpointer data)
{
- GailTreeView *gailview;
+ GtkTreeViewAccessible *accessible;
GtkTreeView *tree_view;
GtkWidget *widget;
- GailTreeViewCellInfo *info;
+ GtkTreeViewAccessibleCellInfo *info;
GtkTreeSelection *tree_selection;
GtkTreePath *path;
GHashTableIter iter;
- gailview = GAIL_TREE_VIEW (data);
- widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (gailview));
+ accessible = GTK_TREE_VIEW_ACCESSIBLE (data);
+ widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible));
if (widget == NULL)
- /*
- * destroy signal emitted for widget
- */
return;
- tree_view = GTK_TREE_VIEW (widget);
+ tree_view = GTK_TREE_VIEW (widget);
tree_selection = gtk_tree_view_get_selection (tree_view);
- clean_rows (gailview);
+ clean_rows (accessible);
/* FIXME: clean rows iterates through all cells too */
- g_hash_table_iter_init (&iter, gailview->cell_info_by_index);
+ g_hash_table_iter_init (&iter, accessible->cell_info_by_index);
while (g_hash_table_iter_next (&iter, NULL, (gpointer *)&info))
{
if (info->in_use)
- {
- gail_cell_remove_state (info->cell, ATK_STATE_SELECTED, TRUE);
-
- path = gtk_tree_row_reference_get_path (info->cell_row_ref);
- if (path && gtk_tree_selection_path_is_selected (tree_selection, path))
- gail_cell_add_state (info->cell, ATK_STATE_SELECTED, TRUE);
- gtk_tree_path_free (path);
- }
+ {
+ gail_cell_remove_state (info->cell, ATK_STATE_SELECTED, TRUE);
+
+ path = gtk_tree_row_reference_get_path (info->cell_row_ref);
+ if (path && gtk_tree_selection_path_is_selected (tree_selection, path))
+ gail_cell_add_state (info->cell, ATK_STATE_SELECTED, TRUE);
+ gtk_tree_path_free (path);
+ }
}
if (gtk_widget_get_realized (widget))
- g_signal_emit_by_name (gailview, "selection_changed");
+ g_signal_emit_by_name (accessible, "selection_changed");
}
static void
columns_changed (GtkTreeView *tree_view)
{
- AtkObject *atk_obj = gtk_widget_get_accessible (GTK_WIDGET(tree_view));
- GailTreeView *gailview = GAIL_TREE_VIEW (atk_obj);
+ AtkObject *atk_obj;
+ GtkTreeViewAccessible *accessible;
GList *tv_cols, *tmp_list;
gboolean column_found;
gboolean move_found = FALSE;
@@ -1980,24 +1745,26 @@ columns_changed (GtkTreeView *tree_view)
gint column_count = 0;
gint i;
- /*
- * This function must determine if the change is an add, delete or
- * a move based upon its cache of TreeViewColumns in
- * gailview->col_data
- */
+ atk_obj = gtk_widget_get_accessible (GTK_WIDGET(tree_view));
+ accessible = GTK_TREE_VIEW_ACCESSIBLE (atk_obj);
+
+ /* This function must determine if the change is an add, delete
+ * or a move based upon its cache of TreeViewColumns in
+ * accessible->col_data
+ */
tv_cols = gtk_tree_view_get_columns (tree_view);
- gailview->n_cols = g_list_length (tv_cols);
+ accessible->n_cols = g_list_length (tv_cols);
/* check for adds or moves */
for (tmp_list = tv_cols; tmp_list; tmp_list = tmp_list->next)
{
column_found = FALSE;
- for (i = 0; i < gailview->col_data->len; i++)
+ for (i = 0; i < accessible->col_data->len; i++)
{
if ((GtkTreeViewColumn *)tmp_list->data ==
- (GtkTreeViewColumn *)g_array_index (gailview->col_data,
+ (GtkTreeViewColumn *)g_array_index (accessible->col_data,
GtkTreeViewColumn *, i))
{
column_found = TRUE;
@@ -2008,10 +1775,10 @@ columns_changed (GtkTreeView *tree_view)
if (!stale_set)
{
/* Set all rows to ATK_STATE_STALE */
- traverse_cells (gailview, NULL, TRUE, FALSE);
+ traverse_cells (accessible, NULL, TRUE, FALSE);
stale_set = TRUE;
}
-
+
/* Just emit one column reordered signal when a move happens */
g_signal_emit_by_name (atk_obj, "column_reordered");
move_found = TRUE;
@@ -2021,8 +1788,7 @@ columns_changed (GtkTreeView *tree_view)
}
}
- /*
- * If column_found is FALSE, then an insert happened for column
+ /* If column_found is FALSE, then an insert happened for column
* number column_count
*/
if (!column_found)
@@ -2032,7 +1798,7 @@ columns_changed (GtkTreeView *tree_view)
if (!stale_set)
{
/* Set all rows to ATK_STATE_STALE */
- traverse_cells (gailview, NULL, TRUE, FALSE);
+ traverse_cells (accessible, NULL, TRUE, FALSE);
stale_set = TRUE;
}
@@ -2040,13 +1806,11 @@ columns_changed (GtkTreeView *tree_view)
g_signal_emit_by_name (atk_obj, "column_inserted", column_count, 1);
/* Generate children-changed signals */
- for (row = 0; row < gailview->n_rows; row++)
+ for (row = 0; row < accessible->n_rows; row++)
{
- /*
- * Pass NULL as the child object, i.e. 4th argument.
- */
+ /* Pass NULL as the child object, i.e. 4th argument */
g_signal_emit_by_name (atk_obj, "children_changed::add",
- ((row * gailview->n_cols) + column_count), NULL, NULL);
+ ((row * accessible->n_cols) + column_count), NULL, NULL);
}
}
@@ -2054,14 +1818,14 @@ columns_changed (GtkTreeView *tree_view)
}
/* check for deletes */
- for (i = 0; i < gailview->col_data->len; i++)
+ for (i = 0; i < accessible->col_data->len; i++)
{
column_found = FALSE;
for (tmp_list = tv_cols; tmp_list; tmp_list = tmp_list->next)
{
if ((GtkTreeViewColumn *)tmp_list->data ==
- (GtkTreeViewColumn *)g_array_index (gailview->col_data,
+ (GtkTreeViewColumn *)g_array_index (accessible->col_data,
GtkTreeViewColumn *, i))
{
column_found = TRUE;
@@ -2069,22 +1833,21 @@ columns_changed (GtkTreeView *tree_view)
}
}
- /*
- * If column_found is FALSE, then a delete happened for column
+ /* If column_found is FALSE, then a delete happened for column
* number i
*/
if (!column_found)
{
gint row;
- clean_cols (gailview,
- (GtkTreeViewColumn *)g_array_index (gailview->col_data,
- GtkTreeViewColumn *, i));
+ clean_cols (accessible,
+ (GtkTreeViewColumn *)g_array_index (accessible->col_data,
+ GtkTreeViewColumn *, i));
if (!stale_set)
{
/* Set all rows to ATK_STATE_STALE */
- traverse_cells (gailview, NULL, TRUE, FALSE);
+ traverse_cells (accessible, NULL, TRUE, FALSE);
stale_set = TRUE;
}
@@ -2092,85 +1855,60 @@ columns_changed (GtkTreeView *tree_view)
g_signal_emit_by_name (atk_obj, "column_deleted", i, 1);
/* Generate children-changed signals */
- for (row = 0; row < gailview->n_rows; row++)
+ for (row = 0; row < accessible->n_rows; row++)
{
- /*
- * Pass NULL as the child object, 4th argument.
- */
+ /* Pass NULL as the child object, 4th argument */
g_signal_emit_by_name (atk_obj, "children_changed::remove",
- ((row * gailview->n_cols) + column_count), NULL, NULL);
+ ((row * accessible->n_cols) + column_count), NULL, NULL);
}
}
}
-
- /* rebuild the array */
- g_array_free (gailview->col_data, TRUE);
- gailview->col_data = g_array_sized_new (FALSE, TRUE,
- sizeof(GtkTreeViewColumn *), 0);
+ /* rebuild the array */
+ g_array_free (accessible->col_data, TRUE);
+ accessible->col_data = g_array_sized_new (FALSE, TRUE, sizeof (GtkTreeViewColumn *), 0);
for (tmp_list = tv_cols; tmp_list; tmp_list = tmp_list->next)
- g_array_append_val (gailview->col_data, tmp_list->data);
+ g_array_append_val (accessible->col_data, tmp_list->data);
g_list_free (tv_cols);
}
-static void
-cursor_changed (GtkTreeView *tree_view)
-{
- GailTreeView *gailview;
-
- gailview = GAIL_TREE_VIEW (gtk_widget_get_accessible (GTK_WIDGET (tree_view)));
- if (gailview->idle_cursor_changed_id != 0)
- return;
-
- /*
- * We notify the focus change in a idle handler so that the processing
- * of the cursor change is completed when the focus handler is called.
- * This will allow actions to be called in the focus handler
- */
- gailview->idle_cursor_changed_id = gdk_threads_add_idle (idle_cursor_changed, gailview);
-}
-
static gint
idle_cursor_changed (gpointer data)
{
- GailTreeView *gail_tree_view = GAIL_TREE_VIEW (data);
+ GtkTreeViewAccessible *accessible = GTK_TREE_VIEW_ACCESSIBLE (data);
GtkTreeView *tree_view;
GtkWidget *widget;
AtkObject *cell;
- gail_tree_view->idle_cursor_changed_id = 0;
+ accessible->idle_cursor_changed_id = 0;
- widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (gail_tree_view));
- /*
- * Widget has been deleted
- */
+ widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible));
if (widget == NULL)
return FALSE;
tree_view = GTK_TREE_VIEW (widget);
- cell = gail_tree_view_ref_focus_cell (tree_view);
+ cell = gtk_tree_view_accessible_ref_focus_cell (tree_view);
if (cell)
{
- if (cell != gail_tree_view->focus_cell)
+ if (cell != accessible->focus_cell)
{
- if (gail_tree_view->focus_cell)
+ if (accessible->focus_cell)
{
- gail_cell_remove_state (GAIL_CELL (gail_tree_view->focus_cell), ATK_STATE_ACTIVE, FALSE);
- gail_cell_remove_state (GAIL_CELL (gail_tree_view->focus_cell), ATK_STATE_FOCUSED, FALSE);
- g_object_unref (gail_tree_view->focus_cell);
+ gail_cell_remove_state (GAIL_CELL (accessible->focus_cell), ATK_STATE_ACTIVE, FALSE);
+ gail_cell_remove_state (GAIL_CELL (accessible->focus_cell), ATK_STATE_FOCUSED, FALSE);
+ g_object_unref (accessible->focus_cell);
+ accessible->focus_cell = cell;
}
- gail_tree_view->focus_cell = cell;
if (gtk_widget_has_focus (widget))
{
gail_cell_add_state (GAIL_CELL (cell), ATK_STATE_ACTIVE, FALSE);
gail_cell_add_state (GAIL_CELL (cell), ATK_STATE_FOCUSED, FALSE);
}
- g_signal_emit_by_name (gail_tree_view,
- "active-descendant-changed",
- cell);
+
+ g_signal_emit_by_name (accessible, "active-descendant-changed", cell);
}
else
g_object_unref (cell);
@@ -2179,20 +1917,36 @@ idle_cursor_changed (gpointer data)
return FALSE;
}
+static void
+cursor_changed (GtkTreeView *tree_view)
+{
+ GtkTreeViewAccessible *accessible;
+
+ accessible = GTK_TREE_VIEW_ACCESSIBLE (gtk_widget_get_accessible (GTK_WIDGET (tree_view)));
+ if (accessible->idle_cursor_changed_id != 0)
+ return;
+
+ /* We notify the focus change in a idle handler so that the processing
+ * of the cursor change is completed when the focus handler is called.
+ * This will allow actions to be called in the focus handler
+ */
+ accessible->idle_cursor_changed_id = gdk_threads_add_idle (idle_cursor_changed, accessible);
+}
+
static gboolean
focus_in (GtkWidget *widget)
{
GtkTreeView *tree_view;
- GailTreeView *gail_tree_view;
+ GtkTreeViewAccessible *accessible;
AtkStateSet *state_set;
AtkObject *cell;
tree_view = GTK_TREE_VIEW (widget);
- gail_tree_view = GAIL_TREE_VIEW (gtk_widget_get_accessible (widget));
+ accessible = GTK_TREE_VIEW_ACCESSIBLE (gtk_widget_get_accessible (widget));
- if (gail_tree_view->focus_cell == NULL)
+ if (accessible->focus_cell == NULL)
{
- cell = gail_tree_view_ref_focus_cell (tree_view);
+ cell = gtk_tree_view_accessible_ref_focus_cell (tree_view);
if (cell)
{
state_set = atk_object_ref_state_set (cell);
@@ -2201,11 +1955,9 @@ focus_in (GtkWidget *widget)
if (!atk_state_set_contains_state (state_set, ATK_STATE_FOCUSED))
{
gail_cell_add_state (GAIL_CELL (cell), ATK_STATE_ACTIVE, FALSE);
- gail_tree_view->focus_cell = cell;
+ accessible->focus_cell = cell;
gail_cell_add_state (GAIL_CELL (cell), ATK_STATE_FOCUSED, FALSE);
- g_signal_emit_by_name (gail_tree_view,
- "active-descendant-changed",
- cell);
+ g_signal_emit_by_name (accessible, "active-descendant-changed", cell);
}
g_object_unref (state_set);
}
@@ -2217,144 +1969,141 @@ focus_in (GtkWidget *widget)
static gboolean
focus_out (GtkWidget *widget)
{
- GailTreeView *gail_tree_view;
+ GtkTreeViewAccessible *accessible;
- gail_tree_view = GAIL_TREE_VIEW (gtk_widget_get_accessible (widget));
- if (gail_tree_view->focus_cell)
+ accessible = GTK_TREE_VIEW_ACCESSIBLE (gtk_widget_get_accessible (widget));
+ if (accessible->focus_cell)
{
- gail_cell_remove_state (GAIL_CELL (gail_tree_view->focus_cell), ATK_STATE_ACTIVE, FALSE);
- gail_cell_remove_state (GAIL_CELL (gail_tree_view->focus_cell), ATK_STATE_FOCUSED, FALSE);
- g_object_unref (gail_tree_view->focus_cell);
- gail_tree_view->focus_cell = NULL;
+ gail_cell_remove_state (GAIL_CELL (accessible->focus_cell), ATK_STATE_ACTIVE, FALSE);
+ gail_cell_remove_state (GAIL_CELL (accessible->focus_cell), ATK_STATE_FOCUSED, FALSE);
+ g_object_unref (accessible->focus_cell);
+ accessible->focus_cell = NULL;
}
return FALSE;
}
static void
model_row_changed (GtkTreeModel *tree_model,
- GtkTreePath *path,
+ GtkTreePath *path,
GtkTreeIter *iter,
- gpointer user_data)
+ gpointer user_data)
{
- GtkTreeView *tree_view = GTK_TREE_VIEW(user_data);
- GailTreeView *gailview;
+ GtkTreeView *tree_view = GTK_TREE_VIEW (user_data);
+ GtkTreeViewAccessible *accessible;
GtkTreePath *cell_path;
- GailTreeViewCellInfo *cell_info;
+ GtkTreeViewAccessibleCellInfo *cell_info;
GHashTableIter hash_iter;
- gailview = GAIL_TREE_VIEW (gtk_widget_get_accessible (GTK_WIDGET (tree_view)));
+ accessible = GTK_TREE_VIEW_ACCESSIBLE (gtk_widget_get_accessible (GTK_WIDGET (tree_view)));
/* Loop through our cached cells */
/* Must loop through them all */
- g_hash_table_iter_init (&hash_iter, gailview->cell_info_by_index);
+ g_hash_table_iter_init (&hash_iter, accessible->cell_info_by_index);
while (g_hash_table_iter_next (&hash_iter, NULL, (gpointer *)&cell_info))
{
if (cell_info->in_use)
- {
- cell_path = gtk_tree_row_reference_get_path (cell_info->cell_row_ref);
-
- if (cell_path != NULL)
- {
- if (path && gtk_tree_path_compare (cell_path, path) == 0)
- {
- if (GAIL_IS_RENDERER_CELL (cell_info->cell))
- {
- update_cell_value (GAIL_RENDERER_CELL (cell_info->cell),
- gailview, TRUE);
- }
- }
- gtk_tree_path_free (cell_path);
- }
- }
+ {
+ cell_path = gtk_tree_row_reference_get_path (cell_info->cell_row_ref);
+
+ if (cell_path != NULL)
+ {
+ if (path && gtk_tree_path_compare (cell_path, path) == 0)
+ {
+ if (GAIL_IS_RENDERER_CELL (cell_info->cell))
+ update_cell_value (GAIL_RENDERER_CELL (cell_info->cell),
+ accessible, TRUE);
+ }
+ gtk_tree_path_free (cell_path);
+ }
+ }
}
- g_signal_emit_by_name (gailview, "visible-data-changed");
+ g_signal_emit_by_name (accessible, "visible-data-changed");
}
static void
column_visibility_changed (GObject *object,
GParamSpec *pspec,
- gpointer user_data)
+ gpointer user_data)
{
if (strcmp (pspec->name, "visible") == 0)
{
- /*
- * A column has been made visible or invisible
- *
+ /* A column has been made visible or invisible
* We update our cache of cells and emit model_changed signal
- */
+ */
GtkTreeView *tree_view = (GtkTreeView *)user_data;
- GailTreeView *gailview;
- GailTreeViewCellInfo *cell_info;
+ GtkTreeViewAccessible *accessible;
+ GtkTreeViewAccessibleCellInfo *cell_info;
GtkTreeViewColumn *this_col = GTK_TREE_VIEW_COLUMN (object);
GtkTreeViewColumn *tv_col;
GHashTableIter iter;
- gailview = GAIL_TREE_VIEW (gtk_widget_get_accessible (GTK_WIDGET (tree_view))
+ accessible = GTK_TREE_VIEW_ACCESSIBLE (gtk_widget_get_accessible (GTK_WIDGET (tree_view))
);
- g_signal_emit_by_name (gailview, "model_changed");
+ g_signal_emit_by_name (accessible, "model_changed");
- g_hash_table_iter_init (&iter, gailview->cell_info_by_index);
+ g_hash_table_iter_init (&iter, accessible->cell_info_by_index);
while (g_hash_table_iter_next (&iter, NULL, (gpointer *)&cell_info))
{
- if (cell_info->in_use)
- {
- tv_col = cell_info->cell_col_ref;
- if (tv_col == this_col)
- {
- GtkTreePath *row_path;
- row_path = gtk_tree_row_reference_get_path (cell_info->cell_row_ref);
- if (GAIL_IS_RENDERER_CELL (cell_info->cell))
- {
- if (gtk_tree_view_column_get_visible (tv_col))
- set_cell_visibility (tree_view,
- cell_info->cell,
- tv_col, row_path, FALSE);
- else
- {
- gail_cell_remove_state (cell_info->cell,
- ATK_STATE_VISIBLE, TRUE);
- gail_cell_remove_state (cell_info->cell,
- ATK_STATE_SHOWING, TRUE);
- }
- }
- gtk_tree_path_free (row_path);
- }
- }
+ if (cell_info->in_use)
+ {
+ tv_col = cell_info->cell_col_ref;
+ if (tv_col == this_col)
+ {
+ GtkTreePath *row_path;
+ row_path = gtk_tree_row_reference_get_path (cell_info->cell_row_ref);
+ if (GAIL_IS_RENDERER_CELL (cell_info->cell))
+ {
+ if (gtk_tree_view_column_get_visible (tv_col))
+ set_cell_visibility (tree_view,
+ cell_info->cell,
+ tv_col, row_path, FALSE);
+ else
+ {
+ gail_cell_remove_state (cell_info->cell, ATK_STATE_VISIBLE, TRUE);
+ gail_cell_remove_state (cell_info->cell, ATK_STATE_SHOWING, TRUE);
+ }
+ }
+ gtk_tree_path_free (row_path);
+ }
+ }
}
}
}
static void
model_row_inserted (GtkTreeModel *tree_model,
- GtkTreePath *path,
- GtkTreeIter *iter,
- gpointer user_data)
+ GtkTreePath *path,
+ GtkTreeIter *iter,
+ gpointer user_data)
{
GtkTreeView *tree_view = (GtkTreeView *)user_data;
+ AtkObject *atk_obj;
+ GtkTreeViewAccessible *accessible;
GtkTreePath *path_copy;
- AtkObject *atk_obj = gtk_widget_get_accessible (GTK_WIDGET (tree_view));
- GailTreeView *gailview = GAIL_TREE_VIEW (atk_obj);
gint row, n_inserted, child_row;
- gailview->n_rows++;
+ atk_obj = gtk_widget_get_accessible (GTK_WIDGET (tree_view));
+ accessible = GTK_TREE_VIEW_ACCESSIBLE (atk_obj);
+ accessible->n_rows++;
- if (gailview->idle_expand_id)
+ if (accessible->idle_expand_id)
{
- g_source_remove (gailview->idle_expand_id);
- gailview->idle_expand_id = 0;
+ g_source_remove (accessible->idle_expand_id);
+ accessible->idle_expand_id = 0;
- /* don't do this if the insertion precedes the idle path, since it will now be invalid */
- if (path && gailview->idle_expand_path &&
- (gtk_tree_path_compare (path, gailview->idle_expand_path) > 0))
- set_expand_state (tree_view, tree_model, gailview, gailview->idle_expand_path, FALSE);
- if (gailview->idle_expand_path)
- gtk_tree_path_free (gailview->idle_expand_path);
+ /* don't do this if the insertion precedes the idle path,
+ * since it will now be invalid
+ */
+ if (path && accessible->idle_expand_path &&
+ (gtk_tree_path_compare (path, accessible->idle_expand_path) > 0))
+ set_expand_state (tree_view, tree_model, accessible, accessible->idle_expand_path, FALSE);
+ if (accessible->idle_expand_path)
+ gtk_tree_path_free (accessible->idle_expand_path);
}
/* Check to see if row is visible */
row = get_row_from_tree_path (tree_view, path);
- /*
- * A row insert is not necessarily visible. For example,
+ /* A row insert is not necessarily visible. For example,
* a row can be draged & dropped into another row, which
* causes an insert on the model that isn't visible in the
* view. Only generate a signal if the inserted row is
@@ -2382,23 +2131,21 @@ model_row_inserted (GtkTreeModel *tree_model,
n_inserted++;
}
else
- n_inserted = 1;
+ n_inserted = 1;
/* Set rows below the inserted row to ATK_STATE_STALE */
- traverse_cells (gailview, path, TRUE, TRUE);
+ traverse_cells (accessible, path, TRUE, TRUE);
/* Generate row-inserted signal */
g_signal_emit_by_name (atk_obj, "row_inserted", row, n_inserted);
/* Generate children-changed signals */
- n_cols = gail_tree_view_get_n_columns (ATK_TABLE (atk_obj));
+ n_cols = gtk_tree_view_accessible_get_n_columns (ATK_TABLE (atk_obj));
for (child_row = row; child_row < (row + n_inserted); child_row++)
{
for (col = 0; col < n_cols; col++)
{
- /*
- * Pass NULL as the child object, i.e. 4th argument
- */
+ /* Pass NULL as the child object, i.e. 4th argument */
g_signal_emit_by_name (atk_obj, "children_changed::add",
((row * n_cols) + col), NULL, NULL);
}
@@ -2406,149 +2153,134 @@ model_row_inserted (GtkTreeModel *tree_model,
}
else
{
- /*
- * The row has been inserted inside another row. This can
+ /* The row has been inserted inside another row. This can
* cause a row that previously couldn't be expanded to now
* be expandable.
*/
path_copy = gtk_tree_path_copy (path);
gtk_tree_path_up (path_copy);
- set_expand_state (tree_view, tree_model, gailview, path_copy, TRUE);
+ set_expand_state (tree_view, tree_model, accessible, path_copy, TRUE);
gtk_tree_path_free (path_copy);
}
}
static void
model_row_deleted (GtkTreeModel *tree_model,
- GtkTreePath *path,
- gpointer user_data)
+ GtkTreePath *path,
+ gpointer user_data)
{
- GtkTreeView *tree_view;
+ GtkTreeView *tree_view = (GtkTreeView *)user_data;
GtkTreePath *path_copy;
AtkObject *atk_obj;
- GailTreeView *gailview;
+ GtkTreeViewAccessible *accessible;
gint row, col;
- tree_view = (GtkTreeView *)user_data;
atk_obj = gtk_widget_get_accessible (GTK_WIDGET (tree_view));
- gailview = GAIL_TREE_VIEW (atk_obj);
+ accessible = GTK_TREE_VIEW_ACCESSIBLE (atk_obj);
- gailview->n_rows--;
- g_assert (gailview->n_rows >= 0);
+ accessible->n_rows--;
- if (gailview->idle_expand_id)
+ if (accessible->idle_expand_id)
{
- g_source_remove (gailview->idle_expand_id);
- gtk_tree_path_free (gailview->idle_expand_path);
- gailview->idle_expand_id = 0;
+ g_source_remove (accessible->idle_expand_id);
+ gtk_tree_path_free (accessible->idle_expand_path);
+ accessible->idle_expand_id = 0;
}
+
/* Check to see if row is visible */
- clean_rows (gailview);
+ clean_rows (accessible);
/* Set rows at or below the specified row to ATK_STATE_STALE */
- traverse_cells (gailview, path, TRUE, TRUE);
+ traverse_cells (accessible, path, TRUE, TRUE);
- /*
- * If deleting a row with a depth > 1, then this may affect the
- * expansion/contraction of its parent(s). Make sure this is
+ /* If deleting a row with a depth > 1, then this may affect the
+ * expansion/contraction of its parent(s). Make sure this is
* handled.
*/
if (gtk_tree_path_get_depth (path) > 1)
{
path_copy = gtk_tree_path_copy (path);
gtk_tree_path_up (path_copy);
- set_expand_state (tree_view, tree_model, gailview, path_copy, TRUE);
+ set_expand_state (tree_view, tree_model, accessible, path_copy, TRUE);
gtk_tree_path_free (path_copy);
}
row = get_row_from_tree_path (tree_view, path);
- /*
- * If the row which is deleted is not visible because it is a child of
+
+ /* If the row which is deleted is not visible because it is a child of
* a collapsed row then row will be -1
*/
if (row > 0)
- g_signal_emit_by_name (atk_obj, "row_deleted", row,
- gailview->n_children_deleted + 1);
- gailview->n_children_deleted = 0;
+ g_signal_emit_by_name (atk_obj, "row_deleted", row,
+ accessible->n_children_deleted + 1);
+ accessible->n_children_deleted = 0;
/* Generate children-changed signals */
- for (col = 0; col < gailview->n_cols; col++)
- {
- /*
- * Pass NULL as the child object, 4th argument.
- */
- g_signal_emit_by_name (atk_obj, "children_changed::remove",
- ((row * gailview->n_cols) + col), NULL, NULL);
- }
+ for (col = 0; col < accessible->n_cols; col++)
+ {
+ /* Pass NULL as the child object, 4th argument */
+ g_signal_emit_by_name (atk_obj, "children_changed::remove",
+ ((row * accessible->n_cols) + col), NULL, NULL);
+ }
}
-/*
- * This function gets called when a row is deleted or when rows are
- * removed from the view due to a collapse event. Note that the
+/* This function gets called when a row is deleted or when rows are
+ * removed from the view due to a collapse event. Note that the
* count is the number of visible *children* of the deleted row,
* so it does not include the row being deleted.
*
- * As this function is called before the rows are removed we just note the
- * number of rows and then deal with it when we get a notification that
- * rows were deleted or collapsed.
+ * As this function is called before the rows are removed we just note
+ * the number of rows and then deal with it when we get a notification
+ * that rows were deleted or collapsed.
*/
static void
-destroy_count_func (GtkTreeView *tree_view,
+destroy_count_func (GtkTreeView *tree_view,
GtkTreePath *path,
- gint count,
- gpointer user_data)
+ gint count,
+ gpointer user_data)
{
- AtkObject *atk_obj = gtk_widget_get_accessible (GTK_WIDGET (tree_view));
- GailTreeView *gailview = GAIL_TREE_VIEW (atk_obj);
+ AtkObject *atk_obj;
+ GtkTreeViewAccessible *accessible;
+
+ atk_obj = gtk_widget_get_accessible (GTK_WIDGET (tree_view));
+ accessible = GTK_TREE_VIEW_ACCESSIBLE (atk_obj);
- if (gailview->n_children_deleted != 0)
+ if (accessible->n_children_deleted != 0)
return;
- gailview->n_children_deleted = count;
+
+ accessible->n_children_deleted = count;
}
-static void
+static void
model_rows_reordered (GtkTreeModel *tree_model,
- GtkTreePath *path,
+ GtkTreePath *path,
GtkTreeIter *iter,
- gint *new_order,
- gpointer user_data)
+ gint *new_order,
+ gpointer user_data)
{
GtkTreeView *tree_view = (GtkTreeView *)user_data;
- AtkObject *atk_obj = gtk_widget_get_accessible (GTK_WIDGET (tree_view));
- GailTreeView *gailview = GAIL_TREE_VIEW (atk_obj);
+ AtkObject *atk_obj;
+ GtkTreeViewAccessible *accessible;
+
+ atk_obj = gtk_widget_get_accessible (GTK_WIDGET (tree_view));
+ accessible = GTK_TREE_VIEW_ACCESSIBLE (atk_obj);
- if (gailview->idle_expand_id)
+ if (accessible->idle_expand_id)
{
- g_source_remove (gailview->idle_expand_id);
- gtk_tree_path_free (gailview->idle_expand_path);
- gailview->idle_expand_id = 0;
+ g_source_remove (accessible->idle_expand_id);
+ gtk_tree_path_free (accessible->idle_expand_path);
+ accessible->idle_expand_id = 0;
}
- traverse_cells (gailview, NULL, TRUE, FALSE);
+ traverse_cells (accessible, NULL, TRUE, FALSE);
g_signal_emit_by_name (atk_obj, "row_reordered");
}
static void
-adjustment_changed (GtkAdjustment *adjustment,
- GtkTreeView *tree_view)
-{
- AtkObject *atk_obj;
- GailTreeView* obj;
-
- /*
- * The scrollbars have changed
- */
- atk_obj = gtk_widget_get_accessible (GTK_WIDGET (tree_view));
- obj = GAIL_TREE_VIEW (atk_obj);
-
- traverse_cells (obj, NULL, FALSE, FALSE);
-}
-
-static void
set_cell_visibility (GtkTreeView *tree_view,
GailCell *cell,
GtkTreeViewColumn *tv_col,
GtkTreePath *tree_path,
- gboolean emit_signal)
+ gboolean emit_signal)
{
GdkRectangle cell_rect;
@@ -2560,9 +2292,8 @@ set_cell_visibility (GtkTreeView *tree_view,
if (cell_rect.height > 0)
{
- /*
- * The height will be zero for a cell for which an antecedent is not
- * expanded
+ /* The height will be zero for a cell for which an antecedent
+ * is not expanded
*/
gail_cell_add_state (cell, ATK_STATE_VISIBLE, emit_signal);
if (is_cell_showing (tree_view, &cell_rect))
@@ -2577,22 +2308,23 @@ set_cell_visibility (GtkTreeView *tree_view,
}
}
-static gboolean
-is_cell_showing (GtkTreeView *tree_view,
- GdkRectangle *cell_rect)
+static gboolean
+is_cell_showing (GtkTreeView *tree_view,
+ GdkRectangle *cell_rect)
{
GdkRectangle rect, *visible_rect;
GdkRectangle rect1, *tree_cell_rect;
gint bx, by;
gboolean is_showing;
- /*
- * A cell is considered "SHOWING" if any part of the cell is in the visible
- * area. Other ways we could do this is by a cell's midpoint or if the cell
- * is fully in the visible range. Since we have the cell_rect x,y,width,height
- * of the cell, any of these is easy to compute.
+
+ /* A cell is considered "SHOWING" if any part of the cell is
+ * in the visible area. Other ways we could do this is by a
+ * cell's midpoint or if the cell is fully in the visible range.
+ * Since we have the cell_rect x, y, width, height of the cell,
+ * any of these is easy to compute.
*
- * It is assumed that cell's rectangle is in widget coordinates so we
- * must transform to tree cordinates.
+ * It is assumed that cell's rectangle is in widget coordinates
+ * so we must transform to tree cordinates.
*/
visible_rect = ▭
tree_cell_rect = &rect1;
@@ -2602,7 +2334,7 @@ is_cell_showing (GtkTreeView *tree_view,
tree_cell_rect->height = cell_rect->height;
gtk_tree_view_get_visible_rect (tree_view, visible_rect);
- gtk_tree_view_convert_tree_to_bin_window_coords (tree_view, visible_rect->x,
+ gtk_tree_view_convert_tree_to_bin_window_coords (tree_view, visible_rect->x,
visible_rect->y, &bx, &by);
if (((tree_cell_rect->x + tree_cell_rect->width) < bx) ||
@@ -2618,18 +2350,17 @@ is_cell_showing (GtkTreeView *tree_view,
/* Misc Public */
-/*
- * This function is called when a cell's flyweight is created in
- * gail_tree_view_table_ref_at with emit_change_signal set to FALSE
- * and in model_row_changed() on receipt of "row-changed" signal when
- * emit_change_signal is set to TRUE
+/* This function is called when a cell's flyweight is created in
+ * gtk_tree_view_accessible_table_ref_at with emit_change_signal
+ * set to FALSE and in model_row_changed() on receipt of "row-changed"
+ * signal when emit_change_signal is set to TRUE
*/
static gboolean
-update_cell_value (GailRendererCell *renderer_cell,
- GailTreeView *gailview,
- gboolean emit_change_signal)
+update_cell_value (GailRendererCell *renderer_cell,
+ GtkTreeViewAccessible *accessible,
+ gboolean emit_change_signal)
{
- GailTreeViewCellInfo *cell_info;
+ GtkTreeViewAccessibleCellInfo *cell_info;
GtkTreeView *tree_view;
GtkTreeModel *tree_model;
GtkTreePath *path;
@@ -2642,7 +2373,7 @@ update_cell_value (GailRendererCell *renderer_cell,
gchar **prop_list;
AtkObject *parent;
gboolean is_expander, is_expanded;
-
+
gail_renderer_cell_class = GAIL_RENDERER_CELL_GET_CLASS (renderer_cell);
if (renderer_cell->renderer)
gtk_cell_renderer_class = GTK_CELL_RENDERER_GET_CLASS (renderer_cell->renderer);
@@ -2652,13 +2383,13 @@ update_cell_value (GailRendererCell *renderer_cell,
prop_list = gail_renderer_cell_class->property_list;
cell = GAIL_CELL (renderer_cell);
- cell_info = find_cell_info (gailview, cell, TRUE);
+ cell_info = find_cell_info (accessible, cell, TRUE);
if (!cell_info || !cell_info->cell_col_ref || !cell_info->cell_row_ref)
return FALSE;
if (emit_change_signal && cell_info->in_use)
{
- tree_view = GTK_TREE_VIEW (gtk_accessible_get_widget (GTK_ACCESSIBLE (gailview)));
+ tree_view = GTK_TREE_VIEW (gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible)));
tree_model = gtk_tree_view_get_model (tree_view);
path = gtk_tree_row_reference_get_path (cell_info->cell_row_ref);
if (path == NULL)
@@ -2677,37 +2408,33 @@ update_cell_value (GailRendererCell *renderer_cell,
is_expander = TRUE;
is_expanded = gtk_tree_view_row_expanded (tree_view, path);
}
- }
+ }
gtk_tree_path_free (path);
gtk_tree_view_column_cell_set_cell_data (cell_info->cell_col_ref,
- tree_model, &iter, is_expander, is_expanded);
+ tree_model, &iter,
+ is_expander, is_expanded);
}
renderers = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (cell_info->cell_col_ref));
if (!renderers)
return FALSE;
- /*
- * If the cell is in a container, its index is used to find the renderer
- * in the list
- */
-
- /*
- * Otherwise, we assume that the cell is represented by the first renderer
- * in the list
+ /* If the cell is in a container, its index is used to find the renderer
+ * in the list. Otherwise, we assume that the cell is represented
+ * by the first renderer in the list
*/
- if (cell_info->in_use) {
+ if (cell_info->in_use)
+ {
parent = atk_object_get_parent (ATK_OBJECT (cell));
- if (!ATK_IS_OBJECT (cell)) g_on_error_query (NULL);
+
if (GAIL_IS_CONTAINER_CELL (parent))
- cur_renderer = g_list_nth (renderers, cell->index);
+ cur_renderer = g_list_nth (renderers, cell->index);
else
- cur_renderer = renderers;
- }
- else {
- return FALSE;
- }
-
+ cur_renderer = renderers;
+ }
+ else
+ return FALSE;
+
if (cur_renderer == NULL)
return FALSE;
@@ -2726,7 +2453,7 @@ update_cell_value (GailRendererCell *renderer_cell,
g_object_get_property (cur_renderer->data, *prop_list, &value);
g_object_set_property (G_OBJECT (renderer_cell->renderer),
*prop_list, &value);
- g_value_unset(&value);
+ g_value_unset (&value);
}
else
g_warning ("Invalid property: %s\n", *prop_list);
@@ -2734,22 +2461,11 @@ update_cell_value (GailRendererCell *renderer_cell,
}
}
g_list_free (renderers);
- return gail_renderer_cell_update_cache (renderer_cell, emit_change_signal);
-}
-static void
-set_iter_nth_row (GtkTreeView *tree_view,
- GtkTreeIter *iter,
- gint row)
-{
- GtkTreeModel *tree_model;
-
- tree_model = gtk_tree_view_get_model (tree_view);
- gtk_tree_model_get_iter_first (tree_model, iter);
- iter = return_iter_nth_row (tree_view, tree_model, iter, 0 , row);
+ return gail_renderer_cell_update_cache (renderer_cell, emit_change_signal);
}
-static gint
+static gint
get_row_from_tree_path (GtkTreeView *tree_view,
GtkTreePath *path)
{
@@ -2778,14 +2494,14 @@ get_row_from_tree_path (GtkTreeView *tree_view,
* Get the specified GtkTreeViewColumn in the GtkTreeView.
* Only visible columns are considered.
*/
-static GtkTreeViewColumn*
-get_column (GtkTreeView *tree_view,
- gint in_col)
+static GtkTreeViewColumn *
+get_column (GtkTreeView *tree_view,
+ gint in_col)
{
GtkTreeViewColumn *tv_col;
gint n_cols = -1;
gint i = 0;
-
+
if (in_col < 0)
{
g_warning ("Request for invalid column %d\n", in_col);
@@ -2793,10 +2509,9 @@ get_column (GtkTreeView *tree_view,
}
tv_col = gtk_tree_view_get_column (tree_view, i);
-
while (tv_col != NULL)
{
- if (gtk_tree_view_column_get_visible (tv_col))
+ if (gtk_tree_view_column_get_visible (tv_col))
n_cols++;
if (in_col == n_cols)
break;
@@ -2813,20 +2528,19 @@ get_column (GtkTreeView *tree_view,
static gint
get_actual_column_number (GtkTreeView *tree_view,
- gint visible_column)
+ gint visible_column)
{
GtkTreeViewColumn *tv_col;
gint actual_column = 0;
gint visible_columns = -1;
- /*
- * This function calculates the column number which corresponds to the
- * specified visible column number
+
+ /* This function calculates the column number which corresponds
+ * to the specified visible column number
*/
tv_col = gtk_tree_view_get_column (tree_view, actual_column);
-
while (tv_col != NULL)
{
- if (gtk_tree_view_column_get_visible (tv_col))
+ if (gtk_tree_view_column_get_visible (tv_col))
visible_columns++;
if (visible_columns == visible_column)
return actual_column;
@@ -2838,20 +2552,20 @@ get_actual_column_number (GtkTreeView *tree_view,
static gint
get_visible_column_number (GtkTreeView *tree_view,
- gint actual_column)
+ gint actual_column)
{
GtkTreeViewColumn *tv_col;
gint column = 0;
gint visible_columns = -1;
- /*
- * This function calculates the visible column number which corresponds to the
- * specified actual column number
+
+ /* This function calculates the visible column number
+ * which corresponds to the specified actual column number
*/
tv_col = gtk_tree_view_get_column (tree_view, column);
while (tv_col != NULL)
{
- if (gtk_tree_view_column_get_visible (tv_col))
+ if (gtk_tree_view_column_get_visible (tv_col))
{
visible_columns++;
if (actual_column == column)
@@ -2866,24 +2580,25 @@ get_visible_column_number (GtkTreeView *tree_view,
return -1;
}
-/**
- * Helper recursive function that returns GtkTreeIter pointer to nth row.
- **/
-static GtkTreeIter*
-return_iter_nth_row(GtkTreeView *tree_view,
- GtkTreeModel *tree_model,
- GtkTreeIter *iter,
- gint increment,
- gint row)
-{
- GtkTreePath *current_path = gtk_tree_model_get_path (tree_model, iter);
+/* Helper recursive function that returns an iter to nth row
+ */
+static GtkTreeIter *
+return_iter_nth_row (GtkTreeView *tree_view,
+ GtkTreeModel *tree_model,
+ GtkTreeIter *iter,
+ gint increment,
+ gint row)
+{
+ GtkTreePath *current_path;
GtkTreeIter new_iter;
gboolean row_expanded;
- if (increment == row) {
- gtk_tree_path_free (current_path);
- return iter;
- }
+ current_path = gtk_tree_model_get_path (tree_model, iter);
+ if (increment == row)
+ {
+ gtk_tree_path_free (current_path);
+ return iter;
+ }
row_expanded = gtk_tree_view_row_expanded (tree_view, current_path);
gtk_tree_path_free (current_path);
@@ -2896,11 +2611,22 @@ return_iter_nth_row(GtkTreeView *tree_view,
return return_iter_nth_row (tree_view, tree_model, iter,
++increment, row);
- return NULL;
+ return NULL;
+}
+
+static void
+set_iter_nth_row (GtkTreeView *tree_view,
+ GtkTreeIter *iter,
+ gint row)
+{
+ GtkTreeModel *tree_model;
+
+ tree_model = gtk_tree_view_get_model (tree_view);
+ gtk_tree_model_get_iter_first (tree_model, iter);
+ iter = return_iter_nth_row (tree_view, tree_model, iter, 0, row);
}
-/**
- * Recursively called until the row specified by orig is found.
+/* Recursively called until the row specified by orig is found.
*
* *count will be set to the visible row number of the child
* relative to the row that was initially passed in as tree_path.
@@ -2912,21 +2638,21 @@ return_iter_nth_row(GtkTreeView *tree_view,
*
* NOTE: the value for depth must be 0 when this recursive function
* is initially called, or it may not function as expected.
- **/
-static void
-iterate_thru_children(GtkTreeView *tree_view,
- GtkTreeModel *tree_model,
- GtkTreePath *tree_path,
- GtkTreePath *orig,
- gint *count,
- gint depth)
+ */
+static void
+iterate_thru_children (GtkTreeView *tree_view,
+ GtkTreeModel *tree_model,
+ GtkTreePath *tree_path,
+ GtkTreePath *orig,
+ gint *count,
+ gint depth)
{
GtkTreeIter iter;
if (!gtk_tree_model_get_iter (tree_model, &iter, tree_path))
return;
- if (tree_path && orig && !gtk_tree_path_compare (tree_path, orig))
+ if (tree_path && orig && !gtk_tree_path_compare (tree_path, orig))
/* Found it! */
return;
@@ -2936,8 +2662,8 @@ iterate_thru_children(GtkTreeView *tree_view,
*count = -1;
return;
}
- else if (gtk_tree_view_row_expanded (tree_view, tree_path) &&
- gtk_tree_model_iter_has_child (tree_model, &iter))
+ else if (gtk_tree_view_row_expanded (tree_view, tree_path) &&
+ gtk_tree_model_iter_has_child (tree_model, &iter))
{
(*count)++;
gtk_tree_path_append_index (tree_path, 0);
@@ -2945,14 +2671,14 @@ iterate_thru_children(GtkTreeView *tree_view,
orig, count, (depth + 1));
return;
}
- else if (gtk_tree_model_iter_next (tree_model, &iter))
+ else if (gtk_tree_model_iter_next (tree_model, &iter))
{
(*count)++;
tree_path = gtk_tree_model_get_path (tree_model, &iter);
if (tree_path)
{
iterate_thru_children (tree_view, tree_model, tree_path,
- orig, count, depth);
+ orig, count, depth);
gtk_tree_path_free (tree_path);
}
return;
@@ -2965,8 +2691,7 @@ iterate_thru_children(GtkTreeView *tree_view,
(*count)++;
- /*
- * Make sure that we back up until we find a row
+ /* Make sure that we back up until we find a row
* where gtk_tree_path_next does not return NULL.
*/
while (!exit_loop)
@@ -2974,7 +2699,7 @@ iterate_thru_children(GtkTreeView *tree_view,
if (gtk_tree_path_get_depth (tree_path) == 0)
/* depth is now zero so */
return;
- gtk_tree_path_next (tree_path);
+ gtk_tree_path_next (tree_path);
/* Verify that the next row is a valid row! */
exit_loop = gtk_tree_model_get_iter (tree_model, &temp_iter, tree_path);
@@ -2989,10 +2714,9 @@ iterate_thru_children(GtkTreeView *tree_view,
}
else
{
- /*
- * If depth is 1 and gtk_tree_model_get_iter returns FALSE,
+ /* If depth is 1 and gtk_tree_model_get_iter returns FALSE,
* then we are at the last row, so just return.
- */
+ */
if (orig != NULL)
*count = -1;
@@ -3001,20 +2725,18 @@ iterate_thru_children(GtkTreeView *tree_view,
}
}
- /*
- * This guarantees that we will stop when we hit the end of the
+ /* This guarantees that we will stop when we hit the end of the
* children.
*/
if (new_depth < 0)
return;
iterate_thru_children (tree_view, tree_model, tree_path,
- orig, count, new_depth);
+ orig, count, new_depth);
return;
}
- /*
- * If it gets here, then the path wasn't found. Situations
+ /* If it gets here, then the path wasn't found. Situations
* that would cause this would be if the path passed in is
* invalid or contained within the last row, but not visible
* because the last row is not expanded. If NULL was passed
@@ -3028,172 +2750,156 @@ iterate_thru_children(GtkTreeView *tree_view,
}
static void
-clean_cell_info (GailTreeView *gailview,
- GailTreeViewCellInfo *cell_info)
+clean_cell_info (GtkTreeViewAccessible *accessible,
+ GtkTreeViewAccessibleCellInfo *cell_info)
{
GObject *obj;
- g_assert (GAIL_IS_TREE_VIEW (gailview));
-
- if (cell_info->in_use) {
+ if (cell_info->in_use)
+ {
obj = G_OBJECT (cell_info->cell);
-
+
gail_cell_add_state (cell_info->cell, ATK_STATE_DEFUNCT, FALSE);
g_object_weak_unref (obj, (GWeakNotify) cell_destroyed, cell_info);
- cell_info->in_use = FALSE;
- if (!gailview->garbage_collection_pending) {
- gailview->garbage_collection_pending = TRUE;
- g_assert (gailview->idle_garbage_collect_id == 0);
- gailview->idle_garbage_collect_id =
- gdk_threads_add_idle (idle_garbage_collect_cell_data, gailview);
- }
- }
+ cell_info->in_use = FALSE;
+ if (!accessible->garbage_collection_pending)
+ {
+ accessible->garbage_collection_pending = TRUE;
+ g_assert (accessible->idle_garbage_collect_id == 0);
+ accessible->idle_garbage_collect_id =
+ gdk_threads_add_idle (idle_garbage_collect_cell_data, accessible);
+ }
+ }
}
-static void
-clean_rows (GailTreeView *gailview)
+static void
+clean_rows (GtkTreeViewAccessible *accessible)
{
- GailTreeViewCellInfo *cell_info;
+ GtkTreeViewAccessibleCellInfo *cell_info;
GHashTableIter iter;
- /* Clean GailTreeViewCellInfo data */
- g_hash_table_iter_init (&iter, gailview->cell_info_by_index);
+ /* Clean GtkTreeViewAccessibleCellInfo data */
+ g_hash_table_iter_init (&iter, accessible->cell_info_by_index);
while (g_hash_table_iter_next (&iter, NULL, (gpointer *)&cell_info))
{
GtkTreePath *row_path;
row_path = gtk_tree_row_reference_get_path (cell_info->cell_row_ref);
- /*
- * If the cell has become invalid because the row has been removed,
+
+ /* If the cell has become invalid because the row has been removed,
* then set the cell's state to ATK_STATE_DEFUNCT and schedule
* its removal. If row_path is NULL then the row has
* been removed.
*/
if (row_path == NULL)
- {
- clean_cell_info (gailview, cell_info);
- }
+ clean_cell_info (accessible, cell_info);
else
- {
- gtk_tree_path_free (row_path);
- }
+ gtk_tree_path_free (row_path);
}
}
static void
-clean_cols (GailTreeView *gailview,
- GtkTreeViewColumn *tv_col)
+clean_cols (GtkTreeViewAccessible *accessible,
+ GtkTreeViewColumn *tv_col)
{
- GailTreeViewCellInfo *cell_info;
+ GtkTreeViewAccessibleCellInfo *cell_info;
GHashTableIter iter;
- /* Clean GailTreeViewCellInfo data */
- g_hash_table_iter_init (&iter, gailview->cell_info_by_index);
+ /* Clean GtkTreeViewAccessibleCellInfo data */
+ g_hash_table_iter_init (&iter, accessible->cell_info_by_index);
while (g_hash_table_iter_next (&iter, NULL, (gpointer *) &cell_info))
{
- /*
- * If the cell has become invalid because the column tv_col
+ /* If the cell has become invalid because the column tv_col
* has been removed, then set the cell's state to ATK_STATE_DEFUNCT
- * and remove the cell from gailview->cell_data.
+ * and remove the cell from accessible->cell_data.
*/
if (cell_info->cell_col_ref == tv_col)
- {
- clean_cell_info (gailview, cell_info);
- }
+ clean_cell_info (accessible, cell_info);
}
}
static gboolean
-idle_garbage_collect_cell_data (gpointer data)
+garbage_collect_cell_data (gpointer data)
{
- GailTreeView *tree_view;
+ GtkTreeViewAccessible *accessible;
+ GtkTreeViewAccessibleCellInfo *cell_info;
+ GHashTableIter iter;
- g_assert (GAIL_IS_TREE_VIEW (data));
- tree_view = (GailTreeView *)data;
+ accessible = (GtkTreeViewAccessible *)data;
- /* this is the idle handler (only one instance allowed), so
- * we can safely delete it.
- */
- tree_view->garbage_collection_pending = FALSE;
- tree_view->idle_garbage_collect_id = 0;
+ accessible->garbage_collection_pending = FALSE;
+ if (accessible->idle_garbage_collect_id != 0)
+ {
+ g_source_remove (accessible->idle_garbage_collect_id);
+ accessible->idle_garbage_collect_id = 0;
+ }
- tree_view->garbage_collection_pending = garbage_collect_cell_data (data);
+ /* Must loop through them all */
+ g_hash_table_iter_init (&iter, accessible->cell_info_by_index);
+ while (g_hash_table_iter_next (&iter, NULL, (gpointer *)&cell_info))
+ {
+ if (!cell_info->in_use)
+ {
+ /* g_object_unref (cell_info->cell); */
+ if (cell_info->cell_row_ref)
+ gtk_tree_row_reference_free (cell_info->cell_row_ref);
+ g_free (cell_info);
+ g_hash_table_iter_remove (&iter);
+ }
+ }
- /* N.B.: if for some reason another handler has re-enterantly been queued
- * while this handler was being serviced, it has its own gsource, therefore this handler
- * should always return FALSE.
- */
- return FALSE;
+ return accessible->garbage_collection_pending;
}
static gboolean
-garbage_collect_cell_data (gpointer data)
+idle_garbage_collect_cell_data (gpointer data)
{
- GailTreeView *tree_view;
- GailTreeViewCellInfo *cell_info;
- GHashTableIter iter;
+ GtkTreeViewAccessible *accessible;
- g_assert (GAIL_IS_TREE_VIEW (data));
- tree_view = (GailTreeView *)data;
+ accessible = (GtkTreeViewAccessible *)data;
- tree_view->garbage_collection_pending = FALSE;
- if (tree_view->idle_garbage_collect_id != 0)
- {
- g_source_remove (tree_view->idle_garbage_collect_id);
- tree_view->idle_garbage_collect_id = 0;
- }
+ /* this is the idle handler (only one instance allowed), so
+ * we can safely delete it.
+ */
+ accessible->garbage_collection_pending = FALSE;
+ accessible->idle_garbage_collect_id = 0;
- /* Must loop through them all */
- g_hash_table_iter_init (&iter, tree_view->cell_info_by_index);
- while (g_hash_table_iter_next (&iter, NULL, (gpointer *)&cell_info))
- {
- if (!cell_info->in_use)
- {
- /* g_object_unref (cell_info->cell); */
- if (cell_info->cell_row_ref)
- gtk_tree_row_reference_free (cell_info->cell_row_ref);
- g_free (cell_info);
- g_hash_table_iter_remove (&iter);
- }
- }
+ accessible->garbage_collection_pending = garbage_collect_cell_data (data);
- return tree_view->garbage_collection_pending;
+ /* N.B.: if for some reason another handler has re-enterantly been
+ * queued while this handler was being serviced, it has its own gsource,
+ * therefore this handler should always return FALSE.
+ */
+ return FALSE;
}
-/**
- * If tree_path is passed in as NULL, then all cells are acted on.
- * Otherwise, just act on those cells that are on a row greater than
- * the specified tree_path. If inc_row is passed in as TRUE, then rows
+/* If tree_path is passed in as NULL, then all cells are acted on.
+ * Otherwise, just act on those cells that are on a row greater than
+ * the specified tree_path. If inc_row is passed in as TRUE, then rows
* greater and equal to the specified tree_path are acted on.
*
- * if set_stale is set the ATK_STATE_STALE is set on cells which are to be
- * acted on.
+ * If set_stale is set the ATK_STATE_STALE is set on cells which
+ * are to be acted on.
*
* The function set_cell_visibility() is called on all cells to be
* acted on to update the visibility of the cell.
- **/
-static void
-traverse_cells (GailTreeView *tree_view,
- GtkTreePath *tree_path,
- gboolean set_stale,
- gboolean inc_row)
-{
- GailTreeViewCellInfo *cell_info;
- GtkTreeView *gtk_tree_view;
+ */
+static void
+traverse_cells (GtkTreeViewAccessible *accessible,
+ GtkTreePath *tree_path,
+ gboolean set_stale,
+ gboolean inc_row)
+{
+ GtkTreeViewAccessibleCellInfo *cell_info;
GtkWidget *widget;
GHashTableIter iter;
- g_assert (GTK_IS_ACCESSIBLE (tree_view));
-
- widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (tree_view));
+ widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible));
if (!widget)
- /* Widget is being deleted */
return;
- gtk_tree_view = GTK_TREE_VIEW (widget);
-
/* Must loop through them all */
- g_hash_table_iter_init (&iter, tree_view->cell_info_by_index);
+ g_hash_table_iter_init (&iter, accessible->cell_info_by_index);
while (g_hash_table_iter_next (&iter, NULL, (gpointer *)&cell_info))
{
GtkTreePath *row_path;
@@ -3216,12 +2922,15 @@ traverse_cells (GailTreeView *tree_view,
else
act_on_cell = FALSE;
}
- if (!cell_info->in_use) g_warning ("warning: cell info destroyed during traversal");
+
+ if (!cell_info->in_use)
+ g_warning ("warning: cell info destroyed during traversal");
+
if (act_on_cell && cell_info->in_use)
{
if (set_stale)
gail_cell_add_state (cell_info->cell, ATK_STATE_STALE, TRUE);
- set_cell_visibility (gtk_tree_view,
+ set_cell_visibility (GTK_TREE_VIEW (widget),
cell_info->cell,
cell_info->cell_col_ref,
row_path, TRUE);
@@ -3230,15 +2939,14 @@ traverse_cells (GailTreeView *tree_view,
}
}
- g_signal_emit_by_name (tree_view, "visible-data-changed");
+ g_signal_emit_by_name (accessible, "visible-data-changed");
}
-/*
- * If the tree_path passed in has children, then
+/* If the tree_path passed in has children, then
* ATK_STATE_EXPANDABLE is set. If the row is expanded
- * ATK_STATE_EXPANDED is turned on. If the row is
+ * ATK_STATE_EXPANDED is turned on. If the row is
* collapsed, then ATK_STATE_EXPANDED is removed.
- *
+ *
* If the tree_path passed in has no children, then
* ATK_STATE_EXPANDABLE and ATK_STATE_EXPANDED are removed.
*
@@ -3246,20 +2954,20 @@ traverse_cells (GailTreeView *tree_view,
* update all cells that are ancestors of the tree_path.
*/
static void
-set_expand_state (GtkTreeView *tree_view,
- GtkTreeModel *tree_model,
- GailTreeView *gailview,
- GtkTreePath *tree_path,
- gboolean set_on_ancestor)
+set_expand_state (GtkTreeView *tree_view,
+ GtkTreeModel *tree_model,
+ GtkTreeViewAccessible *accessible,
+ GtkTreePath *tree_path,
+ gboolean set_on_ancestor)
{
GtkTreeViewColumn *expander_tv;
- GailTreeViewCellInfo *cell_info;
+ GtkTreeViewAccessibleCellInfo *cell_info;
GtkTreePath *cell_path;
GtkTreeIter iter;
gboolean found;
GHashTableIter hash_iter;
- g_hash_table_iter_init (&hash_iter, gailview->cell_info_by_index);
+ g_hash_table_iter_init (&hash_iter, accessible->cell_info_by_index);
while (g_hash_table_iter_next (&hash_iter, NULL, (gpointer *) &cell_info))
{
if (cell_info->in_use)
@@ -3269,7 +2977,7 @@ set_expand_state (GtkTreeView *tree_view,
if (cell_path != NULL)
{
- GailCell *cell = GAIL_CELL (cell_info->cell);
+ GailCell *cell = GAIL_CELL (cell_info->cell);
expander_tv = gtk_tree_view_get_expander_column (tree_view);
@@ -3281,9 +2989,9 @@ set_expand_state (GtkTreeView *tree_view,
if (tree_path && gtk_tree_path_compare (cell_path, tree_path) == 0)
found = TRUE;
else if (set_on_ancestor &&
- gtk_tree_path_get_depth (cell_path) <
- gtk_tree_path_get_depth (tree_path) &&
- gtk_tree_path_is_ancestor (cell_path, tree_path) == 1)
+ gtk_tree_path_get_depth (cell_path) <
+ gtk_tree_path_get_depth (tree_path) &&
+ gtk_tree_path_is_ancestor (cell_path, tree_path) == 1)
/* Only set if set_on_ancestor was passed in as TRUE */
found = TRUE;
}
@@ -3306,15 +3014,12 @@ set_expand_state (GtkTreeView *tree_view,
if (gtk_tree_view_row_expanded (tree_view, cell_path))
gail_cell_add_state (cell, ATK_STATE_EXPANDED, TRUE);
else
- gail_cell_remove_state (cell,
- ATK_STATE_EXPANDED, TRUE);
+ gail_cell_remove_state (cell, ATK_STATE_EXPANDED, TRUE);
}
else
{
- gail_cell_remove_state (cell,
- ATK_STATE_EXPANDED, TRUE);
- if (gail_cell_remove_state (cell,
- ATK_STATE_EXPANDABLE, TRUE))
+ gail_cell_remove_state (cell, ATK_STATE_EXPANDED, TRUE);
+ if (gail_cell_remove_state (cell, ATK_STATE_EXPANDABLE, TRUE))
/* The state may have been propagated to the container cell */
if (!GAIL_IS_CONTAINER_CELL (cell))
gail_cell_remove_action_by_name (cell,
@@ -3334,44 +3039,37 @@ set_expand_state (GtkTreeView *tree_view,
}
}
-
static void
add_cell_actions (GailCell *cell,
- gboolean editable)
+ gboolean editable)
{
if (GAIL_IS_BOOLEAN_CELL (cell))
gail_cell_add_action (cell,
- "toggle",
- "toggles the cell", /* action description */
- NULL,
- toggle_cell_toggled);
+ "toggle", "toggles the cell",
+ NULL, toggle_cell_toggled);
if (editable)
gail_cell_add_action (cell,
- "edit",
- "creates a widget in which the contents of the cell can be edited",
- NULL,
- edit_cell);
+ "edit", "creates a widget in which the contents of the cell can be edited",
+ NULL, edit_cell);
gail_cell_add_action (cell,
- "activate",
- "activate the cell",
- NULL,
- activate_cell);
+ "activate", "activate the cell",
+ NULL, activate_cell);
}
static void
toggle_cell_expanded (GailCell *cell)
{
- GailTreeViewCellInfo *cell_info;
+ GtkTreeViewAccessibleCellInfo *cell_info;
GtkTreeView *tree_view;
GtkTreePath *path;
AtkObject *parent;
AtkStateSet *stateset;
-
+
parent = atk_object_get_parent (ATK_OBJECT (cell));
if (GAIL_IS_CONTAINER_CELL (parent))
parent = atk_object_get_parent (parent);
- cell_info = find_cell_info (GAIL_TREE_VIEW (parent), cell, TRUE);
+ cell_info = find_cell_info (GTK_TREE_VIEW_ACCESSIBLE (parent), cell, TRUE);
if (!cell_info || !cell_info->cell_col_ref || !cell_info->cell_row_ref)
return;
@@ -3387,13 +3085,12 @@ toggle_cell_expanded (GailCell *cell)
gtk_tree_view_expand_row (tree_view, path, TRUE);
g_object_unref (stateset);
gtk_tree_path_free (path);
- return;
}
static void
toggle_cell_toggled (GailCell *cell)
{
- GailTreeViewCellInfo *cell_info;
+ GtkTreeViewAccessibleCellInfo *cell_info;
GtkTreePath *path;
gchar *pathstring;
GList *renderers, *cur_renderer;
@@ -3407,57 +3104,48 @@ toggle_cell_toggled (GailCell *cell)
parent = atk_object_get_parent (parent);
}
- cell_info = find_cell_info (GAIL_TREE_VIEW (parent), cell, TRUE);
+ cell_info = find_cell_info (GTK_TREE_VIEW_ACCESSIBLE (parent), cell, TRUE);
if (!cell_info || !cell_info->cell_col_ref || !cell_info->cell_row_ref)
return;
path = gtk_tree_row_reference_get_path (cell_info->cell_row_ref);
if (!path)
return;
- pathstring = gtk_tree_path_to_string (path);
-
- renderers = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (cell_info->cell_col_ref));
- if (!renderers)
- return;
- /*
- * if the cell is in a container, its index is used to find the
- * renderer in the list
+ /* If the cell is in a container, its index is used to find the
+ * renderer in the list. Otherwise, we assume that the cell is
+ * represented by the first renderer in the list
*/
-
+ renderers = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (cell_info->cell_col_ref));
if (is_container_cell)
cur_renderer = g_list_nth (renderers, cell->index);
else
- /*
- * Otherwise, we assume that the cell is represented by the first
- * renderer in the list
- */
cur_renderer = renderers;
- if (!cur_renderer)
- return;
+ if (cur_renderer)
+ {
+ pathstring = gtk_tree_path_to_string (path);
+ g_signal_emit_by_name (cur_renderer->data, "toggled", pathstring);
+ }
- g_signal_emit_by_name (cur_renderer->data, "toggled", pathstring);
g_list_free (renderers);
g_free (pathstring);
gtk_tree_path_free (path);
- return;
}
static void
edit_cell (GailCell *cell)
{
- GailTreeViewCellInfo *cell_info;
+ GtkTreeViewAccessibleCellInfo *cell_info;
GtkTreeView *tree_view;
GtkTreePath *path;
AtkObject *parent;
- editing = TRUE;
parent = atk_object_get_parent (ATK_OBJECT (cell));
if (GAIL_IS_CONTAINER_CELL (parent))
parent = atk_object_get_parent (parent);
- cell_info = find_cell_info (GAIL_TREE_VIEW (parent), cell, TRUE);
+ cell_info = find_cell_info (GTK_TREE_VIEW_ACCESSIBLE (parent), cell, TRUE);
if (!cell_info || !cell_info->cell_col_ref || !cell_info->cell_row_ref)
return;
@@ -3467,23 +3155,21 @@ edit_cell (GailCell *cell)
return;
gtk_tree_view_set_cursor (tree_view, path, cell_info->cell_col_ref, TRUE);
gtk_tree_path_free (path);
- return;
}
static void
activate_cell (GailCell *cell)
{
- GailTreeViewCellInfo *cell_info;
+ GtkTreeViewAccessibleCellInfo *cell_info;
GtkTreeView *tree_view;
GtkTreePath *path;
AtkObject *parent;
- editing = TRUE;
parent = atk_object_get_parent (ATK_OBJECT (cell));
if (GAIL_IS_CONTAINER_CELL (parent))
parent = atk_object_get_parent (parent);
- cell_info = find_cell_info (GAIL_TREE_VIEW (parent), cell, TRUE);
+ cell_info = find_cell_info (GTK_TREE_VIEW_ACCESSIBLE (parent), cell, TRUE);
if (!cell_info || !cell_info->cell_col_ref || !cell_info->cell_row_ref)
return;
@@ -3493,32 +3179,32 @@ activate_cell (GailCell *cell)
return;
gtk_tree_view_row_activated (tree_view, path, cell_info->cell_col_ref);
gtk_tree_path_free (path);
- return;
}
static void
cell_destroyed (gpointer data)
{
- GailTreeViewCellInfo *cell_info = data;
+ GtkTreeViewAccessibleCellInfo *cell_info = data;
if (!cell_info)
return;
- if (cell_info->in_use) {
+ if (cell_info->in_use)
+ {
cell_info->in_use = FALSE;
- g_assert (GAIL_IS_TREE_VIEW (cell_info->view));
- if (!cell_info->view->garbage_collection_pending) {
- cell_info->view->garbage_collection_pending = TRUE;
- cell_info->view->idle_garbage_collect_id =
- gdk_threads_add_idle (idle_garbage_collect_cell_data, cell_info->view);
- }
- }
+ if (!cell_info->view->garbage_collection_pending)
+ {
+ cell_info->view->garbage_collection_pending = TRUE;
+ cell_info->view->idle_garbage_collect_id =
+ gdk_threads_add_idle (idle_garbage_collect_cell_data, cell_info->view);
+ }
+ }
}
static void
-cell_info_get_index (GtkTreeView *tree_view,
- GailTreeViewCellInfo *info,
- gint *index)
+cell_info_get_index (GtkTreeView *tree_view,
+ GtkTreeViewAccessibleCellInfo *info,
+ gint *index)
{
GtkTreePath *path;
gint column_number;
@@ -3533,170 +3219,148 @@ cell_info_get_index (GtkTreeView *tree_view,
}
static void
-cell_info_new (GailTreeView *gailview,
- GtkTreeModel *tree_model,
- GtkTreePath *path,
- GtkTreeViewColumn *tv_col,
- GailCell *cell )
+cell_info_new (GtkTreeViewAccessible *accessible,
+ GtkTreeModel *tree_model,
+ GtkTreePath *path,
+ GtkTreeViewColumn *tv_col,
+ GailCell *cell)
{
- GailTreeViewCellInfo *cell_info;
-
- g_assert (GAIL_IS_TREE_VIEW (gailview));
+ GtkTreeViewAccessibleCellInfo *cell_info;
- cell_info = g_new (GailTreeViewCellInfo, 1);
+ cell_info = g_new (GtkTreeViewAccessibleCellInfo, 1);
cell_info->cell_row_ref = gtk_tree_row_reference_new (tree_model, path);
cell_info->cell_col_ref = tv_col;
cell_info->cell = cell;
cell_info->in_use = TRUE; /* if we've created it, assume it's in use */
- cell_info->view = gailview;
- g_hash_table_insert (gailview->cell_info_by_index, &cell->index, cell_info);
+ cell_info->view = accessible;
+ g_hash_table_insert (accessible->cell_info_by_index, &cell->index, cell_info);
/* Setup weak reference notification */
-
- g_object_weak_ref (G_OBJECT (cell),
- (GWeakNotify) cell_destroyed,
- cell_info);
+ g_object_weak_ref (G_OBJECT (cell), (GWeakNotify) cell_destroyed, cell_info);
}
-static GailCell*
-find_cell (GailTreeView *gailview,
- gint index)
+static GailCell *
+find_cell (GtkTreeViewAccessible *accessible,
+ gint index)
{
- GailTreeViewCellInfo *info;
- GailCell *retval = NULL;
+ GtkTreeViewAccessibleCellInfo *info;
- info = g_hash_table_lookup (gailview->cell_info_by_index, &index);
- if (info != NULL)
- retval = info->cell;
+ info = g_hash_table_lookup (accessible->cell_info_by_index, &index);
+ if (!info)
+ return NULL;
- return retval;
+ return info->cell;
}
static void
refresh_cell_index (GailCell *cell)
{
- GailTreeViewCellInfo *info;
+ GtkTreeViewAccessibleCellInfo *info;
AtkObject *parent;
GtkTreeView *tree_view;
- GailTreeView *gailview;
+ GtkTreeViewAccessible *accessible;
gint index;
parent = atk_object_get_parent (ATK_OBJECT (cell));
- if (!GAIL_IS_TREE_VIEW (parent))
+ if (!GTK_IS_TREE_VIEW_ACCESSIBLE (parent))
return;
- gailview = GAIL_TREE_VIEW (parent);
- tree_view = GTK_TREE_VIEW (gtk_accessible_get_widget (GTK_ACCESSIBLE (parent)));
+ accessible = GTK_TREE_VIEW_ACCESSIBLE (parent);
- /* Find this cell in the GailTreeView's cache */
+ tree_view = GTK_TREE_VIEW (gtk_accessible_get_widget (GTK_ACCESSIBLE (parent)));
- info = find_cell_info (gailview, cell, TRUE);
+ /* Find this cell in the GtkTreeViewAccessible's cache */
+ info = find_cell_info (accessible, cell, TRUE);
if (!info)
return;
-
- cell_info_get_index (tree_view, info, &index);
- cell->index = index;
- g_hash_table_insert (gailview->cell_info_by_index, &index, info);
-}
-
-static void
-get_selected_rows (GtkTreeModel *model,
- GtkTreePath *path,
- GtkTreeIter *iter,
- gpointer data)
-{
- GPtrArray *array = (GPtrArray *)data;
- g_ptr_array_add (array, gtk_tree_path_copy (path));
+ cell_info_get_index (tree_view, info, &index);
+ cell->index = index;
+ g_hash_table_insert (accessible->cell_info_by_index, &index, info);
}
static void
-connect_model_signals (GtkTreeView *view,
- GailTreeView *gailview)
+connect_model_signals (GtkTreeView *view,
+ GtkTreeViewAccessible *accessible)
{
GObject *obj;
- obj = G_OBJECT (gailview->tree_model);
+ obj = G_OBJECT (accessible->tree_model);
g_signal_connect_data (obj, "row-changed",
- (GCallback) model_row_changed, view, NULL, 0);
+ G_CALLBACK (model_row_changed), view, NULL, 0);
g_signal_connect_data (obj, "row-inserted",
- (GCallback) model_row_inserted, view, NULL,
+ G_CALLBACK (model_row_inserted), view, NULL,
G_CONNECT_AFTER);
g_signal_connect_data (obj, "row-deleted",
- (GCallback) model_row_deleted, view, NULL,
+ G_CALLBACK (model_row_deleted), view, NULL,
G_CONNECT_AFTER);
g_signal_connect_data (obj, "rows-reordered",
- (GCallback) model_rows_reordered, view, NULL,
+ G_CALLBACK (model_rows_reordered), view, NULL,
G_CONNECT_AFTER);
}
static void
-disconnect_model_signals (GailTreeView *view)
+disconnect_model_signals (GtkTreeViewAccessible *accessible)
{
GObject *obj;
GtkWidget *widget;
- obj = G_OBJECT (view->tree_model);
- widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (view));
- g_signal_handlers_disconnect_by_func (obj, (gpointer) model_row_changed, widget);
- g_signal_handlers_disconnect_by_func (obj, (gpointer) model_row_inserted, widget);
- g_signal_handlers_disconnect_by_func (obj, (gpointer) model_row_deleted, widget);
- g_signal_handlers_disconnect_by_func (obj, (gpointer) model_rows_reordered, widget);
+ obj = G_OBJECT (accessible->tree_model);
+ widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible));
+ g_signal_handlers_disconnect_by_func (obj, model_row_changed, widget);
+ g_signal_handlers_disconnect_by_func (obj, model_row_inserted, widget);
+ g_signal_handlers_disconnect_by_func (obj, model_row_deleted, widget);
+ g_signal_handlers_disconnect_by_func (obj, model_rows_reordered, widget);
}
static void
-clear_cached_data (GailTreeView *view)
+clear_cached_data (GtkTreeViewAccessible *accessible)
{
- GailTreeViewCellInfo *cell_info;
+ GtkTreeViewAccessibleCellInfo *cell_info;
GHashTableIter iter;
/* Must loop through them all */
- g_hash_table_iter_init (&iter, view->cell_info_by_index);
+ g_hash_table_iter_init (&iter, accessible->cell_info_by_index);
while (g_hash_table_iter_next (&iter, NULL, (gpointer *) &cell_info))
- {
- clean_cell_info (view, cell_info);
- }
+ clean_cell_info (accessible, cell_info);
/* FIXME: seems pretty inefficient to loop again here */
- garbage_collect_cell_data (view);
+ garbage_collect_cell_data (accessible);
}
-/*
- * Returns the column number of the specified GtkTreeViewColumn
+/* Returns the column number of the specified GtkTreeViewColumn
*
- * If visible is set, the value returned will be the visible column number,
+ * If visible is set, the value returned will be the visible column number,
* i.e. suitable for use in AtkTable function. If visible is not set, the
- * value returned is the actual column number, which is suitable for use in
+ * value returned is the actual column number, which is suitable for use in
* getting an index value.
*/
static gint
get_column_number (GtkTreeView *tree_view,
GtkTreeViewColumn *column,
- gboolean visible)
+ gboolean visible)
{
GtkTreeViewColumn *tv_column;
gint ret_val;
gint i;
AtkObject *atk_obj;
- GailTreeView *gailview;
+ GtkTreeViewAccessible *accessible;
atk_obj = gtk_widget_get_accessible (GTK_WIDGET (tree_view));
- gailview = GAIL_TREE_VIEW (atk_obj);
+ accessible = GTK_TREE_VIEW_ACCESSIBLE (atk_obj);
ret_val = 0;
- for (i = 0; i < gailview->col_data->len; i++)
+ for (i = 0; i < accessible->col_data->len; i++)
{
- tv_column = g_array_index (gailview->col_data, GtkTreeViewColumn *, i);
+ tv_column = g_array_index (accessible->col_data, GtkTreeViewColumn *, i);
if (tv_column == column)
break;
if (!visible || gtk_tree_view_column_get_visible (tv_column))
ret_val++;
}
- if (i == gailview->col_data->len)
- {
- ret_val = -1;
- }
+ if (i == accessible->col_data->len)
+ ret_val = -1;
return ret_val;
}
@@ -3707,13 +3371,13 @@ get_index (GtkTreeView *tree_view,
gint actual_column)
{
AtkObject *atk_obj;
- GailTreeView *gailview;
+ GtkTreeViewAccessible *accessible;
gint depth = 0;
gint index = 1;
gint *indices = NULL;
atk_obj = gtk_widget_get_accessible (GTK_WIDGET (tree_view));
- gailview = GAIL_TREE_VIEW (atk_obj);
+ accessible = GTK_TREE_VIEW_ACCESSIBLE (atk_obj);
if (path)
{
@@ -3734,42 +3398,34 @@ get_index (GtkTreeView *tree_view,
}
if (path)
- index += indices[depth-1];
- index *= gailview->n_cols;
+ index += indices[depth - 1];
+ index *= accessible->n_cols;
index += actual_column;
return index;
}
-/*
- * The function count_rows counts the number of rows starting at iter and ending
- * at end_path. The value of level is the depth of iter and the value of depth
- * is the depth of end_path. Rows at depth before end_path are counted.
- * This functions counts rows which are not visible because an ancestor is
- * collapsed.
+/* The function count_rows counts the number of rows starting at iter
+ * and ending at end_path. The value of level is the depth of iter and
+ * the value of depth is the depth of end_path. Rows at depth before
+ * end_path are counted. This functions counts rows which are not visible
+ * because an ancestor is collapsed.
*/
-static void
+static void
count_rows (GtkTreeModel *model,
- GtkTreeIter *iter,
- GtkTreePath *end_path,
- gint *count,
- gint level,
- gint depth)
+ GtkTreeIter *iter,
+ GtkTreePath *end_path,
+ gint *count,
+ gint level,
+ gint depth)
{
GtkTreeIter child_iter;
-
- if (!model) return;
- level++;
+ if (!model)
+ return;
+ level++;
*count += gtk_tree_model_iter_n_children (model, iter);
-#if 0
- g_print ("count_rows : %d level: %d depth: %d\n", *count, level, depth);
- if (iter != NULL)
- g_print ("path: %s\n",
- gtk_tree_path_to_string (gtk_tree_model_get_path (model, iter)));
-#endif
-
if (gtk_tree_model_get_flags (model) & GTK_TREE_MODEL_LIST_ONLY)
return;
@@ -3784,7 +3440,7 @@ count_rows (GtkTreeModel *model,
{
if (level == depth - 1)
{
- GtkTreePath *iter_path;
+ GtkTreePath *iter_path;
gboolean finished = FALSE;
iter_path = gtk_tree_model_get_path (model, &child_iter);
@@ -3801,18 +3457,18 @@ count_rows (GtkTreeModel *model,
}
}
-/*
- * Find the next node, which has children, at the specified depth below
+/* Find the next node, which has children, at the specified depth below
* the specified iter. The level is the depth of the current iter.
- * The position of the node is returned in path and the return value of TRUE
- * means that a node was found.
+ * The position of the node is returned in path and the return value
+ * of TRUE means that a node was found.
*/
-gboolean get_next_node_with_child_at_depth (GtkTreeModel *model,
- GtkTreeIter *iter,
- GtkTreePath **path,
- gint level,
- gint depth)
+static gboolean
+get_next_node_with_child_at_depth (GtkTreeModel *model,
+ GtkTreeIter *iter,
+ GtkTreePath **path,
+ gint level,
+ gint depth)
{
GtkTreeIter child_iter;
@@ -3831,8 +3487,8 @@ gboolean get_next_node_with_child_at_depth (GtkTreeModel *model,
}
if (level == depth)
- /* We have found what we were looking for */
{
+ /* We have found what we were looking for */
*path = gtk_tree_model_get_path (model, &child_iter);
return TRUE;
}
@@ -3848,13 +3504,12 @@ gboolean get_next_node_with_child_at_depth (GtkTreeModel *model,
return FALSE;
}
-/*
- * Find the next node, which has children, at the same depth as
- * the specified GtkTreePath.
+/* Find the next node, which has children, at the same depth
+ * as the specified GtkTreePath.
*/
-static gboolean
-get_next_node_with_child (GtkTreeModel *model,
- GtkTreePath *path,
+static gboolean
+get_next_node_with_child (GtkTreeModel *model,
+ GtkTreePath *path,
GtkTreePath **return_path)
{
GtkTreeIter iter;
@@ -3886,9 +3541,9 @@ get_next_node_with_child (GtkTreeModel *model,
return FALSE;
}
-static gboolean
-get_tree_path_from_row_index (GtkTreeModel *model,
- gint row_index,
+static gboolean
+get_tree_path_from_row_index (GtkTreeModel *model,
+ gint row_index,
GtkTreePath **tree_path)
{
GtkTreeIter iter;
@@ -3930,9 +3585,9 @@ get_tree_path_from_row_index (GtkTreeModel *model,
else
row_index -= count;
- if (!get_next_node_with_child (model, *tree_path, &next_path))
+ if (!get_next_node_with_child (model, *tree_path, &next_path))
break;
-
+
gtk_tree_path_free (*tree_path);
*tree_path = next_path;
}
@@ -3948,23 +3603,23 @@ get_tree_path_from_row_index (GtkTreeModel *model,
}
static gboolean
-get_path_column_from_index (GtkTreeView *tree_view,
- gint index,
+get_path_column_from_index (GtkTreeView *tree_view,
+ gint index,
GtkTreePath **path,
GtkTreeViewColumn **column)
{
GtkTreeModel *tree_model;
AtkObject *atk_obj;
- GailTreeView *gailview;
+ GtkTreeViewAccessible *accessible;
atk_obj = gtk_widget_get_accessible (GTK_WIDGET (tree_view));
- gailview = GAIL_TREE_VIEW (atk_obj);
+ accessible = GTK_TREE_VIEW_ACCESSIBLE (atk_obj);
tree_model = gtk_tree_view_get_model (tree_view);
- if (gailview->n_cols == 0)
+ if (accessible->n_cols == 0)
return FALSE;
/* First row is the column headers */
- index -= gailview->n_cols;
+ index -= accessible->n_cols;
if (index < 0)
return FALSE;
@@ -3973,20 +3628,20 @@ get_path_column_from_index (GtkTreeView *tree_view,
gint row_index;
gboolean retval;
- row_index = index / gailview->n_cols;
+ row_index = index / accessible->n_cols;
retval = get_tree_path_from_row_index (tree_model, row_index, path);
if (!retval)
return FALSE;
if (*path == NULL)
return FALSE;
- }
+ }
if (column)
{
- *column = gtk_tree_view_get_column (tree_view, index % gailview->n_cols);
+ *column = gtk_tree_view_get_column (tree_view, index % accessible->n_cols);
if (*column == NULL)
{
- if (path)
+ if (path)
gtk_tree_path_free (*path);
return FALSE;
}
@@ -3997,27 +3652,23 @@ get_path_column_from_index (GtkTreeView *tree_view,
static void
set_cell_expandable (GailCell *cell)
{
- if (gail_cell_add_state (cell,
- ATK_STATE_EXPANDABLE,
- FALSE))
+ if (gail_cell_add_state (cell, ATK_STATE_EXPANDABLE, FALSE))
gail_cell_add_action (cell,
- "expand or contract", /* action name */
- "expands or contracts the row in the tree view "
- "containing this cell", /* description */
- NULL, /* Keybinding */
- toggle_cell_expanded);
+ "expand or contract",
+ "expands or contracts the row in the tree view containing this cell",
+ NULL, toggle_cell_expanded);
}
-static GailTreeViewCellInfo*
-find_cell_info (GailTreeView *view,
- GailCell *cell,
- gboolean live_only)
+static GtkTreeViewAccessibleCellInfo *
+find_cell_info (GtkTreeViewAccessible *accessible,
+ GailCell *cell,
+ gboolean live_only)
{
- GailTreeViewCellInfo *cell_info;
+ GtkTreeViewAccessibleCellInfo *cell_info;
GHashTableIter iter;
- /* Clean GailTreeViewCellInfo data */
- g_hash_table_iter_init (&iter, view->cell_info_by_index);
+ /* Clean GtkTreeViewAccessibleCellInfo data */
+ g_hash_table_iter_init (&iter, accessible->cell_info_by_index);
while (g_hash_table_iter_next (&iter, NULL, (gpointer *) &cell_info))
{
if (cell_info->cell == cell && (!live_only || cell_info->in_use))
diff --git a/gtk/a11y/gtktreeviewaccessible.h b/gtk/a11y/gtktreeviewaccessible.h
new file mode 100644
index 0000000..698a83b
--- /dev/null
+++ b/gtk/a11y/gtktreeviewaccessible.h
@@ -0,0 +1,69 @@
+/* GAIL - The GNOME Accessibility Implementation Library
+ * Copyright 2001 Sun Microsystems Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __GTK_TREE_VIEW_ACCESSIBLE_H__
+#define __GTK_TREE_VIEW_ACCESSIBLE_H__
+
+#include <gtk/gtk.h>
+#include "gailcontainer.h"
+#include "gailcell.h"
+
+G_BEGIN_DECLS
+
+#define GTK_TYPE_TREE_VIEW_ACCESSIBLE (gtk_tree_view_accessible_get_type ())
+#define GTK_TREE_VIEW_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_TREE_VIEW_ACCESSIBLE, GtkTreeViewAccessible))
+#define GTK_TREE_VIEW_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_TREE_VIEW_ACCESSIBLE, GtkTreeViewAccessibleClass))
+#define GTK_IS_TREE_VIEW_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_TREE_VIEW_ACCESSIBLE))
+#define GTK_IS_TREE_VIEW_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_TREE_VIEW_ACCESSIBLE))
+#define GTK_TREE_VIEW_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_TREE_VIEW_ACCESSIBLE, GtkTreeViewAccessibleClass))
+
+typedef struct _GtkTreeViewAccessible GtkTreeViewAccessible;
+typedef struct _GtkTreeViewAccessibleClass GtkTreeViewAccessibleClass;
+
+struct _GtkTreeViewAccessible
+{
+ GailContainer parent;
+
+ gint n_children_deleted;
+ gint n_rows;
+ gint n_cols;
+ GArray* col_data;
+ GHashTable *cell_info_by_index;
+ GtkTreeModel *tree_model;
+ AtkObject *focus_cell;
+ GtkAdjustment *old_hadj;
+ GtkAdjustment *old_vadj;
+ guint idle_expand_id;
+ guint idle_garbage_collect_id;
+ guint idle_cursor_changed_id;
+ GtkTreePath *idle_expand_path;
+ gboolean garbage_collection_pending;
+};
+
+struct _GtkTreeViewAccessibleClass
+{
+ GailContainerClass parent_class;
+};
+
+GType gtk_tree_view_accessible_get_type (void);
+AtkObject *gtk_tree_view_accessible_ref_focus_cell (GtkTreeView *treeview);
+
+G_END_DECLS
+
+#endif /* __GTK_TREE_VIEW_ACCESSIBLE_H__ */
diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c
index c5c3bd0..906912e 100644
--- a/gtk/gtktreeview.c
+++ b/gtk/gtktreeview.c
@@ -50,6 +50,7 @@
#include "gtkentryprivate.h"
#include "gtkstylecontextprivate.h"
#include "gtktypebuiltins.h"
+#include "a11y/gtktreeviewaccessible.h"
/**
@@ -1695,6 +1696,8 @@ gtk_tree_view_class_init (GtkTreeViewClass *class)
gtk_binding_entry_add_signal (binding_set, GDK_KEY_F, GDK_CONTROL_MASK, "start-interactive-search", 0);
g_type_class_add_private (o_class, sizeof (GtkTreeViewPrivate));
+
+ gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_TREE_VIEW_ACCESSIBLE);
}
static void
diff --git a/tests/a11y/appchooser.txt b/tests/a11y/appchooser.txt
index 5750f27..213b8ff 100644
--- a/tests/a11y/appchooser.txt
+++ b/tests/a11y/appchooser.txt
@@ -91,7 +91,7 @@ window1
<AtkComponent>
layer: widget
alpha: 1
- unnamed-GailTreeView-5
+ unnamed-GtkTreeViewAccessible-5
"table"
parent: unnamed-GtkScrolledWindowAccessible-4
index: 0
@@ -108,7 +108,7 @@ window1
<column 0 header>
"table column header"
- parent: unnamed-GailTreeView-5
+ parent: unnamed-GtkTreeViewAccessible-5
index: 0
name:
state: enabled focusable selectable sensitive
@@ -154,7 +154,7 @@ window1
action 0 name: click
"table column header"
- parent: unnamed-GailTreeView-5
+ parent: unnamed-GtkTreeViewAccessible-5
index: 0
name:
state: enabled focusable selectable sensitive
@@ -200,7 +200,7 @@ window1
action 0 name: click
unnamed-GailContainerCell-6
"table cell"
- parent: unnamed-GailTreeView-5
+ parent: unnamed-GtkTreeViewAccessible-5
index: 1
state: enabled focusable focused selectable sensitive transient visible
<AtkComponent>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]