63
64
static gboolean a11y_initialized = FALSE;
65
#define INIT_METHOD "gnome_accessibility_module_init"
66
#define DESKTOP_SCHEMA "org.gnome.desktop.interface"
67
#define ACCESSIBILITY_ENABLED_KEY "toolkit-accessibility"
68
#define AT_SPI_SCHEMA "org.a11y.atspi"
69
#define ATK_BRIDGE_LOCATION_KEY "atk-bridge-location"
72
67
unity_a11y_restore_environment(void)
82
77
g_type_class_unref(g_type_class_ref(UNITY_TYPE_UTIL_ACCESSIBLE));
85
/* This method is required because g_setting_new aborts if the schema
88
has_gsettings_schema(const gchar* schema)
90
const char* const* list_schemas = NULL;
91
gboolean found = FALSE;
94
list_schemas = g_settings_list_schemas();
95
for (i = 0; list_schemas [i]; i++)
97
if (!g_strcmp0(list_schemas[i], schema))
108
should_enable_a11y(void)
110
GSettings* desktop_settings = NULL;
111
gboolean value = FALSE;
113
if (!has_gsettings_schema(DESKTOP_SCHEMA))
116
desktop_settings = g_settings_new(DESKTOP_SCHEMA);
117
value = g_settings_get_boolean(desktop_settings, ACCESSIBILITY_ENABLED_KEY);
119
g_object_unref(desktop_settings);
125
get_atk_bridge_path(void)
127
GSettings* atspi_settings = NULL;
128
GVariant *variant = NULL;
131
if (!has_gsettings_schema(AT_SPI_SCHEMA))
134
atspi_settings = g_settings_new(AT_SPI_SCHEMA);
135
variant = g_settings_get_value (atspi_settings, ATK_BRIDGE_LOCATION_KEY);
136
value = g_variant_dup_bytestring (variant, NULL);
138
g_variant_unref (variant);
139
g_object_unref(atspi_settings);
145
a11y_invoke_module(const char* module_path)
148
void (*invoke_fn)(void);
152
g_warning("Accessibility: invalid module path (NULL)");
157
if (!(handle = g_module_open(module_path, (GModuleFlags)0)))
159
g_warning("Accessibility: failed to load module '%s': '%s'",
160
module_path, g_module_error());
165
if (!g_module_symbol(handle, INIT_METHOD, (gpointer*)&invoke_fn))
167
g_warning("Accessibility: error library '%s' does not include "
168
"method '%s' required for accessibility support",
169
module_path, INIT_METHOD);
170
g_module_close(handle);
180
/********************************************************************************/
182
81
* In order to avoid the atk-bridge loading and the GAIL
183
82
* initialization during the gtk_init, it is required to set some
195
94
* Initializes the accessibility (ATK) support on Unity
197
* It loads the atk-bridge if required. It checks:
198
* * If the proper gsettings keys are set
199
* * Loads the proper AtkUtil implementation
202
98
unity_a11y_init(nux::WindowThread* wt)
204
gchar* bridge_path = NULL;
100
if (a11y_initialized)
206
103
unity_a11y_restore_environment();
208
if (!should_enable_a11y())
211
104
load_unity_atk_util(wt);
213
bridge_path = get_atk_bridge_path();
215
if (a11y_invoke_module(bridge_path))
217
g_debug("Unity Oneiric accessibility started, using bridge on %s",
222
a11y_initialized = TRUE;
105
atk_bridge_adaptor_init(NULL, NULL);
108
a11y_initialized = TRUE;
227
110
// NOTE: we run the unit tests manually while developing by
228
111
// uncommenting this. Take a look at the explanation in the