\section{slideshow\-\_\-example.\-c}

\begin{DoxyCodeInclude}

\textcolor{preprocessor}{#include <Elementary.h>}

\textcolor{preprocessor}{#define IMG\_NUM 8}
\textcolor{preprocessor}{}
\textcolor{keyword}{static} Evas\_Object *slideshow, *bt\_start, *bt\_stop;
\textcolor{keyword}{static} Elm_Slideshow_Item_Class itc;

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_notify\_show(\textcolor{keywordtype}{void} *data, Evas *e, Evas\_Object *obj, \textcolor{keywordtype}{void} *event\_info)
\{
   evas\_object\_show(data);
\}

\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);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_mouse\_in\_cb(\textcolor{keywordtype}{void} *data, Evas *e, Evas\_Object *obj, \textcolor{keywordtype}{void} *event\_info)
\{
   elm_notify_timeout_set(data, 0.0);
   evas\_object\_show(data);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_mouse\_out\_cb(\textcolor{keywordtype}{void} *data, Evas *e, Evas\_Object *obj, \textcolor{keywordtype}{void} *event\_info)
\{
   elm_notify_timeout_set(data, 3.0);
\}

\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);
\}

\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);
\}

\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));
\}

\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;
\}

\textcolor{comment}{/* ordering alphabetically */}
\textcolor{keyword}{static} \textcolor{keywordtype}{int}
\_cmp\_func(\textcolor{keyword}{const} \textcolor{keywordtype}{void} *data1, \textcolor{keyword}{const} \textcolor{keywordtype}{void} *data2)
\{
   \textcolor{keyword}{const} \textcolor{keywordtype}{char} *img\_path1, *img\_path2;

   \textcolor{keyword}{const} Elm_Object_Item *slide\_it1 = data1;
   \textcolor{keyword}{const} Elm_Object_Item *slide\_it2 = data2;

   img\_path1 = elm_object_item_data_get(slide\_it1);
   img\_path2 = elm_object_item_data_get(slide\_it2);

   \textcolor{keywordflow}{return} strcasecmp(img\_path1, img\_path2);
\}

EAPI\_MAIN \textcolor{keywordtype}{int}
elm\_main(\textcolor{keywordtype}{int} argc, \textcolor{keywordtype}{char} **argv)
\{
   Evas\_Object *win, *notify, *bx, *bt, *hv, *spin;
   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));

   notify = elm_notify_add(win);
   elm_notify_align_set(notify, 0.5, 1.0);
   evas\_object\_size\_hint\_weight\_set(notify, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   elm_notify_timeout_set(notify, 3.0);
   evas\_object\_show(notify);

   bx = elm_box_add(win);
   elm_box_horizontal_set(bx, EINA\_TRUE);
   elm\_object\_content\_set(notify, bx);
   evas\_object\_show(bx);

   evas\_object\_event\_callback\_add(bx, EVAS\_CALLBACK\_MOUSE\_IN,
                                  \_mouse\_in\_cb, notify);
   evas\_object\_event\_callback\_add(bx, EVAS\_CALLBACK\_MOUSE\_OUT,
                                  \_mouse\_out\_cb, notify);

   bt = elm_button_add(win);
   elm\_object\_text\_set(bt, "First");
   evas\_object\_smart\_callback\_add(bt, "clicked", \_first, slide\_first);
   elm_box_pack_end(bx, bt);
   evas\_object\_show(bt);

   bt = elm_button_add(win);
   elm\_object\_text\_set(bt, "Previous");
   evas\_object\_smart\_callback\_add(bt, "clicked", \_previous, slideshow);
   elm_box_pack_end(bx, bt);
   evas\_object\_show(bt);

   bt = elm_button_add(win);
   elm\_object\_text\_set(bt, "Next");
   evas\_object\_smart\_callback\_add(bt, "clicked", \_next, slideshow);
   elm_box_pack_end(bx, bt);
   evas\_object\_show(bt);

   bt = elm_button_add(win);
   elm\_object\_text\_set(bt, "Last");
   evas\_object\_smart\_callback\_add(bt, "clicked", \_last, slide\_last);
   elm_box_pack_end(bx, bt);
   evas\_object\_show(bt);

   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);

   spin = elm_spinner_add(win);
   elm_spinner_label_format_set(spin, "%2.0f s");
   evas\_object\_smart\_callback\_add(spin, "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);

   bt = elm_button_add(win);
   bt\_start = bt;
   elm\_object\_text\_set(bt, "Start");
   evas\_object\_smart\_callback\_add(bt, "clicked", \_start, spin);
   elm_box_pack_end(bx, bt);
   evas\_object\_show(bt);

   bt = elm_button_add(win);
   bt\_stop = bt;
   elm\_object\_text\_set(bt, "Stop");
   evas\_object\_smart\_callback\_add(bt, "clicked", \_stop, spin);
   elm_box_pack_end(bx, bt);
   elm_object_disabled_set(bt, EINA\_TRUE);
   evas\_object\_show(bt);

   evas\_object\_event\_callback\_add(slideshow, EVAS\_CALLBACK\_MOUSE\_UP,
                                  \_notify\_show, notify);
   evas\_object\_event\_callback\_add(slideshow, EVAS\_CALLBACK\_MOUSE\_MOVE,
                                  \_notify\_show, notify);

   elm_run();
   elm_shutdown();

   return 0;
\}
ELM_MAIN()
\end{DoxyCodeInclude}
 