Commit b17e96fe authored by Alejandro Piñeiro's avatar Alejandro Piñeiro

a11y: provide a way to ensure clutter accessibility

If gtk_init is called after clutter_init, it can override clutter
AtkUtil implementation. In that situation, we can't say that
the accessibility is enabled, as the root object would be wrong.

In order to provide a way to prevent this:

* clutter_get_accessibility_enabled returns true of false
  depending on the current AtkUtil implemented
* cally_accessibility_init always override AtkUtil implementation.
parent 6d9d95d9
......@@ -438,3 +438,15 @@ cally_util_stage_removed_cb (ClutterStageManager *stage_manager,
g_signal_handlers_disconnect_by_func (stage, cally_key_snooper_cb, NULL);
}
void
_cally_util_override_atk_util (void)
{
AtkUtilClass *atk_class = ATK_UTIL_CLASS (g_type_class_ref (ATK_TYPE_UTIL));
atk_class->add_key_event_listener = cally_util_add_key_event_listener;
atk_class->remove_key_event_listener = cally_util_remove_key_event_listener;
atk_class->get_root = cally_util_get_root;
atk_class->get_toolkit_name = cally_util_get_toolkit_name;
atk_class->get_toolkit_version = cally_util_get_toolkit_version;
}
......@@ -77,6 +77,8 @@ struct _CallyUtilClass
CLUTTER_AVAILABLE_IN_1_4
GType cally_util_get_type (void) G_GNUC_CONST;
void _cally_util_override_atk_util (void);
G_END_DECLS
#endif /* __CALLY_UTIL_H__ */
......@@ -53,8 +53,6 @@
#include "clutter-debug.h"
#include "clutter-private.h"
static int cally_initialized = FALSE;
/* factories initialization*/
CALLY_ACCESSIBLE_FACTORY (CALLY_TYPE_ACTOR, cally_actor, cally_actor_new)
CALLY_ACCESSIBLE_FACTORY (CALLY_TYPE_GROUP, cally_group, cally_group_new)
......@@ -77,11 +75,6 @@ CALLY_ACCESSIBLE_FACTORY (CALLY_TYPE_CLONE, cally_clone, cally_clone_new)
gboolean
cally_accessibility_init (void)
{
if (cally_initialized)
return TRUE;
cally_initialized = TRUE;
/* setting the factories */
CALLY_ACTOR_SET_FACTORY (CLUTTER_TYPE_ACTOR, cally_actor);
CALLY_ACTOR_SET_FACTORY (CLUTTER_TYPE_GROUP, cally_group);
......@@ -92,11 +85,11 @@ cally_accessibility_init (void)
CALLY_ACTOR_SET_FACTORY (CLUTTER_TYPE_CLONE, cally_clone);
/* Initialize the CallyUtility class */
g_type_class_unref (g_type_class_ref (CALLY_TYPE_UTIL));
_cally_util_override_atk_util ();
CLUTTER_NOTE (MISC, "Clutter Accessibility initialized");
return cally_initialized;
return TRUE;
}
/**
......@@ -111,5 +104,5 @@ cally_accessibility_init (void)
*/
gboolean cally_get_cally_initialized (void)
{
return cally_initialized;
return !g_strcmp0 (atk_get_toolkit_name (), "clutter");
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment