diff options
author | Lukasz Stanislawski <lukasz.stanislawski@gmail.com> | 2019-02-13 14:37:38 +0100 |
---|---|---|
committer | Lukasz Stanislawski <lukasz.stanislawski@gmail.com> | 2019-02-13 14:37:38 +0100 |
commit | 05d432a3285f09c767e3cdb3a173ec0eb763de60 (patch) | |
tree | f1ecdde6ee87dd995405cec79ba680ca8fc3f30f | |
parent | 0f644bfd9f1726f35c2b1fab04b2444a0b1a3aec (diff) | |
download | efl-05d432a3285f09c767e3cdb3a173ec0eb763de60.tar.gz |
efl_access: add Efl.Access.Provider class
The purpose of this class is to abstract the way of getting
Efl.Access.Object from any Efl.Object.
-rw-r--r-- | src/Makefile_Elementary.am | 2 | ||||
-rw-r--r-- | src/lib/elementary/efl_access_object.c | 45 | ||||
-rw-r--r-- | src/lib/elementary/efl_access_object.eo | 33 | ||||
-rw-r--r-- | src/lib/elementary/efl_access_object.h | 1 | ||||
-rw-r--r-- | src/lib/elementary/efl_access_provider.c | 8 | ||||
-rw-r--r-- | src/lib/elementary/efl_access_provider.eo | 17 | ||||
-rw-r--r-- | src/lib/elementary/elm_interfaces.h | 1 |
7 files changed, 107 insertions, 0 deletions
diff --git a/src/Makefile_Elementary.am b/src/Makefile_Elementary.am index 54452059da..6103a5ba31 100644 --- a/src/Makefile_Elementary.am +++ b/src/Makefile_Elementary.am @@ -110,6 +110,7 @@ elm_public_eolian_files = \ lib/elementary/efl_access_component.eo \ lib/elementary/efl_access_editable_text.eo \ lib/elementary/efl_access_bridge.eo \ + lib/elementary/efl_access_provider.eo \ lib/elementary/efl_access_selection.eo \ lib/elementary/efl_access_text.eo \ lib/elementary/efl_access_value.eo \ @@ -754,6 +755,7 @@ lib_elementary_libelementary_la_SOURCES = \ lib/elementary/efl_access_component.c \ lib/elementary/efl_access_editable_text.c \ lib/elementary/efl_access_bridge.c \ + lib/elementary/efl_access_provider.c \ lib/elementary/efl_access_selection.c \ lib/elementary/efl_access_text.c \ lib/elementary/efl_access_value.c \ diff --git a/src/lib/elementary/efl_access_object.c b/src/lib/elementary/efl_access_object.c index 62e4777f54..c0da36c44d 100644 --- a/src/lib/elementary/efl_access_object.c +++ b/src/lib/elementary/efl_access_object.c @@ -8,6 +8,8 @@ #include "elm_widget.h" #include "elm_priv.h" +static Eina_Inarray providers; + const char* Access_Name[] = { "invalid", "accelerator label", @@ -501,4 +503,47 @@ _efl_access_object_efl_object_destructor(Eo *obj, Efl_Access_Object_Data *pd) efl_destructor(efl_super(obj, EFL_ACCESS_OBJECT_MIXIN)); } +EOLIAN void +_efl_access_object_class_constructor(Efl_Class *cls EINA_UNUSED) +{ + eina_inarray_step_set(&providers, sizeof(Eina_Inarray), sizeof(Eo*), 0); +} + +static int +_eo_pointer_compare(const void *a, const void *b) +{ + return memcmp(a, b, sizeof(Eo*)); +} + +EOLIAN Efl_Access_Object* +_efl_access_object_query(Eo *class EINA_UNUSED, void *pd EINA_UNUSED, Efl_Object *obj) +{ + Efl_Access_Provider **provider; + + EINA_INARRAY_REVERSE_FOREACH(&providers, provider) + { + Efl_Access_Object *access = efl_access_provider_access_object_get(*provider, obj); + if (access) return access; + } + + return NULL; +} + +EOLIAN void +_efl_access_object_access_provider_add(Eo *obj EINA_UNUSED, void *pd EINA_UNUSED, Efl_Access_Provider *provider) +{ + if (eina_inarray_search(&providers, &provider, _eo_pointer_compare) == -1) + { + eina_inarray_push(&providers, &provider); + efl_ref(provider); + } +} + +EOLIAN void +_efl_access_object_access_provider_del(Eo *obj EINA_UNUSED, void *pd EINA_UNUSED, Efl_Access_Provider *provider) +{ + if (eina_inarray_remove(&providers, &provider) != -1) + efl_unref(provider); +} + #include "efl_access_object.eo.c" diff --git a/src/lib/elementary/efl_access_object.eo b/src/lib/elementary/efl_access_object.eo index 6211fe2735..4cbeb76d65 100644 --- a/src/lib/elementary/efl_access_object.eo +++ b/src/lib/elementary/efl_access_object.eo @@ -402,8 +402,41 @@ mixin Efl.Access.Object requires Efl.Object relationships_clear @beta { [[Removes all relationships in accessible object.]] } + query @class { + [[Queries Efl.Object for accessibile implementation. + + The accessibility implementation will be provided by + Efl.Access.Provider installed with @Efl.Access.Object.access_provider_add + function. + + The providers are queried in reverse order the were added. So if two + providers provide accessibility for same object, the accessible + implementation from the most recently added provider will be + returned.]] + params { + @in object: Efl.Object; + } + return: Efl.Access.Object; + } + access_provider_add @class { + [[Adds provider object to the list of providers queried by + @Efl.Access.Object.query + method.]] + params { + @in provider: Efl.Access.Provider; + } + } + access_provider_del @class { + [[Removes provider object from the list of providers queried by + @Efl.Access.Object.query + method.]] + params { + @in provider: Efl.Access.Provider; + } + } } implements { + class.constructor; Efl.Object.destructor; } events { diff --git a/src/lib/elementary/efl_access_object.h b/src/lib/elementary/efl_access_object.h index fdf4d3b8ce..fb9fbc25df 100644 --- a/src/lib/elementary/efl_access_object.h +++ b/src/lib/elementary/efl_access_object.h @@ -4,6 +4,7 @@ #ifdef EFL_BETA_API_SUPPORT #ifdef EFL_EO_API_SUPPORT +typedef Eo Efl_Access_Provider; #include "efl_access_object.eo.h" #include "efl_access_bridge.eo.h" #endif diff --git a/src/lib/elementary/efl_access_provider.c b/src/lib/elementary/efl_access_provider.c new file mode 100644 index 0000000000..9e152b84b9 --- /dev/null +++ b/src/lib/elementary/efl_access_provider.c @@ -0,0 +1,8 @@ +#ifdef HAVE_CONFIG_H + #include "elementary_config.h" +#endif + +#include <Elementary.h> + +#include "efl_access_provider.eo.c" + diff --git a/src/lib/elementary/efl_access_provider.eo b/src/lib/elementary/efl_access_provider.eo new file mode 100644 index 0000000000..2923ef8ddc --- /dev/null +++ b/src/lib/elementary/efl_access_provider.eo @@ -0,0 +1,17 @@ +interface Efl.Access.Provider +{ + methods { + @property access_object { + [[ Get accessibile implementation for Efl.Object ]] + get { + } + keys { + object: Efl.Object; + } + values { + obj: Efl.Access.Object; + } + } + } +} + diff --git a/src/lib/elementary/elm_interfaces.h b/src/lib/elementary/elm_interfaces.h index bcbe8e646f..2ff3218213 100644 --- a/src/lib/elementary/elm_interfaces.h +++ b/src/lib/elementary/elm_interfaces.h @@ -14,6 +14,7 @@ #include "efl_access_component.eo.h" #include "efl_access_editable_text.eo.h" #include "efl_access_selection.eo.h" +#include "efl_access_provider.eo.h" #include "efl_access_value.eo.h" #include "efl_ui_legacy.eo.h" #endif |