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