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