a11y: Add get_renderer_state() to cell accessibles
Accessibles can use this function to query the state that their row would be rendered with.
This commit is contained in:
@ -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);
|
||||
}
|
||||
|
@ -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,
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user