Allow updating the next accessible sibling for a GtkAccessible

This commit is contained in:
Lukáš Tyrychtr 2023-02-15 12:29:16 +01:00
parent d566771262
commit f507dd4962
2 changed files with 37 additions and 1 deletions

View File

@ -49,7 +49,7 @@
* and it has children, whose implementation you don't control, * and it has children, whose implementation you don't control,
* it is necessary to ensure the correct shape of the a11y tree * it is necessary to ensure the correct shape of the a11y tree
* by calling gtk_accessible_set_accessible_parent() and * 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" #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: * gtk_accessible_get_first_accessible_child:
* @self: an accessible object * @self: an accessible object

View File

@ -174,6 +174,10 @@ GtkAccessible * gtk_accessible_get_first_accessible_child (GtkAccessible *self);
GDK_AVAILABLE_IN_4_10 GDK_AVAILABLE_IN_4_10
GtkAccessible * gtk_accessible_get_next_accessible_sibling (GtkAccessible *self); 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 GDK_AVAILABLE_IN_4_10
gboolean gtk_accessible_get_bounds (GtkAccessible *self, gboolean gtk_accessible_get_bounds (GtkAccessible *self,