mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-09 10:20:07 +00:00
a11y: Consolidate accessibility environment variables
Use a single environment variable for everything: - select the ATContext implementation - select the test ATContext - disable ATContext entirely We use the same pattern as GSK_RENDERER, GTK_DEBUG, etc. The documentation needs to be updated to include the environment variable.
This commit is contained in:
parent
e093ed7d67
commit
0af6630521
@ -293,6 +293,24 @@ CSD is always used for windows with a custom titlebar widget set,
|
||||
as the WM should not draw another titlebar or other decorations
|
||||
around the custom one.
|
||||
|
||||
### GTK_A11Y
|
||||
|
||||
If set, selects the accessibility backend to use. The following
|
||||
backends can be selected, provided they are included in the GTK
|
||||
library you are using:
|
||||
|
||||
help
|
||||
: Prints information about available options
|
||||
atspi
|
||||
: Selects the AT-SPI accessibility backend
|
||||
test
|
||||
: Selects the test backend
|
||||
none
|
||||
: Disables the accessibility backend
|
||||
|
||||
The `test` accessibility backend is recommended for test suites and remote
|
||||
continuous integration pipelines.
|
||||
|
||||
### XDG_DTA_HOME, XDG_DATA_DIRS
|
||||
|
||||
GTK uses these environment variables to locate icon themes
|
||||
|
@ -448,17 +448,19 @@ gtk_at_context_get_display (GtkATContext *self)
|
||||
|
||||
static const struct {
|
||||
const char *name;
|
||||
const char *env_name;
|
||||
GtkATContext * (* create_context) (GtkAccessibleRole accessible_role,
|
||||
GtkAccessible *accessible,
|
||||
GdkDisplay *display);
|
||||
} a11y_backends[] = {
|
||||
#if defined(GDK_WINDOWING_WAYLAND)
|
||||
{ "AT-SPI (Wayland)", gtk_at_spi_create_context },
|
||||
{ "AT-SPI (Wayland)", "atspi", gtk_at_spi_create_context },
|
||||
#endif
|
||||
#if defined(GDK_WINDOWING_X11)
|
||||
{ "AT-SPI (X11)", gtk_at_spi_create_context },
|
||||
{ "AT-SPI (X11)", "atspi", gtk_at_spi_create_context },
|
||||
#endif
|
||||
{ NULL, NULL },
|
||||
{ "Test", "test", gtk_test_at_context_new },
|
||||
{ NULL, NULL, NULL },
|
||||
};
|
||||
|
||||
/**
|
||||
@ -480,36 +482,32 @@ gtk_at_context_create (GtkAccessibleRole accessible_role,
|
||||
GtkAccessible *accessible,
|
||||
GdkDisplay *display)
|
||||
{
|
||||
static const char *gtk_test_accessible;
|
||||
static const char *gtk_no_a11y;
|
||||
static const char *gtk_a11y_env;
|
||||
|
||||
if (G_UNLIKELY (gtk_test_accessible == NULL))
|
||||
if (gtk_a11y_env == NULL)
|
||||
{
|
||||
const char *env = g_getenv ("GTK_TEST_ACCESSIBLE");
|
||||
|
||||
if (env != NULL && *env !='\0')
|
||||
gtk_test_accessible = "1";
|
||||
else
|
||||
gtk_test_accessible = "0";
|
||||
gtk_a11y_env = g_getenv ("GTK_A11Y");
|
||||
if (gtk_a11y_env == NULL)
|
||||
gtk_a11y_env = "0";
|
||||
}
|
||||
|
||||
if (G_UNLIKELY (gtk_no_a11y == NULL))
|
||||
{
|
||||
const char *env = g_getenv ("GTK_NO_A11Y");
|
||||
|
||||
if (env != NULL && *env != '\0')
|
||||
gtk_no_a11y = "1";
|
||||
else
|
||||
gtk_no_a11y = "0";
|
||||
}
|
||||
|
||||
/* Shortcut everything if we're running with the test AT context */
|
||||
if (gtk_test_accessible[0] == '1')
|
||||
return gtk_test_at_context_new (accessible_role, accessible);
|
||||
|
||||
if (gtk_no_a11y[0] == '1')
|
||||
/* Short-circuit disabling the accessibility support */
|
||||
if (g_ascii_strcasecmp (gtk_a11y_env, "none") == 0)
|
||||
return NULL;
|
||||
|
||||
if (g_ascii_strcasecmp (gtk_a11y_env, "help") == 0)
|
||||
{
|
||||
g_print ("Supported arguments for GTK_A11Y environment variable:\n");
|
||||
|
||||
#if defined(GDK_WINDOWING_X11) || defined(GDK_WINDOWING_WAYLAND)
|
||||
g_print (" atspi - Use the AT-SPI accessibility backend\n");
|
||||
#endif
|
||||
g_print (" test - Use the test accessibility backend\n");
|
||||
g_print (" none - Disable the accessibility backend\n");
|
||||
g_print (" help - Print this help\n\n");
|
||||
g_print ("Other arguments will cause a warning and be ignored.\n");
|
||||
}
|
||||
|
||||
GtkATContext *res = NULL;
|
||||
|
||||
for (guint i = 0; i < G_N_ELEMENTS (a11y_backends); i++)
|
||||
@ -517,7 +515,8 @@ gtk_at_context_create (GtkAccessibleRole accessible_role,
|
||||
if (a11y_backends[i].name == NULL)
|
||||
break;
|
||||
|
||||
if (a11y_backends[i].create_context != NULL)
|
||||
if (a11y_backends[i].create_context != NULL &&
|
||||
(*gtk_a11y_env == '0' || g_ascii_strcasecmp (a11y_backends[i].env_name, gtk_a11y_env) == 0))
|
||||
{
|
||||
res = a11y_backends[i].create_context (accessible_role, accessible, display);
|
||||
if (res != NULL)
|
||||
@ -525,6 +524,9 @@ gtk_at_context_create (GtkAccessibleRole accessible_role,
|
||||
}
|
||||
}
|
||||
|
||||
if (*gtk_a11y_env != '0' && res == NULL)
|
||||
g_warning ("Unrecognized accessibility backend \"%s\". Try GTK_A11Y=help", gtk_a11y_env);
|
||||
|
||||
/* Fall back to the test context, so we can get debugging data */
|
||||
if (res == NULL)
|
||||
res = g_object_new (GTK_TYPE_TEST_AT_CONTEXT,
|
||||
@ -533,7 +535,6 @@ gtk_at_context_create (GtkAccessibleRole accessible_role,
|
||||
"display", display,
|
||||
NULL);
|
||||
|
||||
/* FIXME: Add GIOExtension for AT contexts */
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -95,6 +95,7 @@ gtk_test_at_context_init (GtkTestATContext *self)
|
||||
* gtk_test_at_context_new:
|
||||
* @accessible_role: the #GtkAccessibleRole for the AT context
|
||||
* @accessible: the #GtkAccessible instance which owns the AT context
|
||||
* @display: a #GdkDisplay
|
||||
*
|
||||
* Creates a new #GtkTestATContext instance for @accessible, using the
|
||||
* given @accessible_role.
|
||||
@ -103,11 +104,13 @@ gtk_test_at_context_init (GtkTestATContext *self)
|
||||
*/
|
||||
GtkATContext *
|
||||
gtk_test_at_context_new (GtkAccessibleRole accessible_role,
|
||||
GtkAccessible *accessible)
|
||||
GtkAccessible *accessible,
|
||||
GdkDisplay *display)
|
||||
{
|
||||
return g_object_new (GTK_TYPE_TEST_AT_CONTEXT,
|
||||
"accessible-role", accessible_role,
|
||||
"accessible", accessible,
|
||||
"display", display,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
@ -31,6 +31,7 @@ G_DECLARE_FINAL_TYPE (GtkTestATContext, gtk_test_at_context, GTK, TEST_AT_CONTEX
|
||||
|
||||
GtkATContext *
|
||||
gtk_test_at_context_new (GtkAccessibleRole accessible_role,
|
||||
GtkAccessible *accessible);
|
||||
GtkAccessible *accessible,
|
||||
GdkDisplay *display);
|
||||
|
||||
G_END_DECLS
|
||||
|
@ -50,7 +50,7 @@ foreach flag: common_cflags
|
||||
endforeach
|
||||
|
||||
test_env = environment()
|
||||
test_env.set('GTK_TEST_ACCESSIBLE', '1')
|
||||
test_env.set('GTK_A11Y', 'test')
|
||||
test_env.set('GSK_RENDERER', 'cairo')
|
||||
test_env.set('G_TEST_SRCDIR', meson.current_source_dir())
|
||||
test_env.set('G_TEST_BUILDDIR', meson.current_build_dir())
|
||||
|
@ -1,4 +1,4 @@
|
||||
[Test]
|
||||
Exec=/bin/sh -c "env G_ENABLE_DIAGNOSTIC=0 GTK_TEST_ACCESSIBLE=1 @libexecdir@/installed-tests/gtk-4.0/css/api --tap -k"
|
||||
Exec=/bin/sh -c "env G_ENABLE_DIAGNOSTIC=0 GTK_A11Y=test @libexecdir@/installed-tests/gtk-4.0/css/api --tap -k"
|
||||
Type=session
|
||||
Output=TAP
|
||||
|
@ -1,4 +1,4 @@
|
||||
[Test]
|
||||
Exec=/bin/sh -c "env G_ENABLE_DIAGNOSTIC=0 GTK_TEST_ACCESSIBLE=1 @libexecdir@/installed-tests/gtk-4.0/css/change/test-css-change --tap -k"
|
||||
Exec=/bin/sh -c "env G_ENABLE_DIAGNOSTIC=0 GTK_A11Y=test @libexecdir@/installed-tests/gtk-4.0/css/change/test-css-change --tap -k"
|
||||
Type=session
|
||||
Output=TAP
|
||||
|
@ -1,5 +1,5 @@
|
||||
changetest_env = environment()
|
||||
changetest_env.set('GTK_TEST_ACCESSIBLE', '1')
|
||||
changetest_env.set('GTK_A11Y', 'test')
|
||||
changetest_env.set('GSK_RENDERER', 'cairo')
|
||||
changetest_env.set('G_TEST_SRCDIR', meson.current_source_dir())
|
||||
changetest_env.set('G_TEST_BUILDDIR', meson.current_build_dir())
|
||||
|
@ -1,5 +1,5 @@
|
||||
csstest_env = environment()
|
||||
csstest_env.set('GTK_TEST_ACCESSIBLE', '1')
|
||||
csstest_env.set('GTK_A11Y', 'test')
|
||||
csstest_env.set('GSK_RENDERER', 'cairo')
|
||||
csstest_env.set('G_TEST_SRCDIR', meson.current_source_dir())
|
||||
csstest_env.set('G_TEST_BUILDDIR', meson.current_build_dir())
|
||||
|
@ -1,5 +1,5 @@
|
||||
nodetest_env = environment()
|
||||
nodetest_env.set('GTK_TEST_ACCESSIBLE', '1')
|
||||
nodetest_env.set('GTK_A11Y', 'test')
|
||||
nodetest_env.set('GSK_RENDERER', 'cairo')
|
||||
nodetest_env.set('G_TEST_SRCDIR', meson.current_source_dir())
|
||||
nodetest_env.set('G_TEST_BUILDDIR', meson.current_build_dir())
|
||||
|
@ -1,4 +1,4 @@
|
||||
[Test]
|
||||
Exec=/bin/sh -c "env G_ENABLE_DIAGNOSTIC=0 GTK_TEST_ACCESSIBLE=1 @libexecdir@/installed-tests/gtk-4.0/css/nodes/test-css-nodes --tap -k"
|
||||
Exec=/bin/sh -c "env G_ENABLE_DIAGNOSTIC=0 GTK_A11Y=test @libexecdir@/installed-tests/gtk-4.0/css/nodes/test-css-nodes --tap -k"
|
||||
Type=session
|
||||
Output=TAP
|
||||
|
@ -1,4 +1,4 @@
|
||||
[Test]
|
||||
Exec=/bin/sh -c "env G_ENABLE_DIAGNOSTIC=0 GTK_TEST_ACCESSIBLE=1 @libexecdir@/installed-tests/gtk-4.0/css/parser/test-css-parser --tap -k"
|
||||
Exec=/bin/sh -c "env G_ENABLE_DIAGNOSTIC=0 GTK_A11Y=test @libexecdir@/installed-tests/gtk-4.0/css/parser/test-css-parser --tap -k"
|
||||
Type=session
|
||||
Output=TAP
|
||||
|
@ -1,5 +1,5 @@
|
||||
styletest_env = environment()
|
||||
styletest_env.set('GTK_TEST_ACCESSIBLE', '1')
|
||||
styletest_env.set('GTK_A11Y', 'test')
|
||||
styletest_env.set('GSK_RENDERER', 'cairo')
|
||||
styletest_env.set('G_TEST_SRCDIR', meson.current_source_dir())
|
||||
styletest_env.set('G_TEST_BUILDDIR', meson.current_build_dir())
|
||||
|
@ -1,4 +1,4 @@
|
||||
[Test]
|
||||
Exec=/bin/sh -c "env G_ENABLE_DIAGNOSTIC=0 GTK_TEST_ACCESSIBLE=1 @libexecdir@/installed-tests/gtk-4.0/css/style/test-css-style --tap -k"
|
||||
Exec=/bin/sh -c "env G_ENABLE_DIAGNOSTIC=0 GTK_A11Y=test @libexecdir@/installed-tests/gtk-4.0/css/style/test-css-style --tap -k"
|
||||
Type=session
|
||||
Output=TAP
|
||||
|
@ -1,4 +1,4 @@
|
||||
[Test]
|
||||
Exec=/bin/sh -c "env G_ENABLE_DIAGNOSTIC=0 GTK_TEST_ACCESSIBLE=1 @testexecdir@/@test@ --tap -k --verbose"
|
||||
Exec=/bin/sh -c "env G_ENABLE_DIAGNOSTIC=0 GTK_A11Y=test @testexecdir@/@test@ --tap -k --verbose"
|
||||
Type=session
|
||||
Output=TAP
|
||||
|
@ -101,7 +101,7 @@ foreach renderer : renderers
|
||||
join_paths(meson.current_source_dir(), 'compare', test + '.png')],
|
||||
env: [
|
||||
'GSK_RENDERER=' + renderer[0],
|
||||
'GTK_TEST_ACCESSIBLE=1',
|
||||
'GTK_A11Y=test',
|
||||
'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
|
||||
'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir())
|
||||
],
|
||||
@ -179,7 +179,7 @@ foreach test : node_parser_tests
|
||||
],
|
||||
env: [
|
||||
'GSK_RENDERER=opengl',
|
||||
'GTK_TEST_ACCESSIBLE=1',
|
||||
'GTK_A11Y=test',
|
||||
'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
|
||||
'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir())
|
||||
],
|
||||
@ -213,7 +213,7 @@ foreach t : tests
|
||||
protocol: 'tap',
|
||||
env: [
|
||||
'GSK_RENDERER=cairo',
|
||||
'GTK_TEST_ACCESSIBLE=1',
|
||||
'GTK_A11Y=test',
|
||||
'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
|
||||
'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir())
|
||||
],
|
||||
|
@ -1,4 +1,4 @@
|
||||
[Test]
|
||||
Exec=/bin/sh -c "env G_ENABLE_DIAGNOSTIC=0 GSK_RENDERER=cairo GTK_TEST_ACCESSIBLE=1 @libexecdir@/installed-tests/gtk-4.0/gsk/test-render-nodes --tap -k --verbose"
|
||||
Exec=/bin/sh -c "env G_ENABLE_DIAGNOSTIC=0 GSK_RENDERER=cairo GTK_A11Y=test @libexecdir@/installed-tests/gtk-4.0/gsk/test-render-nodes --tap -k --verbose"
|
||||
Type=session
|
||||
Output=TAP
|
||||
|
@ -1,4 +1,4 @@
|
||||
[Test]
|
||||
Exec=/bin/sh -c "env GTK_TEST_ACCESSIBLE=1 GSK_RENDERER=vulkan @libexecdir@/installed-tests/gtk-4.0/gsk/test-render-nodes --tap -k --verbose"
|
||||
Exec=/bin/sh -c "env GTK_A11Y=test GSK_RENDERER=vulkan @libexecdir@/installed-tests/gtk-4.0/gsk/test-render-nodes --tap -k --verbose"
|
||||
Type=session
|
||||
Output=TAP
|
||||
|
@ -1,4 +1,4 @@
|
||||
[Test]
|
||||
Exec=/bin/sh -c "env G_ENABLE_DIAGNOSTIC=0 GTK_TEST_ACCESSIBLE=1 @testexecdir@/@test@ --tap -k --verbose"
|
||||
Exec=/bin/sh -c "env G_ENABLE_DIAGNOSTIC=0 GTK_A11Y=test @testexecdir@/@test@ --tap -k --verbose"
|
||||
Type=session
|
||||
Output=TAP
|
||||
|
@ -147,7 +147,7 @@ is_debug = get_option('buildtype').startswith('debug')
|
||||
test_cargs = []
|
||||
|
||||
test_env = environment()
|
||||
test_env.set('GTK_TEST_ACCESSIBLE', '1')
|
||||
test_env.set('GTK_A11Y', 'test')
|
||||
test_env.set('GSK_RENDERER', 'cairo')
|
||||
test_env.set('G_TEST_SRCDIR', meson.current_source_dir())
|
||||
test_env.set('G_TEST_BUILDDIR', meson.current_build_dir())
|
||||
|
@ -451,7 +451,7 @@ xfails = [
|
||||
]
|
||||
|
||||
reftest_env = environment()
|
||||
reftest_env.set('GTK_TEST_ACCESSIBLE', '1')
|
||||
reftest_env.set('GTK_A11Y', 'test')
|
||||
reftest_env.set('GSK_RENDERER', 'opengl')
|
||||
reftest_env.set('G_TEST_SRCDIR', meson.current_source_dir())
|
||||
reftest_env.set('G_TEST_BUILDDIR', meson.current_build_dir())
|
||||
|
@ -1,4 +1,4 @@
|
||||
[Test]
|
||||
Exec=/bin/sh -c "env GTK_THEME=Adwaita:dark GTK_TEST_ACCESSIBLE=1 G_ENABLE_DIAGNOSTIC=0 @libexecdir@/installed-tests/gtk-4.0/gtk-reftest -k --verbose --tap --output $(pwd) --directory @libexecdir@/installed-tests/gtk-4.0/reftests"
|
||||
Exec=/bin/sh -c "env GTK_THEME=Adwaita:dark GTK_A11Y=test G_ENABLE_DIAGNOSTIC=0 @libexecdir@/installed-tests/gtk-4.0/gtk-reftest -k --verbose --tap --output $(pwd) --directory @libexecdir@/installed-tests/gtk-4.0/reftests"
|
||||
Type=session-exclusive
|
||||
Output=TAP
|
||||
|
@ -1,4 +1,4 @@
|
||||
[Test]
|
||||
Exec=/bin/sh -c "env GTK_THEME=HighContrast GTK_TEST_ACCESSIBLE=1 G_ENABLE_DIAGNOSTIC=0 @libexecdir@/installed-tests/gtk-4.0/gtk-reftest -k --verbose --tap --output $(pwd) --directory @libexecdir@/installed-tests/gtk-4.0/reftests"
|
||||
Exec=/bin/sh -c "env GTK_THEME=HighContrast GTK_A11Y=test G_ENABLE_DIAGNOSTIC=0 @libexecdir@/installed-tests/gtk-4.0/gtk-reftest -k --verbose --tap --output $(pwd) --directory @libexecdir@/installed-tests/gtk-4.0/reftests"
|
||||
Type=session-exclusive
|
||||
Output=TAP
|
||||
|
@ -1,4 +1,4 @@
|
||||
[Test]
|
||||
Exec=/bin/sh -c "env GTK_THEME=HighContrastInverse GTK_TEST_ACCESSIBLE=1 G_ENABLE_DIAGNOSTIC=0 @libexecdir@/installed-tests/gtk-4.0/gtk-reftest -k --verbose --tap --output $(pwd) --directory @libexecdir@/installed-tests/gtk-4.0/reftests"
|
||||
Exec=/bin/sh -c "env GTK_THEME=HighContrastInverse GTK_A11Y=test G_ENABLE_DIAGNOSTIC=0 @libexecdir@/installed-tests/gtk-4.0/gtk-reftest -k --verbose --tap --output $(pwd) --directory @libexecdir@/installed-tests/gtk-4.0/reftests"
|
||||
Type=session-exclusive
|
||||
Output=TAP
|
||||
|
@ -1,4 +1,4 @@
|
||||
[Test]
|
||||
Exec=/bin/sh -c "env GTK_TEST_ACCESSIBLE=1 G_ENABLE_DIAGNOSTIC=0 @libexecdir@/installed-tests/gtk-4.0/gtk-reftest -k --verbose --tap --output $(pwd) --directory @libexecdir@/installed-tests/gtk-4.0/reftests"
|
||||
Exec=/bin/sh -c "env GTK_A11Y=test G_ENABLE_DIAGNOSTIC=0 @libexecdir@/installed-tests/gtk-4.0/gtk-reftest -k --verbose --tap --output $(pwd) --directory @libexecdir@/installed-tests/gtk-4.0/reftests"
|
||||
Type=session-exclusive
|
||||
Output=TAP
|
||||
|
@ -23,7 +23,7 @@ if bash.found()
|
||||
env: [
|
||||
'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
|
||||
'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()),
|
||||
'GTK_TEST_ACCESSIBLE=1',
|
||||
'GTK_A11Y=test',
|
||||
'GTK_BUILDER_TOOL=@0@'.format(get_variable('gtk4_builder_tool').full_path()),
|
||||
'GTK_QUERY_SETTINGS=@0@'.format(get_variable('gtk4_query_settings').full_path())
|
||||
],
|
||||
|
@ -1,4 +1,4 @@
|
||||
[Test]
|
||||
Exec=/bin/sh -c "env GTK_TEST_ACCESSIBLE=1 G_ENABLE_DIAGNOSTIC=0 TEST_DATA_DIR=@testexecdir@/@test@-data @testexecdir@/@test@"
|
||||
Exec=/bin/sh -c "env GTK_A11Y=test G_ENABLE_DIAGNOSTIC=0 TEST_DATA_DIR=@testexecdir@/@test@-data @testexecdir@/@test@"
|
||||
Type=session
|
||||
Output=TAP
|
||||
|
Loading…
Reference in New Issue
Block a user