summaryrefslogtreecommitdiff
path: root/src/lib/elementary/elm_interface_atspi_accessible.c
diff options
context:
space:
mode:
authorLukasz Stanislawski <lukasz.stanislawski@gmail.com>2017-10-19 10:13:54 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2017-10-19 10:13:54 +0900
commit57aefc53c18c14ada19dcd09d3e5b5612b277b16 (patch)
tree897745eb7c2d9ccbbde1bc0cf4dd2971c2e625f4 /src/lib/elementary/elm_interface_atspi_accessible.c
parent98622623a0865c525ede12ef5759ab6f5b3af407 (diff)
elm: rename Elm_Interface_Atspi_Accessible interface
Subscribers: cedric, jpeg Differential Revision: https://phab.enlightenment.org/D5341
Diffstat (limited to 'src/lib/elementary/elm_interface_atspi_accessible.c')
-rw-r--r--src/lib/elementary/elm_interface_atspi_accessible.c623
1 files changed, 0 insertions, 623 deletions
diff --git a/src/lib/elementary/elm_interface_atspi_accessible.c b/src/lib/elementary/elm_interface_atspi_accessible.c
deleted file mode 100644
index 22a18ba231..0000000000
--- a/src/lib/elementary/elm_interface_atspi_accessible.c
+++ /dev/null
@@ -1,623 +0,0 @@
1#ifdef HAVE_CONFIG_H
2 #include "elementary_config.h"
3#endif
4
5#define ELM_INTERFACE_ATSPI_ACCESSIBLE_PROTECTED
6
7#include <Elementary.h>
8#include "elm_widget.h"
9#include "elm_priv.h"
10
11const char* Atspi_Name[] = {
12 "invalid",
13 "accelerator label",
14 "alert",
15 "animation",
16 "arrow",
17 "calendar",
18 "canvas",
19 "check box",
20 "check menu item",
21 "color chooser",
22 "column header",
23 "combo box",
24 "dateeditor",
25 "desktop icon",
26 "desktop frame",
27 "dial",
28 "dialog",
29 "directory pane",
30 "drawing area",
31 "file chooser",
32 "filler",
33 "focus traversable",
34 "font chooser",
35 "frame",
36 "glass pane",
37 "html container",
38 "icon",
39 "image",
40 "internal frame",
41 "label",
42 "layered pane",
43 "list",
44 "list item",
45 "menu",
46 "menu bar",
47 "menu item",
48 "option pane",
49 "page tab",
50 "page tab list",
51 "panel",
52 "password text",
53 "popup menu",
54 "progress bar",
55 "push button",
56 "radio button",
57 "radio menu item",
58 "root pane",
59 "row header",
60 "scroll bar",
61 "scroll pane",
62 "separator",
63 "slider",
64 "spin button",
65 "split pane",
66 "status bar",
67 "table",
68 "table cell",
69 "table column header",
70 "table row header",
71 "tearoff menu item",
72 "terminal",
73 "text",
74 "toggle button",
75 "tool bar",
76 "tool tip",
77 "tree",
78 "tree table",
79 "unknown",
80 "viewport",
81 "window",
82 "extended",
83 "header",
84 "footer",
85 "paragraph",
86 "ruler",
87 "application",
88 "autocomplete",
89 "editbar",
90 "embedded",
91 "entry",
92 "chart",
93 "caption",
94 "document frame",
95 "heading",
96 "page",
97 "section",
98 "redundant object",
99 "form",
100 "link",
101 "input method window",
102 "table row",
103 "tree item",
104 "document spreadsheet",
105 "document presentation",
106 "document text",
107 "document web",
108 "document email",
109 "comment",
110 "list box",
111 "grouping",
112 "image map",
113 "notification",
114 "info bar",
115 "last defined"
116};
117
118struct _Elm_Atspi_Event_Handler
119{
120 Efl_Event_Cb cb;
121 void *data;
122};
123
124struct _Elm_Interface_Atspi_Accessible_Data
125{
126 Elm_Atspi_Role role;
127 const char *name;
128 const char *description;
129 const char *translation_domain;
130 Elm_Atspi_Relation_Set relations;
131 Elm_Atspi_Type type: 2;
132};
133
134typedef struct _Elm_Interface_Atspi_Accessible_Data Elm_Interface_Atspi_Accessible_Data;
135
136
137static Eina_List *global_callbacks;
138static Eo *root;
139
140EOLIAN static int
141_elm_interface_atspi_accessible_index_in_parent_get(Eo *obj, Elm_Interface_Atspi_Accessible_Data *pd EINA_UNUSED)
142{
143 Eina_List *l, *children = NULL;
144 Eo *chld, *parent = NULL;
145 int ret = 0;
146
147 parent = elm_interface_atspi_accessible_parent_get(obj);
148 if (!parent) return -1;
149
150 children = elm_interface_atspi_accessible_children_get(parent);
151 if (!children) return -1;
152
153 EINA_LIST_FOREACH(children, l, chld)
154 {
155 if (obj == chld)
156 break;
157 ret++;
158 }
159 if (ret == (int)eina_list_count(children))
160 {
161 ERR("Object %s not present in its AT-SPI parents (%s) children list! This should never happen.", efl_class_name_get(efl_class_get(obj)), efl_class_name_get(efl_class_get(parent)));
162 ret = -1;
163 }
164 eina_list_free(children);
165 return ret;
166}
167
168EOLIAN static Elm_Interface_Atspi_Accessible *
169_elm_interface_atspi_accessible_parent_get(Eo *obj EINA_UNUSED, Elm_Interface_Atspi_Accessible_Data *pd EINA_UNUSED)
170{
171 Elm_Atspi_Type type;
172 Eo *parent = obj;
173
174 do {
175 parent = efl_parent_get(obj);
176 if (efl_isa(parent, ELM_INTERFACE_ATSPI_ACCESSIBLE_MIXIN))
177 {
178 type = elm_interface_atspi_accessible_type_get(parent);
179 if (type != ELM_ATSPI_TYPE_SKIPPED) break;
180 }
181 } while (parent);
182
183 return efl_isa(parent, ELM_INTERFACE_ATSPI_ACCESSIBLE_MIXIN) ? parent : NULL;
184}
185
186EOLIAN static void
187_elm_interface_atspi_accessible_parent_set(Eo *obj, Elm_Interface_Atspi_Accessible_Data *pd EINA_UNUSED, Elm_Interface_Atspi_Accessible *new_parent EINA_UNUSED)
188{
189 WRN("The %s object does not implement the \"accessible_parent_set\" function.",
190 efl_class_name_get(efl_class_get(obj)));
191}
192
193EOLIAN Eina_List*
194_elm_interface_atspi_accessible_attributes_get(Eo *obj EINA_UNUSED, Elm_Interface_Atspi_Accessible_Data *pd EINA_UNUSED)
195{
196 WRN("The %s object does not implement the \"accessible_attributes_set\" function.",
197 efl_class_name_get(efl_class_get(obj)));
198 return NULL;
199}
200
201EOLIAN static Elm_Atspi_Role
202_elm_interface_atspi_accessible_role_get(Eo *obj EINA_UNUSED, Elm_Interface_Atspi_Accessible_Data *pd EINA_UNUSED)
203{
204 return pd->role;
205}
206
207EOLIAN static void
208_elm_interface_atspi_accessible_role_set(Eo *obj, Elm_Interface_Atspi_Accessible_Data *pd EINA_UNUSED, Elm_Atspi_Role role)
209{
210 if (pd->role != role)
211 {
212 pd->role = role;
213 elm_interface_atspi_accessible_role_changed_signal_emit(obj);
214 }
215}
216
217EOLIAN const char *
218_elm_interface_atspi_accessible_role_name_get(Eo *obj EINA_UNUSED, Elm_Interface_Atspi_Accessible_Data *pd EINA_UNUSED)
219{
220 Elm_Atspi_Role role;
221
222 role = elm_interface_atspi_accessible_role_get(obj);
223
224 return role > ELM_ATSPI_ROLE_LAST_DEFINED ? "" : Atspi_Name[role];
225}
226
227EOLIAN const char *
228_elm_interface_atspi_accessible_name_get(Eo *obj EINA_UNUSED, Elm_Interface_Atspi_Accessible_Data *pd)
229{
230#ifdef ENABLE_NLS
231 if (pd->translation_domain)
232 return dgettext(pd->translation_domain, pd->name);
233#endif
234 return pd->name;
235}
236
237EOLIAN static void
238_elm_interface_atspi_accessible_name_set(Eo *obj EINA_UNUSED, Elm_Interface_Atspi_Accessible_Data *pd, const char *val)
239{
240 eina_stringshare_replace(&pd->name, val);
241}
242
243const char * _elm_interface_atspi_accessible_description_get(Eo *obj EINA_UNUSED, Elm_Interface_Atspi_Accessible_Data *pd)
244{
245#ifdef ENABLE_NLS
246 if (pd->translation_domain)
247 return dgettext(pd->translation_domain, pd->description);
248#endif
249 return pd->description;
250}
251
252EOLIAN static void
253_elm_interface_atspi_accessible_description_set(Eo *obj EINA_UNUSED, Elm_Interface_Atspi_Accessible_Data *pd, const char *val)
254{
255 eina_stringshare_replace(&pd->description, val);
256}
257
258EOLIAN static const char *
259_elm_interface_atspi_accessible_localized_role_name_get(Eo *obj EINA_UNUSED, Elm_Interface_Atspi_Accessible_Data *pd EINA_UNUSED)
260{
261 const char *ret = NULL;
262 ret = elm_interface_atspi_accessible_role_name_get(obj);
263#ifdef ENABLE_NLS
264 ret = gettext(ret);
265#endif
266 return ret;
267}
268
269EOLIAN static Eina_List *
270_elm_interface_atspi_accessible_children_get(Eo *obj EINA_UNUSED, Elm_Interface_Atspi_Accessible_Data *pd EINA_UNUSED)
271{
272 Eina_List *children = NULL;
273 Eina_Iterator *iter = NULL;
274 Eo *chld;
275
276 // By default use Efl_Object object hierarchy
277 iter = efl_children_iterator_new(obj);
278 if (!iter) return NULL;
279
280 EINA_ITERATOR_FOREACH(iter, chld)
281 {
282 if (efl_isa(chld, ELM_INTERFACE_ATSPI_ACCESSIBLE_MIXIN))
283 children = eina_list_append(children, chld);
284 }
285 eina_iterator_free(iter);
286
287 return children;
288}
289
290EOLIAN static Elm_Atspi_State_Set
291_elm_interface_atspi_accessible_state_set_get(Eo *obj EINA_UNUSED, Elm_Interface_Atspi_Accessible_Data *pd EINA_UNUSED)
292{
293 return 0;
294}
295
296EOLIAN Elm_Atspi_Relation_Set
297_elm_interface_atspi_accessible_relation_set_get(Eo *obj EINA_UNUSED, Elm_Interface_Atspi_Accessible_Data *pd EINA_UNUSED)
298{
299 return elm_atspi_relation_set_clone(pd->relations);
300}
301
302EAPI void elm_atspi_attributes_list_free(Eina_List *list)
303{
304 Elm_Atspi_Attribute *attr;
305 EINA_LIST_FREE(list, attr)
306 {
307 eina_stringshare_del(attr->key);
308 eina_stringshare_del(attr->value);
309 free(attr);
310 }
311}
312
313EOLIAN void
314_elm_interface_atspi_accessible_event_emit(Eo *class EINA_UNUSED, void *pd EINA_UNUSED, Eo *accessible, const Efl_Event_Description *event, void *event_info)
315{
316 Eina_List *l;
317 Elm_Atspi_Event_Handler *hdl;
318 Elm_Atspi_Type type;
319
320 if (!accessible || !event || !efl_isa(accessible, ELM_INTERFACE_ATSPI_ACCESSIBLE_MIXIN))
321 {
322 CRI("Invalid parameters, event: %s, obj: %s", event ? event->name : "NULL", accessible ? efl_class_name_get(accessible) : "NULL");
323 return;
324 }
325
326 type = elm_interface_atspi_accessible_type_get(accessible);
327 if (type != ELM_ATSPI_TYPE_REGULAR)
328 return;
329
330 if (event == ELM_INTERFACE_ATSPI_ACCESSIBLE_EVENT_CHILDREN_CHANGED)
331 {
332 Elm_Atspi_Event_Children_Changed_Data *atspi_data = event_info;
333 type = elm_interface_atspi_accessible_type_get(atspi_data->child);
334 if (type != ELM_ATSPI_TYPE_REGULAR)
335 return;
336 }
337
338 Efl_Event ev;
339 ev.object = accessible;
340 ev.desc = event;
341 ev.info = event_info;
342 EINA_LIST_FOREACH(global_callbacks, l, hdl)
343 {
344 if (hdl->cb)
345 hdl->cb(hdl->data, &ev);
346 }
347}
348
349EOLIAN Elm_Atspi_Event_Handler *
350_elm_interface_atspi_accessible_event_handler_add(Eo *class EINA_UNUSED, void *pd EINA_UNUSED, Efl_Event_Cb cb, void *data)
351{
352 Elm_Atspi_Event_Handler *ret = calloc(1, sizeof(Elm_Atspi_Event_Handler));
353
354 ret->cb = cb;
355 ret->data = data;
356
357 global_callbacks = eina_list_append(global_callbacks, ret);
358
359 return ret;
360}
361
362EOLIAN void
363_elm_interface_atspi_accessible_event_handler_del(Eo *class EINA_UNUSED, void *pd EINA_UNUSED, Elm_Atspi_Event_Handler *handler)
364{
365 Eina_List *l, *l2;
366 Elm_Atspi_Event_Handler *hdl;
367 EINA_LIST_FOREACH_SAFE(global_callbacks, l, l2, hdl)
368 {
369 if (hdl == handler)
370 {
371 global_callbacks = eina_list_remove_list(global_callbacks, l);
372 free(hdl);
373 break;
374 }
375 }
376}
377
378EOLIAN void
379_elm_interface_atspi_accessible_translation_domain_set(Eo *obj EINA_UNUSED, Elm_Interface_Atspi_Accessible_Data *pd, const char *domain)
380{
381 eina_stringshare_replace(&pd->translation_domain, domain);
382}
383
384
385EOLIAN const char*
386_elm_interface_atspi_accessible_translation_domain_get(Eo *obj EINA_UNUSED, Elm_Interface_Atspi_Accessible_Data *pd)
387{
388 return pd->translation_domain;
389}
390
391EAPI void
392elm_atspi_relation_free(Elm_Atspi_Relation *relation)
393{
394 eina_list_free(relation->objects);
395 free(relation);
396}
397
398EAPI Elm_Atspi_Relation *
399elm_atspi_relation_clone(const Elm_Atspi_Relation *relation)
400{
401 Elm_Atspi_Relation *ret = calloc(1, sizeof(Elm_Atspi_Relation));
402 if (!ret) return NULL;
403
404 ret->type = relation->type;
405 ret->objects = eina_list_clone(relation->objects);
406 return ret;
407}
408
409static void
410_on_rel_obj_del(void *data, const Efl_Event *event)
411{
412 Elm_Atspi_Relation_Set *set = data;
413 Elm_Atspi_Relation *rel;
414 Eina_List *l, *l2, *p, *p2;
415 Eo *rel_obj;
416
417 EINA_LIST_FOREACH_SAFE(*set, l, l2, rel)
418 {
419 EINA_LIST_FOREACH_SAFE(rel->objects, p, p2, rel_obj)
420 {
421 if (rel_obj == event->object)
422 rel->objects = eina_list_remove_list(rel->objects, p);
423 }
424 if (!rel->objects)
425 {
426 *set = eina_list_remove_list(*set, l);
427 free(rel);
428 }
429 }
430}
431
432EAPI Eina_Bool
433elm_atspi_relation_set_relation_append(Elm_Atspi_Relation_Set *set, Elm_Atspi_Relation_Type type, const Eo *rel_obj)
434{
435 Elm_Atspi_Relation *rel;
436 Eina_List *l;
437
438 if (!efl_isa(rel_obj, ELM_INTERFACE_ATSPI_ACCESSIBLE_MIXIN))
439 return EINA_FALSE;
440
441 EINA_LIST_FOREACH(*set, l, rel)
442 {
443 if (rel->type == type)
444 {
445 if (!eina_list_data_find(rel->objects, rel_obj))
446 {
447 rel->objects = eina_list_append(rel->objects, rel_obj);
448 efl_event_callback_add((Eo *) rel_obj, EFL_EVENT_DEL, _on_rel_obj_del, set);
449 }
450 return EINA_TRUE;
451 }
452 }
453
454 rel = calloc(1, sizeof(Elm_Atspi_Relation));
455 if (!rel) return EINA_FALSE;
456
457 rel->type = type;
458 rel->objects = eina_list_append(rel->objects, rel_obj);
459 *set = eina_list_append(*set, rel);
460
461 efl_event_callback_add((Eo *) rel_obj, EFL_EVENT_DEL, _on_rel_obj_del, set);
462 return EINA_TRUE;
463}
464
465EAPI void
466elm_atspi_relation_set_relation_remove(Elm_Atspi_Relation_Set *set, Elm_Atspi_Relation_Type type, const Eo *rel_obj)
467{
468 Eina_List *l;
469 Elm_Atspi_Relation *rel;
470
471 EINA_LIST_FOREACH(*set, l, rel)
472 {
473 if (rel->type == type)
474 {
475 if (eina_list_data_find(rel->objects, rel_obj))
476 {
477 efl_event_callback_del((Eo *) rel_obj, EFL_EVENT_DEL, _on_rel_obj_del, set);
478 rel->objects = eina_list_remove(rel->objects, rel_obj);
479 }
480 if (!rel->objects)
481 {
482 *set = eina_list_remove(*set, rel);
483 elm_atspi_relation_free(rel);
484 }
485 return;
486 }
487 }
488}
489
490EAPI void
491elm_atspi_relation_set_relation_type_remove(Elm_Atspi_Relation_Set *set, Elm_Atspi_Relation_Type type)
492{
493 Eina_List *l;
494 Elm_Atspi_Relation *rel;
495 Eo *obj;
496
497 EINA_LIST_FOREACH(*set, l, rel)
498 {
499 if (rel->type == type)
500 {
501 EINA_LIST_FOREACH(rel->objects, l, obj)
502 efl_event_callback_del(obj, EFL_EVENT_DEL, _on_rel_obj_del, set);
503 *set = eina_list_remove(*set, rel);
504 elm_atspi_relation_free(rel);
505 return;
506 }
507 }
508}
509
510EAPI void
511elm_atspi_relation_set_free(Elm_Atspi_Relation_Set set)
512{
513 Elm_Atspi_Relation *rel;
514 Eina_List *l;
515 Eo *obj;
516
517 EINA_LIST_FREE(set, rel)
518 {
519 EINA_LIST_FOREACH(rel->objects, l, obj)
520 efl_event_callback_del(obj, EFL_EVENT_DEL, _on_rel_obj_del, set);
521 elm_atspi_relation_free(rel);
522 }
523}
524
525EAPI Elm_Atspi_Relation_Set
526elm_atspi_relation_set_clone(const Elm_Atspi_Relation_Set set)
527{
528 Elm_Atspi_Relation_Set ret = NULL;
529 Eina_List *l;
530 Elm_Atspi_Relation *rel;
531
532 EINA_LIST_FOREACH(set, l, rel)
533 {
534 Elm_Atspi_Relation *cpy = elm_atspi_relation_clone(rel);
535 ret = eina_list_append(ret, cpy);
536 }
537
538 return ret;
539}
540
541EOLIAN static Eina_Bool
542_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)
543{
544 return elm_atspi_relation_set_relation_append(&sd->relations, type, relation_obj);
545}
546
547EOLIAN static void
548_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)
549{
550 if (relation_obj)
551 elm_atspi_relation_set_relation_remove(&sd->relations, type, relation_obj);
552 else
553 elm_atspi_relation_set_relation_type_remove(&sd->relations, type);
554}
555
556EOLIAN static void
557_elm_interface_atspi_accessible_relationships_clear(Eo *obj EINA_UNUSED, Elm_Interface_Atspi_Accessible_Data *sd)
558{
559 elm_atspi_relation_set_free(sd->relations);
560 sd->relations = NULL;
561}
562
563EOLIAN Eo*
564_elm_interface_atspi_accessible_root_get(Eo *class EINA_UNUSED, void *pd EINA_UNUSED)
565{
566 if (!root)
567 root = efl_add(ELM_ATSPI_APP_OBJECT_CLASS, NULL);
568
569 return root;
570}
571
572EOLIAN Elm_Atspi_Type
573_elm_interface_atspi_accessible_type_get(Eo *obj EINA_UNUSED, Elm_Interface_Atspi_Accessible_Data *pd)
574{
575 return pd->type;
576}
577
578EOLIAN void
579_elm_interface_atspi_accessible_type_set(Eo *obj, Elm_Interface_Atspi_Accessible_Data *pd, Elm_Atspi_Type val)
580{
581 Elm_Interface_Atspi_Accessible *parent;
582 if (val == pd->type)
583 return;
584
585 parent = elm_interface_atspi_accessible_parent_get(obj);
586
587 switch (val)
588 {
589 case ELM_ATSPI_TYPE_DISABLED:
590 case ELM_ATSPI_TYPE_SKIPPED:
591 if (parent) elm_interface_atspi_accessible_children_changed_del_signal_emit(parent, obj);
592 elm_interface_atspi_accessible_removed(obj);
593 break;
594 case ELM_ATSPI_TYPE_REGULAR:
595 if (parent) elm_interface_atspi_accessible_children_changed_added_signal_emit(parent, obj);
596 elm_interface_atspi_accessible_added(obj);
597 }
598 pd->type = val;
599}
600
601EOLIAN void
602_elm_interface_atspi_accessible_efl_object_destructor(Eo *obj, Elm_Interface_Atspi_Accessible_Data *pd)
603{
604 eina_stringshare_del(pd->name);
605 eina_stringshare_del(pd->description);
606 eina_stringshare_del(pd->translation_domain);
607 elm_atspi_relation_set_free(pd->relations);
608
609 efl_destructor(efl_super(obj, ELM_INTERFACE_ATSPI_ACCESSIBLE_MIXIN));
610}
611
612void
613_elm_interface_atspi_shutdown(void)
614{
615 Elm_Atspi_Event_Handler *hdl;
616
617 EINA_LIST_FREE(global_callbacks, hdl)
618 free(hdl);
619
620 ELM_SAFE_DEL(root);
621}
622
623#include "elm_interface_atspi_accessible.eo.c"