This application is aimed to exemplify the slideshow widget.

It consists of a window with a slideshow widget set as \char`\"{}resize
object\char`\"{}, along with a control bar, in the form of a notify. Those controls will exercise most of the slideshow's A\-P\-I functions.

We create the slideshow, itself, first, making it {\bfseries loop} on its image itens, when in slideshow mode\-:  
\begin{DoxyCodeInclude}
   slideshow = elm_slideshow_add(win);
   elm_slideshow_loop_set(slideshow, EINA\_TRUE);
   evas\_object\_size\_hint\_weight\_set(slideshow,
                                    EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   elm_win_resize_object_add(win, slideshow);
   evas\_object\_show(slideshow);

\end{DoxyCodeInclude}


Next, we define the {\bfseries item class} for our slideshow items. Slideshow images are going to be Elementary \hyperlink{group__Photo}{photo} widgets, here, as pointed by our {\ttfamily get} class function. We'll let the Elementary infrastructure to delete those objects for us, and, as there's no additional data attached to our slideshow items, the {\ttfamily del} class function can be left undefined\-:  
\begin{DoxyCodeInclude}
\textcolor{keyword}{static} Elm_Slideshow_Item_Class itc;

\end{DoxyCodeInclude}
  
\begin{DoxyCodeInclude}
   itc.func.get = \_get;
   itc.func.del = NULL;

\end{DoxyCodeInclude}
  
\begin{DoxyCodeInclude}
\textcolor{comment}{/* get our images to make slideshow items */}
\textcolor{keyword}{static} Evas\_Object *
\_get(\textcolor{keywordtype}{void} *data, Evas\_Object *obj)
\{
   Evas\_Object *photo = elm_photo_add(obj);
   elm_photo_file_set(photo, data);
   elm_photo_fill_inside_set(photo, EINA\_TRUE);
   elm_object_style_set(photo, \textcolor{stringliteral}{"shadow"});

   \textcolor{keywordflow}{return} photo;
\}

\end{DoxyCodeInclude}


We now get to populate the slideshow widget with items. Our images are going to be some randomly chosen from the Elementary package, nine of them. For the first eight, we insert them ordered in the widget, by using \hyperlink{group__Slideshow_gad7c4e69fcd76ae9676183582692ca109}{elm\-\_\-slideshow\-\_\-item\-\_\-sorted\-\_\-insert()}. The comparing function will use the image names to sort items. The last item is inserted at the end of the slideshow's items list, with \hyperlink{group__Slideshow_gae602464862d550daf75773e5364c5ec4}{elm\-\_\-slideshow\-\_\-item\-\_\-add()}. We check out how that list ends with \hyperlink{group__Slideshow_ga1ce2563bf731075e8d7b06656d84a066}{elm\-\_\-slideshow\-\_\-items\-\_\-get()}, than\-:  
\begin{DoxyCodeInclude}

\end{DoxyCodeInclude}
  
\begin{DoxyCodeInclude}
   Elm_Object_Item *slide\_first = NULL, *slide\_last = NULL, *slide\_it = NULL;
   \textcolor{keyword}{const} \textcolor{keywordtype}{char} *transition, *layout;
   \textcolor{keyword}{const} Eina\_List *l, *list;
   \textcolor{keyword}{const} \textcolor{keywordtype}{char} *data\_dir;
   \textcolor{keywordtype}{char} img[IMG\_NUM][PATH\_MAX];
   \textcolor{keywordtype}{char} *img\_files[] =
     \{
        \textcolor{stringliteral}{"logo.png"}, \textcolor{stringliteral}{"plant\_01.jpg"}, \textcolor{stringliteral}{"rock\_01.jpg"}, \textcolor{stringliteral}{"rock\_02.jpg"}, \textcolor{stringliteral}{"sky\_01.jpg"},
        \textcolor{stringliteral}{"wood\_01.jpg"}, \textcolor{stringliteral}{"mystrale.jpg"}, \textcolor{stringliteral}{"mystrale\_2.jpg"}
     \};
   \textcolor{keywordtype}{int} i = 0;

   elm_app_info_set(elm\_main, \textcolor{stringliteral}{"elementary"}, \textcolor{stringliteral}{"images"});

   data\_dir = elm_app_data_dir_get();
   \textcolor{keywordflow}{for} (i = 0; i < IMG\_NUM; i++)
     snprintf(img[i], PATH\_MAX, \textcolor{stringliteral}{"%s/images/%s"}, data\_dir, img\_files[i]);

   elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);

   win = elm_win_util_standard_add(\textcolor{stringliteral}{"slideshow"}, \textcolor{stringliteral}{"Slideshow example"});
   elm_win_autodel_set(win, EINA\_TRUE);
   evas\_object\_resize(win, 600, 400);
   evas\_object\_show(win);

   slideshow = elm_slideshow_add(win);
   elm_slideshow_loop_set(slideshow, EINA\_TRUE);
   evas\_object\_size\_hint\_weight\_set(slideshow,
                                    EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   elm_win_resize_object_add(win, slideshow);
   evas\_object\_show(slideshow);

   itc.func.get = \_get;
   itc.func.del = NULL;

   \textcolor{keywordflow}{for} (i = 0; i < IMG\_NUM; i++)
     \{
        slide\_it = elm_slideshow_item_sorted_insert(slideshow, &itc, img[i],
                                                    \_cmp\_func);
        \textcolor{keywordflow}{if} (!slide\_first) slide\_first = slide\_it;
     \}
   slide\_last = slide\_it;

   list = elm_slideshow_items_get(slideshow);
   fprintf(stdout, \textcolor{stringliteral}{"List of items in the slideshow:\(\backslash\)n"});
   EINA\_LIST\_FOREACH(list, l, slide\_it)
     fprintf(stdout, "\(\backslash\)t%s\(\backslash\)n",
             (const \textcolor{keywordtype}{char} *)elm_object_item_data_get(slide\_it));

\end{DoxyCodeInclude}


Note that we save the pointers to the first and last items in the slideshow, for future use.

What follows is the code creating a notify, to be shown over the slideshow's viewport, with knobs to act on it. We're not showing that boilerplate code, but only the callbacks attached to the interesting smart events of those knobs. The first four are buttons, which will\-:
\begin{DoxyItemize}
\item Select the {\bfseries next} item in the slideshow
\item Select the {\bfseries previous} item in the slideshow
\item Select the {\bfseries first} item in the slideshow
\item Select the {\bfseries last} item in the slideshow
\end{DoxyItemize}

Check out the code for those four actions, being the two last {\ttfamily data} pointers the same {\ttfamily first} and {\ttfamily last} pointers we save before, respectively\-:  
\begin{DoxyCodeInclude}
\textcolor{comment}{/* jump to next item, cyclically */}
\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_next(\textcolor{keywordtype}{void}  *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event\_info)
\{
   elm_slideshow_next(data);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_previous(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event\_info)
\{
   elm_slideshow_previous(data);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_first(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event\_info)
\{
   elm_slideshow_item_show(data);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_last(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event\_info)
\{
   elm_slideshow_item_show(data);
\}

\end{DoxyCodeInclude}


What follow are two hoversels, meant for one to change the slideshow's {\bfseries transition} and {\bfseries layout} styles, respectively. We fetch all the available transition and layout names to populate those widgets and, when one selects any of them, we apply the corresponding setters on the slideshow\-:  
\begin{DoxyCodeInclude}
   hv = elm_hoversel_add(win);
   elm_box_pack_end(bx, hv);
   elm_hoversel_hover_parent_set(hv, win);
   EINA\_LIST\_FOREACH(elm_slideshow_transitions_get(slideshow), l, transition)
     elm_hoversel_item_add(hv, transition, NULL, 0, \_transition\_select,
                           transition);
   elm\_object\_text\_set(hv, eina\_list\_data\_get(
         elm_slideshow_transitions_get(slideshow)));
   evas\_object\_show(hv);

   hv = elm_hoversel_add(win);
   elm_box_pack_end(bx, hv);
   elm_hoversel_hover_parent_set(hv, win);
   EINA\_LIST\_FOREACH(elm_slideshow_layouts_get(slideshow), l, layout)
     elm_hoversel_item_add(hv, layout, NULL, 0, \_layout\_select, layout);
   elm\_object\_text\_set(hv, elm_slideshow_layout_get(slideshow));
   evas\_object\_show(hv);

\end{DoxyCodeInclude}
  
\begin{DoxyCodeInclude}
\textcolor{comment}{/* transition changed */}
\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_transition\_select(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event\_info)
\{
   elm_slideshow_transition_set(slideshow, data);
   elm\_object\_text\_set(obj, data);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_layout\_select(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event\_info)
\{
   elm_slideshow_layout_set(slideshow, data);
   elm\_object\_text\_set(obj, data);
\}

\end{DoxyCodeInclude}


For one to change the transition {\bfseries time} on the slideshow widget, we use a spinner widget. We set it to the initial value of 3 (seconds), which will be probed by the next knob -- a button starting the slideshow, de facto. Note that changing the transition time while a slideshow is already happening will adjust its transition time\-:  
\begin{DoxyCodeInclude}
   spin = elm_spinner_add(win);
   elm_spinner_label_format_set(spin, \textcolor{stringliteral}{"%2.0f s"});
   evas\_object\_smart\_callback\_add(spin, \textcolor{stringliteral}{"changed"}, \_spin, spin);
   elm_spinner_step_set(spin, 1);
   elm_spinner_min_max_set(spin, 1, 30);
   elm_spinner_value_set(spin, 3);
   elm_box_pack_end(bx, spin);
   evas\_object\_show(spin);

\end{DoxyCodeInclude}
  
\begin{DoxyCodeInclude}
\textcolor{comment}{/* slideshow transition time has changed */}
\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_spin(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event\_info)
\{
   \textcolor{keywordflow}{if} (elm_slideshow_timeout_get(slideshow) > 0)
     elm_slideshow_timeout_set(slideshow, elm_spinner_value_get(data));
\}

\end{DoxyCodeInclude}


Finally, we have two buttons which will, respectively, start and stop the slideshow on our widget. Here are their \char`\"{}clicked\char`\"{} callbacks\-:  
\begin{DoxyCodeInclude}
\textcolor{comment}{/* start the show! */}
\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_start(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event\_info)
\{
   elm_slideshow_timeout_set(slideshow, elm_spinner_value_get(data));

   elm_object_disabled_set(bt\_start, EINA\_TRUE);
   elm_object_disabled_set(bt\_stop, EINA\_FALSE);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_stop(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event\_info)
\{
   elm_slideshow_timeout_set(slideshow, 0.0);
   elm_object_disabled_set(bt\_start, EINA\_FALSE);
   elm_object_disabled_set(bt\_stop, EINA\_TRUE);
\}

\end{DoxyCodeInclude}


This is how the example program's window looks like\-:  
\begin{DoxyImage}
\includegraphics{screenshots/slideshow_example}
\caption{width=}
\end{DoxyImage}


See the full \hyperlink{slideshow_example_c}{source code} for this example. 