summaryrefslogtreecommitdiff
path: root/legacy/elementary/src/lib/elm_interface_atspi_accessible.c
diff options
context:
space:
mode:
authorLukasz Stanislawski <lukasz.stanislawski@gmail.com>2015-10-04 22:30:31 +0200
committerLukasz Stanislawski <l.stanislaws@samsung.com>2015-10-05 08:58:12 +0200
commit0c8a75442a4fc8222312aa4a685387b626a52ebd (patch)
tree9e8e8d1514b69495322b273778f97675c94d0e94 /legacy/elementary/src/lib/elm_interface_atspi_accessible.c
parent83fd91edf53c6ad21bbba02f3be2ef0c2e0a4daa (diff)
atspi: add new relationship append/remove/clear API
Allow to add some extra contextul information about accessibility objects which can be used by Assistive Technology to provide better user experience. API is still marked as beta. @feature
Diffstat (limited to '')
-rw-r--r--legacy/elementary/src/lib/elm_interface_atspi_accessible.c180
1 files changed, 176 insertions, 4 deletions
diff --git a/legacy/elementary/src/lib/elm_interface_atspi_accessible.c b/legacy/elementary/src/lib/elm_interface_atspi_accessible.c
index 709d142ff0..0c0a213fcd 100644
--- a/legacy/elementary/src/lib/elm_interface_atspi_accessible.c
+++ b/legacy/elementary/src/lib/elm_interface_atspi_accessible.c
@@ -127,6 +127,7 @@ struct _Elm_Interface_Atspi_Accessible_Data
127 const char *name; 127 const char *name;
128 const char *description; 128 const char *description;
129 const char *translation_domain; 129 const char *translation_domain;
130 Elm_Atspi_Relation_Set relations;
130 Elm_Interface_Atspi_Accessible *parent; 131 Elm_Interface_Atspi_Accessible *parent;
131}; 132};
132 133
@@ -290,12 +291,10 @@ _elm_interface_atspi_accessible_state_set_get(Eo *obj EINA_UNUSED, Elm_Interface
290 return 0; 291 return 0;
291} 292}
292 293
293EOLIAN Eina_List* 294EOLIAN Elm_Atspi_Relation_Set
294_elm_interface_atspi_accessible_relation_set_get(Eo *obj EINA_UNUSED, Elm_Interface_Atspi_Accessible_Data *pd EINA_UNUSED) 295_elm_interface_atspi_accessible_relation_set_get(Eo *obj EINA_UNUSED, Elm_Interface_Atspi_Accessible_Data *pd EINA_UNUSED)
295{ 296{
296 WRN("The %s object does not implement the \"accessible_relation_set\" function.", 297 return elm_atspi_relation_set_clone(pd->relations);
297 eo_class_name_get(eo_class_get(obj)));
298 return NULL;
299} 298}
300 299
301EAPI void elm_atspi_attributes_list_free(Eina_List *list) 300EAPI void elm_atspi_attributes_list_free(Eina_List *list)
@@ -369,4 +368,177 @@ _elm_interface_atspi_accessible_translation_domain_get(Eo *obj EINA_UNUSED, Elm_
369 return pd->translation_domain; 368 return pd->translation_domain;
370} 369}
371 370
371EAPI void
372elm_atspi_relation_free(Elm_Atspi_Relation *relation)
373{
374 eina_list_free(relation->objects);
375 free(relation);
376}
377
378EAPI Elm_Atspi_Relation *
379elm_atspi_relation_clone(const Elm_Atspi_Relation *relation)
380{
381 Elm_Atspi_Relation *ret = calloc(sizeof(Elm_Atspi_Relation), 1);
382 if (!ret) return NULL;
383
384 ret->type = relation->type;
385 ret->objects = eina_list_clone(relation->objects);
386 return ret;
387}
388
389static Eina_Bool
390_on_rel_obj_del(void *data, Eo *obj, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
391{
392 Elm_Atspi_Relation_Set *set = data;
393 Elm_Atspi_Relation *rel;
394 Eina_List *l, *l2, *p, *p2;
395 Eo *rel_obj;
396
397 EINA_LIST_FOREACH_SAFE(*set, l, l2, rel)
398 {
399 EINA_LIST_FOREACH_SAFE(rel->objects, p, p2, rel_obj)
400 {
401 if (rel_obj == obj)
402 rel->objects = eina_list_remove_list(rel->objects, p);
403 }
404 if (!rel->objects)
405 {
406 *set = eina_list_remove_list(*set, l);
407 free(rel);
408 }
409 }
410 return EINA_TRUE;
411}
412
413EAPI Eina_Bool
414elm_atspi_relation_set_relation_append(Elm_Atspi_Relation_Set *set, Elm_Atspi_Relation_Type type, const Eo *rel_obj)
415{
416 Elm_Atspi_Relation *rel;
417 Eina_List *l;
418
419 if (!eo_isa(rel_obj, ELM_INTERFACE_ATSPI_ACCESSIBLE_MIXIN))
420 return EINA_FALSE;
421
422 EINA_LIST_FOREACH(*set, l, rel)
423 {
424 if (rel->type == type)
425 {
426 if (!eina_list_data_find(rel->objects, rel_obj))
427 {
428 rel->objects = eina_list_append(rel->objects, rel_obj);
429 eo_do(rel_obj, eo_event_callback_add(EO_BASE_EVENT_DEL, _on_rel_obj_del, set));
430 }
431 return EINA_TRUE;
432 }
433 }
434
435 rel = calloc(sizeof(Elm_Atspi_Relation), 1);
436 if (!rel) return EINA_FALSE;
437
438 rel->type = type;
439 rel->objects = eina_list_append(rel->objects, rel_obj);
440 *set = eina_list_append(*set, rel);
441
442 eo_do(rel_obj, eo_event_callback_add(EO_BASE_EVENT_DEL, _on_rel_obj_del, set));
443 return EINA_TRUE;
444}
445
446EAPI void
447elm_atspi_relation_set_relation_remove(Elm_Atspi_Relation_Set *set, Elm_Atspi_Relation_Type type, const Eo *rel_obj)
448{
449 Eina_List *l;
450 Elm_Atspi_Relation *rel;
451
452 EINA_LIST_FOREACH(*set, l, rel)
453 {
454 if (rel->type == type)
455 {
456 if (eina_list_data_find(rel->objects, rel_obj))
457 {
458 eo_do(rel_obj, eo_event_callback_del(EO_BASE_EVENT_DEL, _on_rel_obj_del, set));
459 rel->objects = eina_list_remove(rel->objects, rel_obj);
460 }
461 if (!rel->objects)
462 {
463 *set = eina_list_remove(*set, rel);
464 elm_atspi_relation_free(rel);
465 }
466 return;
467 }
468 }
469}
470
471EAPI void
472elm_atspi_relation_set_relation_type_remove(Elm_Atspi_Relation_Set *set, Elm_Atspi_Relation_Type type)
473{
474 Eina_List *l;
475 Elm_Atspi_Relation *rel;
476 Eo *obj;
477
478 EINA_LIST_FOREACH(*set, l, rel)
479 {
480 if (rel->type == type)
481 {
482 EINA_LIST_FOREACH(rel->objects, l, obj)
483 eo_do(obj, eo_event_callback_del(EO_BASE_EVENT_DEL, _on_rel_obj_del, set));
484 *set = eina_list_remove(*set, rel);
485 elm_atspi_relation_free(rel);
486 return;
487 }
488 }
489}
490
491EAPI void
492elm_atspi_relation_set_free(Elm_Atspi_Relation_Set set)
493{
494 Elm_Atspi_Relation *rel;
495 Eina_List *l;
496 Eo *obj;
497
498 EINA_LIST_FREE(set, rel)
499 {
500 EINA_LIST_FOREACH(rel->objects, l, obj)
501 eo_do(obj, eo_event_callback_del(EO_BASE_EVENT_DEL, _on_rel_obj_del, set));
502 elm_atspi_relation_free(rel);
503 }
504}
505
506EAPI Elm_Atspi_Relation_Set
507elm_atspi_relation_set_clone(const Elm_Atspi_Relation_Set set)
508{
509 Elm_Atspi_Relation_Set ret = NULL;
510 Eina_List *l;
511 Elm_Atspi_Relation *rel;
512
513 EINA_LIST_FOREACH(set, l, rel)
514 {
515 Elm_Atspi_Relation *cpy = elm_atspi_relation_clone(rel);
516 ret = eina_list_append(ret, cpy);
517 }
518
519 return ret;
520}
521
522EOLIAN static Eina_Bool
523_elm_interface_atspi_accessible_relationship_append(Eo *obj EINA_UNUSED, Elm_Interface_Atspi_Accessible_Data *sd, Elm_Atspi_Relation_Type type, const Elm_Interface_Atspi_Accessible *relation_obj)
524{
525 return elm_atspi_relation_set_relation_append(&sd->relations, type, relation_obj);
526}
527
528EOLIAN static void
529_elm_interface_atspi_accessible_relationship_remove(Eo *obj EINA_UNUSED, Elm_Interface_Atspi_Accessible_Data *sd, Elm_Atspi_Relation_Type type, const Elm_Interface_Atspi_Accessible *relation_obj)
530{
531 if (relation_obj)
532 elm_atspi_relation_set_relation_remove(&sd->relations, type, relation_obj);
533 else
534 elm_atspi_relation_set_relation_type_remove(&sd->relations, type);
535}
536
537EOLIAN static void
538_elm_interface_atspi_accessible_relationships_clear(Eo *obj EINA_UNUSED, Elm_Interface_Atspi_Accessible_Data *sd)
539{
540 elm_atspi_relation_set_free(sd->relations);
541 sd->relations = NULL;
542}
543
372#include "elm_interface_atspi_accessible.eo.c" 544#include "elm_interface_atspi_accessible.eo.c"