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