unsigned char is promoted to int, which lacks the 32nd bit to
make 0xff << 24 work. Explicitly cast to unsigned int to make
it clear what we want to happen.
While the text data returned by the `get_contents`
function from the `GtkAccessibleTextInterface` does not
have to be NUL-terminated,
`gtk_accessible_text_get_contents` returns the
text contents as NUL-terminated UTF-8 data.
An empty string (returned as empty, i.e. size = 0,
but not NULL GBytes* data by `get_contents`) is valid, and
therefore also needs to be NUL-terminated, so do this.
Without this, e.g. querying the text of an empty paragraph
in the Gtk 4 variant of LibreOffice with the newly added
GtkAccessibleInterface implementation [1] gives an incorrect
result.
Previous sample use in Accerciser's IPython console:
In [24]: acc.queryText().getText(0, -1)
Out[24]: '[Invalid UTF-8]'
With this change in place, it now returns an empty
string as expected:
In [25]: acc.queryText().getText(0, -1)
Out[25]: ''
[1] https://git.libreoffice.org/core/commit/e268efd612d12ae9a459d6b9d0cb23220f025163
Multilanguage searching for GtkEmojiChooser
This makes the Emoji chooser search look for strings in both
the current locale (if available), and in English. Each resource
file now contains the locale+English data. To accommodate the
changed dataset and schema, the recent-emoji settings key has
been renamed to recently-used-emoji.
See merge request GNOME/gtk!6804
The text retrieved using `gtk_accessible_text_get_contents`
already contains only the character at the given offset,
and so the character is at index 0 in `str`, rather than at
the same offset again, so adjust this accordingly.
With this in place, querying the character in a
LibreOffice paragraph consisting of the text
"Hello world." now gives the expected results
with a pending LibreOffice change [1] to support
the new GtkAccessibleText interface:
In [1]: text = acc.queryText()
In [2]: text.getCharacterAtOffset(0)
Out[2]: 72
In [3]: text.getCharacterAtOffset(1)
Out[3]: 101
In [4]: text.getCharacterAtOffset(2)
Out[4]: 108
In [5]: text.getCharacterAtOffset(3)
Out[5]: 108
In [6]: text.getCharacterAtOffset(4)
Out[6]: 111
Previously, this would only work correctly
for an index of 0:
In [1]: text = acc.queryText()
In [2]: text.getCharacterAtOffset(0)
Out[2]: 72
In [3]: text.getCharacterAtOffset(1)
Out[3]: 0
In [4]: text.getCharacterAtOffset(2)
Out[4]: 0
In [5]: text.getCharacterAtOffset(3)
Out[5]: 0
In [6]: text.getCharacterAtOffset(4)
Out[6]: 0
[1] https://gerrit.libreoffice.org/c/core/+/163733
This command can be used to compare the rendering of a node
to a reference image. It can also be used to compare the
renderings of two nodes, or to compare two images.
We are going to use it in the AccessibleText implementations, so there's
no need to have it under a11y.
Also, change the apis from taking a GVariantBuilder to just return
plain arrays.
The AccessibleText interface is meant to be implemented by widgets and
other accessible objects that expose selectable, navigatable, or rich
text to assistive technologies.
This kind of text is not covered by the plain accessible name and
description, as it contains things like a caret, or text attributes.
This commit adds a stub GtkAccessibleText with its basic virtual
functions; the interface will be implemented by widgets like GtkLabel,
GtkInscription, GtkText, and GtkTextView. A further commit will ensure
that the AT-SPI implementation will convert from GTK to AT-SPI through a
generic (internal API); and, finally, we'll remove the widget type
checks in the AT-SPI implementation of GtkATContext, and only check for
GtkAccessibleText.
Fixes: #5912