a11y: Add child state change to GtkATContext

And the required private API in GtkAccessible to notify AT contexts of
changes in the children list.
This commit is contained in:
Emmanuele Bassi 2020-10-15 14:49:14 +01:00
parent 8880e3bd2e
commit fbb08a30e2
4 changed files with 61 additions and 0 deletions

View File

@ -751,3 +751,27 @@ gtk_accessible_should_present (GtkAccessible *self)
return TRUE;
}
void
gtk_accessible_update_children (GtkAccessible *self,
GtkAccessible *child,
GtkAccessibleChildState state)
{
GtkATContext *context;
if (GTK_IS_WIDGET (self) &&
gtk_widget_get_root (GTK_WIDGET (self)) == NULL)
return;
context = gtk_accessible_get_at_context (self);
/* propagate changes up from ignored widgets */
if (gtk_accessible_get_accessible_role (self) == GTK_ACCESSIBLE_ROLE_NONE)
context = gtk_accessible_get_at_context (GTK_ACCESSIBLE (gtk_widget_get_parent (GTK_WIDGET (self))));
if (context == NULL)
return;
gtk_at_context_child_changed (context, state, child);
gtk_at_context_update (context);
}

View File

@ -49,4 +49,8 @@ gboolean gtk_accessible_get_platform_state (GtkAccessible *s
void gtk_accessible_bounds_changed (GtkAccessible *self);
void gtk_accessible_update_children (GtkAccessible *self,
GtkAccessible *child,
GtkAccessibleChildState state);
G_END_DECLS

View File

@ -155,6 +155,13 @@ gtk_at_context_real_bounds_change (GtkATContext *self)
{
}
static void
gtk_at_context_real_child_change (GtkATContext *self,
GtkAccessibleChildChange change,
GtkAccessible *child)
{
}
static void
gtk_at_context_class_init (GtkATContextClass *klass)
{
@ -167,6 +174,7 @@ gtk_at_context_class_init (GtkATContextClass *klass)
klass->state_change = gtk_at_context_real_state_change;
klass->platform_change = gtk_at_context_real_platform_change;
klass->bounds_change = gtk_at_context_real_bounds_change;
klass->child_change = gtk_at_context_real_child_change;
/**
* GtkATContext:accessible-role:
@ -979,3 +987,11 @@ gtk_at_context_bounds_changed (GtkATContext *self)
{
GTK_AT_CONTEXT_GET_CLASS (self)->bounds_change (self);
}
void
gtk_at_context_child_changed (GtkATContext *self,
GtkAccessibleChildChange change,
GtkAccessible *child)
{
GTK_AT_CONTEXT_GET_CLASS (self)->child_change (self, change, child);
}

View File

@ -90,6 +90,16 @@ typedef enum {
GTK_ACCESSIBLE_PLATFORM_CHANGE_FOCUSED = 1 << GTK_ACCESSIBLE_PLATFORM_STATE_FOCUSED,
} GtkAccessiblePlatformChange;
typedef enum {
GTK_ACCESSIBLE_CHILD_STATE_ADDED,
GTK_ACCESSIBLE_CHILD_STATE_REMOVED
} GtkAccessibleChildState;
typedef enum {
GTK_ACCESSIBLE_CHILD_CHANGE_ADDED = 1 << GTK_ACCESSIBLE_CHILD_STATE_ADDED,
GTK_ACCESSIBLE_CHILD_CHANGE_REMOVED = 1 << GTK_ACCESSIBLE_CHILD_STATE_REMOVED
} GtkAccessibleChildChange;
struct _GtkATContext
{
GObject parent_instance;
@ -124,6 +134,10 @@ struct _GtkATContextClass
GtkAccessiblePlatformChange changed_platform);
void (* bounds_change) (GtkATContext *self);
void (* child_change) (GtkATContext *self,
GtkAccessibleChildChange changed_child,
GtkAccessible *child);
};
GdkDisplay * gtk_at_context_get_display (GtkATContext *self);
@ -158,6 +172,9 @@ char * gtk_at_context_get_description (GtkATContext
void gtk_at_context_platform_changed (GtkATContext *self,
GtkAccessiblePlatformChange change);
void gtk_at_context_bounds_changed (GtkATContext *self);
void gtk_at_context_child_changed (GtkATContext *self,
GtkAccessibleChildChange change,
GtkAccessible *child);
const char * gtk_accessible_property_get_attribute_name (GtkAccessibleProperty property);
const char * gtk_accessible_relation_get_attribute_name (GtkAccessibleRelation relation);