1 #include <Elementary.h>
2 #include "elm_module_priv.h"
6 #include <appsvc/appsvc.h>
9 #include "cbhm_helper.h"
11 #define MULTI_(id) dgettext("sys_string", #id)
12 #define S_SELECT MULTI_(IDS_COM_SK_SELECT)
13 #define S_SELECT_ALL MULTI_(IDS_COM_BODY_SELECT_ALL)
14 #define S_COPY MULTI_(IDS_COM_BODY_COPY)
15 #define S_CUT MULTI_(IDS_COM_BODY_CUT)
16 #define S_PASTE MULTI_(IDS_COM_BODY_PASTE)
17 #define S_CLIPBOARD MULTI_(IDS_COM_BODY_CLIPBOARD)
18 #define S_COPIED MULTI_(IDS_COM_POP_COPIED_TO_CLIPBOARD)
19 #define S_TRANSLATE dgettext("elementary", "Translate")
21 #define CP_ICON_THEME_SET(ITEM) elm_widget_theme_object_set(ext_mod->popup, \
22 icon,"copypaste", ITEM, "default")
24 Elm_Entry_Extension_data *ext_mod;
25 static int _mod_hook_count = 0;
27 typedef struct _Elm_Entry_Context_Menu_Item Elm_Entry_Context_Menu_Item;
29 struct _Elm_Entry_Context_Menu_Item
33 const char *icon_file;
34 const char *icon_group;
35 Elm_Icon_Type icon_type;
40 static void _entry_del_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
41 static void _entry_hide_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
42 static void _entry_move_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
43 static void _entry_mouse_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
44 static void _entry_mouse_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
45 static void _ctxpopup_hide(Evas_Object *popup);
46 static void _ctxpopup_dismissed_cb(void *data, Evas_Object *obj, void *event_info);
47 void obj_longpress(Evas_Object *obj);
51 _remove_tags(const char *str)
57 Eina_Strbuf *buf = eina_strbuf_new();
61 if (!eina_strbuf_append(buf, str))
63 eina_strbuf_free(buf);
67 eina_strbuf_replace_all(buf, "<br>", " ");
68 eina_strbuf_replace_all(buf, "<br/>", " ");
69 eina_strbuf_replace_all(buf, "<ps>", " ");
70 eina_strbuf_replace_all(buf, "<ps/>", " ");
74 const char *temp = eina_strbuf_string_get(buf);
76 char *startTag = NULL;
79 startTag = strstr(temp, "<");
81 endTag = strstr(startTag, ">");
84 if (!endTag || startTag > endTag)
87 size_t sindex = startTag - temp;
88 size_t eindex = endTag - temp + 1;
89 if (!eina_strbuf_remove(buf, sindex, eindex))
92 ret = eina_strbuf_string_steal(buf);
93 eina_strbuf_free(buf);
99 _parent_mouse_down_cb(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
101 if ((!ext_mod) || (!ext_mod->popup))
103 ext_mod->popup_clicked = EINA_TRUE;
104 evas_object_hide(ext_mod->popup);
105 ext_mod->mouse_up = EINA_FALSE;
106 ext_mod->entry_move = EINA_FALSE;
110 _parent_mouse_up_cb(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
112 if ((!ext_mod) || (!ext_mod->popup))
114 if ((ext_mod->popup_clicked) && (ext_mod->popup_showing))
116 ext_mod->popup_showing = EINA_FALSE;
117 evas_object_event_callback_del(ext_mod->caller, EVAS_CALLBACK_DEL, _entry_del_cb);
118 evas_object_event_callback_del(ext_mod->caller, EVAS_CALLBACK_HIDE, _entry_hide_cb);
119 evas_object_event_callback_del(ext_mod->caller, EVAS_CALLBACK_MOVE, _entry_move_cb);
121 evas_object_event_callback_del(ext_mod->caller, EVAS_CALLBACK_MOUSE_DOWN,
122 _entry_mouse_down_cb);
123 evas_object_event_callback_del(ext_mod->caller, EVAS_CALLBACK_MOUSE_UP,
125 evas_object_event_callback_del(ext_mod->ctx_par, EVAS_CALLBACK_MOUSE_DOWN,
126 _parent_mouse_down_cb);
127 evas_object_event_callback_del(ext_mod->ctx_par, EVAS_CALLBACK_MOUSE_UP,
128 _parent_mouse_up_cb);
129 evas_object_smart_callback_del(ext_mod->popup, "dismissed", _ctxpopup_dismissed_cb);
134 _entry_del_cb(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
138 evas_object_event_callback_del(ext_mod->ctx_par, EVAS_CALLBACK_MOUSE_DOWN,
139 _parent_mouse_down_cb);
140 evas_object_event_callback_del(ext_mod->ctx_par, EVAS_CALLBACK_MOUSE_UP,
141 _parent_mouse_up_cb);
144 _ctxpopup_hide(ext_mod->popup);
145 evas_object_del(ext_mod->popup);
146 ext_mod->popup = NULL;
152 _entry_hide_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
154 evas_object_hide(data);
158 _entry_mouse_down_cb(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
160 if ((!ext_mod) || (!ext_mod->popup))
162 ext_mod->mouse_up = EINA_FALSE;
163 ext_mod->mouse_down = EINA_TRUE;
167 _ctx_show(void *data)
169 ext_mod->show_timer = NULL;
170 if (!data) return ECORE_CALLBACK_CANCEL;
171 ext_mod->entry_move = EINA_FALSE;
172 if (ext_mod->popup_showing)
176 return ECORE_CALLBACK_CANCEL;
180 _entry_mouse_up_cb(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
184 if (ext_mod->mouse_down && ext_mod->entry_move)
186 evas_object_smart_callback_del(ext_mod->popup, "dismissed", _ctxpopup_dismissed_cb);
187 if (ext_mod->show_timer) ecore_timer_del(ext_mod->show_timer);
188 ext_mod->show_timer = ecore_timer_add(0.1, _ctx_show, obj);
190 ext_mod->mouse_up = EINA_TRUE;
191 ext_mod->mouse_down = EINA_FALSE;
195 _entry_move_cb(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
199 ext_mod->entry_move = EINA_TRUE;
200 ext_mod->popup_clicked = EINA_FALSE;
201 evas_object_hide(ext_mod->popup);
202 evas_object_smart_callback_del(ext_mod->popup, "dismissed", _ctxpopup_dismissed_cb);
203 if (ext_mod->show_timer) ecore_timer_del(ext_mod->show_timer);
204 ext_mod->show_timer = ecore_timer_add(0.1, _ctx_show, obj);
208 _ctxpopup_hide(Evas_Object *popup)
210 if (!ext_mod->popup_showing) return;
211 ext_mod->popup_showing = EINA_FALSE;
212 evas_object_hide(popup);
213 evas_object_event_callback_del(ext_mod->caller, EVAS_CALLBACK_DEL, _entry_del_cb);
214 evas_object_event_callback_del(ext_mod->caller, EVAS_CALLBACK_HIDE, _entry_hide_cb);
215 evas_object_event_callback_del(ext_mod->caller, EVAS_CALLBACK_MOVE, _entry_move_cb);
216 if (_elm_config->access_mode && ext_mod->caller)
217 _elm_access_highlight_set(ext_mod->caller, EINA_TRUE);
223 if (!ext_mod) return EINA_FALSE;
225 Evas_Coord sx, sy, sw, sh;
230 elm_entry_extension_module_data_get(ext_mod->caller, ext_mod);
232 vp.x = ext_mod->viewport_rect.x;
233 vp.y = ext_mod->viewport_rect.y;
234 vp.w = ext_mod->viewport_rect.w;
235 vp.h = ext_mod->viewport_rect.h;
237 if (edje_object_part_text_selection_geometry_get(ext_mod->ent, "elm.text", &sx, &sy, &sw, &sh))
239 if ((ext_mod->viewport_rect.x != -1) || (ext_mod->viewport_rect.y != -1) ||
240 (ext_mod->viewport_rect.w != -1) || (ext_mod->viewport_rect.h != -1))
248 if (eina_rectangle_intersection(&sel, &vp))
258 if ((ext_mod->viewport_rect.x != -1) || (ext_mod->viewport_rect.y != -1) ||
259 (ext_mod->viewport_rect.w != -1) || (ext_mod->viewport_rect.h != -1))
262 Evas_Coord cx, cy, cw, ch;
265 evas_object_geometry_get(ext_mod->ent, &ex, &ey, NULL, NULL);
266 edje_object_part_text_cursor_geometry_get(ext_mod->ent, "elm.text",
274 if (eina_rectangle_intersection(&cur, &vp))
286 _ctxpopup_position(Evas_Object *obj __UNUSED__)
291 Evas_Coord sx, sy, sw, sh;
292 Evas_Coord x, y, w, h;
293 int gap = 13; //in GUI
296 evas_object_geometry_get(ext_mod->ent, &ex, &ey, NULL, NULL);
297 elm_ctxpopup_direction_priority_set(ext_mod->popup, ELM_CTXPOPUP_DIRECTION_UP,
298 ELM_CTXPOPUP_DIRECTION_DOWN, ELM_CTXPOPUP_DIRECTION_LEFT,
299 ELM_CTXPOPUP_DIRECTION_RIGHT);
300 if (!edje_object_part_text_selection_geometry_get(ext_mod->ent, "elm.text", &sx, &sy, &sw, &sh))
301 { //cannot get selection shape
302 Evas_Coord cx, cy, cw, ch;
303 Evas_Coord chx, chy, chw, chh;
304 Eina_Bool ch_visible = EINA_FALSE;
305 Eina_Bool need_update = EINA_FALSE;
306 Eina_Bool up_avai, down_avai;
308 edje_object_part_text_cursor_geometry_get(ext_mod->ent, "elm.text",
312 evas_object_move(ext_mod->popup, x, y);
313 avai = elm_ctxpopup_direction_available_get
314 (ext_mod->popup, ELM_CTXPOPUP_DIRECTION_DOWN);
315 if (avai == EINA_TRUE)
317 elm_ctxpopup_direction_priority_set(ext_mod->popup,
318 ELM_CTXPOPUP_DIRECTION_DOWN,
319 ELM_CTXPOPUP_DIRECTION_UP,
320 ELM_CTXPOPUP_DIRECTION_LEFT,
321 ELM_CTXPOPUP_DIRECTION_RIGHT);
324 evas_object_move(ext_mod->popup, x, y);
325 avai = elm_ctxpopup_direction_available_get
326 (ext_mod->popup, ELM_CTXPOPUP_DIRECTION_UP);
327 if (avai == EINA_TRUE)
328 need_update = EINA_TRUE;
331 //limit ctx in viewport
332 if (ext_mod->viewport_rect.x != -1 || ext_mod->viewport_rect.y != -1
333 || ext_mod->viewport_rect.w != -1 || ext_mod->viewport_rect.h != -1)
335 if (ext_mod->viewport_rect.x > x)
336 x = ext_mod->viewport_rect.x;
337 else if (x > ext_mod->viewport_rect.x + ext_mod->viewport_rect.w)
338 x = ext_mod->viewport_rect.x + ext_mod->viewport_rect.w;
340 if (ext_mod->viewport_rect.y > y)
341 y = ext_mod->viewport_rect.y;
342 else if (y > ext_mod->viewport_rect.y + ext_mod->viewport_rect.h)
343 y = ext_mod->viewport_rect.y + ext_mod->viewport_rect.h;
346 evas_object_move(ext_mod->popup, x, y);
348 ch_visible = edje_object_part_text_cursor_handler_geometry_get
349 (ext_mod->ent, "elm.text", &chx, &chy, &chw, &chh);
350 up_avai = elm_ctxpopup_direction_available_get
351 (ext_mod->popup, ELM_CTXPOPUP_DIRECTION_UP);
352 down_avai = elm_ctxpopup_direction_available_get
353 (ext_mod->popup, ELM_CTXPOPUP_DIRECTION_DOWN);
354 //move to above or below cursor handler
357 if ((chy < cy) && (up_avai == EINA_TRUE))
360 evas_object_move(ext_mod->popup, x, y);
361 up_avai = elm_ctxpopup_direction_available_get
362 (ext_mod->popup, ELM_CTXPOPUP_DIRECTION_UP);
363 if (up_avai == EINA_FALSE)
364 need_update = EINA_TRUE;
366 else if ((chy > cy) && (down_avai == EINA_TRUE))
369 evas_object_move(ext_mod->popup, x, y);
370 down_avai = elm_ctxpopup_direction_available_get
371 (ext_mod->popup, ELM_CTXPOPUP_DIRECTION_DOWN);
372 if (down_avai == EINA_FALSE)
373 need_update = EINA_TRUE;
376 if (((up_avai == EINA_FALSE) && (down_avai == EINA_FALSE)) || need_update)
378 y = ey + cy + ch / 2;
379 elm_ctxpopup_direction_priority_set(ext_mod->popup,
380 ELM_CTXPOPUP_DIRECTION_LEFT,
381 ELM_CTXPOPUP_DIRECTION_RIGHT,
382 ELM_CTXPOPUP_DIRECTION_UP,
383 ELM_CTXPOPUP_DIRECTION_DOWN);
384 evas_object_move(ext_mod->popup, x, y);
387 else //get selection shape
389 Evas_Coord shx, shy, shw, shh;
390 Evas_Coord ehx, ehy, ehw, ehh;
391 /* Currently, we cannot get size of ctxpopup, we must set hard value for threshold.
392 After fixing ctxpopup, we can get correctly threshold */
393 Evas_Coord threshold = 300;
395 edje_object_part_text_selection_handler_geometry_get(ext_mod->ent, "elm.text",
396 EDJE_SELECTION_HANDLER_START,
397 &shx, ­, &shw, &shh);
398 edje_object_part_text_selection_handler_geometry_get(ext_mod->ent, "elm.text",
399 EDJE_SELECTION_HANDLER_END,
400 &ehx, &ehy, &ehw, &ehh);
401 if (ext_mod->viewport_rect.x != -1 || ext_mod->viewport_rect.y != -1
402 || ext_mod->viewport_rect.w != -1 || ext_mod->viewport_rect.h != -1)
404 Evas_Coord vx, vy, vw, vh, x2, y2;
406 if ((ehh > 0) && (ey + ehy + ehh > sy + sh))
408 //y2 = ey + ehy + ehh;
413 vx = ext_mod->viewport_rect.x;
414 vy = ext_mod->viewport_rect.y;
415 vw = ext_mod->viewport_rect.w;
416 vh = ext_mod->viewport_rect.h;
418 //limit ctx in viewport
423 y = vy; //case: start of selection is behind the viewport
427 if ((sx >= vx) && (ey + shy < sy)) //case: start handler is upside
431 evas_object_move(ext_mod->popup, x + w/2, y);
432 avai = elm_ctxpopup_direction_available_get
433 (ext_mod->popup, ELM_CTXPOPUP_DIRECTION_UP);
434 if (avai == EINA_FALSE)
439 else if ((sx + sw <= vx + vw) && (ey + ehy < sy))
446 if (x2 > vx + vw) x2 = vx + vw;
447 if (y2 > vy + vh) y2 = vy + vh;
450 evas_object_move(ext_mod->popup, x + w/2, y);
451 avai = elm_ctxpopup_direction_available_get
452 (ext_mod->popup, ELM_CTXPOPUP_DIRECTION_UP);
453 if (avai == EINA_TRUE)
456 else //get selection & cannot get viewport
458 Evas_Coord ww, wh, x2, y2;
460 if (ey + ehy + ehh > sy + sh)
461 y2 = ey + ehy + ehh; //end handler is downside
465 ecore_x_window_size_get(ecore_x_window_root_first_get(), &ww, &wh);
471 y = 0; //start of selection is negative
475 if (ey + shy < sy) //start handler is upside
479 evas_object_move(ext_mod->popup, x + w/2, y);
480 avai = elm_ctxpopup_direction_available_get
481 (ext_mod->popup, ELM_CTXPOPUP_DIRECTION_UP);
482 if (avai == EINA_FALSE)
490 if (x2 > ww) x2 = ww;
491 if (y2 > wh) y2 = wh;
496 evas_object_move(ext_mod->popup, x, y);
498 avai = elm_ctxpopup_direction_available_get
499 (ext_mod->popup, ELM_CTXPOPUP_DIRECTION_UP);
500 if (avai == EINA_FALSE)
503 Eina_Rectangle sel; //selection area which is not covered by start,end sel handlers
506 elm_ctxpopup_direction_priority_set(ext_mod->popup, ELM_CTXPOPUP_DIRECTION_DOWN,
507 ELM_CTXPOPUP_DIRECTION_UP,
508 ELM_CTXPOPUP_DIRECTION_LEFT,
509 ELM_CTXPOPUP_DIRECTION_RIGHT);
510 vp.x = ext_mod->viewport_rect.x;
511 vp.y = ext_mod->viewport_rect.y;
512 vp.w = ext_mod->viewport_rect.w;
513 vp.h = ext_mod->viewport_rect.h;
515 if (ey + shy + shh < sy + sh)
516 sel.y = sy > ey + shy + shh ? sy : ey + shy + shh;
520 cry = sy + sh < ey + ehy ? sy + sh : ey + ehy;
521 sel.h = cry > sel.y ? cry - sel.y : sel.y - cry;
522 if ((eina_rectangle_intersection(&sel, &vp)) && (sel.h > threshold))
524 elm_ctxpopup_direction_priority_set(ext_mod->popup, ELM_CTXPOPUP_DIRECTION_UP,
525 ELM_CTXPOPUP_DIRECTION_DOWN,
526 ELM_CTXPOPUP_DIRECTION_LEFT,
527 ELM_CTXPOPUP_DIRECTION_RIGHT);
528 evas_object_move(ext_mod->popup, x, sel.y + sel.h/2);
529 avai = elm_ctxpopup_direction_available_get
530 (ext_mod->popup, ELM_CTXPOPUP_DIRECTION_UP);
531 if (avai == EINA_TRUE)
536 if ((y < ey + ehy + ehh) && (ey + ehy < vp.y + vp.h)) //end handler is downside
539 evas_object_move(ext_mod->popup, x, y);
540 avai = elm_ctxpopup_direction_available_get
541 (ext_mod->popup, ELM_CTXPOPUP_DIRECTION_DOWN);
542 if (avai == EINA_TRUE)
545 evas_object_move(ext_mod->popup, x, y);
546 avai = elm_ctxpopup_direction_available_get
547 (ext_mod->popup, ELM_CTXPOPUP_DIRECTION_DOWN);
548 if (avai == EINA_TRUE)
552 evas_object_move(ext_mod->popup, x, y);
553 avai = elm_ctxpopup_direction_available_get
554 (ext_mod->popup, ELM_CTXPOPUP_DIRECTION_DOWN);
555 if (avai == EINA_TRUE)
558 // not enough space and small viewport (like landscape mode)
563 if (!eina_rectangle_intersection(&sel, &vp))
566 if (ey + shy < sel.y) //start handler is up side
569 while (y <= sel.y + ehh/2)
571 evas_object_move(ext_mod->popup, x, y);
572 avai = elm_ctxpopup_direction_available_get
573 (ext_mod->popup, ELM_CTXPOPUP_DIRECTION_UP);
574 if (avai == EINA_TRUE)
581 if (ey + ehy + ehh > sel.y + sel.h) //end handler is down side
584 while (y > sel.y + sel.h - ehh/2)
586 evas_object_move(ext_mod->popup, x, y);
587 avai = elm_ctxpopup_direction_available_get
588 (ext_mod->popup, ELM_CTXPOPUP_DIRECTION_DOWN);
589 if (avai == EINA_TRUE)
597 while (y > sel.y + sel.h - ehh/2)
599 evas_object_move(ext_mod->popup, x, y);
600 avai = elm_ctxpopup_direction_available_get
601 (ext_mod->popup, ELM_CTXPOPUP_DIRECTION_DOWN);
602 if (avai == EINA_TRUE)
609 elm_ctxpopup_direction_priority_set(ext_mod->popup,
610 ELM_CTXPOPUP_DIRECTION_LEFT,
611 ELM_CTXPOPUP_DIRECTION_RIGHT,
612 ELM_CTXPOPUP_DIRECTION_UP,
613 ELM_CTXPOPUP_DIRECTION_DOWN);
616 evas_object_move(ext_mod->popup, x, y);
617 avai = elm_ctxpopup_direction_available_get
618 (ext_mod->popup, ELM_CTXPOPUP_DIRECTION_LEFT);
619 if (avai == EINA_TRUE)
624 evas_object_move(ext_mod->popup, x, y);
625 avai = elm_ctxpopup_direction_available_get
626 (ext_mod->popup, ELM_CTXPOPUP_DIRECTION_LEFT);
627 if (avai == EINA_TRUE)
630 elm_ctxpopup_direction_priority_set(ext_mod->popup,
631 ELM_CTXPOPUP_DIRECTION_RIGHT,
632 ELM_CTXPOPUP_DIRECTION_LEFT,
633 ELM_CTXPOPUP_DIRECTION_UP,
634 ELM_CTXPOPUP_DIRECTION_DOWN);
637 evas_object_move(ext_mod->popup, x, y);
638 avai = elm_ctxpopup_direction_available_get
639 (ext_mod->popup, ELM_CTXPOPUP_DIRECTION_RIGHT);
640 if (avai == EINA_TRUE)
645 evas_object_move(ext_mod->popup, x, y);
646 avai = elm_ctxpopup_direction_available_get
647 (ext_mod->popup, ELM_CTXPOPUP_DIRECTION_RIGHT);
648 if (avai == EINA_TRUE)
653 while (x < sel.x + sel.w/2)
655 evas_object_move(ext_mod->popup, x, y);
656 avai = elm_ctxpopup_direction_available_get
657 (ext_mod->popup, ELM_CTXPOPUP_DIRECTION_LEFT);
658 if (avai == EINA_TRUE)
665 while (x > sel.x + sel.w/2)
667 evas_object_move(ext_mod->popup, x, y);
668 avai = elm_ctxpopup_direction_available_get
669 (ext_mod->popup, ELM_CTXPOPUP_DIRECTION_RIGHT);
670 if (avai == EINA_TRUE)
677 while (x > sel.x + sel.w/2)
679 evas_object_move(ext_mod->popup, x, y);
680 avai = elm_ctxpopup_direction_available_get
681 (ext_mod->popup, ELM_CTXPOPUP_DIRECTION_RIGHT);
682 if (avai == EINA_TRUE)
691 _select_all(void *data, Evas_Object *obj, void *event_info)
693 if((!ext_mod) || (!data)) return;
696 ext_mod->selectall(data, obj, event_info);
700 _select(void *data, Evas_Object *obj, void *event_info)
702 if((!ext_mod) || (!data)) return;
704 ext_mod->select(data, obj, event_info);
709 _paste(void *data, Evas_Object *obj, void *event_info)
711 if((!ext_mod) || (!data)) return;
713 ext_mod->paste(data, obj, event_info);
718 _cut(void *data, Evas_Object *obj, void *event_info)
720 if((!ext_mod) || (!data)) return;
722 ext_mod->cut(data, obj, event_info);
727 _copy(void *data, Evas_Object *obj, void *event_info)
729 if((!ext_mod) || (!data)) return;
731 ext_mod->copy(data, obj, event_info);
733 elm_entry_select_none(data);
737 _cancel(void *data, Evas_Object *obj, void *event_info)
739 if((!ext_mod) || (!data)) return;
741 ext_mod->cancel(data, obj, event_info);
747 _recvd_bundle(const char *key, const int type __UNUSED__, const bundle_keyval_t *kv, void *date __UNUSED__)
752 if (!ext_mod) return;
754 if (bundle_keyval_type_is_array((bundle_keyval_t *)kv) <= 0)
756 bundle_keyval_get_basic_val((bundle_keyval_t *)kv, (void **)&val, &size);
757 if (!strcmp(key, "source_text"))
759 ext_mod->source_text = strdup(val);
761 if (!strcmp(key, "target_text"))
763 ext_mod->target_text = strdup(val);
769 _translate_cb(bundle *b, int request_code __UNUSED__, appsvc_result_val rv, void *data __UNUSED__)
771 if (!ext_mod) return;
773 if (ext_mod->source_text)
775 free(ext_mod->source_text);
776 ext_mod->source_text = NULL;
778 if (ext_mod->target_text)
780 free(ext_mod->target_text);
781 ext_mod->target_text = NULL;
783 if ((rv == APPSVC_RES_CANCEL) || (rv == APPSVC_RES_NOT_OK)) //CANCEL, NOT_OK, OK
789 bundle_foreach(b, _recvd_bundle, NULL);
791 if ((ext_mod->source_text) || (ext_mod->target_text))
793 if (ext_mod->editable)
795 ext_mod->paste_translation(ext_mod->source_text,
796 ext_mod->caller, ext_mod->target_text);
807 top = elm_widget_top_get(ext_mod->caller);
808 xwin = elm_win_xwindow_get(top);
814 _translate_menu(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
816 if (!ext_mod) return;
818 bundle *b = bundle_create();
823 ext_mod->keep_selection(NULL, ext_mod->caller, NULL);
825 appsvc_set_operation(b, APPSVC_OPERATION_PICK);
826 appsvc_set_appid(b, "com.samsung.stranslator-shared");
828 if (ext_mod->selmode)
830 const char *selection = elm_entry_selection_get(ext_mod->caller);
833 unsigned int winid = _get_window_id();
835 snprintf(wis, 20, "%u", winid);
836 appsvc_add_data(b, "winid", wis);
837 appsvc_add_data(b, "display", "yes");
838 appsvc_add_data(b, "text_type", "plain_text");
839 appsvc_add_data(b, "source_language", "recently_used"); //auto_detection, recently_used
840 appsvc_add_data(b, "target_language", "recently_used"); //recently_used, specify(en_US)
841 appsvc_add_data(b, "result_type", "selective"); //target_only, selective, both
842 if (ext_mod->editable)
843 appsvc_add_data(b, "mode", "edit_mode_translate"); //edit_mode, edit_mode_translate
845 appsvc_add_data(b, "mode", "view_mode_translate"); //view_mode, view_mode_translate
847 char *str = _remove_tags(selection);
849 appsvc_add_data(b, "source_text", str);
851 appsvc_add_data(b, "source_text", selection);
854 appsvc_run_service(b, 0, _translate_cb, NULL);
856 elm_entry_input_panel_hide(ext_mod->caller);
862 _clipboard_menu(void *data, Evas_Object *obj, void *event_info __UNUSED__)
867 #ifdef HAVE_ELEMENTARY_X
868 ecore_x_selection_secondary_set(elm_win_xwindow_get(obj), NULL, 0);
870 if (ext_mod->cnp_mode != ELM_CNP_MODE_MARKUP)
871 _cbhm_msg_send(data, "show0");
873 _cbhm_msg_send(data, "show1");
879 _item_clicked(void *data, Evas_Object *obj, void *event_info __UNUSED__)
881 Elm_Entry_Context_Menu_Item *it = data;
882 Evas_Object *obj2 = it->obj;
884 if (it->func) it->func(it->data, obj2, NULL);
889 _ctxpopup_dismissed_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__)
891 Elm_Ctxpopup_Direction dir;
892 if (!ext_mod) return;
894 dir = elm_ctxpopup_direction_get(obj);
895 //clear selection if ctxpopup is dismissed by clicking (not parent resizing)
896 if (dir != ELM_CTXPOPUP_DIRECTION_UNKNOWN)
898 if ((ext_mod->mouse_up) && (ext_mod->entry_move))
900 _ctxpopup_position(obj);
901 evas_object_show(ext_mod->popup);
905 elm_entry_select_none(data);
906 ext_mod->popup_showing = EINA_FALSE;
907 if (_elm_config->access_mode)
908 _elm_access_highlight_set(ext_mod->caller, EINA_FALSE);
911 else if (ext_mod->popup_showing)
913 if (_in_viewport_check())
915 if (ext_mod->show_timer) ecore_timer_del(ext_mod->show_timer);
916 ext_mod->show_timer = ecore_timer_add(0.1, _ctx_show, data);
919 ext_mod->mouse_up = EINA_FALSE;
922 // module api funcs needed
924 elm_modapi_init(void *m __UNUSED__)
926 return 1; // succeed always
930 elm_modapi_shutdown(void *m __UNUSED__)
932 return 1; // succeed always
935 // module funcs for the specific module type
937 obj_hook(Evas_Object *obj)
940 //if(_mod_hook_count > 1) return;
944 ext_mod = ELM_NEW(Elm_Entry_Extension_data);
945 if (!ext_mod) return;
946 elm_entry_extension_module_data_get(obj, ext_mod);
947 ext_mod->mouse_up = EINA_FALSE;
948 ext_mod->mouse_down = EINA_FALSE;
949 ext_mod->entry_move = EINA_FALSE;
951 // Clipboard item: can be removed by application
952 elm_entry_context_menu_item_add(obj, "Clipboard", NULL,
953 ELM_ICON_STANDARD, NULL, NULL);
956 // Tranlate item: can be removed by application
957 elm_entry_context_menu_item_add(obj, "Translate", NULL,
958 ELM_ICON_STANDARD, NULL, NULL);
963 obj_unhook(Evas_Object *obj __UNUSED__)
966 if(_mod_hook_count > 0) return;
970 evas_object_event_callback_del(ext_mod->ctx_par, EVAS_CALLBACK_MOUSE_DOWN,
971 _parent_mouse_down_cb);
972 evas_object_event_callback_del(ext_mod->ctx_par, EVAS_CALLBACK_MOUSE_UP,
973 _parent_mouse_up_cb);
974 if (ext_mod->show_timer)
976 ecore_timer_del(ext_mod->show_timer);
977 ext_mod->show_timer = NULL;
981 evas_object_del(ext_mod->popup);
982 ext_mod->popup = NULL;
984 if (ext_mod->source_text)
986 free(ext_mod->source_text);
987 ext_mod->source_text = NULL;
989 if (ext_mod->target_text)
991 free(ext_mod->target_text);
992 ext_mod->target_text = NULL;
1000 obj_longpress(Evas_Object *obj)
1002 if(!ext_mod) return;
1004 Evas_Object *ctxparent;
1005 Evas_Object *parent, *child;
1007 const Elm_Entry_Context_Menu_Item *it;
1008 const char *context_menu_orientation;
1010 Elm_Object_Item *added_item = NULL;
1011 Eina_Bool has_clipboard = EINA_FALSE;
1012 Eina_Bool has_translate = EINA_FALSE;
1013 Eina_Bool has_focused = EINA_FALSE;
1014 Ecore_X_Atom first_cbhm_item_type = 0;
1017 elm_entry_extension_module_data_get(obj, ext_mod);
1018 has_focused = elm_widget_focus_get(obj);
1019 if (ext_mod->context_menu && has_focused)
1021 Eina_List *lao = NULL;
1022 Evas_Object *ao = NULL;
1023 #ifdef HAVE_ELEMENTARY_X
1025 if (elm_entry_cnp_mode_get(obj) != ELM_CNP_MODE_MARKUP)
1026 cbhm_count = _cbhm_item_count_get(obj, ATOM_INDEX_CBHM_COUNT_TEXT);
1028 cbhm_count = _cbhm_item_count_get(obj, ATOM_INDEX_CBHM_COUNT_ALL);
1032 evas_object_event_callback_del(obj, EVAS_CALLBACK_DEL, _entry_del_cb);
1033 evas_object_event_callback_del(obj, EVAS_CALLBACK_HIDE, _entry_hide_cb);
1034 evas_object_event_callback_del(obj, EVAS_CALLBACK_MOVE, _entry_move_cb);
1035 evas_object_event_callback_del(obj, EVAS_CALLBACK_MOUSE_DOWN, _entry_mouse_down_cb);
1036 evas_object_event_callback_del(obj, EVAS_CALLBACK_MOUSE_UP, _entry_mouse_up_cb);
1037 evas_object_event_callback_del(ext_mod->ctx_par, EVAS_CALLBACK_MOUSE_DOWN,
1038 _parent_mouse_down_cb);
1039 evas_object_event_callback_del(ext_mod->ctx_par, EVAS_CALLBACK_MOUSE_UP,
1040 _parent_mouse_up_cb);
1041 evas_object_smart_callback_del(ext_mod->popup, "dismissed", _ctxpopup_dismissed_cb);
1042 evas_object_del(ext_mod->popup);
1043 ext_mod->popup = NULL;
1045 ctxparent = elm_widget_top_get(obj);
1046 parent = elm_widget_parent_get(obj);
1052 if (!strcmp(elm_widget_type_get(parent), "elm_conformant"))
1058 parent = elm_widget_parent_get(parent);
1061 ext_mod->ctx_par = ctxparent;
1065 ext_mod->popup = elm_ctxpopup_add(ctxparent);
1066 if (_elm_config->access_mode)
1068 elm_object_tree_focus_allow_set(ext_mod->popup, EINA_TRUE);
1069 elm_object_focus_allow_set(ext_mod->popup, EINA_FALSE);
1073 elm_object_tree_focus_allow_set(ext_mod->popup, EINA_FALSE);
1075 evas_object_smart_callback_add(ext_mod->popup, "dismissed", _ctxpopup_dismissed_cb, obj);
1076 evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL, _entry_del_cb, ext_mod->popup);
1077 evas_object_event_callback_add(obj, EVAS_CALLBACK_HIDE, _entry_hide_cb, ext_mod->popup);
1081 ext_mod->caller = NULL;
1084 elm_object_style_set(ext_mod->popup, "copypaste");
1086 elm_ctxpopup_horizontal_set(ext_mod->popup, EINA_TRUE);
1087 context_menu_orientation = edje_object_data_get
1088 (ext_mod->ent, "context_menu_orientation");
1089 if ((context_menu_orientation) &&
1090 (!strcmp(context_menu_orientation, "vertical")))
1091 elm_ctxpopup_horizontal_set(ext_mod->popup, EINA_FALSE);
1093 EINA_LIST_FOREACH(ext_mod->items, l, it)
1095 if (!strcmp(it->label, "Clipboard"))
1096 has_clipboard = EINA_TRUE;
1097 else if (!strcmp(it->label, "Translate"))
1098 has_translate = EINA_TRUE;
1100 if (!ext_mod->selmode)
1102 if (!ext_mod->password)
1104 if (!elm_entry_is_empty(obj))
1106 #ifndef ELM_FEATURE_WEARABLE
1107 icon = edje_object_add(evas_object_evas_get(ext_mod->popup));
1108 CP_ICON_THEME_SET("select");
1109 added_item = elm_ctxpopup_item_append(ext_mod->popup, S_SELECT, icon, _select, obj);
1110 if (_elm_config->access_mode)
1112 elm_object_focus_allow_set(VIEW(added_item), EINA_FALSE);
1113 ao = ((Elm_Widget_Item *)added_item)->access_obj;
1114 elm_object_focus_allow_set(ao, EINA_FALSE);
1115 lao = eina_list_append(lao, ao);
1119 icon = edje_object_add(evas_object_evas_get(ext_mod->popup));
1120 CP_ICON_THEME_SET("select_all");
1121 #ifdef ELM_FEATURE_WEARABLE
1122 added_item = elm_ctxpopup_item_append(ext_mod->popup, NULL,
1123 icon, _select_all, obj);
1125 added_item = elm_ctxpopup_item_append(ext_mod->popup, S_SELECT_ALL,
1126 icon, _select_all, obj);
1128 if (_elm_config->access_mode)
1130 elm_object_focus_allow_set(VIEW(added_item), EINA_FALSE);
1131 ao = ((Elm_Widget_Item *)added_item)->access_obj;
1132 elm_object_focus_allow_set(ao, EINA_FALSE);
1133 lao = eina_list_append(lao, ao);
1138 #ifdef HAVE_ELEMENTARY_X
1141 if (1) // need way to detect if someone has a selection
1144 if (elm_entry_cnp_mode_get(obj) == ELM_CNP_MODE_PLAINTEXT)
1146 _cbhm_item_get(obj, 0, &first_cbhm_item_type, NULL);
1147 if (ext_mod->editable &&
1148 !(first_cbhm_item_type == ecore_x_atom_get("text/uri")) &&
1149 !(first_cbhm_item_type == ecore_x_atom_get("text/uri-list")))
1151 icon = edje_object_add(evas_object_evas_get(ext_mod->popup));
1152 CP_ICON_THEME_SET("paste");
1153 #ifdef ELM_FEATURE_WEARABLE
1154 added_item = elm_ctxpopup_item_append(ext_mod->popup, NULL,
1157 added_item = elm_ctxpopup_item_append(ext_mod->popup, S_PASTE,
1160 if (_elm_config->access_mode)
1162 elm_object_focus_allow_set(VIEW(added_item), EINA_FALSE);
1163 ao = ((Elm_Widget_Item *)added_item)->access_obj;
1164 elm_object_focus_allow_set(ao, EINA_FALSE);
1165 lao = eina_list_append(lao, ao);
1171 if (ext_mod->editable)
1173 icon = edje_object_add(evas_object_evas_get(ext_mod->popup));
1174 CP_ICON_THEME_SET("paste");
1175 #ifdef ELM_FEATURE_WEARABLE
1176 added_item = elm_ctxpopup_item_append(ext_mod->popup, NULL,
1179 added_item = elm_ctxpopup_item_append(ext_mod->popup, S_PASTE,
1182 if (_elm_config->access_mode)
1184 elm_object_focus_allow_set(VIEW(added_item), EINA_FALSE);
1185 ao = ((Elm_Widget_Item *)added_item)->access_obj;
1186 elm_object_focus_allow_set(ao, EINA_FALSE);
1187 lao = eina_list_append(lao, ao);
1192 //elm_ctxpopup_item_append(wd->ctxpopup, NULL, "Selectall",_select_all, obj );
1194 #ifdef HAVE_ELEMENTARY_X
1195 if ((!ext_mod->password) && (ext_mod->editable) && (cbhm_count) && (has_clipboard))
1197 if ((!ext_mod->password) && (ext_mod->editable) && (has_clipboard))
1200 icon = edje_object_add(evas_object_evas_get(ext_mod->popup));
1201 CP_ICON_THEME_SET("clipboard");
1202 #ifdef ELM_FEATURE_WEARABLE
1203 added_item = elm_ctxpopup_item_append(ext_mod->popup, NULL,
1204 icon, _clipboard_menu, obj); // Clipboard
1206 added_item = elm_ctxpopup_item_append(ext_mod->popup, S_CLIPBOARD,
1207 icon, _clipboard_menu, obj); // Clipboard
1209 if (_elm_config->access_mode)
1211 elm_object_focus_allow_set(VIEW(added_item), EINA_FALSE);
1212 ao = ((Elm_Widget_Item *)added_item)->access_obj;
1213 elm_object_focus_allow_set(ao, EINA_FALSE);
1214 lao = eina_list_append(lao, ao);
1216 //elm_ctxpopup_item_append(ext_mod->popup, "More", NULL, _clipboard_menu, obj );
1220 const char *entry_str;
1221 entry_str = elm_entry_selection_get(obj);
1222 if ((entry_str) && (has_translate))
1224 icon = edje_object_add(evas_object_evas_get(ext_mod->popup));
1225 CP_ICON_THEME_SET("translate");
1226 added_item = elm_ctxpopup_item_append(ext_mod->popup, S_TRANSLATE,
1227 icon, _translate_menu, obj);
1228 if (_elm_config->access_mode)
1230 elm_object_focus_allow_set(VIEW(added_item), EINA_FALSE);
1231 ao = ((Elm_Widget_Item *)added_item)->access_obj;
1232 elm_object_focus_allow_set(ao, EINA_FALSE);
1233 lao = eina_list_append(lao, ao);
1240 if (!ext_mod->password)
1242 if (ext_mod->have_selection)
1244 Eina_Bool selected_all = EINA_TRUE;
1245 ext_mod->is_selected_all(&selected_all, obj, NULL);
1246 if (selected_all == EINA_FALSE)
1248 icon = edje_object_add(evas_object_evas_get(ext_mod->popup));
1249 CP_ICON_THEME_SET("select_all");
1250 #ifdef ELM_FEATURE_WEARABLE
1251 added_item = elm_ctxpopup_item_append(ext_mod->popup, NULL,
1252 icon, _select_all, obj);
1254 added_item = elm_ctxpopup_item_append(ext_mod->popup, S_SELECT_ALL,
1255 icon, _select_all, obj);
1257 if (_elm_config->access_mode)
1259 elm_object_focus_allow_set(VIEW(added_item), EINA_FALSE);
1260 ao = ((Elm_Widget_Item *)added_item)->access_obj;
1261 elm_object_focus_allow_set(ao, EINA_FALSE);
1262 lao = eina_list_append(lao, ao);
1266 icon = edje_object_add(evas_object_evas_get(ext_mod->popup));
1267 CP_ICON_THEME_SET("copy");
1268 #ifdef ELM_FEATURE_WEARABLE
1269 added_item = elm_ctxpopup_item_append(ext_mod->popup, NULL,
1272 added_item = elm_ctxpopup_item_append(ext_mod->popup, S_COPY,
1275 if (_elm_config->access_mode)
1277 elm_object_focus_allow_set(VIEW(added_item), EINA_FALSE);
1278 ao = ((Elm_Widget_Item *)added_item)->access_obj;
1279 elm_object_focus_allow_set(ao, EINA_FALSE);
1280 lao = eina_list_append(lao, ao);
1282 if (ext_mod->editable)
1284 icon = edje_object_add(evas_object_evas_get(ext_mod->popup));
1285 CP_ICON_THEME_SET("cut");
1286 #ifdef ELM_FEATURE_WEARABLE
1287 added_item = elm_ctxpopup_item_append(ext_mod->popup, NULL,
1290 added_item = elm_ctxpopup_item_append(ext_mod->popup, S_CUT,
1293 if (_elm_config->access_mode)
1295 elm_object_focus_allow_set(VIEW(added_item), EINA_FALSE);
1296 ao = ((Elm_Widget_Item *)added_item)->access_obj;
1297 elm_object_focus_allow_set(ao, EINA_FALSE);
1298 lao = eina_list_append(lao, ao);
1301 #ifdef HAVE_ELEMENTARY_X
1302 if (ext_mod->editable && cbhm_count)
1304 if (ext_mod->editable)
1307 if (elm_entry_cnp_mode_get(obj) == ELM_CNP_MODE_PLAINTEXT)
1309 _cbhm_item_get(obj, 0, &first_cbhm_item_type, NULL);
1310 if (!(first_cbhm_item_type == ecore_x_atom_get("text/uri")) &&
1311 !(first_cbhm_item_type == ecore_x_atom_get("text/uri-list")))
1313 icon = edje_object_add(evas_object_evas_get(ext_mod->popup));
1314 CP_ICON_THEME_SET("paste");
1315 #ifdef ELM_FEATURE_WEARABLE
1316 added_item = elm_ctxpopup_item_append(ext_mod->popup, NULL,
1319 added_item = elm_ctxpopup_item_append(ext_mod->popup, S_PASTE,
1322 if (_elm_config->access_mode)
1324 elm_object_focus_allow_set(VIEW(added_item), EINA_FALSE);
1325 ao = ((Elm_Widget_Item *)added_item)->access_obj;
1326 elm_object_focus_allow_set(ao, EINA_FALSE);
1327 lao = eina_list_append(lao, ao);
1333 icon = edje_object_add(evas_object_evas_get(ext_mod->popup));
1334 CP_ICON_THEME_SET("paste");
1335 #ifdef ELM_FEATURE_WEARABLE
1336 added_item = elm_ctxpopup_item_append(ext_mod->popup, NULL,
1339 added_item = elm_ctxpopup_item_append(ext_mod->popup, S_PASTE,
1342 if (_elm_config->access_mode)
1344 elm_object_focus_allow_set(VIEW(added_item), EINA_FALSE);
1345 ao = ((Elm_Widget_Item *)added_item)->access_obj;
1346 elm_object_focus_allow_set(ao, EINA_FALSE);
1347 lao = eina_list_append(lao, ao);
1354 _cancel(obj,ext_mod->popup,NULL);
1355 if (!elm_entry_is_empty(obj))
1357 #ifndef ELM_FEATURE_WEARABLE
1358 icon = edje_object_add(evas_object_evas_get(ext_mod->popup));
1359 CP_ICON_THEME_SET("select");
1360 added_item = elm_ctxpopup_item_append(ext_mod->popup, S_SELECT,
1361 icon, _select, obj);
1362 if (_elm_config->access_mode)
1364 elm_object_focus_allow_set(VIEW(added_item), EINA_FALSE);
1365 ao = ((Elm_Widget_Item *)added_item)->access_obj;
1366 elm_object_focus_allow_set(ao, EINA_FALSE);
1367 lao = eina_list_append(lao, ao);
1370 icon = edje_object_add(evas_object_evas_get(ext_mod->popup));
1371 CP_ICON_THEME_SET("select_all");
1372 #ifdef ELM_FEATURE_WEARABLE
1373 added_item = elm_ctxpopup_item_append(ext_mod->popup, NULL,
1374 icon, _select_all, obj);
1376 added_item = elm_ctxpopup_item_append(ext_mod->popup, S_SELECT_ALL,
1377 icon, _select_all, obj);
1379 if (_elm_config->access_mode)
1381 elm_object_focus_allow_set(VIEW(added_item), EINA_FALSE);
1382 ao = ((Elm_Widget_Item *)added_item)->access_obj;
1383 elm_object_focus_allow_set(ao, EINA_FALSE);
1384 lao = eina_list_append(lao, ao);
1387 #ifdef HAVE_ELEMENTARY_X
1390 if (1) // need way to detect if someone has a selection
1393 if (ext_mod->editable)
1395 icon = edje_object_add(evas_object_evas_get(ext_mod->popup));
1396 CP_ICON_THEME_SET("paste");
1397 #ifdef ELM_FEATURE_WEARABLE
1398 added_item = elm_ctxpopup_item_append(ext_mod->popup, NULL,
1401 added_item = elm_ctxpopup_item_append(ext_mod->popup, S_PASTE,
1404 if (_elm_config->access_mode)
1406 elm_object_focus_allow_set(VIEW(added_item), EINA_FALSE);
1407 ao = ((Elm_Widget_Item *)added_item)->access_obj;
1408 elm_object_focus_allow_set(ao, EINA_FALSE);
1409 lao = eina_list_append(lao, ao);
1415 #ifdef HAVE_ELEMENTARY_X
1416 if ((ext_mod->editable) && (cbhm_count) && (has_clipboard))
1418 if ((ext_mod->editable) && (has_clipboard))
1421 icon = edje_object_add(evas_object_evas_get(ext_mod->popup));
1422 CP_ICON_THEME_SET("clipboard");
1423 #ifdef ELM_FEATURE_WEARABLE
1424 added_item = elm_ctxpopup_item_append(ext_mod->popup, NULL,
1425 icon, _clipboard_menu, obj);
1427 added_item = elm_ctxpopup_item_append(ext_mod->popup, S_CLIPBOARD,
1428 icon, _clipboard_menu, obj);
1430 if (_elm_config->access_mode)
1432 elm_object_focus_allow_set(VIEW(added_item), EINA_FALSE);
1433 ao = ((Elm_Widget_Item *)added_item)->access_obj;
1434 elm_object_focus_allow_set(ao, EINA_FALSE);
1435 lao = eina_list_append(lao, ao);
1437 //elm_ctxpopup_item_append(ext_mod->popup, "More", NULL, _clipboard_menu, obj );
1441 const char *entry_str;
1442 entry_str = elm_entry_selection_get(obj);
1443 if ((entry_str) && (has_translate))
1445 icon = edje_object_add(evas_object_evas_get(ext_mod->popup));
1446 CP_ICON_THEME_SET("translate");
1447 added_item = elm_ctxpopup_item_append(ext_mod->popup, S_TRANSLATE,
1448 icon, _translate_menu, obj);
1449 if (_elm_config->access_mode)
1451 elm_object_focus_allow_set(VIEW(added_item), EINA_FALSE);
1452 ao = ((Elm_Widget_Item *)added_item)->access_obj;
1453 elm_object_focus_allow_set(ao, EINA_FALSE);
1454 lao = eina_list_append(lao, ao);
1460 EINA_LIST_FOREACH(ext_mod->items, l, it)
1462 if (strcmp(it->label, "Clipboard") && strcmp(it->label, "Translate"))
1464 Evas_Object *ic = NULL;
1467 ic = elm_icon_add(obj);
1468 elm_image_resizable_set(ic, EINA_FALSE, EINA_TRUE);
1469 if (it->icon_type == ELM_ICON_FILE)
1470 elm_image_file_set(ic, it->icon_file, it->icon_group);
1471 else if (it->icon_type == ELM_ICON_STANDARD)
1472 elm_icon_standard_set(ic, it->icon_file);
1474 #ifdef ELM_FEATURE_WEARABLE
1475 added_item = elm_ctxpopup_item_append(ext_mod->popup, NULL,
1476 ic, _item_clicked, it );
1478 added_item = elm_ctxpopup_item_append(ext_mod->popup, it->label,
1479 ic, _item_clicked, it );
1481 if (_elm_config->access_mode)
1483 elm_object_focus_allow_set(VIEW(added_item), EINA_FALSE);
1484 ao = ((Elm_Widget_Item *)added_item)->access_obj;
1485 elm_object_focus_allow_set(ao, EINA_FALSE);
1486 lao = eina_list_append(lao, ao);
1490 if (ext_mod->popup && added_item)
1492 Evas_Object *first_it_ao, *cur_it_ao, *prev_it_ao;
1493 Evas_Object *popup_ao;
1494 Elm_Widget_Smart_Data *wd;
1500 ext_mod->caller = obj;
1501 if (_in_viewport_check())
1503 ext_mod->popup_showing = EINA_TRUE;
1504 _ctxpopup_position(obj);
1505 evas_object_show(ext_mod->popup);
1506 ext_mod->popup_clicked = EINA_FALSE;
1507 ext_mod->mouse_up = EINA_FALSE;
1510 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOVE, _entry_move_cb, ext_mod->popup);
1511 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_DOWN,
1512 _entry_mouse_down_cb, ext_mod->popup);
1513 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_UP,
1514 _entry_mouse_up_cb, ext_mod->popup);
1515 evas_object_event_callback_add(ext_mod->ctx_par, EVAS_CALLBACK_MOUSE_DOWN,
1516 _parent_mouse_down_cb, ext_mod->popup);
1517 evas_object_event_callback_add(ext_mod->ctx_par, EVAS_CALLBACK_MOUSE_UP,
1518 _parent_mouse_up_cb, ext_mod->popup);
1519 layer = evas_object_layer_get(ext_mod->caller);
1520 layer = layer >= EVAS_LAYER_MAX ? EVAS_LAYER_MAX : layer + 1;
1521 evas_object_layer_set(ext_mod->popup, layer);
1523 if (_elm_config->access_mode)
1525 wd = evas_object_smart_data_get(ext_mod->popup);
1526 po = (Evas_Object *)edje_object_part_object_get(wd->resize_obj,
1528 popup_ao = elm_access_object_get(po);
1529 count = eina_list_count(lao);
1530 first_it_ao = eina_list_data_get(lao);
1531 elm_access_highlight_next_set(popup_ao,
1532 ELM_HIGHLIGHT_DIR_NEXT,
1534 elm_access_highlight_next_set(first_it_ao,
1535 ELM_HIGHLIGHT_DIR_PREVIOUS,
1537 prev_it_ao = eina_list_data_get(lao);
1539 EINA_LIST_FOREACH(lao, lc, cur_it_ao)
1543 elm_access_highlight_next_set(prev_it_ao,
1544 ELM_HIGHLIGHT_DIR_NEXT,
1546 elm_access_highlight_next_set(cur_it_ao,
1547 ELM_HIGHLIGHT_DIR_PREVIOUS,
1549 elm_access_highlight_next_set(cur_it_ao,
1550 ELM_HIGHLIGHT_DIR_NEXT,
1552 elm_access_highlight_next_set(popup_ao,
1553 ELM_HIGHLIGHT_DIR_PREVIOUS,
1558 elm_access_highlight_next_set(prev_it_ao,
1559 ELM_HIGHLIGHT_DIR_NEXT,
1561 elm_access_highlight_next_set(cur_it_ao,
1562 ELM_HIGHLIGHT_DIR_PREVIOUS,
1566 prev_it_ao = cur_it_ao;
1568 elm_access_highlight_set(popup_ao);
1570 eina_list_free(lao);
1573 ext_mod->caller = NULL;
1578 obj_mouseup(Evas_Object *obj)
1580 if (!obj || !ext_mod)
1586 obj_hidemenu(Evas_Object *obj)
1588 if (!obj || !ext_mod || obj != ext_mod->caller)
1591 _ctxpopup_hide(ext_mod->popup);
1592 // if (ext_mod->popup) evas_object_del(ext_mod->popup);