elementary: cleanup a little bit the slideshow.
[framework/uifw/elementary.git] / src / lib / elm_slideshow.c
1 #include <Elementary.h>
2 #include "elm_priv.h"
3
4 typedef struct _Widget_Data Widget_Data;
5
6 struct _Elm_Slideshow_Item
7 {
8    Elm_Widget_Item base;
9
10    Eina_List *l, *l_built;
11
12    const Elm_Slideshow_Item_Class *itc;
13 };
14
15 struct _Widget_Data
16 {
17    Evas_Object *slideshow;
18
19    // list of Elm_Slideshow_Item*
20    Eina_List *items;
21    Eina_List *items_built;
22
23    Elm_Slideshow_Item *current;
24    Elm_Slideshow_Item *previous;
25
26    Eina_List *transitions;
27    const char *transition;
28
29    int count_item_pre_before;
30    int count_item_pre_after;
31    Ecore_Timer *timer;
32    double timeout;
33    Eina_Bool loop:1;
34
35    struct {
36         const char *current;
37         Eina_List *list; //list of const char *
38    } layout;
39 };
40
41 static const char *widtype = NULL;
42 static void _del_hook(Evas_Object *obj);
43 static void _mirrored_set(Evas_Object *obj, Eina_Bool rtl);
44 static void _theme_hook(Evas_Object *obj);
45 static void _sizing_eval(Evas_Object *obj);
46 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
47 static Eina_Bool _timer_cb(void *data);
48 static void _on_focus_hook(void *data, Evas_Object *obj);
49 static Eina_Bool _event_hook(Evas_Object *obj, Evas_Object *src,
50                              Evas_Callback_Type type, void *event_info);
51
52 static const char SIG_CHANGED[] = "changed";
53
54 static const Evas_Smart_Cb_Description _signals[] = {
55    {SIG_CHANGED, ""},
56    {NULL, NULL}
57 };
58
59 static Eina_Bool
60 _event_hook(Evas_Object *obj, Evas_Object *src __UNUSED__, Evas_Callback_Type type, void *event_info)
61 {
62    if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
63    Evas_Event_Key_Down *ev = event_info;
64    Widget_Data *wd = elm_widget_data_get(obj);
65    if (!wd) return EINA_FALSE;
66    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
67    if (elm_widget_disabled_get(obj)) return EINA_FALSE;
68    if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
69      {
70         elm_slideshow_previous(obj);
71         ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
72         return EINA_TRUE;
73      }
74    if ((!strcmp(ev->keyname, "Right")) || (!strcmp(ev->keyname, "KP_Right")))
75      {
76         elm_slideshow_next(obj);
77         ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
78         return EINA_TRUE;
79      }
80    if ((!strcmp(ev->keyname, "Return")) ||
81        (!strcmp(ev->keyname, "KP_Enter")) ||
82        (!strcmp(ev->keyname, "space")))
83      {
84         if (wd->timeout)
85           {
86              if (wd->timer)
87                {
88                   ecore_timer_del(wd->timer);
89                   wd->timer = NULL;
90                }
91              else
92                elm_slideshow_timeout_set(obj, wd->timeout);
93           }
94         ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
95         return EINA_TRUE;
96      }
97    return EINA_FALSE;
98 }
99
100 static void
101 _del_hook(Evas_Object *obj)
102 {
103    const char *layout;
104    Widget_Data *wd = elm_widget_data_get(obj);
105    if (!wd) return;
106    elm_slideshow_clear(obj);
107    elm_widget_stringlist_free(wd->transitions);
108    if (wd->timer) ecore_timer_del(wd->timer);
109    EINA_LIST_FREE(wd->layout.list, layout)
110       eina_stringshare_del(layout);
111    free(wd);
112 }
113
114 static void
115 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
116 {
117    Widget_Data *wd = elm_widget_data_get(obj);
118    if (!wd) return;
119    if (elm_widget_focus_get(obj))
120      {
121         edje_object_signal_emit(wd->slideshow, "elm,action,focus", "elm");
122         evas_object_focus_set(wd->slideshow, EINA_TRUE);
123      }
124    else
125      {
126         edje_object_signal_emit(wd->slideshow, "elm,action,unfocus", "elm");
127         evas_object_focus_set(wd->slideshow, EINA_FALSE);
128      }
129 }
130
131 static void
132 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
133 {
134    Widget_Data *wd = elm_widget_data_get(obj);
135    if (!wd) return;
136    edje_object_mirrored_set(wd->slideshow, rtl);
137 }
138
139 static void
140 _theme_hook(Evas_Object *obj)
141 {
142    Widget_Data *wd = elm_widget_data_get(obj);
143    if (!wd) return;
144    _elm_widget_mirrored_reload(obj);
145    _mirrored_set(obj, elm_widget_mirrored_get(obj));
146    _elm_theme_object_set(obj, wd->slideshow, "slideshow", "base", elm_widget_style_get(obj));
147    edje_object_scale_set(wd->slideshow, elm_widget_scale_get(obj) *
148                          _elm_config->scale);
149    _sizing_eval(obj);
150 }
151
152 static void
153 _sizing_eval(Evas_Object *obj)
154 {
155    Widget_Data *wd = elm_widget_data_get(obj);
156    Evas_Coord minw = -1, minh = -1;
157    if (!wd) return;
158    edje_object_size_min_calc(wd->slideshow, &minw, &minh);
159    evas_object_size_hint_min_set(obj, minw, minh);
160    evas_object_size_hint_max_set(obj, minw, minh);
161 }
162
163
164 static Elm_Slideshow_Item* _item_prev_get(Elm_Slideshow_Item* item)
165 {
166    Widget_Data *wd = elm_widget_data_get(item->base.widget);
167    Elm_Slideshow_Item* prev = eina_list_data_get(eina_list_prev(item->l));
168    if ((!prev) && (wd->loop))
169      prev = eina_list_data_get(eina_list_last(item->l));
170    return prev;
171 }
172
173 static Elm_Slideshow_Item* _item_next_get(Elm_Slideshow_Item* item)
174 {
175    Widget_Data *wd = elm_widget_data_get(item->base.widget);
176    Elm_Slideshow_Item* next = eina_list_data_get(eina_list_next(item->l));
177    if ((!next) && (wd->loop))
178      next = eina_list_data_get(wd->items);
179    return next;
180 }
181
182 static void
183 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
184 {
185    _sizing_eval(data);
186 }
187
188 static void
189 _sub_del(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
190 {
191    ;
192 }
193
194 static void
195 _item_realize(Elm_Slideshow_Item *item)
196 {
197    Elm_Slideshow_Item *_item_prev, *_item_next;
198    Evas_Object *obj = item->base.widget;
199    Widget_Data *wd = elm_widget_data_get(obj);
200    int ac, bc, lc, ic = 0;
201
202    if (!wd) return;
203    if ((!item->base.view) && (item->itc->func.get))
204      {
205         item->base.view = item->itc->func.get((void*)item->base.data, obj);
206         evas_object_smart_member_add(item->base.view, obj);
207         item->l_built = eina_list_append(NULL, item);
208         wd->items_built = eina_list_merge(wd->items_built, item->l_built);
209         evas_object_hide(item->base.view);
210      }
211    else if (item->l_built)
212      wd->items_built = eina_list_demote_list(wd->items_built, item->l_built);
213
214    //pre-create previous and next item
215    ac = wd->count_item_pre_after;
216    _item_next = item;
217    bc = wd->count_item_pre_before;
218    _item_prev = item;
219    lc = eina_list_count(wd->items) - 1;
220    while (lc > 0 && ((ac > 0) || (bc > 0)))
221      {
222         if (lc > 0 && ac > 0)
223           {
224              --ac;
225              --lc;
226              if (_item_next)
227                {
228                   _item_next = _item_next_get(_item_next);
229                   if ((_item_next)
230                       && (!_item_next->base.view)
231                       && (_item_next->itc->func.get))
232                     {
233                        ic++;
234                        _item_next->base.view =
235                           _item_next->itc->func.get(
236                              (void*)_item_next->base.data, obj);
237                        evas_object_smart_member_add(_item_next->base.view, obj);
238                        _item_next->l_built = eina_list_append(NULL, _item_next);
239                        wd->items_built = eina_list_merge(wd->items_built,
240                                                          _item_next->l_built);
241                        evas_object_hide(_item_next->base.view);
242                     }
243                   else if (_item_next && _item_next->l_built)
244                     {
245                        ic++;
246                        wd->items_built =
247                            eina_list_demote_list(wd->items_built,
248                                              _item_next->l_built);
249                     }
250                }
251           }
252
253         if (lc > 0 && bc > 0)
254           {
255              --bc;
256              --lc;
257              if (_item_prev)
258                {
259                   _item_prev = _item_prev_get(_item_prev);
260                   if ((_item_prev)
261                       && (!_item_prev->base.view)
262                       && (_item_prev->itc->func.get))
263                     {
264                        ic++;
265                        _item_prev->base.view =
266                           _item_prev->itc->func.get(
267                              (void*)_item_prev->base.data, obj);
268                        evas_object_smart_member_add(_item_prev->base.view, obj);
269                        _item_prev->l_built = eina_list_append(NULL, _item_prev);
270                        wd->items_built = eina_list_merge(wd->items_built,
271                                                          _item_prev->l_built);
272                        evas_object_hide(_item_prev->base.view);
273                     }
274                   else if (_item_prev && _item_prev->l_built)
275                     {
276                        ic++;
277                        wd->items_built =
278                            eina_list_demote_list(wd->items_built,
279                                              _item_prev->l_built);
280                     }
281                }
282           }
283      }
284
285    //delete unused items
286    lc = ic + 1;
287    while ((int)eina_list_count(wd->items_built) > lc)
288      {
289         item = eina_list_data_get(wd->items_built);
290         wd->items_built = eina_list_remove_list(wd->items_built,
291                                                 wd->items_built);
292         if (item->itc->func.del)
293           item->itc->func.del((void*)item->base.data, item->base.view);
294         evas_object_del(item->base.view);
295         item->base.view = NULL;
296      }
297 }
298
299 static void
300 _end(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
301 {
302    Elm_Slideshow_Item *item;
303    Widget_Data *wd = elm_widget_data_get(data);
304    if (!wd) return;
305
306    item = wd->previous;
307    if (item)
308      {
309         edje_object_part_unswallow(wd->slideshow, item->base.view);
310         evas_object_hide(item->base.view);
311         wd->previous = NULL;
312      }
313
314    item = wd->current;
315    if ((!item) || (!item->base.view)) return;
316
317    _item_realize(item);
318    edje_object_part_unswallow(wd->slideshow, item->base.view);
319
320    edje_object_part_swallow(wd->slideshow, "elm.swallow.1", item->base.view);
321    edje_object_signal_emit(wd->slideshow, "anim,end", "slideshow");
322 }
323
324 static Eina_Bool
325 _timer_cb(void *data)
326 {
327    Evas_Object *obj = data;
328    Widget_Data *wd = elm_widget_data_get(obj);
329    if (!wd) return ECORE_CALLBACK_CANCEL;
330    wd->timer = NULL;
331    elm_slideshow_next(obj);
332    return ECORE_CALLBACK_CANCEL;
333 }
334
335 EAPI Evas_Object *
336 elm_slideshow_add(Evas_Object *parent)
337 {
338    Evas_Object *obj;
339    Evas *e;
340    Widget_Data *wd;
341
342    ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
343
344    ELM_SET_WIDTYPE(widtype, "slideshow");
345    elm_widget_type_set(obj, "slideshow");
346    elm_widget_sub_object_add(parent, obj);
347    elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
348    elm_widget_data_set(obj, wd);
349    elm_widget_del_hook_set(obj, _del_hook);
350    elm_widget_theme_hook_set(obj, _theme_hook);
351    elm_widget_can_focus_set(obj, EINA_TRUE);
352    elm_widget_event_hook_set(obj, _event_hook);
353
354    wd->current = NULL;
355    wd->previous = NULL;
356
357    wd->slideshow = edje_object_add(e);
358    _elm_theme_object_set(obj, wd->slideshow, "slideshow", "base", "default");
359    evas_object_smart_member_add(wd->slideshow, obj);
360    wd->count_item_pre_before = 2;
361    wd->count_item_pre_after = 2;
362    elm_widget_resize_object_set(obj, wd->slideshow);
363    evas_object_show(wd->slideshow);
364
365    wd->transitions = elm_widget_stringlist_get(edje_object_data_get(wd->slideshow, "transitions"));
366    if (eina_list_count(wd->transitions) > 0)
367      wd->transition = eina_stringshare_add(eina_list_data_get(wd->transitions));
368
369    wd->layout.list = elm_widget_stringlist_get(edje_object_data_get(wd->slideshow, "layouts"));
370    if (eina_list_count(wd->layout.list) > 0)
371      wd->layout.current = eina_list_data_get(wd->layout.list);
372
373    edje_object_signal_callback_add(wd->slideshow, "end", "slideshow", _end, obj);
374
375    evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
376    evas_object_event_callback_add(obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, obj);
377
378    evas_object_smart_callbacks_descriptions_set(obj, _signals);
379
380    _mirrored_set(obj, elm_widget_mirrored_get(obj));
381    _sizing_eval(obj);
382    return obj;
383 }
384
385 EAPI Elm_Slideshow_Item*
386 elm_slideshow_item_add(Evas_Object *obj, const Elm_Slideshow_Item_Class *itc, const void *data)
387 {
388    Elm_Slideshow_Item *item;
389    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
390    Widget_Data *wd = elm_widget_data_get(obj);
391
392    if (!wd) return NULL;
393    item = elm_widget_item_new(obj, Elm_Slideshow_Item);
394    item->base.data = data;
395    item->itc = itc;
396    item->l = eina_list_append(item->l, item);
397
398    wd->items = eina_list_merge(wd->items, item->l);
399
400    if (!wd->current) elm_slideshow_show(item);
401
402    return item;
403 }
404
405 EAPI Elm_Slideshow_Item*
406 elm_slideshow_item_sorted_insert(Evas_Object *obj, const Elm_Slideshow_Item_Class *itc, const void *data, Eina_Compare_Cb func)
407 {
408    Elm_Slideshow_Item *item;
409    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
410    Widget_Data *wd = elm_widget_data_get(obj);
411
412    if (!wd) return NULL;
413    item = elm_widget_item_new(obj, Elm_Slideshow_Item);
414    item->base.data = data;
415    item->itc = itc;
416    item->l = eina_list_append(item->l, item);
417
418    wd->items = eina_list_sorted_merge(wd->items, item->l, func);
419
420    if (!wd->current) elm_slideshow_show(item);
421
422    return item;
423 }
424
425 EAPI void
426 elm_slideshow_show(Elm_Slideshow_Item *item)
427 {
428    char buf[1024];
429    Elm_Slideshow_Item *next = NULL;
430    Widget_Data *wd;
431    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
432    wd = elm_widget_data_get(item->base.widget);
433    if (!wd)
434      return;
435    if (item == wd->current)
436      return;
437
438    next = item;
439    _end(item->base.widget, item->base.widget, NULL, NULL);
440
441    if (wd->timer) ecore_timer_del(wd->timer);
442    if (wd->timeout > 0.0)
443      wd->timer = ecore_timer_add(wd->timeout, _timer_cb, item->base.widget);
444    _item_realize(next);
445    edje_object_part_swallow(wd->slideshow, "elm.swallow.2", next->base.view);
446    snprintf(buf, sizeof(buf), "%s,next", wd->transition);
447    edje_object_signal_emit(wd->slideshow, buf, "slideshow");
448    wd->previous = wd->current;
449    wd->current = next;
450    evas_object_smart_callback_call(item->base.widget, SIG_CHANGED, wd->current);
451 }
452
453 EAPI void
454 elm_slideshow_next(Evas_Object *obj)
455 {
456    char buf[1024];
457    Elm_Slideshow_Item *next = NULL;
458    ELM_CHECK_WIDTYPE(obj, widtype);
459    Widget_Data *wd = elm_widget_data_get(obj);
460
461    if (!wd) return;
462
463    if (wd->current)
464      next = _item_next_get(wd->current);
465
466    if ((!next) || (next == wd->current)) return;
467
468    _end(obj, obj, NULL, NULL);
469
470    if (wd->timer) ecore_timer_del(wd->timer);
471    if (wd->timeout > 0.0)
472      wd->timer = ecore_timer_add(wd->timeout, _timer_cb, obj);
473
474    _item_realize(next);
475
476    edje_object_part_swallow(wd->slideshow, "elm.swallow.2", next->base.view);
477
478    snprintf(buf, sizeof(buf), "%s,next", wd->transition);
479    edje_object_signal_emit(wd->slideshow, buf, "slideshow");
480
481    wd->previous = wd->current;
482    wd->current = next;
483    evas_object_smart_callback_call(obj, SIG_CHANGED, wd->current);
484 }
485
486 EAPI void
487 elm_slideshow_previous(Evas_Object *obj)
488 {
489    char buf[1024];
490    Elm_Slideshow_Item *prev = NULL;
491    ELM_CHECK_WIDTYPE(obj, widtype);
492    Widget_Data *wd = elm_widget_data_get(obj);
493
494    if (!wd) return;
495
496    if (wd->current)
497      prev = _item_prev_get(wd->current);
498
499    if ((!prev) ||  (prev == wd->current)) return;
500
501    _end(obj, obj, NULL, NULL);
502
503    if (wd->timer) ecore_timer_del(wd->timer);
504    if (wd->timeout > 0.0)
505      wd->timer = ecore_timer_add(wd->timeout, _timer_cb, obj);
506
507    _item_realize(prev);
508
509    edje_object_part_swallow(wd->slideshow, "elm.swallow.2", prev->base.view);
510
511    snprintf(buf, 1024, "%s,previous", wd->transition);
512    edje_object_signal_emit(wd->slideshow, buf, "slideshow");
513
514    wd->previous = wd->current;
515    wd->current = prev;
516    evas_object_smart_callback_call(obj, SIG_CHANGED, wd->current);
517 }
518
519 EAPI const Eina_List *
520 elm_slideshow_transitions_get(const Evas_Object *obj)
521 {
522    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
523    Widget_Data *wd = elm_widget_data_get(obj);
524    if (!wd) return NULL;
525    return wd->transitions;
526 }
527
528 EAPI const Eina_List *
529 elm_slideshow_layouts_get(const Evas_Object *obj)
530 {
531    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
532    Widget_Data *wd = elm_widget_data_get(obj);
533    if (!wd) return NULL;
534    return wd->layout.list;
535 }
536
537 EAPI void
538 elm_slideshow_transition_set(Evas_Object *obj, const char *transition)
539 {
540    ELM_CHECK_WIDTYPE(obj, widtype);
541    Widget_Data *wd = elm_widget_data_get(obj);
542    if (!wd) return;
543    eina_stringshare_replace(&wd->transition, transition);
544 }
545
546 EAPI const char *
547 elm_slideshow_transition_get(const Evas_Object *obj)
548 {
549    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
550    Widget_Data *wd = elm_widget_data_get(obj);
551    if (!wd) return NULL;
552    return wd->transition;
553 }
554
555 EAPI void
556 elm_slideshow_timeout_set(Evas_Object *obj, double timeout)
557 {
558    ELM_CHECK_WIDTYPE(obj, widtype);
559    Widget_Data *wd = elm_widget_data_get(obj);
560    if (!wd) return;
561    wd->timeout = timeout;
562    if (wd->timer) ecore_timer_del(wd->timer);
563    wd->timer = NULL;
564    if (timeout > 0.0)
565      wd->timer = ecore_timer_add(timeout, _timer_cb, obj);
566 }
567
568 EAPI double
569 elm_slideshow_timeout_get(const Evas_Object *obj)
570 {
571    ELM_CHECK_WIDTYPE(obj, widtype) -1.0;
572    Widget_Data *wd = elm_widget_data_get(obj);
573    if (!wd) return -1.0;
574    return wd->timeout;
575 }
576
577 EAPI void
578 elm_slideshow_loop_set(Evas_Object *obj, Eina_Bool loop)
579 {
580    ELM_CHECK_WIDTYPE(obj, widtype);
581    Widget_Data *wd = elm_widget_data_get(obj);
582    if (!wd) return;
583    wd->loop = loop;
584 }
585
586 EAPI const char *
587 elm_slideshow_layout_get(const Evas_Object *obj)
588 {
589    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
590    Widget_Data *wd = elm_widget_data_get(obj);
591    if (!wd) return EINA_FALSE;
592    return wd->layout.current;
593 }
594
595 EAPI void
596 elm_slideshow_layout_set(Evas_Object *obj, const char *layout)
597 {
598    char buf[PATH_MAX];
599    ELM_CHECK_WIDTYPE(obj, widtype);
600    Widget_Data *wd = elm_widget_data_get(obj);
601    if (!wd) return;
602
603    wd->layout.current = layout;
604    snprintf(buf, sizeof(buf), "layout,%s", layout);
605    edje_object_signal_emit(wd->slideshow, buf, "slideshow");
606 }
607
608 EAPI Eina_Bool
609 elm_slideshow_loop_get(const Evas_Object *obj)
610 {
611    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
612    Widget_Data *wd = elm_widget_data_get(obj);
613    if (!wd) return EINA_FALSE;
614    return wd->loop;
615 }
616
617 EAPI void
618 elm_slideshow_clear(Evas_Object *obj)
619 {
620    Elm_Slideshow_Item *item;
621    ELM_CHECK_WIDTYPE(obj, widtype);
622    Widget_Data *wd = elm_widget_data_get(obj);
623    if (!wd) return;
624    wd->previous = NULL;
625    wd->current = NULL;
626    EINA_LIST_FREE(wd->items_built, item)
627      {
628         if (item->itc->func.del)
629           item->itc->func.del((void*)item->base.data, item->base.view);
630         evas_object_del(item->base.view);
631         item->base.view = NULL;
632      }
633
634    EINA_LIST_FREE(wd->items, item)
635      {
636         elm_widget_item_del(item);
637      }
638 }
639
640 EAPI void
641 elm_slideshow_item_del(Elm_Slideshow_Item *item)
642 {
643    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
644    Widget_Data *wd = elm_widget_data_get(item->base.widget);
645    if (!wd) return;
646    if (wd->previous == item) wd->previous = NULL;
647    if (wd->current == item)
648      {
649         Eina_List *l = eina_list_data_find_list(wd->items, item);
650         Eina_List *l2 = eina_list_next(l);
651         wd->current = NULL;
652         if (!l2)
653           {
654              l2 = eina_list_prev(l);
655              if (l2)
656                elm_slideshow_show(eina_list_data_get(l2));
657
658           }
659         else
660           elm_slideshow_show(eina_list_data_get(l2));
661      }
662
663    wd->items = eina_list_remove_list(wd->items, item->l);
664    wd->items_built = eina_list_remove_list(wd->items_built, item->l_built);
665
666    if ((item->base.view) && (item->itc->func.del))
667      item->itc->func.del((void*)item->base.data, item->base.view);
668    if (item->base.view)
669      evas_object_del(item->base.view);
670    free(item);
671 }
672
673 EAPI const Eina_List *
674 elm_slideshow_items_get(const Evas_Object *obj)
675 {
676    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
677    Widget_Data *wd = elm_widget_data_get(obj);
678    if (!wd) return NULL;
679    return wd->items;
680 }
681
682 EAPI Elm_Slideshow_Item *
683 elm_slideshow_item_current_get(const Evas_Object *obj)
684 {
685    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
686    Widget_Data *wd = elm_widget_data_get(obj);
687    if (!wd) return NULL;
688    return wd->current;
689 }
690
691 EAPI Evas_Object *
692 elm_slideshow_item_object_get(const Elm_Slideshow_Item * item)
693 {
694    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
695    return item->base.view;
696 }
697
698 EAPI void *
699 elm_slideshow_item_data_get(const Elm_Slideshow_Item * item)
700 {
701    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
702    return elm_widget_item_data_get(item);
703 }
704
705 EAPI int
706 elm_slideshow_cache_before_get(const Evas_Object *obj)
707 {
708    ELM_CHECK_WIDTYPE(obj, widtype) -1;
709    Widget_Data *wd = elm_widget_data_get(obj);
710    if (!wd) return -1;
711    return wd->count_item_pre_before;
712 }
713
714 EAPI void
715 elm_slideshow_cache_before_set(Evas_Object *obj, int count)
716 {
717    ELM_CHECK_WIDTYPE(obj, widtype);
718    Widget_Data *wd = elm_widget_data_get(obj);
719    if (!wd) return;
720    if (count < 0) count = 0;
721    wd->count_item_pre_before = count;
722 }
723
724 EAPI int
725 elm_slideshow_cache_after_get(const Evas_Object *obj)
726 {
727    ELM_CHECK_WIDTYPE(obj, widtype) -1;
728    Widget_Data *wd = elm_widget_data_get(obj);
729    if (!wd) return -1;
730    return wd->count_item_pre_after;
731 }
732
733 EAPI void
734 elm_slideshow_cache_after_set(Evas_Object *obj, int count)
735 {
736    ELM_CHECK_WIDTYPE(obj, widtype);
737    Widget_Data *wd = elm_widget_data_get(obj);
738    if (!wd) return;
739    if (count < 0) count = 0;
740    wd->count_item_pre_after = count;
741 }
742
743 EAPI Elm_Slideshow_Item *
744 elm_slideshow_item_nth_get(const Evas_Object *obj, unsigned int nth)
745 {
746    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
747    Widget_Data *wd = elm_widget_data_get(obj);
748    if (!wd) return NULL;
749    return eina_list_nth(wd->items, nth);
750 }
751
752 EAPI unsigned int
753 elm_slideshow_count_get(const Evas_Object *obj)
754 {
755    ELM_CHECK_WIDTYPE(obj, widtype) 0;
756    Widget_Data *wd = elm_widget_data_get(obj);
757    if (!wd) return 0;
758    return eina_list_count(wd->items);
759 }