Accessibility properties in ui files for gtk4

In a gtk3 app, I might have a .ui builder file chunk like the following, to set an accessibility property:

<child internal-child="accessible">
    <object class="AtkObject" id="back-button-atkobject">
        <property name="AtkObject::accessible-name" translatable="yes">Back</property>

In gtk4, AtkObject is gone and the a11y layer is fairly different. But I haven’t been able to find an example in the gtk source or documentation for what the new .ui file syntax for setting accessibility properties is. I think I could do the above in code with something like:

gtk_accessible_update_property(GTK_ACCESSIBLE(button), GTK_ACCESSIBLE_PROPERTY_LABEL, _("Back"), -1);

But can anyone share how would I do it in the .ui file? The gtk4 docs mention builder files, but don’t have an example.

Thanks in advance!

1 Like

The XML syntax is:

  <property name="…">…</property>
  <relation name="…">…</relation>
  <state name="…">…</state>

as documented in the GtkWidget as GtkBuildable section. The property, relation, and state names are described in the Accessibility section of the API reference.


Thank you! Missed that bit.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.