diff --git a/gtk/gtkaccessible.c b/gtk/gtkaccessible.c index 7d1da7d398..dc56e7d3b3 100644 --- a/gtk/gtkaccessible.c +++ b/gtk/gtkaccessible.c @@ -49,7 +49,7 @@ * and it has children, whose implementation you don't control, * it is necessary to ensure the correct shape of the a11y tree * by calling gtk_accessible_set_accessible_parent() and - * gtk_accessible_set_next_accessible_sibling() as appropriate. + * updating the sibling by gtk_accessible_update_next_accessible_sibling(). */ #include "config.h" @@ -159,6 +159,38 @@ gtk_accessible_set_accessible_parent (GtkAccessible *self, } } +/** + * gtk_accessible_update_next_accessible_sibling: + * @self: a `GtkAccessible` + * @new_sibling: (nullable): the new next accessible sibling to set + * + * Updates the next accessible sibling of @self. + * That might be useful when a new child of a custom `GtkAccessible` + * is created, and it needs to be linked to a previous child. + * + * Since: 4.10 + */ +void +gtk_accessible_update_next_accessible_sibling (GtkAccessible *self, + GtkAccessible *new_sibling) +{ + GtkATContext *context; + + g_return_if_fail (GTK_IS_ACCESSIBLE (self)); + + context = gtk_accessible_get_at_context (self); + if (!context) + return; + + if (gtk_at_context_get_accessible_parent (context) == NULL) + { + g_critical ("Failed to update next accessible sibling: no parent accessible set for this accessible"); + return; + } + + gtk_at_context_set_next_accessible_sibling (context, new_sibling); +} + /** * gtk_accessible_get_first_accessible_child: * @self: an accessible object diff --git a/gtk/gtkaccessible.h b/gtk/gtkaccessible.h index b9bb5476a5..8b40cf8272 100644 --- a/gtk/gtkaccessible.h +++ b/gtk/gtkaccessible.h @@ -174,6 +174,10 @@ GtkAccessible * gtk_accessible_get_first_accessible_child (GtkAccessible *self); GDK_AVAILABLE_IN_4_10 GtkAccessible * gtk_accessible_get_next_accessible_sibling (GtkAccessible *self); +GDK_AVAILABLE_IN_4_10 +void gtk_accessible_update_next_accessible_sibling (GtkAccessible *self, + GtkAccessible *new_sibling); + GDK_AVAILABLE_IN_4_10 gboolean gtk_accessible_get_bounds (GtkAccessible *self,