1 #include <Elementary.h>
4 typedef struct _Mod_Api Mod_Api;
8 void (*out_read) (const char *txt);
9 void (*out_read_done) (void);
10 void (*out_cancel) (void);
11 void (*out_done_callback_set) (void (*func) (void *data), const void *data);
14 static int initted = 0;
15 static Elm_Module *mod = NULL;
16 static Mod_Api *mapi = NULL;
23 if (initted > 1) return;
24 if (!(m = _elm_module_find_as("access/api"))) return;
26 m->api = malloc(sizeof(Mod_Api));
29 ((Mod_Api *)(m->api) )->out_read = // called to read out some text
30 _elm_module_symbol_get(m, "out_read");
31 ((Mod_Api *)(m->api) )->out_read_done = // called to set a done marker so when it is reached the done callback is called
32 _elm_module_symbol_get(m, "out_read_done");
33 ((Mod_Api *)(m->api) )->out_cancel = // called to read out some text
34 _elm_module_symbol_get(m, "out_cancel");
35 ((Mod_Api *)(m->api) )->out_done_callback_set = // called when last read done
36 _elm_module_symbol_get(m, "out_done_callback_set");
40 static Elm_Access_Item *
41 _access_add_set(Elm_Access_Info *ac, int type)
47 EINA_LIST_FOREACH(ac->items, l, ai)
53 if (ai->data) eina_stringshare_del(ai->data);
60 ai = calloc(1, sizeof(Elm_Access_Item));
62 ac->items = eina_list_prepend(ac->items, ai);
66 _access_obj_over_timeout_cb(void *data)
68 Elm_Access_Info *ac = evas_object_data_get(data, "_elm_access");
69 if (!ac) return EINA_FALSE;
70 _elm_access_read(ac, ELM_ACCESS_CANCEL, data, NULL);
71 _elm_access_read(ac, ELM_ACCESS_TYPE, data, NULL);
72 _elm_access_read(ac, ELM_ACCESS_INFO, data, NULL);
73 _elm_access_read(ac, ELM_ACCESS_STATE, data, NULL);
74 _elm_access_read(ac, ELM_ACCESS_DONE, data, NULL);
75 ac->delay_timer = NULL;
80 _access_obj_mouse_in_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
82 Elm_Access_Info *ac = evas_object_data_get(data, "_elm_access");
87 ecore_timer_del(ac->delay_timer);
88 ac->delay_timer = NULL;
90 ac->delay_timer = ecore_timer_add(0.2, _access_obj_over_timeout_cb, data);
94 _access_obj_mouse_out_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
96 Elm_Access_Info *ac = evas_object_data_get(data, "_elm_access");
100 ecore_timer_del(ac->delay_timer);
101 ac->delay_timer = NULL;
106 _access_obj_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
110 evas_object_event_callback_del_full(obj, EVAS_CALLBACK_MOUSE_IN,
111 _access_obj_mouse_in_cb, data);
112 evas_object_event_callback_del_full(obj, EVAS_CALLBACK_MOUSE_OUT,
113 _access_obj_mouse_out_cb, data);
114 evas_object_event_callback_del_full(obj, EVAS_CALLBACK_DEL,
115 _access_obj_del_cb, data);
116 ac = evas_object_data_get(data, "_elm_access");
117 evas_object_data_del(data, "_elm_access");
120 _elm_access_clear(ac);
126 _access_read_done(void *data __UNUSED__)
128 printf("read done\n");
131 //-------------------------------------------------------------------------//
134 _elm_access_clear(Elm_Access_Info *ac)
141 ecore_timer_del(ac->delay_timer);
142 ac->delay_timer = NULL;
144 EINA_LIST_FREE(ac->items, ai)
148 if (ai->data) eina_stringshare_del(ai->data);
155 _elm_access_text_set(Elm_Access_Info *ac, int type, const char *text)
157 Elm_Access_Item *ai = _access_add_set(ac, type);
159 ai->data = eina_stringshare_add(text);
163 _elm_access_callback_set(Elm_Access_Info *ac, int type, Elm_Access_Content_Cb func, const void *data)
165 Elm_Access_Item *ai = _access_add_set(ac, type);
172 _elm_access_text_get(Elm_Access_Info *ac, int type, Evas_Object *obj, Elm_Widget_Item *item)
177 if (!ac) return NULL;
178 EINA_LIST_FOREACH(ac->items, l, ai)
180 if (ai->type == type)
182 if (ai->func) return ai->func(ai->data, obj, item);
183 else if (ai->data) return strdup(ai->data);
191 _elm_access_read(Elm_Access_Info *ac, int type, Evas_Object *obj, Elm_Widget_Item *item)
193 char *txt = _elm_access_text_get(ac, type, obj, item);
198 if (mapi->out_done_callback_set)
199 mapi->out_done_callback_set(_access_read_done, NULL);
200 if (type == ELM_ACCESS_DONE)
202 if (mapi->out_read_done) mapi->out_read_done();
204 else if (type == ELM_ACCESS_CANCEL)
206 if (mapi->out_cancel) mapi->out_cancel();
212 if (mapi->out_read) mapi->out_read(txt);
213 if (mapi->out_read) mapi->out_read(".\n");
221 _elm_access_say(const char *txt)
226 if (mapi->out_done_callback_set)
227 mapi->out_done_callback_set(_access_read_done, NULL);
228 if (mapi->out_cancel) mapi->out_cancel();
231 if (mapi->out_read) mapi->out_read(txt);
232 if (mapi->out_read) mapi->out_read(".\n");
234 if (mapi->out_read_done) mapi->out_read_done();
238 EAPI Elm_Access_Info *
239 _elm_access_object_get(Evas_Object *obj)
241 return evas_object_data_get(obj, "_elm_access");
245 _elm_access_object_register(Evas_Object *obj, Evas_Object *hoverobj)
249 evas_object_event_callback_add(hoverobj, EVAS_CALLBACK_MOUSE_IN,
250 _access_obj_mouse_in_cb, obj);
251 evas_object_event_callback_add(hoverobj, EVAS_CALLBACK_MOUSE_OUT,
252 _access_obj_mouse_out_cb, obj);
253 evas_object_event_callback_add(hoverobj, EVAS_CALLBACK_DEL,
254 _access_obj_del_cb, obj);
255 ac = calloc(1, sizeof(Elm_Access_Info));
256 evas_object_data_set(obj, "_elm_access", ac);
259 // XXX special version for items
261 //_elm_access_item_hover_register(Elm_Widget_Item *item, Evas_Object *hoverobj)