Hello, I am pleased to announce a new Cambalache stable release.
Version 0.94.0 – Accessibility Release!
-
- Gtk 4 and Gtk 3 accessibility support
- Support property subclass override defaults
- AdwDialog placeholder support
- Improved object description in hierarchy
- Lots of bug fixes and minor UI improvements
How it started?
A couple of months ago I decided to make a poll on Mastodon about which feature people would like to see next.
To my surprise GtkExpression did not come up first and GResources where not the last one.
Data Model
First things firsts, how to store a11y data in the project”
So what are we trying to sotre? from Gtk documentation:
GtkWidget
allows defining accessibility information, such as properties, relations, and states, using the custom<accessibility>
element:
<object class="GtkButton" id="button1"> <accessibility> <property name="label">Download</property> <relation name="labelled-by">label1</relation> </accessibility> </object>
These looks a lot like regular properties so my first idea was to store them as properties in the data model.
So I decided to create one custom/fake interface class for each type of a11y data CmbAccessibleProperty, CmbAccessibleRelation and CmbAccessibleState.
These are hardcoded in cmb-catalog-gen tool and look like this
# Property name: (type, default value, since version) self.__a11y_add_ifaces_from_enum([ ( "Property", "GtkAccessibleProperty", { "autocomplete": ["GtkAccessibleAutocomplete", "none", None], "description": ["gchararray", None, None], ... } ), ( "Relation", "GtkAccessibleRelation", { "active-descendant": ["GtkAccessible", None, None], "controls": ["CmbAccessibleList", None, None], # Reference List "described-by": ["CmbAccessibleList", None, None], # Reference List ... } ), ( "State", "GtkAccessibleState", { "busy": ["gboolean", "False", None], "checked": ["CmbAccessibleTristateUndefined", "undefined", None], "disabled": ["gboolean", "False", None], "expanded": ["CmbBooleanUndefined", "undefined", None], ... } ) ])
This function will create the custom interface with all the properties and make sure all values in the GtkEnumeration are covered.
One fundamental difference with properties is that some a11y relations can be used more than once to specify multiple values.
To cover this I created a new value type called CmbAccessibleList which is simply a coma separated list of values.
This way the import and export code can handle loading and exporting a11y data into Cambalache data model.
Editing a11y data in the UI
Now since these interfaces are not real, no actual widget implements them, they wont show up automatically in the UI.
This can be easily solved by adding a new tab “a11y” to the object editor which only shows a11y interface properties.Now at this point it is possible to create and edit accessibility metadata for any UI but as Emmanuelle pointed out not every a11y property and relation is valid for every role.
To know what is valid or not you need to read WAI-ARIA specs or write a script that pulls all the metadata from it.
With this metadata handy is it easy to filter properties and relations depending on the a11y role.BTW keep in mind that accessible-role property should not be changed under normal circumstances.
Where to get it?
From Flathub
flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo flatpak install flathub ar.xjuan.Cambalache
or directly from gitlab
git clone https://gitlab.gnome.org/jpu/cambalache.git
Matrix channel
Have any question? come chat with us at #cambalache:gnome.org
Mastodon
Follow me in Mastodon @xjuan to get news related to Cambalache development.
Happy coding!
Very good news Juan! btw I hope to see soon GtkExpression support too ! 😉
Hi, yes its in the TODO list
Would you like to help implement it?