Commit Graph

24 Commits

Author SHA1 Message Date
Matthias Clasen
91f7b9663f gtk: Clean up docs syntax
Replace leftover gtk-doc syntax (#Type) with backquotes.
2021-05-22 17:25:26 -04:00
Matthias Clasen
cc0df3c315 accessiblevalue: Drop SECTION
This is private.
2021-03-11 16:37:37 +00:00
Emmanuele Bassi
f9db651f32 a11y: Do not copy the list of references
The constructor for GtkReferenceListAccessibleValue is transfer full,
which means we should not be copying the GList around.

Fixes: #3343
2020-11-10 14:31:56 +00:00
Emmanuele Bassi
c264254d4b a11y: Parse reference lists using varargs
Using GList is a bit lame, and makes the API more complicated to use
than necessary in the common case.

The only real use case for a GList is gtk_widget_add_mnemonic_label(),
and for that we can use the GValue-based API instead.

Fixes: #3343
2020-11-10 14:31:56 +00:00
Emmanuele Bassi
6af89e9034 a11y: Add GValue initializers for accessible attributes
Consumers of the GValue-based API for GtkAccessible need to have a way
to initialize the GValue with the correct type for the given attribute.
2020-11-10 14:31:56 +00:00
Matthias Clasen
c783e9aa5f Treat tristate as an enum when parsing
This makes it so that you have to explicitly specify
"true" and "false" for the checked state, but it
matches how this enumeration is meant to be used.
2020-10-26 08:01:13 -04:00
Matthias Clasen
fce455ae0b a11y: Parse booleans in ui files as expected
Accept the same syntax for booleans as GtkBuilder
does elsewhere.
2020-10-25 12:20:55 -04:00
Emmanuele Bassi
80756322cd a11y: Handle relations in UI files
A bit hacky: we skip parsing values that have a reference or
reference-list type, but we do not error out. Instead, we return a NULL
value, which we catch in the GtkBuildable interface implementation to
get the actual object, and construct a reference list value.

There's still some ickyness around the value type that can only be
solved by having an attribute and role taxonomy.
2020-10-21 14:48:49 +01:00
Emmanuele Bassi
4ea2a6628f a11y: Add parsing code for accessible values
We need to be able to go from a string representation of an accessible
value to its GtkAccessibleValue instance.
2020-10-21 13:33:37 +01:00
Emmanuele Bassi
701a0dabd0 a11y: Different value types cannot be equal
Bail out early, instead of going deep into the GtkAccessibleValue type
equal() implementation, where we expect both accessible values to have
the same type.
2020-08-25 16:36:08 +01:00
Emmanuele Bassi
bf06cad5d9 a11y: Add proper error reporting to value collection
We're currently overloading NULL to mean both "this value is undefined,
and should be reset to its default" and "the value collection failed".
Let's do error reporting right, by using GError to mean "the collection
failed, for this specific reason"; then, we can use a NULL return value
to signal that the accessible attribute should be reset to its default
value.

This is only relevant for pointer-sized attribute values: strings,
references, and reference lists; numeric, boolean, tristate, and token
values either cannot be undefined, or have a specific "undefined" value.
2020-07-28 16:49:13 +01:00
Emmanuele Bassi
7f04faf30d a11y: Use undefined as default for string attributes
Instead of an empty string.
2020-07-28 16:49:13 +01:00
Emmanuele Bassi
05d9e0c1c8 a11y: Allow unsetting the relations using NULL
Accessible values storing references and reference lists can be unset by
using NULL to mean "undefined"; since we cannot return the NULL value,
we need to intercept it when collecting a value, and replace it with an
undefined GtkAccessibleValue, which is also the value used as the
default for GtkAccessibleRelation values that store a reference or a
reference list.

Fixes: #2955
2020-07-27 14:26:19 +01:00
Matthias Clasen
4c5df54e39 a11y: Be a bit safer against crashes
We are collecting values from varargs and use them
as indices into static arrays. We should at least
do some bounds checking to prevent silly crashes.
2020-07-27 00:21:01 -04:00
Emmanuele Bassi
86b58529fd a11y: Change the collection type for reflist attributes 2020-07-26 20:31:15 +01:00
Emmanuele Bassi
2fee3793b4 a11y: Allow storing list of references in GtkAccessibleValue
It's one of the fundamental accessible value types in ARIA.
2020-07-26 20:31:15 +01:00
Emmanuele Bassi
1124f2507d a11y: Add relations API
Since we split relation attributes from the generic properties, we need
to add API for setting and retrieving their values.
2020-07-26 20:31:15 +01:00
Emmanuele Bassi
d37511f76b a11y: Simplify GtkAccessibleValue
Reduce the amount of subclassing, by handling collection of fundamental
types directly from the generic code paths. We now handle boolean,
tristate, integer, number, string, and relation values in the generic
code path; if an attribute supports the "undefined" value, we return the
undefined value singleton.
2020-07-26 20:31:15 +01:00
Emmanuele Bassi
55d29d08a1 a11y: Resync with the ARIA spec
Drop roles and properties that were deprecated in WAI-ARIA 1.1, and add
new roles and properties defined in WAI-ARIA 1.2 and later.

We also split the relationship properties into their own enumeration, so
we can keep the GtkAccessibleProperty type more compact.
2020-07-26 20:31:15 +01:00
Emmanuele Bassi
ae446e8f4a Remove GTK_ACCESSIBLE_STATE_NONE
It's pointless, we can use an explicit value of `-1` everywhere.
Additionally, it complicates all code that uses the state enumeration as
an array index, since now we need to guard against a negative offset.
2020-07-26 20:31:15 +01:00
Emmanuele Bassi
93978544c0 a11y: Collect reference value
Some properties that take a reference to an accessible haven't been
updated to collect the correct type.
2020-07-26 20:31:15 +01:00
Emmanuele Bassi
da1ce01a6f Add accessible properties to GtkAccessible
We propagate the accessible state and properties to each ATContext in
the same virtual function, since they are functionally similar.
2020-07-26 20:31:15 +01:00
Emmanuele Bassi
382fa01301 Plumb all the GtkAccessibleProperty values into GtkAccessibleValue
Similarly to how we deal with GtkAccessibleState.
2020-07-26 20:31:15 +01:00
Emmanuele Bassi
55120a25db Add GtkAccessibleValue
All accessible properties and states may have one of the following
types:

 - true/false
 - true/false/undefined
 - true/false/mixed/undefined
 - reference (to another UI element)
 - reference list
 - integer
 - number (real numerical value)
 - string
 - token (one of a limited set of allowed values)
 - token list

See: https://www.w3.org/WAI/PF/aria/states_and_properties#propcharacteristic_value

The GtkAccessibleValue is a simple reference counted type that can be
"subclassed" to implement each value type.

This initial commit adds GtkAccessibleValue and the basic subclasses for
plain boolean, tristate (true/false/undefined), and token types,
including statically allocated values that can be shared instead of
allocated.
2020-07-26 20:31:14 +01:00