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