a11y: Add _gtk_cell_accessible_set_cell_data()
See the function documentation for details. Also included is the implementation for the treeview, but no users yet.
This commit is contained in:
@ -421,3 +421,27 @@ atk_component_interface_init (AtkComponentIface *iface)
|
||||
iface->get_extents = gtk_cell_accessible_get_extents;
|
||||
iface->grab_focus = gtk_cell_accessible_grab_focus;
|
||||
}
|
||||
|
||||
/**
|
||||
* _gtk_cell_accessible_set_cell_data:
|
||||
* @cell: a #GtkCellAccessible
|
||||
*
|
||||
* Sets the cell data to the row used by @cell. This is useful in
|
||||
* particular if you want to work with cell renderers.
|
||||
*
|
||||
* Note that this function is potentially slow, so be careful.
|
||||
**/
|
||||
void
|
||||
_gtk_cell_accessible_set_cell_data (GtkCellAccessible *cell)
|
||||
{
|
||||
AtkObject *parent;
|
||||
|
||||
g_return_if_fail (GTK_IS_CELL_ACCESSIBLE (cell));
|
||||
|
||||
parent = gtk_widget_get_accessible (cell->widget);
|
||||
if (parent == NULL)
|
||||
return;
|
||||
|
||||
_gtk_cell_accessible_parent_set_cell_data (GTK_CELL_ACCESSIBLE_PARENT (parent), cell);
|
||||
}
|
||||
|
||||
|
@ -50,6 +50,8 @@ struct _GtkCellAccessibleClass
|
||||
|
||||
GType _gtk_cell_accessible_get_type (void);
|
||||
|
||||
void _gtk_cell_accessible_set_cell_data (GtkCellAccessible *cell);
|
||||
|
||||
void _gtk_cell_accessible_initialise (GtkCellAccessible *cell,
|
||||
GtkWidget *widget,
|
||||
AtkObject *parent);
|
||||
|
@ -111,3 +111,19 @@ _gtk_cell_accessible_parent_get_child_index (GtkCellAccessibleParent *parent,
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_cell_accessible_parent_set_cell_data (GtkCellAccessibleParent *parent,
|
||||
GtkCellAccessible *cell)
|
||||
{
|
||||
GtkCellAccessibleParentIface *iface;
|
||||
|
||||
g_return_if_fail (GTK_IS_CELL_ACCESSIBLE_PARENT (parent));
|
||||
g_return_if_fail (GTK_IS_CELL_ACCESSIBLE (cell));
|
||||
|
||||
iface = GTK_CELL_ACCESSIBLE_PARENT_GET_IFACE (parent);
|
||||
|
||||
if (iface->set_cell_data)
|
||||
(iface->set_cell_data) (parent, cell);
|
||||
}
|
||||
|
||||
|
@ -60,6 +60,9 @@ struct _GtkCellAccessibleParentIface
|
||||
GtkCellAccessible *cell);
|
||||
int ( *get_child_index) (GtkCellAccessibleParent *parent,
|
||||
GtkCellAccessible *cell);
|
||||
void ( *set_cell_data) (GtkCellAccessibleParent *parent,
|
||||
GtkCellAccessible *cell);
|
||||
|
||||
};
|
||||
|
||||
GType _gtk_cell_accessible_parent_get_type (void);
|
||||
@ -78,6 +81,8 @@ gboolean _gtk_cell_accessible_parent_grab_focus (GtkCellAccessibleParent *
|
||||
GtkCellAccessible *cell);
|
||||
int _gtk_cell_accessible_parent_get_child_index (GtkCellAccessibleParent *parent,
|
||||
GtkCellAccessible *cell);
|
||||
void _gtk_cell_accessible_parent_set_cell_data (GtkCellAccessibleParent *parent,
|
||||
GtkCellAccessible *cell);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@ -1516,6 +1516,51 @@ gtk_tree_view_accessible_get_child_index (GtkCellAccessibleParent *parent,
|
||||
return cell_info_get_index (tree_view, cell_info);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_tree_view_accessible_set_cell_data (GtkCellAccessibleParent *parent,
|
||||
GtkCellAccessible *cell)
|
||||
{
|
||||
GtkTreeViewAccessibleCellInfo *cell_info;
|
||||
GtkTreeView *treeview;
|
||||
gboolean is_expander, is_expanded;
|
||||
GtkTreeModel *model;
|
||||
GtkTreeIter iter;
|
||||
GtkTreePath *path;
|
||||
|
||||
cell_info = find_cell_info (GTK_TREE_VIEW_ACCESSIBLE (parent), cell);
|
||||
if (!cell_info)
|
||||
return;
|
||||
|
||||
treeview = GTK_TREE_VIEW (gtk_accessible_get_widget (GTK_ACCESSIBLE (parent)));
|
||||
model = gtk_tree_view_get_model (treeview);
|
||||
|
||||
if (GTK_RBNODE_FLAG_SET (cell_info->node, GTK_RBNODE_IS_PARENT) &&
|
||||
cell_info->cell_col_ref == gtk_tree_view_get_expander_column (treeview))
|
||||
{
|
||||
is_expander = TRUE;
|
||||
is_expanded = cell_info->node->children != NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
is_expander = FALSE;
|
||||
is_expanded = FALSE;
|
||||
}
|
||||
|
||||
path = cell_info_get_path (cell_info);
|
||||
if (path == NULL ||
|
||||
!gtk_tree_model_get_iter (model, &iter, path))
|
||||
{
|
||||
/* We only track valid cells, this should never happen */
|
||||
g_return_if_reached ();
|
||||
}
|
||||
|
||||
gtk_tree_view_column_cell_set_cell_data (cell_info->cell_col_ref,
|
||||
model,
|
||||
&iter,
|
||||
is_expander,
|
||||
is_expanded);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_cell_accessible_parent_interface_init (GtkCellAccessibleParentIface *iface)
|
||||
{
|
||||
@ -1523,6 +1568,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->set_cell_data = gtk_tree_view_accessible_set_cell_data;
|
||||
}
|
||||
|
||||
/* signal handling */
|
||||
|
Reference in New Issue
Block a user