
\begin{DoxyCodeInclude}
\textcolor{comment}{//Compile with:}
\textcolor{comment}{//gcc -g layout\_example\_02.c -o layout\_example\_02 `pkg-config --cflags --libs elementary`}

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

\textcolor{preprocessor}{#define TABLE "example/table"}
\textcolor{preprocessor}{}\textcolor{preprocessor}{#define BOX "example/box"}
\textcolor{preprocessor}{}\textcolor{preprocessor}{#define TITLE "example/title"}
\textcolor{preprocessor}{}\textcolor{preprocessor}{#define SWALLOW "example/custom"}
\textcolor{preprocessor}{}
\textcolor{keyword}{static} \textcolor{keyword}{const} \textcolor{keywordtype}{char} *images[] = \{ \textcolor{stringliteral}{"home"}, \textcolor{stringliteral}{"close"}, \textcolor{stringliteral}{"arrow\_up"}, \textcolor{stringliteral}{"arrow\_down"}, NULL \};

\textcolor{keyword}{struct }\_App \{
     \textcolor{keywordtype}{int} current;
\};

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_signal\_cb(\textcolor{keywordtype}{void} *data, Evas\_Object *o, \textcolor{keyword}{const} \textcolor{keywordtype}{char} *emission, \textcolor{keyword}{const} \textcolor{keywordtype}{char} *source)
\{
   \textcolor{keyword}{struct }\_App *app = data;
   Evas\_Object *icon = elm_object_part_content_get(o, \textcolor{stringliteral}{"elm.swallow.content"});

   printf(\textcolor{stringliteral}{"signal received\(\backslash\)n"});

   \textcolor{keywordflow}{if} (!strcmp(\textcolor{stringliteral}{"elm,action,back"}, emission))
     app->current--;
   \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (!strcmp(\textcolor{stringliteral}{"elm,action,next"}, emission))
     app->current++;

   \textcolor{keywordflow}{if} (app->current < 0)
     app->current = (\textcolor{keyword}{sizeof}(images) / \textcolor{keyword}{sizeof}(images[0])) - 2;
   \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (images[app->current] == NULL)
     app->current = 0;

   elm_icon_standard_set(icon, images[app->current]);
\}

EAPI\_MAIN \textcolor{keywordtype}{int}
elm\_main(\textcolor{keywordtype}{int} argc, \textcolor{keywordtype}{char} **argv)
\{
   Evas\_Object *win, *layout, *icon;
   \textcolor{keyword}{struct }\_App app;

   app.current = 0;

   elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);

   win = elm_win_util_standard_add(\textcolor{stringliteral}{"layout"}, \textcolor{stringliteral}{"Layout"});
   elm_win_autodel_set(win, EINA\_TRUE);

   \textcolor{comment}{// Adding layout and filling it with widgets}
   layout = elm_layout_add(win);
   evas\_object\_size\_hint\_weight\_set(layout, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   elm_win_resize_object_add(win, layout);
   \textcolor{keywordflow}{if} (!elm_layout_theme_set(
         layout, \textcolor{stringliteral}{"layout"}, \textcolor{stringliteral}{"application"}, \textcolor{stringliteral}{"content-back-next"}))
     fprintf(stderr, \textcolor{stringliteral}{"Failed to set layout"});
   evas\_object\_show(layout);

   icon = elm_icon_add(win);
   elm_icon_standard_set(icon, images[app.current]);
   evas\_object\_size\_hint\_weight\_set(layout, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   elm_object_part_content_set(layout, \textcolor{stringliteral}{"elm.swallow.content"}, icon);

   elm_object_signal_callback_add(layout, \textcolor{stringliteral}{"elm,action,back"}, \textcolor{stringliteral}{""}, \_signal\_cb, &app);
   elm_object_signal_callback_add(layout, \textcolor{stringliteral}{"elm,action,next"}, \textcolor{stringliteral}{""}, \_signal\_cb, &app);

   evas\_object\_resize(win, 320, 320);
   evas\_object\_show(win);

   elm_run();
   elm_shutdown();

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