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