From 3c378bdfc46fe898ee6a588fd31525a30efa4f2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Pi=C3=B1eiro?= Date: Mon, 2 Jul 2012 19:31:02 +0200 Subject: a11y: Port to atk-bridge gtk3 and gnome-shell already did that. Now the prefered way to initialize the bridge is using atk-bridge library, instead of load a module (bzr r2455.4.1) --- plugins/unityshell/src/unitya11y.cpp | 78 +----------------------------------- 1 file changed, 2 insertions(+), 76 deletions(-) (limited to 'plugins/unityshell/src') diff --git a/plugins/unityshell/src/unitya11y.cpp b/plugins/unityshell/src/unitya11y.cpp index 9f2117d5d..53843785b 100644 --- a/plugins/unityshell/src/unitya11y.cpp +++ b/plugins/unityshell/src/unitya11y.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include "unitya11y.h" #include "unitya11ytests.h" @@ -65,8 +66,6 @@ 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) @@ -121,62 +120,6 @@ should_enable_a11y(void) 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 @@ -194,15 +137,10 @@ 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()) @@ -210,19 +148,7 @@ unity_a11y_init(nux::WindowThread* wt) load_unity_atk_util(wt); - 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); + atk_bridge_adaptor_init (NULL, NULL); // NOTE: we run manually the unit tests while developing by // uncommenting this. Take a look to the explanation on -- cgit v1.2.3 From ac23e16a636b4ce60d813cf49de6edc6129f98b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Pi=C3=B1eiro?= Date: Mon, 2 Jul 2012 19:59:54 +0200 Subject: a11y: Don't check 'toolkit-accessibility' gsettings variable So accessibility is always on, like in gtk3 and gnome-shell (bzr r2455.4.2) --- plugins/unityshell/src/unitya11y.cpp | 46 ------------------------------------ 1 file changed, 46 deletions(-) (limited to 'plugins/unityshell/src') diff --git a/plugins/unityshell/src/unitya11y.cpp b/plugins/unityshell/src/unitya11y.cpp index 53843785b..79ad37516 100644 --- a/plugins/unityshell/src/unitya11y.cpp +++ b/plugins/unityshell/src/unitya11y.cpp @@ -64,8 +64,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" static void unity_a11y_restore_environment(void) @@ -81,45 +79,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 abort 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; -} - /********************************************************************************/ /* * In order to avoid the atk-bridge loading and the GAIL @@ -142,12 +101,7 @@ void unity_a11y_init(nux::WindowThread* wt) { unity_a11y_restore_environment(); - - if (!should_enable_a11y()) - return; - load_unity_atk_util(wt); - atk_bridge_adaptor_init (NULL, NULL); // NOTE: we run manually the unit tests while developing by -- cgit v1.2.3 From 9ebbb72f6b16441b72b8f94352a9cf430becdb93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Pi=C3=B1eiro?= Date: Tue, 3 Jul 2012 18:50:13 +0200 Subject: a11y: Port the panel service accessibility support to atk-bridge As Unity plugin itself, moving to atk-bridge library. Also solving minor issues (bzr r2455.4.3) --- plugins/unityshell/src/unitya11y.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'plugins/unityshell/src') diff --git a/plugins/unityshell/src/unitya11y.cpp b/plugins/unityshell/src/unitya11y.cpp index 79ad37516..fb0016f0d 100644 --- a/plugins/unityshell/src/unitya11y.cpp +++ b/plugins/unityshell/src/unitya11y.cpp @@ -63,8 +63,6 @@ static GHashTable* accessible_table = NULL; static gboolean a11y_initialized = FALSE; -#define INIT_METHOD "gnome_accessibility_module_init" - static void unity_a11y_restore_environment(void) { @@ -100,9 +98,15 @@ unity_a11y_preset_environment(void) void unity_a11y_init(nux::WindowThread* wt) { + if (a11y_initialized) + return; + unity_a11y_restore_environment(); load_unity_atk_util(wt); - atk_bridge_adaptor_init (NULL, NULL); + atk_bridge_adaptor_init(NULL, NULL); + atk_get_root(); + + a11y_initialized = TRUE; // NOTE: we run manually the unit tests while developing by // uncommenting this. Take a look to the explanation on -- cgit v1.2.3