summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShilpa Singh <shilpa.singh@samsung.com>2017-11-22 11:54:44 +0900
committerShinwoo Kim <cinoo.kim@samsung.com>2017-11-22 11:54:45 +0900
commit11292dec353d3967ce568ed7017976277b18b2ed (patch)
tree3de5bf683f7124c03119020a19b7253cfb4dd7e3
parent2c559a1ee9210b46e4f44346d87ff75e4229740b (diff)
downloadefl-11292dec353d3967ce568ed7017976277b18b2ed.tar.gz
efl_access: Add attribute_append, attributes_clear APIs
Summary: Add attribute append and attributes clear API, attributes of widget/widget_item helps in adding additional information about the widget/widget item in the form of key-value pair. Test Plan: Query the attributes using atspi_accessible_get_attributes in atspi_client and an hash table consisting of updates attributes should be returned. Signed-Off By: Shilpa Singh <shilpa.singh@samsung.com> Signed-Off By: Lukasz Wlazly <l.wlazly@partner.samsung.com> Reviewers: kimcinoo, lukasz.stanislawski Subscribers: cedric, govi, rajeshps, jpeg Differential Revision: https://phab.enlightenment.org/D5510
-rw-r--r--src/lib/elementary/efl_access.c65
-rw-r--r--src/lib/elementary/efl_access.eo17
-rw-r--r--src/lib/elementary/elm_widget.c47
-rw-r--r--src/lib/elementary/elm_widget_item.eo1
4 files changed, 115 insertions, 15 deletions
diff --git a/src/lib/elementary/efl_access.c b/src/lib/elementary/efl_access.c
index 4586012b77..dc02dbb703 100644
--- a/src/lib/elementary/efl_access.c
+++ b/src/lib/elementary/efl_access.c
@@ -123,11 +123,12 @@ struct _Efl_Access_Event_Handler
struct _Efl_Access_Data
{
- Efl_Access_Role role;
+ Efl_Access_Relation_Set relations;
+ Eina_List *attr_list;
const char *name;
const char *description;
const char *translation_domain;
- Efl_Access_Relation_Set relations;
+ Efl_Access_Role role;
Efl_Access_Type type: 2;
};
@@ -193,9 +194,63 @@ _efl_access_parent_set(Eo *obj, Efl_Access_Data *pd EINA_UNUSED, Efl_Access *new
EOLIAN Eina_List*
_efl_access_attributes_get(Eo *obj EINA_UNUSED, Efl_Access_Data *pd EINA_UNUSED)
{
- WRN("The %s object does not implement the \"accessible_attributes_set\" function.",
- efl_class_name_get(efl_class_get(obj)));
- return NULL;
+ Eina_List *attr_list = NULL;
+ if (pd->attr_list)
+ {
+ Eina_List *l = NULL;
+ Efl_Access_Attribute *t_attr = NULL;
+ EINA_LIST_FOREACH(pd->attr_list, l, t_attr)
+ {
+ Efl_Access_Attribute *attr = calloc(1, sizeof(Efl_Access_Attribute));
+ if (!attr)
+ return attr_list;
+
+ attr->key = eina_stringshare_add(t_attr->key);
+ attr->value = eina_stringshare_add(t_attr->value);
+ attr_list = eina_list_append(attr_list, attr);
+ }
+ }
+ return attr_list;
+}
+
+EOLIAN static void
+_efl_access_attribute_append(Eo *obj EINA_UNUSED, Efl_Access_Data *pd EINA_UNUSED, const char *key, const char *value)
+{
+ Eina_List *l;
+ Efl_Access_Attribute *attr = NULL;
+
+ if (!key || !value) return;
+
+ /* Check existing attributes has this key */
+ EINA_LIST_FOREACH(pd->attr_list, l, attr)
+ {
+ if (!strcmp((const char *)attr->key, key))
+ {
+ eina_stringshare_replace(&attr->value, value);
+ return;
+ }
+ }
+
+ /* Add new attribute */
+ attr = calloc(1, sizeof(Efl_Access_Attribute));
+ if (!attr) return;
+
+ attr->key = eina_stringshare_add(key);
+ attr->value = eina_stringshare_add(value);
+ pd->attr_list = eina_list_append(pd->attr_list, attr);
+}
+
+EOLIAN static void _efl_access_attributes_clear(Eo *obj EINA_UNUSED, Efl_Access_Data *pd)
+{
+ if (!pd->attr_list) return;
+ Efl_Access_Attribute *attr;
+ EINA_LIST_FREE(pd->attr_list, attr)
+ {
+ eina_stringshare_del(attr->key);
+ eina_stringshare_del(attr->value);
+ free(attr);
+ }
+ pd->attr_list = NULL;
}
EOLIAN static Efl_Access_Role
diff --git a/src/lib/elementary/efl_access.eo b/src/lib/elementary/efl_access.eo
index 0ae001a433..33b361d0bb 100644
--- a/src/lib/elementary/efl_access.eo
+++ b/src/lib/elementary/efl_access.eo
@@ -298,10 +298,23 @@ mixin Efl.Access (Efl.Interface, Efl.Object)
get {
}
values {
- /* FIXME: API for attribute free */
- attributes: list<ptr(Efl.Access.Attribute) @owned> @owned; [[List of object attributes]]
+ attributes: list<ptr(Efl.Access.Attribute) @owned> @owned; [[List of object attributes, Must be freed by the user]]
}
}
+ attribute_append {
+ [[Add key-value pair identifying object extra attributes
+ ]]
+ params {
+ @in key: const(string); [[The string key to give extra information]]
+ @in value: const(string); [[The string value to give extra information]]
+ }
+ }
+ attributes_clear {
+ [[Removes all attributes in accessible object.
+
+ \@internal
+ ]]
+ }
@property index_in_parent @protected @beta {
[[Gets index of the child in parent's children list.]]
get {
diff --git a/src/lib/elementary/elm_widget.c b/src/lib/elementary/elm_widget.c
index 8ef0713bfc..3b122a9b84 100644
--- a/src/lib/elementary/elm_widget.c
+++ b/src/lib/elementary/elm_widget.c
@@ -3766,6 +3766,7 @@ _elm_widget_item_efl_object_destructor(Eo *eo_item, Elm_Widget_Item_Data *item)
}
eina_hash_free(item->labels);
+ efl_access_attributes_clear(eo_item);
efl_access_removed(eo_item);
EINA_MAGIC_SET(item, EINA_MAGIC_NONE);
@@ -5083,7 +5084,7 @@ _elm_widget_efl_object_destructor(Eo *obj, Elm_Widget_Smart_Data *sd)
efl_event_callback_del(sd->manager.provider, EFL_UI_FOCUS_USER_EVENT_MANAGER_CHANGED, _manager_changed_cb, obj);
sd->manager.provider = NULL;
}
-
+ efl_access_attributes_clear(obj);
efl_access_removed(obj);
if (sd->logical.parent)
{
@@ -5260,15 +5261,45 @@ _elm_widget_efl_access_state_set_get(Eo *obj, Elm_Widget_Smart_Data *pd EINA_UNU
EOLIAN static Eina_List*
_elm_widget_efl_access_attributes_get(Eo *obj, Elm_Widget_Smart_Data *pd EINA_UNUSED)
{
- Eina_List *ret = NULL;
- Efl_Access_Attribute *attr = calloc(1, sizeof(Efl_Access_Attribute));
- if (!attr) return NULL;
+ Eina_List *attr_list = NULL;
- attr->key = eina_stringshare_add("type");
- attr->value = eina_stringshare_add(evas_object_type_get(obj));
+ attr_list = efl_access_attributes_get(efl_super(obj, ELM_WIDGET_CLASS));
- ret = eina_list_append(ret, attr);
- return ret;
+ //Add type and style information in addition.
+ Efl_Access_Attribute *attr = NULL;
+ attr = calloc(1, sizeof(Efl_Access_Attribute));
+ if (attr)
+ {
+ attr->key = eina_stringshare_add("type");
+ attr->value = eina_stringshare_add(elm_widget_type_get(obj));
+ attr_list = eina_list_append(attr_list, attr);
+ }
+
+ attr = calloc(1, sizeof(Efl_Access_Attribute));
+ if (attr)
+ {
+ attr->key = eina_stringshare_add("style");
+ attr->value = eina_stringshare_add(elm_widget_style_get(obj));
+ attr_list = eina_list_append(attr_list, attr);
+ }
+
+ return attr_list;
+}
+
+EOLIAN static Eina_List *
+_elm_widget_item_efl_access_attributes_get(Eo *eo_item, Elm_Widget_Item_Data *pd EINA_UNUSED)
+{
+ Eina_List *attr_list = NULL;
+ attr_list = efl_access_attributes_get(efl_super(eo_item, ELM_WIDGET_ITEM_CLASS));
+ Efl_Access_Attribute *attr = NULL;
+ attr = calloc(1, sizeof(Efl_Access_Attribute));
+ if (attr)
+ {
+ attr->key = eina_stringshare_add("style");
+ attr->value = eina_stringshare_add(elm_object_item_style_get(eo_item));
+ attr_list = eina_list_append(attr_list, attr);
+ }
+ return attr_list;
}
EOLIAN static Eina_Rect
diff --git a/src/lib/elementary/elm_widget_item.eo b/src/lib/elementary/elm_widget_item.eo
index b7ad3c33be..b5321f017a 100644
--- a/src/lib/elementary/elm_widget_item.eo
+++ b/src/lib/elementary/elm_widget_item.eo
@@ -541,6 +541,7 @@ class Elm.Widget.Item(Efl.Object, Efl.Access,
Efl.Object.constructor;
Efl.Object.destructor;
Efl.Access.state_set { get; }
+ Efl.Access.attributes { get; }
Efl.Access.Component.extents { get; set; }
Efl.Access.Component.alpha { get; }
Efl.Access.Component.layer { get; }