summaryrefslogtreecommitdiff
path: root/plugins/unityshell/src
diff options
authorMarco Trevisan (Treviño) <mail@3v1n0.net>2012-09-10 18:07:39 +0200
committerMarco Trevisan (Treviño) <mail@3v1n0.net>2012-09-10 18:07:39 +0200
commit63c5ac3733b59b35f92be94321f38937dd304e02 (patch)
tree5d46ffd07f996b06ee95173c833c376d3bc08b47 /plugins/unityshell/src
parenteb5728f748c8fdef8d3334183046bb1234fd50f3 (diff)
parentd0d706a9bf8d05e4821ad72aed8888b0aeefe61b (diff)
Merging trunk
(bzr r2529.14.58)
Diffstat (limited to 'plugins/unityshell/src')
-rw-r--r--plugins/unityshell/src/unitya11y.cpp129
1 files changed, 6 insertions, 123 deletions
diff --git a/plugins/unityshell/src/unitya11y.cpp b/plugins/unityshell/src/unitya11y.cpp
index 9a8c143d9..1035af609 100644
--- a/plugins/unityshell/src/unitya11y.cpp
+++ b/plugins/unityshell/src/unitya11y.cpp
@@ -20,6 +20,7 @@
#include <gio/gio.h>
#include <gmodule.h>
#include <stdio.h>
+#include <atk-bridge.h>
#include "unitya11y.h"
#include "unitya11ytests.h"
@@ -62,12 +63,6 @@ static GHashTable* accessible_table = NULL;
static gboolean a11y_initialized = FALSE;
-#define INIT_METHOD "gnome_accessibility_module_init"
-#define DESKTOP_SCHEMA "org.gnome.desktop.interface"
-#define ACCESSIBILITY_ENABLED_KEY "toolkit-accessibility"
-#define AT_SPI_SCHEMA "org.a11y.atspi"
-#define ATK_BRIDGE_LOCATION_KEY "atk-bridge-location"
-
static void
unity_a11y_restore_environment(void)
{
@@ -82,102 +77,6 @@ load_unity_atk_util(nux::WindowThread* wt)
g_type_class_unref(g_type_class_ref(UNITY_TYPE_UTIL_ACCESSIBLE));
}
-/* This method is required because g_setting_new aborts if the schema
- is not present. */
-static gboolean
-has_gsettings_schema(const gchar* schema)
-{
- const char* const* list_schemas = NULL;
- gboolean found = FALSE;
- int i = 0;
-
- list_schemas = g_settings_list_schemas();
- for (i = 0; list_schemas [i]; i++)
- {
- if (!g_strcmp0(list_schemas[i], schema))
- {
- found = TRUE;
- break;
- }
- }
-
- return found;
-}
-
-static gboolean
-should_enable_a11y(void)
-{
- GSettings* desktop_settings = NULL;
- gboolean value = FALSE;
-
- if (!has_gsettings_schema(DESKTOP_SCHEMA))
- return FALSE;
-
- desktop_settings = g_settings_new(DESKTOP_SCHEMA);
- value = g_settings_get_boolean(desktop_settings, ACCESSIBILITY_ENABLED_KEY);
-
- g_object_unref(desktop_settings);
-
- return value;
-}
-
-static gchar*
-get_atk_bridge_path(void)
-{
- GSettings* atspi_settings = NULL;
- GVariant *variant = NULL;
- char* value = NULL;
-
- if (!has_gsettings_schema(AT_SPI_SCHEMA))
- return NULL;
-
- atspi_settings = g_settings_new(AT_SPI_SCHEMA);
- variant = g_settings_get_value (atspi_settings, ATK_BRIDGE_LOCATION_KEY);
- value = g_variant_dup_bytestring (variant, NULL);
-
- g_variant_unref (variant);
- g_object_unref(atspi_settings);
-
- return value;
-}
-
-static gboolean
-a11y_invoke_module(const char* module_path)
-{
- GModule* handle;
- void (*invoke_fn)(void);
-
- if (!module_path)
- {
- g_warning("Accessibility: invalid module path (NULL)");
-
- return FALSE;
- }
-
- if (!(handle = g_module_open(module_path, (GModuleFlags)0)))
- {
- g_warning("Accessibility: failed to load module '%s': '%s'",
- module_path, g_module_error());
-
- return FALSE;
- }
-
- if (!g_module_symbol(handle, INIT_METHOD, (gpointer*)&invoke_fn))
- {
- g_warning("Accessibility: error library '%s' does not include "
- "method '%s' required for accessibility support",
- module_path, INIT_METHOD);
- g_module_close(handle);
-
- return FALSE;
- }
-
- invoke_fn();
-
- return TRUE;
-}
-
-/********************************************************************************/
/*
* In order to avoid the atk-bridge loading and the GAIL
* initialization during the gtk_init, it is required to set some
@@ -194,35 +93,19 @@ unity_a11y_preset_environment(void)
/*
* Initializes the accessibility (ATK) support on Unity
*
- * It loads the atk-bridge if required. It checks:
- * * If the proper gsettings keys are set
- * * Loads the proper AtkUtil implementation
*/
void
unity_a11y_init(nux::WindowThread* wt)
{
- gchar* bridge_path = NULL;
-
- unity_a11y_restore_environment();
-
- if (!should_enable_a11y())
+ if (a11y_initialized)
return;
+ unity_a11y_restore_environment();
load_unity_atk_util(wt);
+ atk_bridge_adaptor_init(NULL, NULL);
+ atk_get_root();
- bridge_path = get_atk_bridge_path();
-
- if (a11y_invoke_module(bridge_path))
- {
- g_debug("Unity Oneiric accessibility started, using bridge on %s",
- bridge_path);
-
- atk_get_root();
-
- a11y_initialized = TRUE;
- }
-
- g_free(bridge_path);
+ a11y_initialized = TRUE;
// NOTE: we run the unit tests manually while developing by
// uncommenting this. Take a look at the explanation in the