19
19
#include <gio/gio.h>
20
#include <atk-bridge.h>
21
22
#include "panel-a11y.h"
22
23
#include "panel-util-accessible.h"
24
25
static gboolean a11y_initialized = FALSE;
26
#define INIT_METHOD "gnome_accessibility_module_init"
27
#define DESKTOP_SCHEMA "org.gnome.desktop.interface"
28
#define ACCESSIBILITY_ENABLED_KEY "toolkit-accessibility"
29
#define AT_SPI_SCHEMA "org.a11y.atspi"
30
#define ATK_BRIDGE_LOCATION_KEY "atk-bridge-location"
33
/* This method is required because g_setting_new abort if the schema
36
has_gsettings_schema (const gchar *schema)
38
const char * const *list_schemas = NULL;
39
gboolean found = FALSE;
42
list_schemas = g_settings_list_schemas ();
43
for (i = 0; list_schemas [i]; i++)
45
if (!g_strcmp0 (list_schemas[i], schema))
56
should_enable_a11y (void)
58
GSettings *desktop_settings = NULL;
59
gboolean value = FALSE;
61
if (!has_gsettings_schema (DESKTOP_SCHEMA))
64
desktop_settings = g_settings_new (DESKTOP_SCHEMA);
65
value = g_settings_get_boolean (desktop_settings, ACCESSIBILITY_ENABLED_KEY);
67
g_object_unref (desktop_settings);
73
get_atk_bridge_path (void)
75
GSettings *atspi_settings = NULL;
76
GVariant *variant = NULL;
79
if (!has_gsettings_schema (AT_SPI_SCHEMA))
82
atspi_settings = g_settings_new(AT_SPI_SCHEMA);
83
variant = g_settings_get_value (atspi_settings, ATK_BRIDGE_LOCATION_KEY);
84
value = g_variant_dup_bytestring (variant, NULL);
86
g_variant_unref (variant);
87
g_object_unref (atspi_settings);
93
a11y_invoke_module (const char *module_path)
96
void (*invoke_fn) (void);
100
g_warning ("Accessibility: invalid module path (NULL)");
105
if (!(handle = g_module_open (module_path, (GModuleFlags)0)))
107
g_warning ("Accessibility: failed to load module '%s': '%s'",
108
module_path, g_module_error ());
113
if (!g_module_symbol (handle, INIT_METHOD, (gpointer *)&invoke_fn))
115
g_warning ("Accessibility: error library '%s' does not include "
116
"method '%s' required for accessibility support",
117
module_path, INIT_METHOD);
118
g_module_close (handle);
129
28
panel_a11y_init (void)
131
gchar *bridge_path = NULL;
133
30
if (a11y_initialized)
137
34
g_unsetenv ("NO_AT_BRIDGE");
138
35
g_unsetenv ("NO_GAIL");
140
if (!should_enable_a11y ())
143
37
/* Load PanelUtilAccessible class */
144
38
g_type_class_unref (g_type_class_ref (PANEL_TYPE_UTIL_ACCESSIBLE));
146
bridge_path = get_atk_bridge_path ();
147
if (a11y_invoke_module (bridge_path))
149
g_debug ("Unity accessibility started, using bridge on %s", bridge_path);
152
g_free (bridge_path);
39
atk_bridge_adaptor_init(NULL, NULL);
155
41
a11y_initialized = TRUE;