diff --git a/gtk/a11y/gtkcellaccessible.c b/gtk/a11y/gtkcellaccessible.c index bc503a9c27..47c5f97314 100644 --- a/gtk/a11y/gtkcellaccessible.c +++ b/gtk/a11y/gtkcellaccessible.c @@ -445,3 +445,38 @@ _gtk_cell_accessible_set_cell_data (GtkCellAccessible *cell) _gtk_cell_accessible_parent_set_cell_data (GTK_CELL_ACCESSIBLE_PARENT (parent), cell); } +/** + * _gtk_cell_accessible_get_state: + * @cell: a #GtkCellAccessible + * @expandable: (out): %NULL or pointer to boolean that gets set to + * whether the cell can be expanded + * @expanded: (out): %NULL or pointer to boolean that gets set to + * whether the cell is expanded + * + * Gets the state that would be used to render the area referenced by @cell. + * + * Returns: the #GtkCellRendererState for cell + **/ +GtkCellRendererState +_gtk_cell_accessible_get_state (GtkCellAccessible *cell, + gboolean *expandable, + gboolean *expanded) +{ + AtkObject *parent; + + g_return_val_if_fail (GTK_IS_CELL_ACCESSIBLE (cell), 0); + + if (expandable) + *expandable = FALSE; + if (expanded) + *expanded = FALSE; + + parent = gtk_widget_get_accessible (cell->widget); + if (parent == NULL) + return 0; + + return _gtk_cell_accessible_parent_get_renderer_state (GTK_CELL_ACCESSIBLE_PARENT (parent), + cell, + expandable, + expanded); +} diff --git a/gtk/a11y/gtkcellaccessible.h b/gtk/a11y/gtkcellaccessible.h index 823ae8dfbc..84cd4bff2b 100644 --- a/gtk/a11y/gtkcellaccessible.h +++ b/gtk/a11y/gtkcellaccessible.h @@ -50,6 +50,10 @@ struct _GtkCellAccessibleClass GType _gtk_cell_accessible_get_type (void); +GtkCellRendererState + _gtk_cell_accessible_get_state (GtkCellAccessible *cell, + gboolean *expandable, + gboolean *expanded); void _gtk_cell_accessible_set_cell_data (GtkCellAccessible *cell); void _gtk_cell_accessible_initialise (GtkCellAccessible *cell, diff --git a/gtk/a11y/gtkcellaccessibleparent.c b/gtk/a11y/gtkcellaccessibleparent.c index 76c6b76411..6f76ccb146 100644 --- a/gtk/a11y/gtkcellaccessibleparent.c +++ b/gtk/a11y/gtkcellaccessibleparent.c @@ -112,6 +112,30 @@ _gtk_cell_accessible_parent_get_child_index (GtkCellAccessibleParent *parent, return -1; } +GtkCellRendererState +_gtk_cell_accessible_parent_get_renderer_state (GtkCellAccessibleParent *parent, + GtkCellAccessible *cell, + gboolean *expandable, + gboolean *expanded) +{ + GtkCellAccessibleParentIface *iface; + + g_return_val_if_fail (GTK_IS_CELL_ACCESSIBLE_PARENT (parent), 0); + g_return_val_if_fail (GTK_IS_CELL_ACCESSIBLE (cell), 0); + + iface = GTK_CELL_ACCESSIBLE_PARENT_GET_IFACE (parent); + + if (expandable) + *expandable = FALSE; + if (expanded) + *expanded = FALSE; + + if (iface->get_renderer_state) + return (iface->get_renderer_state) (parent, cell, expandable, expanded); + else + return 0; +} + void _gtk_cell_accessible_parent_set_cell_data (GtkCellAccessibleParent *parent, GtkCellAccessible *cell) diff --git a/gtk/a11y/gtkcellaccessibleparent.h b/gtk/a11y/gtkcellaccessibleparent.h index 797a784267..78edf0298d 100644 --- a/gtk/a11y/gtkcellaccessibleparent.h +++ b/gtk/a11y/gtkcellaccessibleparent.h @@ -60,6 +60,11 @@ struct _GtkCellAccessibleParentIface GtkCellAccessible *cell); int ( *get_child_index) (GtkCellAccessibleParent *parent, GtkCellAccessible *cell); + GtkCellRendererState + ( *get_renderer_state) (GtkCellAccessibleParent *parent, + GtkCellAccessible *cell, + gboolean *expandable, + gboolean *expanded); void ( *set_cell_data) (GtkCellAccessibleParent *parent, GtkCellAccessible *cell); @@ -81,6 +86,11 @@ gboolean _gtk_cell_accessible_parent_grab_focus (GtkCellAccessibleParent * GtkCellAccessible *cell); int _gtk_cell_accessible_parent_get_child_index (GtkCellAccessibleParent *parent, GtkCellAccessible *cell); +GtkCellRendererState + _gtk_cell_accessible_parent_get_renderer_state(GtkCellAccessibleParent *parent, + GtkCellAccessible *cell, + gboolean *expandable, + gboolean *expanded); void _gtk_cell_accessible_parent_set_cell_data (GtkCellAccessibleParent *parent, GtkCellAccessible *cell); diff --git a/gtk/a11y/gtktreeviewaccessible.c b/gtk/a11y/gtktreeviewaccessible.c index d8bf3d61ca..bdc853db01 100644 --- a/gtk/a11y/gtktreeviewaccessible.c +++ b/gtk/a11y/gtktreeviewaccessible.c @@ -1516,6 +1516,64 @@ gtk_tree_view_accessible_get_child_index (GtkCellAccessibleParent *parent, return cell_info_get_index (tree_view, cell_info); } +static GtkCellRendererState +gtk_tree_view_accessible_get_renderer_state (GtkCellAccessibleParent *parent, + GtkCellAccessible *cell, + gboolean *expandable, + gboolean *expanded) +{ + GtkTreeViewAccessibleCellInfo *cell_info; + GtkTreeView *treeview; + GtkCellRendererState flags; + + cell_info = find_cell_info (GTK_TREE_VIEW_ACCESSIBLE (parent), cell); + if (!cell_info) + return 0; + + flags = 0; + + if (GTK_RBNODE_FLAG_SET (cell_info->node, GTK_RBNODE_IS_SELECTED)) + flags |= GTK_CELL_RENDERER_SELECTED; + + if (GTK_RBNODE_FLAG_SET (cell_info->node, GTK_RBNODE_IS_PRELIT)) + flags |= GTK_CELL_RENDERER_PRELIT; + + if (gtk_tree_view_column_get_sort_indicator (cell_info->cell_col_ref)) + flags |= GTK_CELL_RENDERER_SORTED; + + treeview = GTK_TREE_VIEW (gtk_accessible_get_widget (GTK_ACCESSIBLE (parent))); + if (gtk_widget_has_focus (GTK_WIDGET (treeview))) + { + GtkTreeViewColumn *column; + GtkTreePath *path; + GtkRBTree *tree; + GtkRBNode *node; + + gtk_tree_view_get_cursor (treeview, &path, &column); + if (path) + { + _gtk_tree_view_find_node (treeview, path, &tree, &node); + gtk_tree_path_free (path); + } + else + tree = NULL; + + if (cell_info->cell_col_ref == column + && cell_info->tree == tree + && cell_info->node == node) + flags |= GTK_CELL_RENDERER_FOCUSED; + } + + if (expandable) + *expandable = GTK_RBNODE_FLAG_SET (cell_info->node, GTK_RBNODE_IS_PARENT) + && cell_info->cell_col_ref == gtk_tree_view_get_expander_column (treeview); + if (expanded) + *expanded = cell_info->node->children + && cell_info->cell_col_ref == gtk_tree_view_get_expander_column (treeview); + + return flags; +} + static void gtk_tree_view_accessible_set_cell_data (GtkCellAccessibleParent *parent, GtkCellAccessible *cell) @@ -1568,6 +1626,7 @@ gtk_cell_accessible_parent_interface_init (GtkCellAccessibleParentIface *iface) iface->get_cell_area = gtk_tree_view_accessible_get_cell_area; iface->grab_focus = gtk_tree_view_accessible_grab_cell_focus; iface->get_child_index = gtk_tree_view_accessible_get_child_index; + iface->get_renderer_state = gtk_tree_view_accessible_get_renderer_state; iface->set_cell_data = gtk_tree_view_accessible_set_cell_data; }