Merge branch 'intefl/svn_merge' of ssh://165.213.149.219:21922/slp/pkgs/e/elementary...
[framework/uifw/elementary.git] / src / lib / elm_list.c
1 #include <Elementary.h>
2 #include "elm_priv.h"
3 #include "els_scroller.h"
4
5 #define SWIPE_MOVES 12
6
7 typedef struct _Widget_Data Widget_Data;
8 typedef struct _Elm_List_Item Elm_List_Item;
9
10 struct _Widget_Data
11 {
12    Evas_Object *scr, *box, *self;
13    Eina_List *items, *selected, *to_delete;
14    Elm_Object_Item *last_selected_item;
15    Elm_List_Mode mode;
16    Elm_List_Mode h_mode;
17    Evas_Coord minw[2], minh[2];
18    Elm_Object_Select_Mode select_mode;
19    int walking;
20    int movements;
21    struct {
22         Evas_Coord x, y;
23    } history[SWIPE_MOVES];
24    Eina_Bool scr_minw : 1;
25    Eina_Bool scr_minh : 1;
26    Eina_Bool swipe : 1;
27    Eina_Bool fix_pending : 1;
28    Eina_Bool on_hold : 1;
29    Eina_Bool multi : 1;
30    Eina_Bool longpressed : 1;
31    Eina_Bool wasselected : 1;
32 };
33
34 struct _Elm_List_Item
35 {
36    ELM_WIDGET_ITEM;
37    Widget_Data *wd;
38    Eina_List *node;
39    const char *label;
40    Evas_Object *icon, *end;
41    Evas_Smart_Cb func;
42    Ecore_Timer *long_timer;
43    Ecore_Timer *swipe_timer;
44    Eina_Bool deleted : 1;
45    Eina_Bool even : 1;
46    Eina_Bool is_even : 1;
47    Eina_Bool is_separator : 1;
48    Eina_Bool fixed : 1;
49    Eina_Bool selected : 1;
50    Eina_Bool highlighted : 1;
51    Eina_Bool dummy_icon : 1;
52    Eina_Bool dummy_end : 1;
53 };
54
55 static const char *widtype = NULL;
56 static void _del_hook(Evas_Object *obj);
57 static void _mirrored_set(Evas_Object *obj, Eina_Bool rtl);
58 static void _theme_hook(Evas_Object *obj);
59 static void _sizing_eval(Evas_Object *obj);
60 static void _disable_hook(Evas_Object *obj);
61 static void _on_focus_hook(void *data, Evas_Object *obj);
62 static void _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source);
63 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
64 static void _sub_del(void *data, Evas_Object *obj, void *event_info);
65 static void _fix_items(Evas_Object *obj);
66 static void _mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event_info);
67 static void _mouse_up(void *data, Evas *evas, Evas_Object *obj, void *event_info);
68 static void _mouse_move(void *data, Evas *evas, Evas_Object *obj, void *event_info);
69 static void _edge_left(void *data, Evas_Object *scr, void *event_info);
70 static void _edge_right(void *data, Evas_Object *scr, void *event_info);
71 static void _edge_top(void *data, Evas_Object *scr, void *event_info);
72 static void _edge_bottom(void *data, Evas_Object *scr, void *event_info);
73 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
74 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
75 static Eina_Bool _item_single_select_up(Widget_Data *wd);
76 static Eina_Bool _item_single_select_down(Widget_Data *wd);
77 static Eina_Bool _event_hook(Evas_Object *obj, Evas_Object *src,
78                              Evas_Callback_Type type, void *event_info);
79 static Eina_Bool _deselect_all_items(Widget_Data *wd);
80
81 static const char SIG_ACTIVATED[] = "activated";
82 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
83 static const char SIG_SELECTED[] = "selected";
84 static const char SIG_UNSELECTED[] = "unselected";
85 static const char SIG_LONGPRESSED[] = "longpressed";
86 static const char SIG_EDGE_TOP[] = "edge,top";
87 static const char SIG_EDGE_BOTTOM[] = "edge,bottom";
88 static const char SIG_EDGE_LEFT[] = "edge,left";
89 static const char SIG_EDGE_RIGHT[] = "edge,right";
90
91 static const Evas_Smart_Cb_Description _signals[] = {
92    {SIG_ACTIVATED, ""},
93    {SIG_CLICKED_DOUBLE, ""},
94    {SIG_SELECTED, ""},
95    {SIG_UNSELECTED, ""},
96    {SIG_LONGPRESSED, ""},
97    {SIG_EDGE_TOP, ""},
98    {SIG_EDGE_BOTTOM, ""},
99    {SIG_EDGE_LEFT, ""},
100    {SIG_EDGE_RIGHT, ""},
101    {NULL, NULL}
102 };
103
104 #define ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, ...)                      \
105    ELM_OBJ_ITEM_CHECK_OR_RETURN(it, __VA_ARGS__);                        \
106 if (((Elm_List_Item *)it)->deleted)                                     \
107 {                                                                        \
108    ERR("ERROR: "#it" has been DELETED.\n");                              \
109    return __VA_ARGS__;                                                   \
110 }
111
112 static inline void
113 _elm_list_item_free(Elm_List_Item *it)
114 {
115    evas_object_event_callback_del_full
116       (VIEW(it), EVAS_CALLBACK_MOUSE_DOWN, _mouse_down, it);
117    evas_object_event_callback_del_full
118       (VIEW(it), EVAS_CALLBACK_MOUSE_UP, _mouse_up, it);
119    evas_object_event_callback_del_full
120       (VIEW(it), EVAS_CALLBACK_MOUSE_MOVE, _mouse_move, it);
121
122    if (it->icon)
123      evas_object_event_callback_del_full
124         (it->icon, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
125          _changed_size_hints, WIDGET(it));
126
127    if (it->end)
128      evas_object_event_callback_del_full
129         (it->end, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
130          _changed_size_hints, WIDGET(it));
131
132    eina_stringshare_del(it->label);
133
134    if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
135    if (it->long_timer) ecore_timer_del(it->long_timer);
136    if (it->icon) evas_object_del(it->icon);
137    if (it->end) evas_object_del(it->end);
138 }
139
140 static Eina_Bool
141 _event_hook(Evas_Object *obj, Evas_Object *src __UNUSED__, Evas_Callback_Type type, void *event_info)
142 {
143    if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
144    Evas_Event_Key_Down *ev = event_info;
145    Widget_Data *wd = elm_widget_data_get(obj);
146    if (!wd) return EINA_FALSE;
147    if (!wd->items) return EINA_FALSE;
148    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
149    if (elm_widget_disabled_get(obj)) return EINA_FALSE;
150
151    Elm_List_Item *it = NULL;
152    Evas_Coord x = 0;
153    Evas_Coord y = 0;
154    Evas_Coord step_x = 0;
155    Evas_Coord step_y = 0;
156    Evas_Coord v_w = 0;
157    Evas_Coord v_h = 0;
158    Evas_Coord page_x = 0;
159    Evas_Coord page_y = 0;
160
161    elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
162    elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
163    elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
164    elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
165
166    /* TODO: fix logic for horizontal mode */
167    if ((!strcmp(ev->keyname, "Left")) ||
168        (!strcmp(ev->keyname, "KP_Left")))
169      {
170         if ((wd->h_mode) &&
171             (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
172               (_item_multi_select_up(wd)))
173              || (_item_single_select_up(wd))))
174           {
175              ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
176              return EINA_TRUE;
177           }
178         else
179           x -= step_x;
180      }
181    else if ((!strcmp(ev->keyname, "Right")) ||
182             (!strcmp(ev->keyname, "KP_Right")))
183      {
184         if ((wd->h_mode) &&
185             (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
186               (_item_multi_select_down(wd)))
187              || (_item_single_select_down(wd))))
188           {
189              ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
190              return EINA_TRUE;
191           }
192         else
193           x += step_x;
194      }
195    else if ((!strcmp(ev->keyname, "Up"))  ||
196             (!strcmp(ev->keyname, "KP_Up")))
197      {
198         if ((!wd->h_mode) &&
199             (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
200               (_item_multi_select_up(wd)))
201              || (_item_single_select_up(wd))))
202           {
203              ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
204              return EINA_TRUE;
205           }
206         else
207           y -= step_y;
208      }
209    else if ((!strcmp(ev->keyname, "Down")) ||
210             (!strcmp(ev->keyname, "KP_Down")))
211      {
212         if ((!wd->h_mode) &&
213             (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
214               (_item_multi_select_down(wd)))
215              || (_item_single_select_down(wd))))
216           {
217              ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
218              return EINA_TRUE;
219           }
220         else
221           y += step_y;
222      }
223    else if ((!strcmp(ev->keyname, "Home")) ||
224             (!strcmp(ev->keyname, "KP_Home")))
225      {
226         it = eina_list_data_get(wd->items);
227         elm_list_item_bring_in((Elm_Object_Item *)it);
228         ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
229         return EINA_TRUE;
230      }
231    else if ((!strcmp(ev->keyname, "End")) ||
232             (!strcmp(ev->keyname, "KP_End")))
233      {
234         it = eina_list_data_get(eina_list_last(wd->items));
235         elm_list_item_bring_in((Elm_Object_Item *)it);
236         ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
237         return EINA_TRUE;
238      }
239    else if ((!strcmp(ev->keyname, "Prior")) ||
240             (!strcmp(ev->keyname, "KP_Prior")))
241      {
242         if (wd->h_mode)
243           {
244              if (page_x < 0)
245                x -= -(page_x * v_w) / 100;
246              else
247                x -= page_x;
248           }
249         else
250           {
251              if (page_y < 0)
252                y -= -(page_y * v_h) / 100;
253              else
254                y -= page_y;
255           }
256      }
257    else if ((!strcmp(ev->keyname, "Next")) ||
258             (!strcmp(ev->keyname, "KP_Next")))
259      {
260         if (wd->h_mode)
261           {
262              if (page_x < 0)
263                x += -(page_x * v_w) / 100;
264              else
265                x += page_x;
266           }
267         else
268           {
269              if (page_y < 0)
270                y += -(page_y * v_h) / 100;
271              else
272                y += page_y;
273           }
274      }
275    else if (((!strcmp(ev->keyname, "Return")) ||
276             (!strcmp(ev->keyname, "KP_Enter")) ||
277             (!strcmp(ev->keyname, "space")))
278            && (!wd->multi) && (wd->selected))
279      {
280         it = (Elm_List_Item *) elm_list_selected_item_get(obj);
281         evas_object_smart_callback_call(WIDGET(it), SIG_ACTIVATED, it);
282      }
283    else if (!strcmp(ev->keyname, "Escape"))
284      {
285         if (!_deselect_all_items(wd)) return EINA_FALSE;
286         ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
287         return EINA_TRUE;
288      }
289    else return EINA_FALSE;
290
291    ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
292    elm_smart_scroller_child_pos_set(wd->scr, x, y);
293    return EINA_TRUE;
294 }
295
296 static void
297 _translate_hook(Evas_Object *obj)
298 {
299    evas_object_smart_callback_call(obj, "language,changed", NULL);
300 }
301
302 static Eina_Bool
303 _deselect_all_items(Widget_Data *wd)
304 {
305    if (!wd->selected) return EINA_FALSE;
306    while (wd->selected)
307      elm_list_item_selected_set((Elm_Object_Item *) wd->selected->data,
308                                 EINA_FALSE);
309
310    return EINA_TRUE;
311 }
312
313 static Eina_Bool
314 _item_multi_select_up(Widget_Data *wd)
315 {
316    if (!wd->selected) return EINA_FALSE;
317    if (!wd->multi) return EINA_FALSE;
318
319    Elm_Object_Item *prev = elm_list_item_prev(wd->last_selected_item);
320    if (!prev) return EINA_TRUE;
321
322    if (elm_list_item_selected_get(prev))
323      {
324         elm_list_item_selected_set(wd->last_selected_item, EINA_FALSE);
325         wd->last_selected_item = prev;
326         elm_list_item_show(wd->last_selected_item);
327      }
328    else
329      {
330         elm_list_item_selected_set(prev, EINA_TRUE);
331         elm_list_item_show(prev);
332      }
333    return EINA_TRUE;
334 }
335
336 static Eina_Bool
337 _item_multi_select_down(Widget_Data *wd)
338 {
339    if (!wd->selected) return EINA_FALSE;
340    if (!wd->multi) return EINA_FALSE;
341
342    Elm_Object_Item *next = elm_list_item_next(wd->last_selected_item);
343    if (!next) return EINA_TRUE;
344
345    if (elm_list_item_selected_get(next))
346      {
347         elm_list_item_selected_set(wd->last_selected_item, EINA_FALSE);
348         wd->last_selected_item = next;
349         elm_list_item_show(wd->last_selected_item);
350      }
351    else
352      {
353         elm_list_item_selected_set(next, EINA_TRUE);
354         elm_list_item_show(next);
355      }
356    return EINA_TRUE;
357 }
358
359 static Eina_Bool
360 _item_single_select_up(Widget_Data *wd)
361 {
362    Elm_Object_Item *prev;
363
364    if (!wd->selected) prev = eina_list_data_get(eina_list_last(wd->items));
365    else prev = elm_list_item_prev(wd->last_selected_item);
366    if (!prev) return EINA_FALSE;
367
368    _deselect_all_items(wd);
369
370    elm_list_item_selected_set(prev, EINA_TRUE);
371    elm_list_item_show(prev);
372    return EINA_TRUE;
373 }
374
375 static Eina_Bool
376 _item_single_select_down(Widget_Data *wd)
377 {
378    Elm_Object_Item *next;
379
380    if (!wd->selected) next = eina_list_data_get(wd->items);
381    else next = elm_list_item_next(wd->last_selected_item);
382    if (!next) return EINA_FALSE;
383
384    _deselect_all_items(wd);
385
386    elm_list_item_selected_set(next, EINA_TRUE);
387    elm_list_item_show(next);
388    return EINA_TRUE;
389 }
390
391 static void
392 _elm_list_process_deletions(Widget_Data *wd)
393 {
394    Elm_List_Item *it;
395
396    wd->walking++; // avoid nested deletion and also _sub_del() fix_items
397
398    EINA_LIST_FREE(wd->to_delete, it)
399      {
400         wd->items = eina_list_remove_list(wd->items, it->node);
401         _elm_list_item_free(it);
402         elm_widget_item_free(it);
403      }
404
405    wd->walking--;
406 }
407
408 static inline void
409 _elm_list_walk(Widget_Data *wd)
410 {
411    if (wd->walking < 0)
412      {
413         ERR("ERROR: walking was negative. fixed!\n");
414         wd->walking = 0;
415      }
416    wd->walking++;
417 }
418
419 static inline void
420 _elm_list_unwalk(Widget_Data *wd)
421 {
422    wd->walking--;
423    if (wd->walking < 0)
424      {
425         ERR("ERROR: walking became negative. fixed!\n");
426         wd->walking = 0;
427      }
428
429    if (wd->walking)
430      return;
431
432    if (wd->to_delete)
433      _elm_list_process_deletions(wd);
434
435    if (wd->fix_pending)
436      {
437         wd->fix_pending = EINA_FALSE;
438         _fix_items(wd->self);
439         _sizing_eval(wd->self);
440      }
441 }
442
443 static void
444 _del_pre_hook(Evas_Object *obj)
445 {
446    Widget_Data *wd = elm_widget_data_get(obj);
447    if (!wd) return;
448
449    evas_object_event_callback_del(wd->scr,
450                                   EVAS_CALLBACK_CHANGED_SIZE_HINTS,
451                                   _changed_size_hints);
452    evas_object_event_callback_del(wd->box,
453                                   EVAS_CALLBACK_CHANGED_SIZE_HINTS,
454                                   _changed_size_hints);
455 }
456
457 static void
458 _del_hook(Evas_Object *obj)
459 {
460    Widget_Data *wd = elm_widget_data_get(obj);
461    Elm_List_Item *it;
462    Eina_List *n;
463
464    if (!wd) return;
465    if (wd->walking)
466      ERR("ERROR: list deleted while walking.\n");
467
468    _elm_list_walk(wd);
469    EINA_LIST_FOREACH(wd->items, n, it) elm_widget_item_pre_notify_del(it);
470    _elm_list_unwalk(wd);
471    if (wd->to_delete)
472      ERR("ERROR: leaking nodes!\n");
473
474    EINA_LIST_FREE(wd->items, it)
475      {
476         _elm_list_item_free(it);
477         elm_widget_item_free(it);
478      }
479    eina_list_free(wd->selected);
480    free(wd);
481 }
482
483 static void
484 _show_region_hook(void *data, Evas_Object *obj)
485 {
486    Widget_Data *wd = elm_widget_data_get(data);
487    Evas_Coord x, y, w, h;
488    if (!wd) return;
489    elm_widget_show_region_get(obj, &x, &y, &w, &h);
490    elm_smart_scroller_child_region_set(wd->scr, x, y, w, h);
491 }
492
493 static void
494 _disable_hook(Evas_Object *obj)
495 {
496    Widget_Data *wd = elm_widget_data_get(obj);
497    if (!wd) return;
498    if (elm_widget_disabled_get(obj))
499      {
500         _signal_emit_hook(obj, "elm,state,disabled", "elm");
501         elm_widget_scroll_freeze_push(obj);
502         elm_widget_scroll_hold_push(obj);
503         /* FIXME: if we get to have a way to only un-highlight items
504          * in the future, keeping them selected... */
505         _deselect_all_items(wd);
506      }
507    else
508      {
509         _signal_emit_hook(obj, "elm,state,enabled", "elm");
510         elm_widget_scroll_freeze_pop(obj);
511         elm_widget_scroll_hold_pop(obj);
512      }
513 }
514
515 static void
516 _sizing_eval(Evas_Object *obj)
517 {
518
519    Widget_Data *wd = elm_widget_data_get(obj);
520    if (!wd) return;
521    Evas_Coord  vw, vh, minw, minh, maxw, maxh, w, h, vmw, vmh;
522    double xw, yw;
523
524    evas_object_size_hint_min_get(wd->box, &minw, &minh);
525    evas_object_size_hint_max_get(wd->box, &maxw, &maxh);
526    evas_object_size_hint_weight_get(wd->box, &xw, &yw);
527    if (!wd->scr) return;
528    elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
529    if (xw > 0.0)
530      {
531         if ((minw > 0) && (vw < minw)) vw = minw;
532         else if ((maxw > 0) && (vw > maxw)) vw = maxw;
533      }
534    else if (minw > 0) vw = minw;
535    if (yw > 0.0)
536      {
537         if ((minh > 0) && (vh < minh)) vh = minh;
538         else if ((maxh > 0) && (vh > maxh)) vh = maxh;
539      }
540    else if (minh > 0) vh = minh;
541    evas_object_resize(wd->box, vw, vh);
542    w = -1;
543    h = -1;
544    edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
545                              &vmw, &vmh);
546    if (wd->scr_minw) w = vmw + minw;
547    if (wd->scr_minh) h = vmh + minh;
548
549    evas_object_size_hint_max_get(obj, &maxw, &maxh);
550    if ((maxw > 0) && (w > maxw))
551      w = maxw;
552    if ((maxh > 0) && (h > maxh))
553      h = maxh;
554
555    evas_object_size_hint_min_set(obj, w, h);
556 }
557
558 static void
559 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
560 {
561    Widget_Data *wd = elm_widget_data_get(obj);
562    edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
563                            emission, source);
564 }
565
566 static void
567 _signal_callback_add_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
568 {
569    Widget_Data *wd = elm_widget_data_get(obj);
570    edje_object_signal_callback_add(elm_smart_scroller_edje_object_get(wd->scr),
571                                    emission, source, func_cb, data);
572 }
573
574 static void
575 _signal_callback_del_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
576 {
577    Widget_Data *wd = elm_widget_data_get(obj);
578    edje_object_signal_callback_del_full(
579       elm_smart_scroller_edje_object_get(wd->scr),
580       emission, source, func_cb, data);
581 }
582
583 static void
584 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
585 {
586    Widget_Data *wd = elm_widget_data_get(obj);
587    Elm_List_Item *it;
588    Eina_List *n;
589
590    if (!wd) return;
591    if (wd->scr)
592      elm_smart_scroller_mirrored_set(wd->scr, rtl);
593
594    EINA_LIST_FOREACH(wd->items, n, it)
595       edje_object_mirrored_set(VIEW(it), rtl);
596 }
597
598 static void
599 _theme_hook(Evas_Object *obj)
600 {
601    Widget_Data *wd = elm_widget_data_get(obj);
602    Elm_List_Item *it;
603    Eina_List *n;
604
605    if (!wd) return;
606    _elm_widget_mirrored_reload(obj);
607    _mirrored_set(obj, elm_widget_mirrored_get(obj));
608
609    if (wd->scr)
610      {
611         Evas_Object *edj;
612         const char *str;
613
614         elm_smart_scroller_object_theme_set(obj, wd->scr, "list", "base",
615                                             elm_widget_style_get(obj));
616         //        edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
617         edj = elm_smart_scroller_edje_object_get(wd->scr);
618         str = edje_object_data_get(edj, "focus_highlight");
619         if ((str) && (!strcmp(str, "on")))
620           elm_widget_highlight_in_theme_set(obj, EINA_TRUE);
621         else
622           elm_widget_highlight_in_theme_set(obj, EINA_FALSE);
623         elm_object_style_set(wd->scr, elm_widget_style_get(obj));
624      }
625    EINA_LIST_FOREACH(wd->items, n, it)
626      {
627         edje_object_scale_set(VIEW(it), elm_widget_scale_get(obj) * _elm_config->scale);
628         it->fixed = 0;
629      }
630    _fix_items(obj);
631    _sizing_eval(obj);
632 }
633
634 static void
635 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
636 {
637    Widget_Data *wd = elm_widget_data_get(obj);
638    if (!wd) return;
639    if (elm_widget_focus_get(obj))
640      {
641         edje_object_signal_emit(wd->self, "elm,action,focus", "elm");
642         evas_object_focus_set(wd->self, EINA_TRUE);
643
644         if ((wd->selected) && (!wd->last_selected_item))
645           wd->last_selected_item = eina_list_data_get(wd->selected);
646      }
647    else
648      {
649         edje_object_signal_emit(wd->self, "elm,action,unfocus", "elm");
650         evas_object_focus_set(wd->self, EINA_FALSE);
651      }
652 }
653
654 static void
655 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
656 {
657    Widget_Data *wd = elm_widget_data_get(data);
658    if (!wd) return;
659    _fix_items(data);
660    _sizing_eval(data);
661 }
662
663 static void
664 _sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info)
665 {
666    Widget_Data *wd = elm_widget_data_get(obj);
667    Evas_Object *sub = event_info;
668    const Eina_List *l;
669    Elm_List_Item *it;
670
671    if (!wd) return;
672    if (!sub) abort();
673    if ((sub == wd->box) || (sub == wd->scr)) return;
674
675    EINA_LIST_FOREACH(wd->items, l, it)
676      {
677         if ((sub == it->icon) || (sub == it->end))
678           {
679              if (it->icon == sub) it->icon = NULL;
680              if (it->end == sub) it->end = NULL;
681              evas_object_event_callback_del_full
682              (sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints,
683               obj);
684              if (!wd->walking)
685                {
686                   _fix_items(obj);
687                   _sizing_eval(obj);
688                }
689              else
690                wd->fix_pending = EINA_TRUE;
691              break;
692           }
693      }
694 }
695
696 static void
697 _item_highlight(Elm_List_Item *it)
698 {
699    Evas_Object *obj = WIDGET(it);
700    Widget_Data *wd = elm_widget_data_get(obj);
701    const char *selectraise;
702
703    if (!wd) return;
704    ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
705    if ((it->highlighted) || (it->base.disabled) ||
706        (wd->select_mode == ELM_OBJECT_SELECT_MODE_NONE)) return;
707
708    evas_object_ref(obj);
709    _elm_list_walk(wd);
710
711    edje_object_signal_emit(VIEW(it), "elm,state,selected", "elm");
712    selectraise = edje_object_data_get(VIEW(it), "selectraise");
713    if ((selectraise) && (!strcmp(selectraise, "on")))
714      evas_object_raise(VIEW(it));
715    it->highlighted = EINA_TRUE;
716
717    _elm_list_unwalk(wd);
718    evas_object_unref(obj);
719 }
720
721 static void
722 _item_select(Elm_List_Item *it)
723 {
724    Evas_Object *obj = WIDGET(it);
725    Widget_Data *wd = elm_widget_data_get(obj);
726
727    if (!wd) return;
728    ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
729    if (it->base.disabled || (wd->select_mode == ELM_OBJECT_SELECT_MODE_NONE)) return;
730    if (it->selected)
731      {
732         if (wd->select_mode == ELM_OBJECT_SELECT_MODE_ALWAYS) goto call;
733         return;
734      }
735    it->selected = EINA_TRUE;
736    wd->selected = eina_list_append(wd->selected, it);
737
738 call:
739    evas_object_ref(obj);
740    _elm_list_walk(wd);
741
742    if (it->func) it->func((void *)it->base.data, WIDGET(it), it);
743    evas_object_smart_callback_call(obj, SIG_SELECTED, it);
744    it->wd->last_selected_item = (Elm_Object_Item *)it;
745
746    _elm_list_unwalk(wd);
747    evas_object_unref(obj);
748 }
749
750 static void
751 _item_unselect(Elm_List_Item *it)
752 {
753    Evas_Object *obj = WIDGET(it);
754    Widget_Data *wd = elm_widget_data_get(obj);
755    const char *stacking, *selectraise;
756
757    if (!wd) return;
758    ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
759    if (!it->highlighted) return;
760
761    evas_object_ref(obj);
762    _elm_list_walk(wd);
763
764    edje_object_signal_emit(VIEW(it), "elm,state,unselected", "elm");
765    stacking = edje_object_data_get(VIEW(it), "stacking");
766    selectraise = edje_object_data_get(VIEW(it), "selectraise");
767    if ((selectraise) && (!strcmp(selectraise, "on")))
768      {
769         if ((stacking) && (!strcmp(stacking, "below")))
770           evas_object_lower(VIEW(it));
771      }
772    it->highlighted = EINA_FALSE;
773    if (it->selected)
774      {
775         it->selected = EINA_FALSE;
776         wd->selected = eina_list_remove(wd->selected, it);
777         evas_object_smart_callback_call(WIDGET(it), SIG_UNSELECTED, it);
778      }
779
780    _elm_list_unwalk(wd);
781    evas_object_unref(obj);
782 }
783
784 static Eina_Bool
785 _swipe_cancel(void *data)
786 {
787    Elm_List_Item *it = data;
788    Widget_Data *wd = elm_widget_data_get(WIDGET(it));
789
790    if (!wd) return ECORE_CALLBACK_CANCEL;
791    ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, ECORE_CALLBACK_CANCEL);
792    wd->swipe = EINA_FALSE;
793    wd->movements = 0;
794    return ECORE_CALLBACK_RENEW;
795 }
796
797 static void
798 _mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
799 {
800    Elm_List_Item *it = data;
801    Evas_Object *obj2 = WIDGET(it);
802    Widget_Data *wd = elm_widget_data_get(obj2);
803    Evas_Event_Mouse_Move *ev = event_info;
804
805    if (!wd) return;
806    ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
807
808    evas_object_ref(obj2);
809    _elm_list_walk(wd);
810
811    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
812      {
813         if (!wd->on_hold)
814           {
815              wd->on_hold = EINA_TRUE;
816              if (it->long_timer)
817                {
818                   ecore_timer_del(it->long_timer);
819                   it->long_timer = NULL;
820                }
821              if (!wd->wasselected)
822                _item_unselect(it);
823           }
824         if (wd->movements == SWIPE_MOVES) wd->swipe = EINA_TRUE;
825         else
826           {
827              wd->history[wd->movements].x = ev->cur.canvas.x;
828              wd->history[wd->movements].y = ev->cur.canvas.y;
829              if (abs((wd->history[wd->movements].x - wd->history[0].x)) > 40)
830                wd->swipe = EINA_TRUE;
831              else
832                wd->movements++;
833           }
834      }
835
836    _elm_list_unwalk(wd);
837    evas_object_unref(obj2);
838 }
839
840 static void
841 _edge_left(void *data, Evas_Object *scr __UNUSED__, void *event_info __UNUSED__)
842 {
843    Evas_Object *obj = data;
844    evas_object_smart_callback_call(obj, SIG_EDGE_LEFT, NULL);
845 }
846
847 static void
848 _edge_right(void *data, Evas_Object *scr __UNUSED__, void *event_info __UNUSED__)
849 {
850    Evas_Object *obj = data;
851    evas_object_smart_callback_call(obj, SIG_EDGE_RIGHT, NULL);
852 }
853
854 static void
855 _edge_top(void *data, Evas_Object *scr __UNUSED__, void *event_info __UNUSED__)
856 {
857    Evas_Object *obj = data;
858    evas_object_smart_callback_call(obj, SIG_EDGE_TOP, NULL);
859 }
860
861 static void
862 _edge_bottom(void *data, Evas_Object *scr __UNUSED__, void *event_info __UNUSED__)
863 {
864    Evas_Object *obj = data;
865    evas_object_smart_callback_call(obj, SIG_EDGE_BOTTOM, NULL);
866 }
867
868 static Eina_Bool
869 _long_press(void *data)
870 {
871    Elm_List_Item *it = data;
872    Evas_Object *obj = WIDGET(it);
873    Widget_Data *wd = elm_widget_data_get(obj);
874
875    if (!wd) goto end;
876
877    ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, ECORE_CALLBACK_CANCEL);
878    it->long_timer = NULL;
879    if (it->base.disabled) goto end;
880
881    wd->longpressed = EINA_TRUE;
882    evas_object_smart_callback_call(WIDGET(it), SIG_LONGPRESSED, it);
883
884 end:
885    return ECORE_CALLBACK_CANCEL;
886 }
887
888 static void
889 _swipe(Elm_List_Item *it)
890 {
891    int i, sum = 0;
892    Widget_Data *wd = elm_widget_data_get(WIDGET(it));
893
894    ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
895    if (!wd) return;
896    wd->swipe = EINA_FALSE;
897    for (i = 0; i < wd->movements; i++)
898      {
899         sum += wd->history[i].x;
900         if (abs(wd->history[0].y - wd->history[i].y) > 10) return;
901      }
902
903    sum /= wd->movements;
904    if (abs(sum - wd->history[0].x) <= 10) return;
905    evas_object_smart_callback_call(WIDGET(it), "swipe", it);
906 }
907
908 static void
909 _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
910 {
911    Elm_List_Item *it = data;
912    Evas_Object *obj2 = WIDGET(it);
913    Widget_Data *wd = elm_widget_data_get(obj2);
914    Evas_Event_Mouse_Down *ev = event_info;
915
916    if (!wd) return;
917    ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
918    if (ev->button != 1) return;
919    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) wd->on_hold = EINA_TRUE;
920    else wd->on_hold = EINA_FALSE;
921    if (wd->on_hold) return;
922    wd->wasselected = it->selected;
923
924    evas_object_ref(obj2);
925    _elm_list_walk(wd);
926
927    _item_highlight(it);
928    wd->longpressed = EINA_FALSE;
929    if (it->long_timer) ecore_timer_del(it->long_timer);
930    it->long_timer = ecore_timer_add(_elm_config->longpress_timeout, _long_press, it);
931    if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
932    it->swipe_timer = ecore_timer_add(0.4, _swipe_cancel, it);
933    /* Always call the callbacks last - the user may delete our context! */
934    if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
935      {
936         evas_object_smart_callback_call(WIDGET(it), SIG_CLICKED_DOUBLE, it);
937         evas_object_smart_callback_call(WIDGET(it), SIG_ACTIVATED, it);
938      }
939    wd->swipe = EINA_FALSE;
940    wd->movements = 0;
941
942    _elm_list_unwalk(wd);
943    evas_object_unref(obj2);
944 }
945
946 static void
947 _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
948 {
949    Elm_List_Item *it = data;
950    Evas_Object *obj2 = WIDGET(it);
951    Widget_Data *wd = elm_widget_data_get(obj2);
952    Evas_Event_Mouse_Up *ev = event_info;
953
954    if (!wd) return;
955    ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
956    if (ev->button != 1) return;
957    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) wd->on_hold = EINA_TRUE;
958    else wd->on_hold = EINA_FALSE;
959    wd->longpressed = EINA_FALSE;
960    if (it->long_timer)
961      {
962         ecore_timer_del(it->long_timer);
963         it->long_timer = NULL;
964      }
965    if (it->swipe_timer)
966      {
967         ecore_timer_del(it->swipe_timer);
968         it->swipe_timer = NULL;
969      }
970    if (wd->on_hold)
971      {
972         if (wd->swipe) _swipe(data);
973         wd->on_hold = EINA_FALSE;
974         return;
975      }
976    if (wd->longpressed)
977      {
978         if (!wd->wasselected) _item_unselect(it);
979         wd->wasselected = 0;
980         return;
981      }
982
983    if (it->base.disabled)
984      return;
985    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
986
987    evas_object_ref(obj2);
988    _elm_list_walk(wd);
989
990    if (wd->multi)
991      {
992         if (!it->selected)
993           {
994              _item_highlight(it);
995              _item_select(it);
996           }
997         else _item_unselect(it);
998      }
999    else
1000      {
1001         if (!it->selected)
1002           {
1003              while (wd->selected)
1004                _item_unselect(wd->selected->data);
1005              _item_highlight(it);
1006              _item_select(it);
1007           }
1008         else
1009           {
1010              const Eina_List *l, *l_next;
1011              Elm_List_Item *it2;
1012
1013              EINA_LIST_FOREACH_SAFE(wd->selected, l, l_next, it2)
1014                 if (it2 != it) _item_unselect(it2);
1015              _item_highlight(it);
1016              _item_select(it);
1017           }
1018      }
1019
1020    _elm_list_unwalk(wd);
1021    evas_object_unref(obj2);
1022 }
1023
1024 static void
1025 _item_disable(Elm_Object_Item *it)
1026 {
1027    Elm_List_Item *item = (Elm_List_Item *)it;
1028    if (item->base.disabled)
1029      edje_object_signal_emit(VIEW(item), "elm,state,disabled", "elm");
1030    else
1031      edje_object_signal_emit(VIEW(item), "elm,state,enabled", "elm");
1032 }
1033
1034 static void
1035 _item_content_set(Elm_Object_Item *it, const char *part, Evas_Object *content)
1036 {
1037    Elm_List_Item *item = (Elm_List_Item *)it;
1038    Evas_Object **icon_p = NULL;
1039    Eina_Bool dummy = EINA_FALSE;
1040
1041    if ((!part) || (!strcmp(part, "start")))
1042      {
1043         icon_p = &(item->icon);
1044         dummy = item->dummy_icon;
1045         if (!content) item->dummy_icon = EINA_FALSE;
1046         else item->dummy_icon = EINA_TRUE;
1047      }
1048    else if (!strcmp(part, "end"))
1049      {
1050         icon_p = &(item->end);
1051         dummy = item->dummy_end;
1052         if (!content) item->dummy_end = EINA_FALSE;
1053         else item->dummy_end = EINA_TRUE;
1054      }
1055    else
1056      return;
1057
1058    if (content == *icon_p) return;
1059    if ((dummy) && (!content)) return;
1060    if (dummy) evas_object_del(*icon_p);
1061    if (!content)
1062      {
1063         content = evas_object_rectangle_add(evas_object_evas_get(WIDGET(item)));
1064         evas_object_color_set(content, 0, 0, 0, 0);
1065      }
1066    if (*icon_p)
1067      {
1068         evas_object_del(*icon_p);
1069         *icon_p = NULL;
1070      }
1071    *icon_p = content;
1072    if (VIEW(item))
1073      edje_object_part_swallow(VIEW(item), "elm.swallow.icon", content);
1074 }
1075
1076 static Evas_Object *
1077 _item_content_get(const Elm_Object_Item *it, const char *part)
1078 {
1079    Elm_List_Item *item = (Elm_List_Item *)it;
1080
1081    if ((!part) || (!strcmp(part, "start")))
1082      {
1083         if (item->dummy_icon) return NULL;
1084         return item->icon;
1085      }
1086    else if (!strcmp(part, "end"))
1087      {
1088         if (item->dummy_end) return NULL;
1089         return item->end;
1090      }
1091    return NULL;
1092 }
1093
1094 static Evas_Object *
1095 _item_content_unset(const Elm_Object_Item *it, const char *part)
1096 {
1097    Elm_List_Item *item = (Elm_List_Item *)it;
1098
1099    if ((!part) || (!strcmp(part, "start")))
1100      {
1101         Evas_Object *obj = item->icon;
1102         _item_content_set((Elm_Object_Item *)it, part, NULL);
1103         return obj;
1104      }
1105    else if (!strcmp(part, "end"))
1106      {
1107         Evas_Object *obj = item->end;
1108         _item_content_set((Elm_Object_Item *)it, part, NULL);
1109         return obj;
1110      }
1111    return NULL;
1112 }
1113
1114 static void
1115 _item_text_set(Elm_Object_Item *it, const char *part, const char *text)
1116 {
1117    Elm_List_Item *list_it = (Elm_List_Item *)it;
1118    if (part && strcmp(part, "default")) return;
1119    if (!eina_stringshare_replace(&list_it->label, text)) return;
1120    if (VIEW(list_it))
1121      edje_object_part_text_set(VIEW(list_it), "elm.text", text);
1122 }
1123
1124 static const char *
1125 _item_text_get(const Elm_Object_Item *it, const char *part)
1126 {
1127    if (part && strcmp(part, "default")) return NULL;
1128    return ((Elm_List_Item *)it)->label;
1129 }
1130
1131 static Eina_Bool
1132 _item_del_pre_hook(Elm_Object_Item *it)
1133 {
1134    Evas_Object *obj = WIDGET(it);
1135    Elm_List_Item *item = (Elm_List_Item *)it;
1136    Widget_Data *wd = elm_widget_data_get(obj);
1137    if (!wd) return EINA_FALSE;
1138
1139    if (item->selected) _item_unselect(item);
1140
1141    if (wd->walking > 0)
1142      {
1143         if (item->deleted) return EINA_FALSE;
1144         item->deleted = EINA_TRUE;
1145         wd->to_delete = eina_list_append(wd->to_delete, item);
1146         return EINA_FALSE;
1147      }
1148
1149    wd->items = eina_list_remove_list(wd->items, item->node);
1150
1151    evas_object_ref(obj);
1152    _elm_list_walk(wd);
1153
1154    _elm_list_item_free(item);
1155
1156    _elm_list_unwalk(wd);
1157    evas_object_unref(obj);
1158
1159    return EINA_TRUE;
1160 }
1161
1162 static Elm_List_Item *
1163 _item_new(Evas_Object *obj, const char *label, Evas_Object *icon, Evas_Object *end, Evas_Smart_Cb func, const void *data)
1164 {
1165    Widget_Data *wd = elm_widget_data_get(obj);
1166    Elm_List_Item *it;
1167
1168    if (!wd) return NULL;
1169    it = elm_widget_item_new(obj, Elm_List_Item);
1170    it->wd = wd;
1171    it->label = eina_stringshare_add(label);
1172    it->icon = icon;
1173    it->end = end;
1174    it->func = func;
1175    it->base.data = data;
1176    VIEW(it) = edje_object_add(evas_object_evas_get(obj));
1177    edje_object_mirrored_set(VIEW(it), elm_widget_mirrored_get(obj));
1178    evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_DOWN,
1179                                   _mouse_down, it);
1180    evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_UP,
1181                                   _mouse_up, it);
1182    evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_MOVE,
1183                                   _mouse_move, it);
1184    evas_object_size_hint_weight_set(VIEW(it), EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1185    evas_object_size_hint_align_set(VIEW(it), EVAS_HINT_FILL, EVAS_HINT_FILL);
1186    if (it->icon)
1187      {
1188         elm_widget_sub_object_add(obj, it->icon);
1189         evas_object_event_callback_add(it->icon, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1190                                        _changed_size_hints, obj);
1191      }
1192    if (it->end)
1193      {
1194         elm_widget_sub_object_add(obj, it->end);
1195         evas_object_event_callback_add(it->end, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1196                                        _changed_size_hints, obj);
1197      }
1198    elm_widget_item_disable_hook_set(it, _item_disable);
1199    elm_widget_item_content_set_hook_set(it, _item_content_set);
1200    elm_widget_item_content_get_hook_set(it, _item_content_get);
1201    elm_widget_item_content_unset_hook_set(it, _item_content_unset);
1202    elm_widget_item_text_set_hook_set(it, _item_text_set);
1203    elm_widget_item_text_get_hook_set(it, _item_text_get);
1204    elm_widget_item_del_pre_hook_set(it, _item_del_pre_hook);
1205    return it;
1206 }
1207
1208 static void
1209 _elm_list_mode_set_internal(Widget_Data *wd)
1210 {
1211    if (!wd->scr)
1212      return;
1213
1214    if (wd->mode == ELM_LIST_LIMIT)
1215      {
1216         if (!wd->h_mode)
1217           {
1218              wd->scr_minw = EINA_TRUE;
1219              wd->scr_minh = EINA_FALSE;
1220           }
1221         else
1222           {
1223              wd->scr_minw = EINA_FALSE;
1224              wd->scr_minh = EINA_TRUE;
1225           }
1226      }
1227    else if (wd->mode == ELM_LIST_EXPAND)
1228      {
1229         wd->scr_minw = EINA_TRUE;
1230         wd->scr_minh = EINA_TRUE;
1231      }
1232    else
1233      {
1234         wd->scr_minw = EINA_FALSE;
1235         wd->scr_minh = EINA_FALSE;
1236      }
1237
1238    _sizing_eval(wd->self);
1239 }
1240
1241 static void
1242 _fix_items(Evas_Object *obj)
1243 {
1244    Widget_Data *wd = elm_widget_data_get(obj);
1245    if (!wd) return;
1246    const Eina_List *l;
1247    Elm_List_Item *it;
1248    Evas_Coord minw[2] = { 0, 0 }, minh[2] = { 0, 0 };
1249    Evas_Coord mw, mh;
1250    int i, redo = 0;
1251    const char *style = elm_widget_style_get(obj);
1252    const char *it_plain = wd->h_mode ? "h_item" : "item";
1253    const char *it_odd = wd->h_mode ? "h_item_odd" : "item_odd";
1254    const char *it_compress = wd->h_mode ? "h_item_compress" : "item_compress";
1255    const char *it_compress_odd = wd->h_mode ? "h_item_compress_odd" : "item_compress_odd";
1256
1257    if (wd->walking)
1258      {
1259         wd->fix_pending = EINA_TRUE;
1260         return;
1261      }
1262
1263    evas_object_ref(obj);
1264    _elm_list_walk(wd); // watch out "return" before unwalk!
1265
1266    EINA_LIST_FOREACH(wd->items, l, it)
1267      {
1268         if (it->deleted) continue;
1269         if (it->icon)
1270           {
1271              evas_object_size_hint_min_get(it->icon, &mw, &mh);
1272              if (mw > minw[0]) minw[0] = mw;
1273              if (mh > minh[0]) minh[0] = mh;
1274           }
1275         if (it->end)
1276           {
1277              evas_object_size_hint_min_get(it->end, &mw, &mh);
1278              if (mw > minw[1]) minw[1] = mw;
1279              if (mh > minh[1]) minh[1] = mh;
1280           }
1281      }
1282
1283    if ((minw[0] != wd->minw[0]) || (minw[1] != wd->minw[1]) ||
1284        (minw[0] != wd->minh[0]) || (minh[1] != wd->minh[1]))
1285      {
1286         wd->minw[0] = minw[0];
1287         wd->minw[1] = minw[1];
1288         wd->minh[0] = minh[0];
1289         wd->minh[1] = minh[1];
1290         redo = 1;
1291      }
1292    i = 0;
1293    EINA_LIST_FOREACH(wd->items, l, it)
1294      {
1295         if (it->deleted)
1296           continue;
1297
1298         it->even = i & 0x1;
1299         if ((it->even != it->is_even) || (!it->fixed) || (redo))
1300           {
1301              const char *stacking;
1302
1303              /* FIXME: separators' themes seem to be b0rked */
1304              if (it->is_separator)
1305                _elm_theme_object_set(obj, VIEW(it), "separator",
1306                                      wd->h_mode ? "horizontal" : "vertical",
1307                                      style);
1308              else if (wd->mode == ELM_LIST_COMPRESS)
1309                {
1310                   if (it->even)
1311                     _elm_theme_object_set(obj, VIEW(it), "list",
1312                                           it_compress, style);
1313                   else
1314                     _elm_theme_object_set(obj, VIEW(it), "list",
1315                                           it_compress_odd, style);
1316                }
1317              else
1318                {
1319                   if (it->even)
1320                     _elm_theme_object_set(obj, VIEW(it), "list", it_plain,
1321                                           style);
1322                   else
1323                     _elm_theme_object_set(obj, VIEW(it), "list", it_odd,
1324                                           style);
1325                }
1326              stacking = edje_object_data_get(VIEW(it), "stacking");
1327              if (stacking)
1328                {
1329                   if (!strcmp(stacking, "below"))
1330                     evas_object_lower(VIEW(it));
1331                   else if (!strcmp(stacking, "above"))
1332                     evas_object_raise(VIEW(it));
1333                }
1334              edje_object_part_text_set(VIEW(it), "elm.text", it->label);
1335
1336              if ((!it->icon) && (minh[0] > 0))
1337                {
1338                   it->icon = evas_object_rectangle_add(evas_object_evas_get(VIEW(it)));
1339                   evas_object_color_set(it->icon, 0, 0, 0, 0);
1340                   it->dummy_icon = EINA_TRUE;
1341                }
1342              if ((!it->end) && (minh[1] > 0))
1343                {
1344                   it->end = evas_object_rectangle_add(evas_object_evas_get(VIEW(it)));
1345                   evas_object_color_set(it->end, 0, 0, 0, 0);
1346                   it->dummy_end = EINA_TRUE;
1347                }
1348              if (it->icon)
1349                {
1350                   evas_object_size_hint_min_set(it->icon, minw[0], minh[0]);
1351                   evas_object_size_hint_max_set(it->icon, 99999, 99999);
1352                   edje_object_part_swallow(VIEW(it), "elm.swallow.icon", it->icon);
1353                }
1354              if (it->end)
1355                {
1356                   evas_object_size_hint_min_set(it->end, minw[1], minh[1]);
1357                   evas_object_size_hint_max_set(it->end, 99999, 99999);
1358                   edje_object_part_swallow(VIEW(it), "elm.swallow.end", it->end);
1359                }
1360              if (!it->fixed)
1361                {
1362                   // this may call up user and it may modify the list item
1363                   // but we're safe as we're flagged as walking.
1364                   // just don't process further
1365                   edje_object_message_signal_process(VIEW(it));
1366                   if (it->deleted)
1367                     continue;
1368                   mw = mh = -1;
1369                   elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1370                   edje_object_size_min_restricted_calc(VIEW(it), &mw, &mh, mw, mh);
1371                   elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1372                   evas_object_size_hint_min_set(VIEW(it), mw, mh);
1373                   evas_object_show(VIEW(it));
1374                }
1375              if ((it->selected) || (it->highlighted))
1376                {
1377                   const char *selectraise;
1378
1379                   // this may call up user and it may modify the list item
1380                   // but we're safe as we're flagged as walking.
1381                   // just don't process further
1382                   edje_object_signal_emit(VIEW(it), "elm,state,selected", "elm");
1383                   if (it->deleted)
1384                     continue;
1385
1386                   selectraise = edje_object_data_get(VIEW(it), "selectraise");
1387                   if ((selectraise) && (!strcmp(selectraise, "on")))
1388                     evas_object_raise(VIEW(it));
1389                }
1390              if (it->base.disabled)
1391                edje_object_signal_emit(VIEW(it), "elm,state,disabled",
1392                                        "elm");
1393
1394              it->fixed = EINA_TRUE;
1395              it->is_even = it->even;
1396           }
1397         i++;
1398      }
1399
1400    mw = 0; mh = 0;
1401    evas_object_size_hint_min_get(wd->box, &mw, &mh);
1402
1403    _elm_list_mode_set_internal(wd);
1404
1405    _elm_list_unwalk(wd);
1406    evas_object_unref(obj);
1407 }
1408
1409 static void
1410 _hold_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1411 {
1412    Widget_Data *wd = elm_widget_data_get(obj);
1413    if (!wd) return;
1414    if (wd->scr)
1415      elm_smart_scroller_hold_set(wd->scr, EINA_TRUE);
1416 }
1417
1418 static void
1419 _hold_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1420 {
1421    Widget_Data *wd = elm_widget_data_get(obj);
1422    if (!wd) return;
1423    if (wd->scr)
1424      elm_smart_scroller_hold_set(wd->scr, EINA_FALSE);
1425 }
1426
1427 static void
1428 _freeze_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1429 {
1430    Widget_Data *wd = elm_widget_data_get(obj);
1431    if (!wd) return;
1432    if (wd->scr)
1433      elm_smart_scroller_freeze_set(wd->scr, EINA_TRUE);
1434 }
1435
1436 static void
1437 _freeze_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1438 {
1439    Widget_Data *wd = elm_widget_data_get(obj);
1440    if (!wd) return;
1441    if (wd->scr)
1442      elm_smart_scroller_freeze_set(wd->scr, EINA_FALSE);
1443 }
1444
1445 static void
1446 _resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1447 {
1448    _sizing_eval(data);
1449 }
1450
1451 EAPI Evas_Object *
1452 elm_list_add(Evas_Object *parent)
1453 {
1454    Evas_Object *obj;
1455    Evas *e;
1456    Widget_Data *wd;
1457    Evas_Coord minw, minh;
1458
1459    ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
1460
1461    ELM_SET_WIDTYPE(widtype, "list");
1462    elm_widget_type_set(obj, "list");
1463    elm_widget_sub_object_add(parent, obj);
1464    elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
1465    elm_widget_data_set(obj, wd);
1466    elm_widget_del_pre_hook_set(obj, _del_pre_hook);
1467    elm_widget_del_hook_set(obj, _del_hook);
1468    elm_widget_theme_hook_set(obj, _theme_hook);
1469    elm_widget_disable_hook_set(obj, _disable_hook);
1470    elm_widget_can_focus_set(obj, EINA_TRUE);
1471    elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
1472    elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
1473    elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
1474    elm_widget_event_hook_set(obj, _event_hook);
1475    elm_widget_translate_hook_set(obj, _translate_hook);
1476
1477    wd->self = obj;
1478    wd->scr = elm_smart_scroller_add(e);
1479    elm_smart_scroller_widget_set(wd->scr, obj);
1480    elm_widget_resize_object_set(obj, wd->scr);
1481    evas_object_event_callback_add(wd->scr, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1482                                   _changed_size_hints, obj);
1483    edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr), &minw, &minh);
1484    evas_object_size_hint_min_set(obj, minw, minh);
1485    evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _resize, obj);
1486
1487    elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE,
1488                                        _elm_config->thumbscroll_bounce_enable);
1489
1490    wd->box = elm_box_add(parent);
1491    elm_box_homogeneous_set(wd->box, 1);
1492    evas_object_size_hint_weight_set(wd->box, EVAS_HINT_EXPAND, 0.0);
1493    evas_object_size_hint_align_set(wd->box, EVAS_HINT_FILL, 0.0);
1494    elm_widget_on_show_region_hook_set(wd->box, _show_region_hook, obj);
1495    elm_widget_sub_object_add(obj, wd->box);
1496    elm_smart_scroller_child_set(wd->scr, wd->box);
1497    evas_object_event_callback_add(wd->box, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1498                                   _changed_size_hints, obj);
1499
1500    evas_object_show(wd->box);
1501
1502    _theme_hook(obj);
1503
1504    wd->mode = ELM_LIST_SCROLL;
1505
1506    evas_object_smart_callback_add(wd->scr, "edge,left", _edge_left, obj);
1507    evas_object_smart_callback_add(wd->scr, "edge,right", _edge_right, obj);
1508    evas_object_smart_callback_add(wd->scr, "edge,top", _edge_top, obj);
1509    evas_object_smart_callback_add(wd->scr, "edge,bottom", _edge_bottom, obj);
1510
1511    evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
1512    evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
1513    evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
1514    evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
1515    evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
1516
1517    evas_object_smart_callbacks_descriptions_set(obj, _signals);
1518
1519    _mirrored_set(obj, elm_widget_mirrored_get(obj));
1520    _sizing_eval(obj);
1521    return obj;
1522 }
1523
1524 EAPI void
1525 elm_list_go(Evas_Object *obj)
1526 {
1527    ELM_CHECK_WIDTYPE(obj, widtype);
1528    Widget_Data *wd = elm_widget_data_get(obj);
1529    if (!wd) return;
1530    _fix_items(obj);
1531 }
1532
1533 EAPI void
1534 elm_list_multi_select_set(Evas_Object *obj, Eina_Bool multi)
1535 {
1536    ELM_CHECK_WIDTYPE(obj, widtype);
1537    Widget_Data *wd = elm_widget_data_get(obj);
1538    if (!wd) return;
1539    wd->multi = multi;
1540 }
1541
1542 EAPI Eina_Bool
1543 elm_list_multi_select_get(const Evas_Object *obj)
1544 {
1545    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1546    Widget_Data *wd = elm_widget_data_get(obj);
1547    if (!wd) return EINA_FALSE;
1548    return wd->multi;
1549 }
1550
1551 EAPI void
1552 elm_list_mode_set(Evas_Object *obj, Elm_List_Mode mode)
1553 {
1554    ELM_CHECK_WIDTYPE(obj, widtype);
1555
1556    Widget_Data *wd;
1557
1558    wd = elm_widget_data_get(obj);
1559    if (!wd)
1560      return;
1561    if (wd->mode == mode)
1562      return;
1563    wd->mode = mode;
1564
1565    _elm_list_mode_set_internal(wd);
1566 }
1567
1568 EAPI Elm_List_Mode
1569 elm_list_mode_get(const Evas_Object *obj)
1570 {
1571    ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
1572    Widget_Data *wd = elm_widget_data_get(obj);
1573    if (!wd) return ELM_LIST_LAST;
1574    return wd->mode;
1575 }
1576
1577 EAPI void
1578 elm_list_horizontal_set(Evas_Object *obj, Eina_Bool horizontal)
1579 {
1580    ELM_CHECK_WIDTYPE(obj, widtype);
1581
1582    Widget_Data *wd;
1583    Eina_Bool bounce = _elm_config->thumbscroll_bounce_enable;
1584
1585    wd = elm_widget_data_get(obj);
1586    if (!wd)
1587      return;
1588
1589    if (wd->h_mode == horizontal)
1590      return;
1591
1592    wd->h_mode = horizontal;
1593    elm_box_horizontal_set(wd->box, horizontal);
1594
1595    if (horizontal)
1596      {
1597         evas_object_size_hint_weight_set(wd->box, 0.0, EVAS_HINT_EXPAND);
1598         evas_object_size_hint_align_set(wd->box, 0.0, EVAS_HINT_FILL);
1599         elm_smart_scroller_bounce_allow_set(wd->scr, bounce, EINA_FALSE);
1600      }
1601    else
1602      {
1603         evas_object_size_hint_weight_set(wd->box, EVAS_HINT_EXPAND, 0.0);
1604         evas_object_size_hint_align_set(wd->box, EVAS_HINT_FILL, 0.0);
1605         elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE, bounce);
1606      }
1607
1608    _elm_list_mode_set_internal(wd);
1609 }
1610
1611 EAPI Eina_Bool
1612 elm_list_horizontal_get(const Evas_Object *obj)
1613 {
1614    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1615
1616    Widget_Data *wd;
1617
1618    wd = elm_widget_data_get(obj);
1619    if (!wd)
1620      return EINA_FALSE;
1621
1622    return wd->h_mode;
1623 }
1624
1625 EAPI void
1626 elm_list_select_mode_set(Evas_Object *obj, Elm_Object_Select_Mode mode)
1627 {
1628    ELM_CHECK_WIDTYPE(obj, widtype);
1629    Widget_Data *wd = elm_widget_data_get(obj);
1630    if (!wd) return;
1631    if (mode >= ELM_OBJECT_SELECT_MODE_MAX)
1632      return;
1633    if (wd->select_mode != mode)
1634      wd->select_mode = mode;
1635 }
1636
1637 EAPI Elm_Object_Select_Mode
1638 elm_list_select_mode_get(const Evas_Object *obj)
1639 {
1640    ELM_CHECK_WIDTYPE(obj, widtype) ELM_OBJECT_SELECT_MODE_MAX;
1641    Widget_Data *wd = elm_widget_data_get(obj);
1642    if (!wd) return ELM_OBJECT_SELECT_MODE_MAX;
1643    return wd->select_mode;
1644 }
1645
1646 EINA_DEPRECATED EAPI void
1647 elm_list_always_select_mode_set(Evas_Object *obj,
1648                                 Eina_Bool    always_select)
1649 {
1650    ELM_CHECK_WIDTYPE(obj, widtype);
1651    Widget_Data *wd = elm_widget_data_get(obj);
1652    if (!wd) return;
1653    if (always_select)
1654      elm_list_select_mode_set(obj, ELM_OBJECT_SELECT_MODE_ALWAYS);
1655    else
1656      {
1657         Elm_Object_Select_Mode oldmode = elm_list_select_mode_get(obj);
1658         if (oldmode == ELM_OBJECT_SELECT_MODE_ALWAYS)
1659           elm_list_select_mode_set(obj, ELM_OBJECT_SELECT_MODE_DEFAULT);
1660      }
1661 }
1662
1663 EINA_DEPRECATED EAPI Eina_Bool
1664 elm_list_always_select_mode_get(const Evas_Object *obj)
1665 {
1666    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1667    Widget_Data *wd = elm_widget_data_get(obj);
1668    if (!wd) return EINA_FALSE;
1669    Elm_Object_Select_Mode oldmode = elm_list_select_mode_get(obj);
1670    if (oldmode == ELM_OBJECT_SELECT_MODE_ALWAYS)
1671      return EINA_TRUE;
1672    return EINA_FALSE;
1673 }
1674
1675 EAPI void
1676 elm_list_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce)
1677 {
1678    ELM_CHECK_WIDTYPE(obj, widtype);
1679    Widget_Data *wd = elm_widget_data_get(obj);
1680    if (!wd) return;
1681    if (wd->scr)
1682      elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
1683 }
1684
1685 EAPI void
1686 elm_list_bounce_get(const Evas_Object *obj, Eina_Bool *h_bounce, Eina_Bool *v_bounce)
1687 {
1688    ELM_CHECK_WIDTYPE(obj, widtype);
1689    Widget_Data *wd = elm_widget_data_get(obj);
1690    if (!wd) return;
1691    elm_smart_scroller_bounce_allow_get(wd->scr, h_bounce, v_bounce);
1692 }
1693
1694 EAPI void
1695 elm_list_scroller_policy_set(Evas_Object *obj, Elm_Scroller_Policy policy_h, Elm_Scroller_Policy policy_v)
1696 {
1697    ELM_CHECK_WIDTYPE(obj, widtype);
1698    Widget_Data *wd = elm_widget_data_get(obj);
1699    if ((!wd) || (!wd->scr)) return;
1700    if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
1701        (policy_v >= ELM_SCROLLER_POLICY_LAST))
1702      return;
1703    elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
1704 }
1705
1706 EAPI void
1707 elm_list_scroller_policy_get(const Evas_Object *obj, Elm_Scroller_Policy *policy_h, Elm_Scroller_Policy *policy_v)
1708 {
1709    ELM_CHECK_WIDTYPE(obj, widtype);
1710    Widget_Data *wd = elm_widget_data_get(obj);
1711    Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
1712    if ((!wd) || (!wd->scr)) return;
1713    elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
1714    if (policy_h) *policy_h = (Elm_Scroller_Policy) s_policy_h;
1715    if (policy_v) *policy_v = (Elm_Scroller_Policy) s_policy_v;
1716 }
1717
1718 EAPI void
1719 elm_list_clear(Evas_Object *obj)
1720 {
1721    ELM_CHECK_WIDTYPE(obj, widtype);
1722    Widget_Data *wd = elm_widget_data_get(obj);
1723    Elm_List_Item *it;
1724
1725    if (!wd) return;
1726    if (!wd->items) return;
1727
1728    eina_list_free(wd->selected);
1729    wd->selected = NULL;
1730
1731    if (wd->walking > 0)
1732      {
1733         Eina_List *n;
1734
1735         EINA_LIST_FOREACH(wd->items, n, it)
1736           {
1737              if (it->deleted) continue;
1738              it->deleted = EINA_TRUE;
1739              wd->to_delete = eina_list_append(wd->to_delete, it);
1740           }
1741         return;
1742      }
1743
1744    evas_object_ref(obj);
1745    _elm_list_walk(wd);
1746
1747    EINA_LIST_FREE(wd->items, it)
1748      {
1749         _elm_list_item_free(it);
1750         elm_widget_item_free(it);
1751      }
1752
1753    _elm_list_unwalk(wd);
1754
1755    _fix_items(obj);
1756    _sizing_eval(obj);
1757    evas_object_unref(obj);
1758 }
1759
1760 EAPI const Eina_List *
1761 elm_list_items_get(const Evas_Object *obj)
1762 {
1763    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1764    Widget_Data *wd = elm_widget_data_get(obj);
1765    if (!wd) return NULL;
1766    return wd->items;
1767 }
1768
1769 EAPI Elm_Object_Item *
1770 elm_list_selected_item_get(const Evas_Object *obj)
1771 {
1772    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1773    Widget_Data *wd = elm_widget_data_get(obj);
1774    if (!wd) return NULL;
1775    if (wd->selected) return (Elm_Object_Item *) wd->selected->data;
1776    return NULL;
1777 }
1778
1779 EAPI const Eina_List *
1780 elm_list_selected_items_get(const Evas_Object *obj)
1781 {
1782    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1783    Widget_Data *wd = elm_widget_data_get(obj);
1784    if (!wd) return NULL;
1785    return wd->selected;
1786 }
1787
1788 EAPI Elm_Object_Item *
1789 elm_list_item_append(Evas_Object *obj, const char *label, Evas_Object *icon, Evas_Object *end, Evas_Smart_Cb func, const void *data)
1790 {
1791    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1792    Widget_Data *wd = elm_widget_data_get(obj);
1793    Elm_List_Item *it = _item_new(obj, label, icon, end, func, data);
1794
1795    wd->items = eina_list_append(wd->items, it);
1796    it->node = eina_list_last(wd->items);
1797    elm_box_pack_end(wd->box, VIEW(it));
1798    return (Elm_Object_Item *)it;
1799 }
1800
1801 EAPI Elm_Object_Item *
1802 elm_list_item_prepend(Evas_Object *obj, const char *label, Evas_Object *icon, Evas_Object *end, Evas_Smart_Cb func, const void *data)
1803 {
1804    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1805    Widget_Data *wd = elm_widget_data_get(obj);
1806    Elm_List_Item *it = _item_new(obj, label, icon, end, func, data);
1807
1808    wd->items = eina_list_prepend(wd->items, it);
1809    it->node = wd->items;
1810    elm_box_pack_start(wd->box, VIEW(it));
1811    return (Elm_Object_Item *)it;
1812 }
1813
1814 EAPI Elm_Object_Item *
1815 elm_list_item_insert_before(Evas_Object *obj, Elm_Object_Item *before, const char *label, Evas_Object *icon, Evas_Object *end, Evas_Smart_Cb func, const void *data)
1816 {
1817    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1818    ELM_LIST_ITEM_CHECK_DELETED_RETURN(before, NULL);
1819
1820    Widget_Data *wd;
1821    Elm_List_Item *it, *before_it;
1822
1823    wd = elm_widget_data_get(obj);
1824    if (!wd) return NULL;
1825
1826    before_it = (Elm_List_Item *) before;
1827    if (!before_it->node) return NULL;
1828
1829    it = _item_new(obj, label, icon, end, func, data);
1830    wd->items = eina_list_prepend_relative_list(wd->items, it, before_it->node);
1831    it->node = before_it->node->prev;
1832    elm_box_pack_before(wd->box, VIEW(it), VIEW(before_it));
1833    return (Elm_Object_Item *)it;
1834 }
1835
1836 EAPI Elm_Object_Item *
1837 elm_list_item_insert_after(Evas_Object *obj, Elm_Object_Item *after, const char *label, Evas_Object *icon, Evas_Object *end, Evas_Smart_Cb func, const void *data)
1838 {
1839    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1840    ELM_LIST_ITEM_CHECK_DELETED_RETURN(after, NULL);
1841
1842    Widget_Data *wd;
1843    Elm_List_Item *it, *after_it;
1844
1845    wd = elm_widget_data_get(obj);
1846    if (!wd) return NULL;
1847
1848    after_it = (Elm_List_Item *) after;
1849    if (!after_it->node) return NULL;
1850
1851    it = _item_new(obj, label, icon, end, func, data);
1852    wd->items = eina_list_append_relative_list(wd->items, it, after_it->node);
1853    it->node = after_it->node->next;
1854    elm_box_pack_after(wd->box, VIEW(it), VIEW(after_it));
1855    return (Elm_Object_Item *)it;
1856 }
1857
1858 EAPI Elm_Object_Item *
1859 elm_list_item_sorted_insert(Evas_Object *obj, const char *label, Evas_Object *icon, Evas_Object *end, Evas_Smart_Cb func, const void *data, Eina_Compare_Cb cmp_func)
1860 {
1861    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1862    Widget_Data *wd = elm_widget_data_get(obj);
1863    Elm_List_Item *it = _item_new(obj, label, icon, end, func, data);
1864    Eina_List *l;
1865
1866    wd->items = eina_list_sorted_insert(wd->items, cmp_func, it);
1867    l = eina_list_data_find_list(wd->items, it);
1868    l = eina_list_next(l);
1869    if (!l)
1870      {
1871         it->node = eina_list_last(wd->items);
1872         elm_box_pack_end(wd->box, VIEW(it));
1873      }
1874    else
1875      {
1876         Elm_List_Item *before = eina_list_data_get(l);
1877         it->node = before->node->prev;
1878         elm_box_pack_before(wd->box, VIEW(it), VIEW(before));
1879      }
1880    return (Elm_Object_Item *)it;
1881 }
1882
1883 EAPI void
1884 elm_list_item_separator_set(Elm_Object_Item *it, Eina_Bool setting)
1885 {
1886    ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1887    ((Elm_List_Item *)it)->is_separator = !!setting;
1888 }
1889
1890 EAPI Eina_Bool
1891 elm_list_item_separator_get(const Elm_Object_Item *it)
1892 {
1893    ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, EINA_FALSE);
1894    return ((Elm_List_Item *)it)->is_separator;
1895 }
1896
1897 EAPI void
1898 elm_list_item_selected_set(Elm_Object_Item *it, Eina_Bool selected)
1899 {
1900    ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1901    Evas_Object *obj = WIDGET(it);
1902    Widget_Data *wd = elm_widget_data_get(obj);
1903    Elm_List_Item *item = (Elm_List_Item *)it;
1904    if (!wd) return;
1905
1906    selected = !!selected;
1907    if (item->selected == selected) return;
1908
1909    evas_object_ref(obj);
1910    _elm_list_walk(wd);
1911
1912    if (selected)
1913      {
1914         if (!wd->multi)
1915           {
1916              while (wd->selected)
1917                _item_unselect(wd->selected->data);
1918           }
1919         _item_highlight(item);
1920         _item_select(item);
1921      }
1922    else
1923      _item_unselect(item);
1924
1925    _elm_list_unwalk(wd);
1926    evas_object_unref(obj);
1927 }
1928
1929 EAPI Eina_Bool
1930 elm_list_item_selected_get(const Elm_Object_Item *it)
1931 {
1932    ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, EINA_FALSE);
1933    return ((Elm_List_Item *)it)->selected;
1934 }
1935
1936 EAPI void
1937 elm_list_item_show(Elm_Object_Item *it)
1938 {
1939    ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1940    Widget_Data *wd = elm_widget_data_get(WIDGET(it));
1941    if (!wd) return;
1942    Evas_Coord bx, by, bw, bh;
1943    Evas_Coord x, y, w, h;
1944
1945    evas_object_geometry_get(wd->box, &bx, &by, &bw, &bh);
1946    evas_object_geometry_get(VIEW(it), &x, &y, &w, &h);
1947    x -= bx;
1948    y -= by;
1949    if (wd->scr) elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
1950 }
1951
1952 EAPI void
1953 elm_list_item_bring_in(Elm_Object_Item *it)
1954 {
1955    ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1956    Widget_Data *wd = elm_widget_data_get(WIDGET(it));
1957    if (!wd) return;
1958    Evas_Coord bx, by, bw, bh;
1959    Evas_Coord x, y, w, h;
1960
1961    evas_object_geometry_get(wd->box, &bx, &by, &bw, &bh);
1962    evas_object_geometry_get(VIEW(it), &x, &y, &w, &h);
1963    x -= bx;
1964    y -= by;
1965    if (wd->scr) elm_smart_scroller_region_bring_in(wd->scr, x, y, w, h);
1966 }
1967
1968 EAPI Evas_Object *
1969 elm_list_item_object_get(const Elm_Object_Item *it)
1970 {
1971    ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, NULL);
1972    return VIEW(it);
1973 }
1974
1975 EAPI Elm_Object_Item *
1976 elm_list_item_prev(const Elm_Object_Item *it)
1977 {
1978    ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, NULL);
1979    Elm_List_Item *item = (Elm_List_Item *)it;
1980    if (item->node->prev) return item->node->prev->data;
1981    else return NULL;
1982 }
1983
1984 EAPI Elm_Object_Item *
1985 elm_list_item_next(const Elm_Object_Item *it)
1986 {
1987    ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, NULL);
1988    Elm_List_Item *item = (Elm_List_Item *)it;
1989    if (item->node->next) return item->node->next->data;
1990    else return NULL;
1991 }
1992
1993 EINA_DEPRECATED EAPI void
1994 elm_list_item_del(Elm_Object_Item *it)
1995 {
1996    elm_object_item_del(it);
1997 }
1998
1999 EINA_DEPRECATED EAPI Evas_Object *
2000 elm_list_item_base_get(const Elm_Object_Item *it)
2001 {
2002    return elm_list_item_object_get(it);
2003 }
2004
2005 EINA_DEPRECATED EAPI void
2006 elm_list_item_disabled_set(Elm_Object_Item *it, Eina_Bool disabled)
2007 {
2008    elm_object_item_disabled_set(it, disabled);
2009 }
2010
2011 EINA_DEPRECATED EAPI Eina_Bool
2012 elm_list_item_disabled_get(const Elm_Object_Item *it)
2013 {
2014    return elm_object_item_disabled_get(it);
2015 }
2016
2017 EINA_DEPRECATED EAPI void
2018 elm_list_item_del_cb_set(Elm_Object_Item *it, Evas_Smart_Cb func)
2019 {
2020    elm_object_item_del_cb_set(it, func);
2021 }
2022
2023 EINA_DEPRECATED EAPI void *
2024 elm_list_item_data_get(const Elm_Object_Item *it)
2025 {
2026    return elm_object_item_data_get(it);
2027 }
2028
2029 EINA_DEPRECATED EAPI Evas_Object *
2030 elm_list_item_icon_get(const Elm_Object_Item *it)
2031 {
2032    return _item_content_get(it, NULL);
2033 }
2034
2035 EINA_DEPRECATED EAPI void
2036 elm_list_item_icon_set(Elm_Object_Item *it, Evas_Object *icon)
2037 {
2038    _item_content_set(it, NULL, icon);
2039 }
2040
2041 EINA_DEPRECATED EAPI Evas_Object *
2042 elm_list_item_end_get(const Elm_Object_Item *it)
2043 {
2044    return _item_content_get(it, "end");
2045 }
2046
2047 EINA_DEPRECATED EAPI void
2048 elm_list_item_end_set(Elm_Object_Item *it, Evas_Object *end)
2049 {
2050    _item_content_set(it, "end", end);
2051 }
2052
2053 EINA_DEPRECATED EAPI const char *
2054 elm_list_item_label_get(const Elm_Object_Item *it)
2055 {
2056    return _item_text_get(it, NULL);
2057 }
2058
2059 EINA_DEPRECATED EAPI void
2060 elm_list_item_label_set(Elm_Object_Item *it, const char *text)
2061 {
2062    _item_text_set(it, NULL, text);
2063 }
2064
2065 EINA_DEPRECATED EAPI void
2066 elm_list_item_tooltip_text_set(Elm_Object_Item *it, const char *text)
2067 {
2068    ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
2069    elm_widget_item_tooltip_text_set(it, text);
2070 }
2071
2072 EINA_DEPRECATED EAPI void
2073 elm_list_item_tooltip_content_cb_set(Elm_Object_Item *it, Elm_Tooltip_Item_Content_Cb func, const void *data, Evas_Smart_Cb del_cb)
2074 {
2075    ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
2076    elm_widget_item_tooltip_content_cb_set(it, func, data, del_cb);
2077 }
2078
2079 EINA_DEPRECATED EAPI void
2080 elm_list_item_tooltip_unset(Elm_Object_Item *it)
2081 {
2082    ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
2083    elm_widget_item_tooltip_unset(it);
2084 }
2085
2086 EINA_DEPRECATED EAPI Eina_Bool
2087 elm_list_item_tooltip_window_mode_set(Elm_Object_Item *it, Eina_Bool disable)
2088 {
2089    ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, EINA_FALSE);
2090    return elm_widget_item_tooltip_window_mode_set(it, disable);
2091 }
2092
2093 EINA_DEPRECATED EAPI Eina_Bool
2094 elm_list_item_tooltip_window_mode_get(const Elm_Object_Item *it)
2095 {
2096    ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, EINA_FALSE);
2097    return elm_widget_item_tooltip_window_mode_get(it);
2098 }
2099
2100 EINA_DEPRECATED EAPI void
2101 elm_list_item_tooltip_style_set(Elm_Object_Item *it, const char *style)
2102 {
2103    ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
2104    elm_widget_item_tooltip_style_set(it, style);
2105 }
2106
2107 EINA_DEPRECATED EAPI const char *
2108 elm_list_item_tooltip_style_get(const Elm_Object_Item *it)
2109 {
2110    ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, NULL);
2111    return elm_widget_item_tooltip_style_get(it);
2112 }
2113
2114 EINA_DEPRECATED EAPI void
2115 elm_list_item_cursor_set(Elm_Object_Item *it, const char *cursor)
2116 {
2117    ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
2118    elm_widget_item_cursor_set(it, cursor);
2119 }
2120
2121 EINA_DEPRECATED EAPI const char *
2122 elm_list_item_cursor_get(const Elm_Object_Item *it)
2123 {
2124    ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, NULL);
2125    return elm_widget_item_cursor_get(it);
2126 }
2127
2128 EINA_DEPRECATED EAPI void
2129 elm_list_item_cursor_unset(Elm_Object_Item *it)
2130 {
2131    ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
2132    elm_widget_item_cursor_unset(it);
2133 }
2134
2135 EINA_DEPRECATED EAPI void
2136 elm_list_item_cursor_style_set(Elm_Object_Item *it, const char *style)
2137 {
2138    ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
2139    elm_widget_item_cursor_style_set(it, style);
2140 }
2141
2142 EINA_DEPRECATED EAPI const char *
2143 elm_list_item_cursor_style_get(const Elm_Object_Item *it)
2144 {
2145    ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, NULL);
2146    return elm_widget_item_cursor_style_get(it);
2147 }
2148
2149 EINA_DEPRECATED EAPI void
2150 elm_list_item_cursor_engine_only_set(Elm_Object_Item *it, Eina_Bool engine_only)
2151 {
2152    ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
2153    elm_widget_item_cursor_engine_only_set(it, engine_only);
2154 }
2155
2156 EINA_DEPRECATED EAPI Eina_Bool
2157 elm_list_item_cursor_engine_only_get(const Elm_Object_Item *it)
2158 {
2159    ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, EINA_FALSE);
2160    return elm_widget_item_cursor_engine_only_get(it);
2161 }