diff options
author | Emmanuele Bassi <ebassi@gnome.org> | 2020-09-29 18:18:36 +0100 |
---|---|---|
committer | Emmanuele Bassi <ebassi@gnome.org> | 2020-10-12 16:19:31 +0100 |
commit | 8f19bb0832189cd39f1e0c06ae279e1893a6ab18 (patch) | |
tree | 088d74d551a436ebcf001bcfe522e640ddbdb77f /gtk/gtkatcontext.c | |
parent | c50916d27be3dd19c97dccdb02b259397e13852c (diff) | |
download | gtk+-8f19bb0832189cd39f1e0c06ae279e1893a6ab18.tar.gz |
a11y: Add dummy AT-SPI context
Does not do anything, at the moment, but it's going to get filled out
soon.
The backend is selected depending on the platform being compiled in;
since we're using AT-SPI on X11 and Wayland, and we don't have other
accessibility implementations, we currently don't care about run time
selection, but we're going to have to deal with that.
Diffstat (limited to 'gtk/gtkatcontext.c')
-rw-r--r-- | gtk/gtkatcontext.c | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/gtk/gtkatcontext.c b/gtk/gtkatcontext.c index 6686e3f9a9..4d86a2346d 100644 --- a/gtk/gtkatcontext.c +++ b/gtk/gtkatcontext.c @@ -36,9 +36,14 @@ #include "gtkatcontextprivate.h" #include "gtkaccessiblevalueprivate.h" +#include "gtkdebug.h" #include "gtktestatcontextprivate.h" #include "gtktypebuiltins.h" +#if defined(GDK_WINDOWING_X11) || defined(GDK_WINDOWING_WAYLAND) +#include "a11y/gtkatspicontextprivate.h" +#endif + G_DEFINE_ABSTRACT_TYPE (GtkATContext, gtk_at_context, G_TYPE_OBJECT) enum @@ -354,6 +359,20 @@ gtk_at_context_get_accessible_role (GtkATContext *self) return self->accessible_role; } +static const struct { + const char *name; + GtkATContext * (* create_context) (GtkAccessibleRole accessible_role, + GtkAccessible *accessible); +} a11y_backends[] = { +#if defined(GDK_WINDOWING_WAYLAND) + { "AT-SPI", _gtk_at_spi_context_new }, +#endif +#if defined(GDK_WINDOWING_X11) + { "AT-SPI", gtk_at_spi_context_new }, +#endif + { NULL, NULL }, +}; + /** * gtk_at_context_create: (constructor) * @accessible_role: the accessible role used by the #GtkATContext @@ -401,8 +420,23 @@ gtk_at_context_create (GtkAccessibleRole accessible_role, if (gtk_no_a11y[0] == '1') return NULL; + GtkATContext *res = NULL; + + for (guint i = 0; i < G_N_ELEMENTS (a11y_backends); i++) + { + GTK_NOTE (A11Y, g_message ("Trying %s a11y backend", a11y_backends[i].name)); + if (a11y_backends[i].create_context != NULL) + { + res = a11y_backends[i].create_context (accessible_role, accessible); + break; + } + } + + if (res == NULL) + res = gtk_test_at_context_new (accessible_role, accessible); + /* FIXME: Add GIOExtension for AT contexts */ - return gtk_test_at_context_new (accessible_role, accessible); + return res; } /*< private > |