a11y: Implement the new GtkAccessible vfuncs
authorLukáš Tyrychtr <lukastyrychtr@gmail.com>
Fri, 9 Sep 2022 09:10:25 +0000 (11:10 +0200)
committerEmmanuele Bassi <ebassi@gnome.org>
Fri, 3 Feb 2023 10:49:17 +0000 (11:49 +0100)
Implement the gtk_accessible functions and begin removing the old widget
based tree calls.

gtk/gtkaccessible.c

index 05f804e25dab8d521aeb59cfc08f9fe92c4cd69e..20ee867242238673610ced3f5d288366777c1624 100644 (file)
@@ -90,6 +90,41 @@ gtk_accessible_get_at_context (GtkAccessible *self)
   return GTK_ACCESSIBLE_GET_IFACE (self)->get_at_context (self);
 }
 
+
+/*
+ * gtk_accessible_get_parent:
+ * @self: a `GtkAccessible`
+ *
+ * Retrieves the parent `GtkAccessible` for the given `GtkAccessible`.
+ *
+ * Returns: (transfer none): the parent `GtkAccessible` or NULL, if we this is the root
+ */
+GtkAccessible *
+gtk_accessible_get_parent (GtkAccessible *self)
+{
+  g_return_val_if_fail (GTK_IS_ACCESSIBLE (self), NULL);
+
+  return GTK_ACCESSIBLE_GET_IFACE (self)->get_parent (self);
+}
+
+
+/*
+ * gtk_accessible_get_child_at_index:
+ * @self: a `GtkAccessible`
+ * @index: the index of the child to get
+ *
+ * Retrieves the child `GtkAccessible` for this `GtkAccessible` with the given @index.
+ *
+ * Returns: (transfer none): the child `GtkAccessible` with the given @index or NULL if the index is outside range
+ */
+GtkAccessible *
+gtk_accessible_get_child_at_index (GtkAccessible *self, guint index)
+{
+  g_return_val_if_fail (GTK_IS_ACCESSIBLE (self), NULL);
+
+  return GTK_ACCESSIBLE_GET_IFACE (self)->get_child_at_index (self, index);
+}
+
 /**
  * gtk_accessible_get_accessible_role: (attributes org.gtk.Method.get_property=accessible-role)
  * @self: a `GtkAccessible`
@@ -712,7 +747,7 @@ gtk_accessible_platform_changed (GtkAccessible               *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))));
+    context = gtk_accessible_get_at_context (gtk_accessible_get_parent (self));
 
   if (context == NULL)
     return;
@@ -829,7 +864,7 @@ gtk_accessible_update_children (GtkAccessible           *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))));
+    context = gtk_accessible_get_at_context (gtk_accessible_get_parent (self));
 
   if (context == NULL)
     return;