summaryrefslogtreecommitdiff
path: root/gtk/gtkaccessible.c
diff options
context:
space:
mode:
authorLukáš Tyrychtr <lukastyrychtr@gmail.com>2022-11-25 16:55:12 +0100
committerEmmanuele Bassi <ebassi@gnome.org>2023-02-03 11:49:17 +0100
commitbc48bfc2b63d5be990068872a912108706419efb (patch)
treee081ca4cf434e88a7a1aa72fc79e60a3334003c8 /gtk/gtkaccessible.c
parent6100258ba2001212e5e27f4c396bd18bc9c40d72 (diff)
downloadgtk+-bc48bfc2b63d5be990068872a912108706419efb.tar.gz
a11y: Use a DOM-like API for iterating accessible objects
The `get_child_at_index()` API model comes from AT-SPI, and it's not an efficient design, especially when coupled with large widgets. Replace `get_child_at_index()` with `get_first_accessible_child()` and `get_next_accessible_sibling()`. That allows efficiently retrieving all the children, simplifies the implementation of GtkAccessible in GtkWidget and closely resembeles the GtkWidget API. Getting the last child and previous sibling for iterating backwards is not a part of the interface at the moment, but they can be added at a later date. Note that this change required tracking the next stack page in GtkStackPage.
Diffstat (limited to 'gtk/gtkaccessible.c')
-rw-r--r--gtk/gtkaccessible.c33
1 files changed, 25 insertions, 8 deletions
diff --git a/gtk/gtkaccessible.c b/gtk/gtkaccessible.c
index b9101a79d3..a029d09f81 100644
--- a/gtk/gtkaccessible.c
+++ b/gtk/gtkaccessible.c
@@ -40,8 +40,8 @@
*
* Every accessible implementation is part of a tree of accessible objects.
* Normally, this tree corresponds to the widget tree, but can be customized
- * by reimplementing the [vfunc@Gtk.Accessible.get_accessible_parent]
- * and [vfunc@Gtk.Accessible.get_child_at_index] virtual functions.
+ * by reimplementing the [vfunc@Gtk.Accessible.get_accessible_parent],
+ * [vfunc@Gtk.Accessible.get_first_accessible_child] and [vfunc@Gtk.Accessible.get_next_accessible_sibling] virtual functions.
* Note that you can not create a top-level accessible object as of now,
* which means that you must always have a parent accessible object.
*/
@@ -115,22 +115,39 @@ gtk_accessible_get_accessible_parent (GtkAccessible *self)
/**
- * gtk_accessible_get_child_at_index:
+ * gtk_accessible_get_first_accessible_child:
* @self: a `GtkAccessible`
- * @idx: the index of the child to get
*
- * Retrieves the child `GtkAccessible` for this `GtkAccessible` with the given @index.
+ * Retrieves the first child `GtkAccessible` for this `GtkAccessible`.
*
- * Returns: (transfer none) (nullable): the child `GtkAccessible` with the given @index or %NULL if the index is outside range
+ * Returns: (transfer none) (nullable): the first `GtkAccessible` child of @self, if @self has accessible children, %NULL otherwise
*
* since: 4.10
*/
GtkAccessible *
-gtk_accessible_get_child_at_index (GtkAccessible *self, guint idx)
+gtk_accessible_get_first_accessible_child (GtkAccessible *self)
{
g_return_val_if_fail (GTK_IS_ACCESSIBLE (self), NULL);
- return GTK_ACCESSIBLE_GET_IFACE (self)->get_child_at_index (self, idx);
+ return GTK_ACCESSIBLE_GET_IFACE (self)->get_first_accessible_child (self);
+}
+
+/**
+ * gtk_accessible_get_next_accessible_sibling:
+ * @self: a `GtkAccessible`
+ *
+ * Retrieves the next `GtkAccessible` sibling of this `GtkAccessible`.
+ *
+ * Returns: (transfer none) (nullable): the next `GtkAccessible` sibling of @self, if @self has a next sibling, %NULL otherwise
+ *
+ * since: 4.10
+ */
+GtkAccessible *
+gtk_accessible_get_next_accessible_sibling (GtkAccessible *self)
+{
+ g_return_val_if_fail (GTK_IS_ACCESSIBLE (self), NULL);
+
+ return GTK_ACCESSIBLE_GET_IFACE (self)->get_next_accessible_sibling (self);
}
/**