Allow updating the next accessible sibling for a GtkAccessible
authorLukáš Tyrychtr <lukastyrychtr@gmail.com>
Wed, 15 Feb 2023 11:29:16 +0000 (12:29 +0100)
committerLukáš Tyrychtr <lukastyrychtr@gmail.com>
Wed, 15 Feb 2023 11:29:16 +0000 (12:29 +0100)
gtk/gtkaccessible.c
gtk/gtkaccessible.h

index 7d1da7d398d06547c9e322d825e55e4f49a968f1..dc56e7d3b3270d8cf851537eadd216da424e7ad8 100644 (file)
@@ -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
index b9bb5476a5037140675074f163b92dea9c1b2907..8b40cf8272fd20094313bc687d219d8289006c22 100644 (file)
@@ -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,