[elementary] Documentation for the slideshow widget.
[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;
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                        _item_next->base.view =
234                           _item_next->itc->func.get(
235                              (void*)_item_next->base.data, obj);
236                        evas_object_smart_member_add(_item_next->base.view, obj);
237                        _item_next->l_built = eina_list_append(NULL, _item_next);
238                        wd->items_built = eina_list_merge(wd->items_built,
239                                                          _item_next->l_built);
240                        evas_object_hide(_item_next->base.view);
241                     }
242                   else if (_item_next && _item_next->l_built)
243                     wd->items_built =
244                        eina_list_demote_list(wd->items_built,
245                                              _item_next->l_built);
246                }
247           }
248
249         if (lc > 0 && bc > 0)
250           {
251              --bc;
252              --lc;
253              if (_item_prev)
254                {
255                   _item_prev = _item_prev_get(_item_prev);
256                   if ((_item_prev)
257                       && (!_item_prev->base.view)
258                       && (_item_prev->itc->func.get))
259                     {
260                        _item_prev->base.view =
261                           _item_prev->itc->func.get(
262                              (void*)_item_prev->base.data, obj);
263                        evas_object_smart_member_add(_item_prev->base.view, obj);
264                        _item_prev->l_built = eina_list_append(NULL, _item_prev);
265                        wd->items_built = eina_list_merge(wd->items_built,
266                                                          _item_prev->l_built);
267                        evas_object_hide(_item_prev->base.view);
268                     }
269                   else if (_item_prev && _item_prev->l_built)
270                     wd->items_built =
271                        eina_list_demote_list(wd->items_built,
272                                              _item_prev->l_built);
273                }
274           }
275      }
276
277    //delete unused items
278    lc = wd->count_item_pre_before + wd->count_item_pre_after + 1;
279    while ((int)eina_list_count(wd->items_built) > lc)
280      {
281         item = eina_list_data_get(wd->items_built);
282         wd->items_built = eina_list_remove_list(wd->items_built,
283                                                 wd->items_built);
284         if (item->itc->func.del)
285           item->itc->func.del((void*)item->base.data, item->base.view);
286         evas_object_del(item->base.view);
287         item->base.view = NULL;
288      }
289 }
290
291 static void
292 _end(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
293 {
294    Elm_Slideshow_Item *item;
295    Widget_Data *wd = elm_widget_data_get(data);
296    if (!wd) return;
297
298    item = wd->previous;
299    if (item)
300      {
301         edje_object_part_unswallow(NULL, item->base.view);
302         evas_object_hide(item->base.view);
303         wd->previous = NULL;
304      }
305
306
307    item = wd->current;
308    if ((!item) || (!item->base.view)) return;
309
310    _item_realize(item);
311    edje_object_part_unswallow(NULL, item->base.view);
312    evas_object_show(item->base.view);
313
314    edje_object_signal_emit(wd->slideshow, "anim,end", "slideshow");
315    edje_object_part_swallow(wd->slideshow, "elm.swallow.1", item->base.view);
316 }
317
318 static Eina_Bool
319 _timer_cb(void *data)
320 {
321    Evas_Object *obj = data;
322    Widget_Data *wd = elm_widget_data_get(obj);
323    if (!wd) return ECORE_CALLBACK_CANCEL;
324    wd->timer = NULL;
325    elm_slideshow_next(obj);
326    return ECORE_CALLBACK_CANCEL;
327 }
328
329 EAPI Evas_Object *
330 elm_slideshow_add(Evas_Object *parent)
331 {
332    Evas_Object *obj;
333    Evas *e;
334    Widget_Data *wd;
335
336    ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
337
338    ELM_SET_WIDTYPE(widtype, "slideshow");
339    elm_widget_type_set(obj, "slideshow");
340    elm_widget_sub_object_add(parent, obj);
341    elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
342    elm_widget_data_set(obj, wd);
343    elm_widget_del_hook_set(obj, _del_hook);
344    elm_widget_theme_hook_set(obj, _theme_hook);
345    elm_widget_can_focus_set(obj, EINA_TRUE);
346    elm_widget_event_hook_set(obj, _event_hook);
347
348    wd->current = NULL;
349    wd->previous = NULL;
350
351    wd->slideshow = edje_object_add(e);
352    _elm_theme_object_set(obj, wd->slideshow, "slideshow", "base", "default");
353    evas_object_smart_member_add(wd->slideshow, obj);
354    wd->count_item_pre_before = 2;
355    wd->count_item_pre_after = 2;
356    elm_widget_resize_object_set(obj, wd->slideshow);
357    evas_object_show(wd->slideshow);
358
359    wd->transitions = elm_widget_stringlist_get(edje_object_data_get(wd->slideshow, "transitions"));
360    if (eina_list_count(wd->transitions) > 0)
361      wd->transition = eina_stringshare_add(eina_list_data_get(wd->transitions));
362
363    wd->layout.list = elm_widget_stringlist_get(edje_object_data_get(wd->slideshow, "layouts"));
364    if (eina_list_count(wd->layout.list) > 0)
365      wd->layout.current = eina_list_data_get(wd->layout.list);
366
367    edje_object_signal_callback_add(wd->slideshow, "end", "slideshow", _end, obj);
368
369    evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
370    evas_object_event_callback_add(obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, obj);
371
372    evas_object_smart_callbacks_descriptions_set(obj, _signals);
373
374    _mirrored_set(obj, elm_widget_mirrored_get(obj));
375    _sizing_eval(obj);
376    return obj;
377 }
378
379 EAPI Elm_Slideshow_Item*
380 elm_slideshow_item_add(Evas_Object *obj, const Elm_Slideshow_Item_Class *itc, const void *data)
381 {
382    Elm_Slideshow_Item *item;
383    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
384    Widget_Data *wd = elm_widget_data_get(obj);
385
386    if (!wd) return NULL;
387    item = elm_widget_item_new(obj, Elm_Slideshow_Item);
388    item->base.data = data;
389    item->itc = itc;
390    item->l = eina_list_append(item->l, item);
391
392    wd->items = eina_list_merge(wd->items, item->l);
393
394    if (!wd->current) elm_slideshow_show(item);
395
396    return item;
397 }
398
399 EAPI Elm_Slideshow_Item*
400 elm_slideshow_item_sorted_insert(Evas_Object *obj, const Elm_Slideshow_Item_Class *itc, const void *data, Eina_Compare_Cb func)
401 {
402    Elm_Slideshow_Item *item;
403    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
404    Widget_Data *wd = elm_widget_data_get(obj);
405
406    if (!wd) return NULL;
407    item = elm_widget_item_new(obj, Elm_Slideshow_Item);
408    item->base.data = data;
409    item->itc = itc;
410    item->l = eina_list_append(item->l, item);
411
412    wd->items = eina_list_sorted_merge(wd->items, item->l, func);
413
414    if (!wd->current) elm_slideshow_show(item);
415
416    return item;
417 }
418
419 EAPI void
420 elm_slideshow_show(Elm_Slideshow_Item *item)
421 {
422    char buf[1024];
423    Elm_Slideshow_Item *next = NULL;
424    Widget_Data *wd;
425    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
426    wd = elm_widget_data_get(item->base.widget);
427    if (!wd)
428      return;
429    if (item == wd->current)
430      return;
431
432    next = item;
433    _end(item->base.widget, item->base.widget, NULL, NULL);
434
435    if (wd->timer) ecore_timer_del(wd->timer);
436    if (wd->timeout > 0.0)
437      wd->timer = ecore_timer_add(wd->timeout, _timer_cb, item->base.widget);
438    _item_realize(next);
439    edje_object_part_swallow(wd->slideshow, "elm.swallow.2", next->base.view);
440    evas_object_show(next->base.view);
441    snprintf(buf, sizeof(buf), "%s,next", wd->transition);
442    edje_object_signal_emit(wd->slideshow, buf, "slideshow");
443    wd->previous = wd->current;
444    wd->current = next;
445    evas_object_smart_callback_call(item->base.widget, SIG_CHANGED, wd->current);
446 }
447
448 EAPI void
449 elm_slideshow_next(Evas_Object *obj)
450 {
451    char buf[1024];
452    Elm_Slideshow_Item *next = NULL;
453    ELM_CHECK_WIDTYPE(obj, widtype);
454    Widget_Data *wd = elm_widget_data_get(obj);
455
456    if (!wd) return;
457
458    if (wd->current)
459      next = _item_next_get(wd->current);
460
461    if ((!next) || (next == wd->current)) return;
462
463    _end(obj, obj, NULL, NULL);
464
465    if (wd->timer) ecore_timer_del(wd->timer);
466    if (wd->timeout > 0.0)
467      wd->timer = ecore_timer_add(wd->timeout, _timer_cb, obj);
468
469    _item_realize(next);
470
471    edje_object_part_swallow(wd->slideshow, "elm.swallow.2", next->base.view);
472    evas_object_show(next->base.view);
473
474    snprintf(buf, sizeof(buf), "%s,next", wd->transition);
475    edje_object_signal_emit(wd->slideshow, buf, "slideshow");
476
477    wd->previous = wd->current;
478    wd->current = next;
479    evas_object_smart_callback_call(obj, SIG_CHANGED, wd->current);
480 }
481
482 EAPI void
483 elm_slideshow_previous(Evas_Object *obj)
484 {
485    char buf[1024];
486    Elm_Slideshow_Item *prev = NULL;
487    ELM_CHECK_WIDTYPE(obj, widtype);
488    Widget_Data *wd = elm_widget_data_get(obj);
489
490    if (!wd) return;
491
492    if (wd->current)
493      prev = _item_prev_get(wd->current);
494
495    if ((!prev) ||  (prev == wd->current)) return;
496
497    _end(obj, obj, NULL, NULL);
498
499    if (wd->timer) ecore_timer_del(wd->timer);
500    if (wd->timeout > 0.0)
501      wd->timer = ecore_timer_add(wd->timeout, _timer_cb, obj);
502
503    _item_realize(prev);
504
505    edje_object_part_swallow(wd->slideshow, "elm.swallow.2", prev->base.view);
506    evas_object_show(prev->base.view);
507
508    snprintf(buf, 1024, "%s,previous", wd->transition);
509    edje_object_signal_emit(wd->slideshow, buf, "slideshow");
510
511    wd->previous = wd->current;
512    wd->current = prev;
513    evas_object_smart_callback_call(obj, SIG_CHANGED, wd->current);
514 }
515
516 EAPI const Eina_List *
517 elm_slideshow_transitions_get(const Evas_Object *obj)
518 {
519    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
520    Widget_Data *wd = elm_widget_data_get(obj);
521    if (!wd) return NULL;
522    return wd->transitions;
523 }
524
525 EAPI const Eina_List *
526 elm_slideshow_layouts_get(const Evas_Object *obj)
527 {
528    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
529    Widget_Data *wd = elm_widget_data_get(obj);
530    if (!wd) return NULL;
531    return wd->layout.list;
532 }
533
534 EAPI void
535 elm_slideshow_transition_set(Evas_Object *obj, const char *transition)
536 {
537    ELM_CHECK_WIDTYPE(obj, widtype);
538    Widget_Data *wd = elm_widget_data_get(obj);
539    if (!wd) return;
540    eina_stringshare_replace(&wd->transition, transition);
541 }
542
543 EAPI const char *
544 elm_slideshow_transition_get(const Evas_Object *obj)
545 {
546    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
547    Widget_Data *wd = elm_widget_data_get(obj);
548    if (!wd) return NULL;
549    return wd->transition;
550 }
551
552 EAPI void
553 elm_slideshow_timeout_set(Evas_Object *obj, double timeout)
554 {
555    ELM_CHECK_WIDTYPE(obj, widtype);
556    Widget_Data *wd = elm_widget_data_get(obj);
557    if (!wd) return;
558    wd->timeout = timeout;
559    if (wd->timer) ecore_timer_del(wd->timer);
560    wd->timer = NULL;
561    if (timeout > 0.0)
562      wd->timer = ecore_timer_add(timeout, _timer_cb, obj);
563 }
564
565 EAPI double
566 elm_slideshow_timeout_get(const Evas_Object *obj)
567 {
568    ELM_CHECK_WIDTYPE(obj, widtype) -1.0;
569    Widget_Data *wd = elm_widget_data_get(obj);
570    if (!wd) return -1.0;
571    return wd->timeout;
572 }
573
574 EAPI void
575 elm_slideshow_loop_set(Evas_Object *obj, Eina_Bool loop)
576 {
577    ELM_CHECK_WIDTYPE(obj, widtype);
578    Widget_Data *wd = elm_widget_data_get(obj);
579    if (!wd) return;
580    wd->loop = loop;
581 }
582
583 EAPI const char *
584 elm_slideshow_layout_get(const Evas_Object *obj)
585 {
586    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
587    Widget_Data *wd = elm_widget_data_get(obj);
588    if (!wd) return EINA_FALSE;
589    return wd->layout.current;
590 }
591
592 EAPI void
593 elm_slideshow_layout_set(Evas_Object *obj, const char *layout)
594 {
595    char buf[PATH_MAX];
596    ELM_CHECK_WIDTYPE(obj, widtype);
597    Widget_Data *wd = elm_widget_data_get(obj);
598    if (!wd) return;
599
600    wd->layout.current = layout;
601    snprintf(buf, sizeof(buf), "layout,%s", layout);
602    edje_object_signal_emit(wd->slideshow, buf, "slideshow");
603 }
604
605 EAPI Eina_Bool
606 elm_slideshow_loop_get(const Evas_Object *obj)
607 {
608    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
609    Widget_Data *wd = elm_widget_data_get(obj);
610    if (!wd) return EINA_FALSE;
611    return wd->loop;
612 }
613
614 EAPI void
615 elm_slideshow_clear(Evas_Object *obj)
616 {
617    Elm_Slideshow_Item *item;
618    ELM_CHECK_WIDTYPE(obj, widtype);
619    Widget_Data *wd = elm_widget_data_get(obj);
620    if (!wd) return;
621    wd->previous = NULL;
622    wd->current = NULL;
623    EINA_LIST_FREE(wd->items_built, item)
624      {
625         if (item->itc->func.del)
626           item->itc->func.del((void*)item->base.data, item->base.view);
627         evas_object_del(item->base.view);
628         item->base.view = NULL;
629      }
630
631    EINA_LIST_FREE(wd->items, item)
632      {
633         elm_widget_item_del(item);
634      }
635 }
636
637 EAPI void
638 elm_slideshow_item_del(Elm_Slideshow_Item *item)
639 {
640    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
641    Widget_Data *wd = elm_widget_data_get(item->base.widget);
642    if (!wd) return;
643    if (wd->previous == item) wd->previous = NULL;
644    if (wd->current == item)
645      {
646         Eina_List *l = eina_list_data_find_list(wd->items, item);
647         Eina_List *l2 = eina_list_next(l);
648         wd->current = NULL;
649         if (!l2)
650           l2 = eina_list_nth_list(wd->items, eina_list_count(wd->items) - 1);
651         if (l2)
652           elm_slideshow_show(eina_list_data_get(l2));
653      }
654
655    wd->items = eina_list_remove_list(wd->items, item->l);
656    wd->items_built = eina_list_remove_list(wd->items_built, item->l_built);
657
658    if ((item->base.view) && (item->itc->func.del))
659      item->itc->func.del((void*)item->base.data, item->base.view);
660    if (item->base.view)
661      evas_object_del(item->base.view);
662    free(item);
663 }
664
665 EAPI const Eina_List *
666 elm_slideshow_items_get(const Evas_Object *obj)
667 {
668    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
669    Widget_Data *wd = elm_widget_data_get(obj);
670    if (!wd) return NULL;
671    return wd->items;
672 }
673
674 EAPI Elm_Slideshow_Item *
675 elm_slideshow_item_current_get(const Evas_Object *obj)
676 {
677    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
678    Widget_Data *wd = elm_widget_data_get(obj);
679    if (!wd) return NULL;
680    return wd->current;
681 }
682
683 EAPI Evas_Object *
684 elm_slideshow_item_object_get(const Elm_Slideshow_Item * item)
685 {
686    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
687    return item->base.view;
688 }
689
690 EAPI void *
691 elm_slideshow_item_data_get(const Elm_Slideshow_Item * item)
692 {
693    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
694    return elm_widget_item_data_get(item);
695 }
696
697 EAPI int
698 elm_slideshow_cache_before_get(const Evas_Object *obj)
699 {
700    ELM_CHECK_WIDTYPE(obj, widtype) -1;
701    Widget_Data *wd = elm_widget_data_get(obj);
702    if (!wd) return -1;
703    return wd->count_item_pre_before;
704 }
705
706 EAPI void
707 elm_slideshow_cache_before_set(Evas_Object *obj, int count)
708 {
709    ELM_CHECK_WIDTYPE(obj, widtype);
710    Widget_Data *wd = elm_widget_data_get(obj);
711    if (!wd) return;
712    if (count < 0) count = 0;
713    wd->count_item_pre_before = count;
714 }
715
716 EAPI int
717 elm_slideshow_cache_after_get(const Evas_Object *obj)
718 {
719    ELM_CHECK_WIDTYPE(obj, widtype) -1;
720    Widget_Data *wd = elm_widget_data_get(obj);
721    if (!wd) return -1;
722    return wd->count_item_pre_after;
723 }
724
725 EAPI void
726 elm_slideshow_cache_after_set(Evas_Object *obj, int count)
727 {
728    ELM_CHECK_WIDTYPE(obj, widtype);
729    Widget_Data *wd = elm_widget_data_get(obj);
730    if (!wd) return;
731    if (count < 0) count = 0;
732    wd->count_item_pre_after = count;
733 }
734
735 EAPI Elm_Slideshow_Item *
736 elm_slideshow_item_nth_get(const Evas_Object *obj, unsigned int nth)
737 {
738    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
739    Widget_Data *wd = elm_widget_data_get(obj);
740    if (!wd) return NULL;
741    return eina_list_nth(wd->items, nth);
742 }
743
744 EAPI unsigned int
745 elm_slideshow_count_get(const Evas_Object *obj)
746 {
747    ELM_CHECK_WIDTYPE(obj, widtype) 0;
748    Widget_Data *wd = elm_widget_data_get(obj);
749    if (!wd) return 0;
750    return eina_list_count(wd->items);
751 }