Merge "custom eail widget implementation" into tizen
[platform/core/uifw/eail.git] / eail / eail_factory.c
1 /*
2  * Copyright (c) 2013 Samsung Electronics Co., Ltd.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this library; see the file COPYING.LIB.  If not, write to
16  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  */
19
20 /**
21  * @file eail_factory.c
22  * @brief Implementation of factory of EAIL accessible widgets
23  */
24
25 #include <Elementary.h>
26
27 #include "eail_factory.h"
28 #include "eail_widget.h"
29 #include "eail_window.h"
30 #include "eail_background.h"
31 #include "eail_box.h"
32 #include "eail_list.h"
33 #include "eail_genlist.h"
34 #include "eail_label.h"
35 #include "eail_button.h"
36 #include "eail_icon.h"
37 #include "eail_entry.h"
38 #include "eail_frame.h"
39 #include "eail_scroller.h"
40 #include "eail_slider.h"
41 #include "eail_action_slider.h"
42 #include "eail_inwin.h"
43 #include "eail_image.h"
44 #include "eail_check.h"
45 #include "eail_radio_button.h"
46 #include "eail_menu.h"
47 #include "eail_photo.h"
48 #include "eail_photocam.h"
49 #include "eail_separator.h"
50 #include "eail_spinner.h"
51 #include "eail_clock.h"
52 #include "eail_calendar.h"
53 #include "eail_grid.h"
54 #include "eail_route.h"
55 #include "eail_dayselector.h"
56 #include "eail_gengrid.h"
57 #include "eail_progressbar.h"
58 #include "eail_diskselector.h"
59 #include "eail_segment_control.h"
60 #include "eail_conformant.h"
61 #include "eail_colorselector.h"
62 #include "eail_notify.h"
63 #include "eail_naviframe.h"
64 #include "eail_datetime.h"
65 #include "eail_hover.h"
66 #include "eail_popup.h"
67 #include "eail_ctxpopup.h"
68 #include "eail_toolbar.h"
69 #include "eail_multibuttonentry.h"
70 #include "eail_web.h"
71 #include "eail_index.h"
72 #include "eail_fileselector.h"
73 #include "eail_fileselector_entry.h"
74 #include "eail_panes.h"
75 #include "eail_panel.h"
76 #include "eail_thumb.h"
77 #include "eail_mapbuf.h"
78 #include "eail_slideshow.h"
79 #include "eail_hoversel.h"
80 #include "eail_map.h"
81 #include "eail_glview.h"
82 #include "eail_bubble.h"
83 #include "eail_plug.h"
84 #include "eail_video.h"
85 #include "eail_flip.h"
86 #include "eail_flipselector.h"
87 #include "eail_layout.h"
88 #include "eail_table.h"
89 #include "eail_prefs.h"
90 #include "eail_item.h"
91 #include "eail_item_parent.h"
92 #include "eail_priv.h"
93
94 /** @brief Cache of created AtkObjects for re-using by multiple ATK clients. It holds
95  * EailFactoryObj* objects inside */
96 static Eina_List *eail_cached_objs = NULL;
97
98 /**
99  * @brief Creates an EailFactoryObj instance for the given widget and adds it to cache
100  *
101  * @param atk_obj AtkObject instance
102  * @param evas_obj Evas_Object instance
103  */
104 static void
105 _eail_factory_append_wdgt_to_cache(AtkObject *atk_obj, Evas_Object *evas_obj)
106 {
107    EailFactoryObj *factory_obj = g_new0(EailFactoryObj, 1);
108    factory_obj->atk_obj = atk_obj;
109    factory_obj->evas_obj = evas_obj;
110
111    eail_cached_objs = eina_list_append(eail_cached_objs, factory_obj);
112 }
113
114 /**
115  * @brief Tries to find an AtkObject representing the given Evas_Object* in cache
116  *
117  * @param widget Evas_Object instance to find in cache
118  *
119  * @returns EailFactoryObj representing the given Evas_Object
120  * or NULL if the widget's representation was not found
121  */
122 static EailFactoryObj *
123 _eail_factory_find_obj_for_widget(const Evas_Object *widget)
124 {
125    const Eina_List *l = NULL;
126    EailFactoryObj *factory_obj = NULL;
127
128    EINA_LIST_FOREACH(eail_cached_objs, l, factory_obj)
129      {
130         if (widget == factory_obj->evas_obj)
131           {
132              return factory_obj;
133           }
134      }
135
136    /* no widget implementation in cache was found */
137    return NULL;
138 }
139
140 /**
141  * @brief Creates an accessible AtkObject for Evas_Object*
142  *
143  * Returned AtkObject should be unreferenced when no longer needed to free memory.
144  *
145  * @param widget Evas_Object* instance
146  *
147  * @returns AtkObject representing the accessible representation of the specified
148  * Evas_Object
149  */
150 static AtkObject *
151 _eail_factory_create_accessible(Evas_Object *widget)
152 {
153    const char *type = NULL;
154    AtkObject *accessible = NULL;
155
156    type = elm_object_widget_type_get(widget);
157
158    if ((!strcmp(type, "Elm_Win")) || (!strcmp(type, "elm_win")))
159      {
160         accessible = g_object_new(EAIL_TYPE_WINDOW, NULL);
161      }
162    else if ((!strcmp(type, "Elm_Bg")) || (!strcmp(type, "elm_bg")))
163      {
164         accessible = g_object_new(EAIL_TYPE_BACKGROUND, NULL);
165      }
166    else if ((!strcmp(type, "Elm_Box")) || (!strcmp(type, "elm_box")))
167      {
168         accessible = g_object_new(EAIL_TYPE_BOX, NULL);
169      }
170    else if ((!strcmp(type, "Elm_List")) || (!strcmp(type, "elm_list")))
171      {
172         accessible = g_object_new(EAIL_TYPE_LIST, NULL);
173      }
174    else if ((!strcmp(type, "Elm_Genlist")) || (!strcmp(type, "elm_genlist")))
175      {
176         accessible = g_object_new(EAIL_TYPE_GENLIST, NULL);
177      }
178    else if ((!strcmp(type, "Elm_Label")) || (!strcmp(type, "elm_label")))
179      {
180         accessible = g_object_new(EAIL_TYPE_LABEL, NULL);
181      }
182    else if ((!strcmp(type, "Elm_Button")) || (!strcmp(type, "elm_button")))
183      {
184         accessible = g_object_new(EAIL_TYPE_BUTTON, NULL);
185      }
186    else if ((!strcmp(type, "Elm_Icon")) || (!strcmp(type, "elm_icon")))
187      {
188         accessible = g_object_new(EAIL_TYPE_ICON, NULL);
189      }
190    else if ((!strcmp(type, "entry")) || (!strcmp(type, "Elm_Entry")) || (!strcmp(type, "elm_entry")))
191      {
192         accessible = g_object_new(EAIL_TYPE_ENTRY, NULL);
193      }
194    else if ((!strcmp(type, "Elm_Frame")) || (!strcmp(type, "elm_frame")))
195      {
196         accessible = g_object_new(EAIL_TYPE_FRAME, NULL);
197      }
198    else if ((!strcmp(type, "Elm_Scroller")) || (!strcmp(type, "elm_scroller")))
199      {
200         accessible = g_object_new(EAIL_TYPE_SCROLLER, NULL);
201      }
202    else if ((!strcmp(type, "Elm_Inwin")) || (!strcmp(type, "elm_inwin")))
203      {
204         accessible = g_object_new(EAIL_TYPE_INWIN, NULL);
205      }
206    else if ((!strcmp(type, "Elm_Slider")) || (!strcmp(type, "elm_slider")))
207      {
208         accessible = g_object_new(EAIL_TYPE_SLIDER, NULL);
209      }
210    else if ((!strcmp(type, "Elm_Actionslider")) || (!strcmp(type, "elm_actionslider")))
211      {
212         accessible = g_object_new(EAIL_TYPE_ACTION_SLIDER, NULL);
213      }
214    else if ((!strcmp(type, "Elm_Imgae")) || (!strcmp(type, "elm_image")))
215      {
216         accessible = g_object_new(EAIL_TYPE_IMAGE, NULL);
217      }
218    else if ((!strcmp(type, "Elm_Check")) || (!strcmp(type, "elm_check")))
219      {
220         accessible = g_object_new(EAIL_TYPE_CHECK, NULL);
221      }
222    else if ((!strcmp(type, "Elm_Radio")) || (!strcmp(type, "elm_radio")))
223      {
224         accessible = g_object_new(EAIL_TYPE_RADIO_BUTTON, NULL);
225      }
226    else if ((!strcmp(type, "Elm_Menu")) || (!strcmp(type, "elm_menu")))
227      {
228         accessible = g_object_new(EAIL_TYPE_MENU, NULL);
229      }
230    else if ((!strcmp(type, "Elm_Photo")) || (!strcmp(type, "elm_photo")))
231      {
232         accessible = g_object_new(EAIL_TYPE_PHOTO, NULL);
233      }
234    else if ((!strcmp(type, "Elm_Photocam")) || (!strcmp(type, "elm_photocam")))
235      {
236         accessible = g_object_new(EAIL_TYPE_PHOTOCAM, NULL);
237      }
238    else if ((!strcmp(type, "Elm_Separator")) || (!strcmp(type, "elm_separator")))
239      {
240         accessible = g_object_new(EAIL_TYPE_SEPARATOR, NULL);
241      }
242    else if ((!strcmp(type, "Elm_Spinner")) || (!strcmp(type, "elm_spinner")))
243      {
244         accessible = g_object_new(EAIL_TYPE_SPINNER, NULL);
245      }
246    else if ((!strcmp(type, "Elm_Clock")) || (!strcmp(type, "elm_clock")))
247      {
248         accessible = g_object_new(EAIL_TYPE_CLOCK, NULL);
249      }
250    else if ((!strcmp(type, "Elm_Calendar")) || (!strcmp(type, "elm_calendar")))
251      {
252         accessible = g_object_new(EAIL_TYPE_CALENDAR, NULL);
253      }
254    else if ((!strcmp(type, "Elm_Grid")) || (!strcmp(type, "elm_grid")))
255      {
256         accessible = g_object_new(EAIL_TYPE_GRID, NULL);
257      }
258    else if ((!strcmp(type, "Elm_Route")) || (!strcmp(type, "elm_route")))
259      {
260         accessible = g_object_new(EAIL_TYPE_ROUTE, NULL);
261      }
262    else if ((!strcmp(type, "Elm_Dayselector")) || (!strcmp(type, "elm_dayselector")))
263      {
264         accessible = g_object_new(EAIL_TYPE_DAYSELECTOR, NULL);
265      }
266    else if ((!strcmp(type, "Elm_Gengrid")) || (!strcmp(type, "elm_gengrid")))
267      {
268         accessible = g_object_new(EAIL_TYPE_GENGRID, NULL);
269      }
270    else if ((!strcmp(type, "Elm_Progressbar")) || (!strcmp(type, "elm_progressbar")))
271      {
272         accessible = g_object_new(EAIL_TYPE_PROGRESSBAR, NULL);
273      }
274    else if ((!strcmp(type, "Elm_Diskselector")) || (!strcmp(type, "elm_diskselector")))
275      {
276         accessible = g_object_new(EAIL_TYPE_DISKSELECTOR, NULL);
277      }
278    else if ((!strcmp(type, "Elm_Segment_Control")) || (!strcmp(type, "elm_segment_control")))
279      {
280         accessible = g_object_new(EAIL_TYPE_SEGMENT_CONTROL, NULL);
281      }
282    else if ((!strcmp(type, "Elm_Conformant")) || (!strcmp(type, "elm_conformant")))
283      {
284         accessible = g_object_new(EAIL_TYPE_CONFORMANT, NULL);
285      }
286    else if ((!strcmp(type, "Elm_Notify")) || (!strcmp(type, "elm_notify")))
287      {
288         accessible = g_object_new(EAIL_TYPE_NOTIFY, NULL);
289      }
290    else if ((!strcmp(type, "popup")) || (!strcmp(type, "Elm_Popup")) || (!strcmp(type, "elm_popup")))
291      {
292         accessible = g_object_new(EAIL_TYPE_POPUP, NULL);
293      }
294    else if ((!strcmp(type, "ctxpopup")) || (!strcmp(type, "Elm_Ctxpopup")) || (!strcmp(type, "elm_ctxpopup")))
295      {
296         accessible = g_object_new(EAIL_TYPE_CTXPOPUP, NULL);
297      }
298    else if ((!strcmp(type, "toolbar")) || (!strcmp(type, "Elm_Toolbar")) || (!strcmp(type, "elm_toolbar")))
299      {
300         accessible = g_object_new(EAIL_TYPE_TOOLBAR, NULL);
301      }
302    else if ((!strcmp(type, "Elm_Multibuttonentry")) || (!strcmp(type, "elm_multibuttonentry")))
303      {
304         accessible = g_object_new(EAIL_TYPE_MULTIBUTTONENTRY, NULL);
305      }
306    else if ((!strcmp(type, "Elm_Web")) || (!strcmp(type, "elm_web")))
307      {
308         accessible = g_object_new(EAIL_TYPE_WEB, NULL);
309      }
310    else if ((!strcmp(type, "Elm_Index")) || (!strcmp(type, "elm_index")))
311      {
312         accessible = g_object_new(EAIL_TYPE_INDEX, NULL);
313      }
314    else if ((!strcmp(type, "Elm_Fileselector")) || (!strcmp(type, "elm_fileselector")))
315      {
316         accessible = g_object_new(EAIL_TYPE_FILESELECTOR, NULL);
317      }
318    else if ((!strcmp(type, "Elm_Fileselector_Entry")) || (!strcmp(type, "elm_fileselector_entry")) ||
319             (!strcmp(type, "fileselector_entry")))
320      {
321         accessible = g_object_new(EAIL_TYPE_FILESELECTOR_ENTRY, NULL);
322      }
323    else if ((!strcmp(type, "Elm_Fileselector_Button")) || (!strcmp(type, "elm_fileselector_button")))
324      {
325         /* NOTE: file selector button from accesibility point of view is
326          * no different in handling than regular push button */
327         accessible = g_object_new(EAIL_TYPE_BUTTON, NULL);
328      }
329    else if ((!strcmp(type, "Elm_Colorselector")) || (!strcmp(type, "elm_colorselector")))
330      {
331         accessible = g_object_new(EAIL_TYPE_COLORSELECTOR, NULL);
332      }
333    else if ((!strcmp(type, "Elm_Naviframe")) || (!strcmp(type, "elm_naviframe")))
334      {
335         accessible = g_object_new(EAIL_TYPE_NAVIFRAME, NULL);
336      }
337    else if ((!strcmp(type, "Elm_Datetime")) || (!strcmp(type, "elm_datetime")))
338      {
339         accessible = g_object_new(EAIL_TYPE_DATETIME, NULL);
340      }
341    else if ((!strcmp(type, "Elm_Hover")) || (!strcmp(type, "elm_hover")))
342      {
343         accessible = g_object_new(EAIL_TYPE_HOVER, NULL);
344      }
345    else if ((!strcmp(type, "Elm_Panes")) || (!strcmp(type, "elm_panes")))
346      {
347         accessible = g_object_new(EAIL_TYPE_PANES, NULL);
348      }
349    else if ((!strcmp(type, "panel")) || (!strcmp(type, "Elm_Panel")) || (!strcmp(type, "elm_panel")))
350      {
351         accessible = g_object_new(EAIL_TYPE_PANEL, NULL);
352      }
353    else if ((!strcmp(type, "Elm_Thumb")) || (!strcmp(type, "elm_thumb")))
354      {
355         accessible = g_object_new(EAIL_TYPE_THUMB, NULL);
356      }
357    else if ((!strcmp(type, "Elm_Mapbuf")) || (!strcmp(type, "elm_mapbuf")))
358      {
359         accessible = g_object_new(EAIL_TYPE_MAPBUF, NULL);
360      }
361    else if ((!strcmp(type, "Elm_Slideshow")) || (!strcmp(type, "elm_slideshow")))
362      {
363         accessible = g_object_new(EAIL_TYPE_SLIDESHOW, NULL);
364      }
365    else if ((!strcmp(type, "Elm_Hoversel")) || (!strcmp(type, "elm_hoversel")))
366      {
367         accessible = g_object_new(EAIL_TYPE_HOVERSEL, NULL);
368      }
369    else if ((!strcmp(type, "Elm_Map")) || (!strcmp(type, "elm_map")))
370      {
371         accessible = g_object_new(EAIL_TYPE_MAP, NULL);
372      }
373    else if ((!strcmp(type, "Elm_Glview")) || (!strcmp(type, "elm_glview")))
374      {
375         accessible = g_object_new(EAIL_TYPE_GLVIEW, NULL);
376      }
377    else if ((!strcmp(type, "Elm_Bubble")) || (!strcmp(type, "elm_bubble")))
378      {
379         accessible = g_object_new(EAIL_TYPE_BUBBLE, NULL);
380      }
381    else if ((!strcmp(type, "Elm_Plug")) || (!strcmp(type, "elm_plug")))
382      {
383         accessible = g_object_new(EAIL_TYPE_PLUG, NULL);
384      }
385    else if ((!strcmp(type, "Elm_Video")) || (!strcmp(type, "elm_video")) || (!strcmp(type, "elm_player")))
386      {
387         accessible = g_object_new(EAIL_TYPE_VIDEO, NULL);
388      }
389    else if ((!strcmp(type, "Elm_Flip")) || (!strcmp(type, "elm_flip")))
390      {
391         accessible = g_object_new(EAIL_TYPE_FLIP, NULL);
392      }
393    else if ((!strcmp(type, "Elm_Flipselector")) || (!strcmp(type, "elm_flipselector")))
394      {
395         accessible = g_object_new(EAIL_TYPE_FLIPSELECTOR, NULL);
396      }
397    else if ((!strcmp(type, "Elm_Layout")) || (!strcmp(type, "elm_layout")))
398      {
399         accessible = g_object_new(EAIL_TYPE_LAYOUT, NULL);
400      }
401    else if ((!strcmp(type, "Elm_Table")) || (!strcmp(type, "elm_table")))
402      {
403         accessible = g_object_new(EAIL_TYPE_TABLE, NULL);
404      }
405    else if ((!strcmp(type, "Elm_Prefs")) || (!strcmp(type, "elm_prefs")))
406      {
407         accessible = g_object_new(EAIL_TYPE_PREFS, NULL);
408      }
409    else
410      {
411         DBG("Unrecognized specific widget type: %s", type);
412         DBG("Creating basic widget with NULL type.");
413         accessible = g_object_new(EAIL_TYPE_WIDGET, NULL);
414      }
415
416    if (accessible)
417      {
418         atk_object_initialize(accessible, widget);
419      }
420
421    return accessible;
422 }
423
424
425 /**
426  * @brief Creates a new EailItem instance with the given ATK role
427  *
428  * @param item Elm_Object_Item instance
429  * @param parent AtkObject instance that holds EailItem instance
430  * @param role AtkRole instance that will be used by EailItem
431  *
432  * @returns EailItem representing the new EailItem instance
433  * or NULL in case of an error
434  */
435 static AtkObject *
436 _eail_factory_create_item_atk_obj(Elm_Object_Item *item,
437                                   AtkRole role,
438                                   AtkObject *parent)
439 {
440    AtkObject *obj;
441
442    obj = g_object_new(EAIL_TYPE_ITEM, NULL);
443    obj->role = role;
444    atk_object_set_parent(obj, parent);
445    atk_object_initialize(obj, item);
446
447    return obj;
448 }
449
450 /**
451  * @param atk_obj AtkObject instance
452  * @param item Elm_Object_Item instance
453  */
454 void
455 eail_factory_append_item_to_cache(AtkObject *atk_obj, Elm_Object_Item *item)
456 {
457    EailFactoryObj *factory_obj = g_new0(EailFactoryObj, 1);
458    factory_obj->atk_obj = atk_obj;
459    factory_obj->obj_item = item;
460
461    eail_cached_objs = eina_list_append(eail_cached_objs, factory_obj);
462 }
463
464 /**
465  * @param item Elm_Object_Item* instance to be found
466  * @returns EailFactoryObj instance or NULL if item's representation was not
467  * found
468  */
469 EailFactoryObj *
470 eail_factory_find_obj_for_item(const Elm_Object_Item *item)
471 {
472    const Eina_List *l = NULL;
473    EailFactoryObj *factory_obj = NULL;
474
475    EINA_LIST_FOREACH(eail_cached_objs, l, factory_obj)
476      {
477         if (item == factory_obj->obj_item)
478           {
479              return factory_obj;
480           }
481      }
482
483    /* no Atk Elm_Object_Item implementation in cache was found */
484    return NULL;
485 }
486
487 /**
488  *
489  * If AtkObject was already created for the given item, instance will be returned
490  * from cache instead of creating a new one (it is needed to allow the setting and
491  * storing of name/description changes by multiple clients).
492  *
493  * @param item Elm_Object_Item instance that will be used as a source for the AtkObject
494  * representation
495  * @param role role for given item
496  * @param parent AtkObject instance that has the given item inside its content (eg. for
497  * list-item this will be EailList instance)
498  *
499  * @returns AtkObject representing the item or NULL in case of a failure
500  */
501 AtkObject *
502 eail_factory_get_item_atk_obj(Elm_Object_Item *item,
503                               AtkRole role,
504                               AtkObject *parent)
505 {
506    AtkObject *atk_obj;
507    EailFactoryObj *factory_obj = NULL;
508
509    if (!EAIL_IS_ITEM_PARENT(parent))
510     {
511        ERR("Parent does not implement ITEM_PARENT interface");
512        return NULL;
513     }
514
515    /* first trying to get object from cache*/
516    factory_obj = eail_factory_find_obj_for_item(item);
517    if (factory_obj)
518       {
519          /* already found implementation, no need to create new obj, returning
520           * existing one from cache */
521           if (!factory_obj->atk_obj)
522             {
523                ERR("No atk obj found in eail_factory_widget!");
524                return NULL;
525             }
526
527          return factory_obj->atk_obj;
528       }
529
530    /* if not in cache then creating and then adding to cache for future use*/
531    atk_obj = _eail_factory_create_item_atk_obj(item, role, parent);
532    eail_factory_append_item_to_cache(atk_obj, item);
533
534    return atk_obj;
535 }
536
537 /**
538  *
539  * @param item Elm_Object_Item* instance to be deregistered
540  */
541 void
542 eail_factory_unregister_item_from_cache(Elm_Object_Item *item)
543 {
544    EailFactoryObj *factory_obj = NULL;
545
546    factory_obj = eail_factory_find_obj_for_item(item);
547    if (!factory_obj) return;
548
549    eail_cached_objs = eina_list_remove(eail_cached_objs, factory_obj);
550
551    g_free(factory_obj);
552 }
553
554 /**
555  *
556  * @param widget Evas_Object* instance to be deregistered
557  */
558 void
559 eail_factory_unregister_wdgt_from_cache(Evas_Object *widget)
560 {
561    EailFactoryObj *factory_obj = NULL;
562
563    factory_obj = _eail_factory_find_obj_for_widget(widget);
564    if (!factory_obj) return;
565
566    eail_cached_objs = eina_list_remove(eail_cached_objs, factory_obj);
567
568    g_free(factory_obj);
569 }
570
571 /**
572  * @param widget Evas_Object* instance
573  *
574  * The returned AtkObject should be unreferenced when no longer needed
575  * to free memory.
576  *
577  * @returns AtkObject which is the accessible representation of the specified
578  * Evas_Object
579  */
580 AtkObject *
581 eail_factory_get_accessible(Evas_Object *widget)
582 {
583    EailFactoryObj *factory_widget = NULL;
584    AtkObject *atk_obj = NULL;
585
586    if (!widget)
587      {
588         DBG("Cannot create accessible for NULL-widget");
589         return NULL;
590      }
591
592    if (!elm_object_widget_check(widget))
593      {
594         DBG("%s is NOT elementary object widget!",
595             evas_object_type_get(widget));
596         return NULL;
597      }
598
599    /* looking for object in cache*/
600    factory_widget = _eail_factory_find_obj_for_widget(widget);
601    if (factory_widget)
602      {
603         /* already found implementation, no need to create new obj, returning
604          * existing one from cache */
605          if (!factory_widget->atk_obj)
606            {
607               ERR("No atk obj found in eail_factory_widget!");
608               return NULL;
609            }
610
611          return factory_widget->atk_obj;
612      }
613
614    /* not found in cache, need to create new instance for atk obj
615     * representation*/
616    atk_obj = _eail_factory_create_accessible(widget);
617    if (!atk_obj)
618      {
619         ERR("No atk obj created in factory");
620         return NULL;
621      }
622
623    /* appending obj for future re-using*/
624    _eail_factory_append_wdgt_to_cache(atk_obj, widget);
625
626    return atk_obj;
627 }
628
629 /**
630  * @param role an AtkRole for objects that have to be found
631  *
632  * @returns an Eina_List filled with AtkObject * objects
633  */
634 Eina_List *
635 eail_factory_find_objects_with_role(AtkRole role)
636 {
637    const Eina_List *l = NULL;
638    Eina_List *results_list = NULL;
639    EailFactoryObj *factory_obj = NULL;
640
641    EINA_LIST_FOREACH(eail_cached_objs, l, factory_obj)
642      {
643         AtkObject *atk_obj = factory_obj->atk_obj;
644         if (atk_obj && role == atk_obj->role)
645           results_list = eina_list_append(results_list, atk_obj);
646      }
647
648    return results_list;
649 }