

This example will illustrates the usage of some basic Ecore\+\_\+\+Evas functions. This example will list the available evas engines, check which one we used to create our window and set some data on our Ecore\+\_\+\+Evas. It also allows you to hide/show all windows in this process(we only have one, but if there were more they would be hidden), to hide the windows type \textquotesingle{}h\textquotesingle{} and hit return, to show them, type \textquotesingle{}s\textquotesingle{} and hit return.

The very first thing we\textquotesingle{}ll do is initialize ecore\+\_\+evas\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{   \textcolor{keywordflow}{if} (\mbox{\hyperlink{group__Ecore__Evas__Group_ga32ddbb6457033ad435a177eb0c4fe235}{ecore\_evas\_init}}() <= 0)}
\DoxyCodeLine{     \textcolor{keywordflow}{return} 1;}

\end{DoxyCodeInclude}


Once inited we query which engines are available\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{}
\DoxyCodeLine{   engines = \mbox{\hyperlink{group__Ecore__Evas__Group_gab05620912f2d3ca276281efa774104d5}{ecore\_evas\_engines\_get}}();}
\DoxyCodeLine{   printf(\textcolor{stringliteral}{"Available engines:\(\backslash\)n"});}
\DoxyCodeLine{   \mbox{\hyperlink{group__Eina__List__Group_gac6efafc19f526d916cdb9757240a8773}{EINA\_LIST\_FOREACH}}(engines, l, data)}
\DoxyCodeLine{     printf(\textcolor{stringliteral}{"\%s\(\backslash\)n"}, data);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Ecore__Evas__Group_ga85538b892d449f5c7a056ca4d49e72a7}{ecore\_evas\_engines\_free}}(engines);}

\end{DoxyCodeInclude}


We then create an Ecore\+\_\+\+Evas(window) with the first available engine, on position 0,0 with size 200,200 and no especial flags, set it\textquotesingle{}s title and show it\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{}
\DoxyCodeLine{   ee = \mbox{\hyperlink{group__Ecore__Evas__Group_gac7f2cdbcb79635c34317c1183dd04cb0}{ecore\_evas\_new}}(NULL, 0, 0, 200, 200, NULL);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Ecore__Evas__Group_ga3b2832e0373bbafae2bb7143618535c1}{ecore\_evas\_title\_set}}(ee, \textcolor{stringliteral}{"Ecore Evas basics Example"});}
\DoxyCodeLine{   \mbox{\hyperlink{group__Ecore__Evas__Group_ga4953047ff97d4f1b0d75a7d513d4f317}{ecore\_evas\_show}}(ee);}

\end{DoxyCodeInclude}


We now add some important data to our Ecore\+\_\+\+Evas\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{}
\DoxyCodeLine{   data = malloc(\textcolor{keyword}{sizeof}(\textcolor{keywordtype}{char}) * 6);}
\DoxyCodeLine{   sprintf(data, \textcolor{stringliteral}{"\%s"}, \textcolor{stringliteral}{"hello"});}
\DoxyCodeLine{   \mbox{\hyperlink{group__Ecore__Evas__Group_gaa86c5abd200a02711aced53d27b9ddb2}{ecore\_evas\_data\_set}}(ee, \textcolor{stringliteral}{"key"}, data);}

\end{DoxyCodeInclude}


And since our data is dynamically allocated we\textquotesingle{}ll need to free it when the Ecore\+\_\+\+Evas dies\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{   \mbox{\hyperlink{group__Ecore__Evas__Group_ga3d478e975e2101b9b821ef24baf3dd9e}{ecore\_evas\_callback\_delete\_request\_set}}(ee, \_on\_delete);}

\end{DoxyCodeInclude}
  
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\textcolor{keyword}{static} \textcolor{keywordtype}{void}}
\DoxyCodeLine{\_on\_delete(Ecore\_Evas *ee)}
\DoxyCodeLine{\{}
\DoxyCodeLine{   free(\mbox{\hyperlink{group__Ecore__Evas__Group_gae00d4a4feb8aec5de03e464fe21a1d30}{ecore\_evas\_data\_get}}(ee, \textcolor{stringliteral}{"key"}));}
\DoxyCodeLine{   \mbox{\hyperlink{group__Ecore__Main__Loop__Group_ga95cf8e97dff0716433c2c5474d606a98}{ecore\_main\_loop\_quit}}();}
\DoxyCodeLine{\}}

\end{DoxyCodeInclude}


We now print which Evas engine is being used for our example\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{   printf(\textcolor{stringliteral}{"Using \%s engine!\(\backslash\)n"}, \mbox{\hyperlink{group__Ecore__Evas__Group_ga1e47d61067e45e24951b8b1d1f131be7}{ecore\_evas\_engine\_name\_get}}(ee));}

\end{DoxyCodeInclude}


We are going to add a background to our window but before we can do that we\textquotesingle{}ll need to get the canvas(\+Evas) on which to draw it\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{}
\DoxyCodeLine{   canvas = \mbox{\hyperlink{group__Ecore__Evas__Group_ga75a7cc694b6069e78df47dab0b0f2d20}{ecore\_evas\_get}}(ee);}

\end{DoxyCodeInclude}


We then do a sanity check, verifying if the Ecore\+\_\+\+Evas of the Evas is the Ecore\+\_\+\+Evas from which we got the Evas\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{   \textcolor{keywordflow}{if} (\mbox{\hyperlink{group__Ecore__Evas__Group_ga81e49472d5b55809952bf9676daf6a82}{ecore\_evas\_ecore\_evas\_get}}(canvas) == ee)}
\DoxyCodeLine{     printf(\textcolor{stringliteral}{"Everything is sane!\(\backslash\)n"});}

\end{DoxyCodeInclude}


Now we can actually add the background\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{}
\DoxyCodeLine{   bg = \mbox{\hyperlink{group__Evas__Object__Rectangle_ga4d80fc32ad1cac28428cebd65d746751}{evas\_object\_rectangle\_add}}(canvas);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Object__Group__Basic_gae34bdcfd7f5100151f6ea8ef4a392949}{evas\_object\_color\_set}}(bg, 0, 0, 255, 255);}
\DoxyCodeLine{   evas\_object\_resize(bg, 200, 200);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}}(bg);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Ecore__Evas__Group_gac35627a5c3a766ee42762dbcc9eb733d}{ecore\_evas\_object\_associate}}(ee, bg, ECORE\_EVAS\_OBJECT\_ASSOCIATE\_BASE);}

\end{DoxyCodeInclude}


To hide and show the windows of this process when the user presses \textquotesingle{}h\textquotesingle{} and \textquotesingle{}s\textquotesingle{} respectively we need to know when the user types something, so we register a callback for when we can read something from {\ttfamily stdin\+:} 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Ecore__FD__Handler__Group_ga832e68eb7f15912abeadef816bb5d2f5}{ecore\_main\_fd\_handler\_add}}(STDIN\_FILENO, \mbox{\hyperlink{group__Ecore__FD__Handler__Group_ggab5644f471dfa3bd182619601d9b60608a1699f804eccf88e7e169a4a20f1d44e7}{ECORE\_FD\_READ}}, \_stdin\_cb, NULL, NULL, NULL);}

\end{DoxyCodeInclude}


The callback that actually does the hiding and showing is pretty simple, it does a {\ttfamily scanf}(which we know won\textquotesingle{}t block since there is something to read on {\ttfamily stdin}) and if the character is an \textquotesingle{}h\textquotesingle{} we iterate over all windows calling {\ttfamily ecore\+\_\+evas\+\_\+hide} on them, if the character is an \textquotesingle{}s\textquotesingle{} we call {\ttfamily ecore\+\_\+evas\+\_\+show} instead\+:  
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\textcolor{keyword}{static} \mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}}}
\DoxyCodeLine{\_stdin\_cb(\textcolor{keywordtype}{void} *data \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}}, \mbox{\hyperlink{group__Ecore__FD__Handler__Group_ga225121ed2123da4b52b76aa08d78c220}{Ecore\_Fd\_Handler}} *handler \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}})}
\DoxyCodeLine{\{}
\DoxyCodeLine{   \mbox{\hyperlink{struct__Eina__List}{Eina\_List}} *l;}
\DoxyCodeLine{   Ecore\_Evas *ee;}
\DoxyCodeLine{   \textcolor{keywordtype}{char} c;}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordtype}{int} ret = scanf(\textcolor{stringliteral}{"\%c"}, \&c);}
\DoxyCodeLine{   \textcolor{keywordflow}{if} (ret < 1) \textcolor{keywordflow}{return} \mbox{\hyperlink{group__Ecore__Main__Loop__Group_ga1ee9db07f9a46a8b20fb83e1c6dbed09}{ECORE\_CALLBACK\_RENEW}};}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordflow}{if} (c == \textcolor{charliteral}{'h'})}
\DoxyCodeLine{     \mbox{\hyperlink{group__Eina__List__Group_gac6efafc19f526d916cdb9757240a8773}{EINA\_LIST\_FOREACH}}(\mbox{\hyperlink{group__Ecore__Evas__Group_gae941cd1dca7354ef68e3137e76db6688}{ecore\_evas\_ecore\_evas\_list\_get}}(), l, ee)}
\DoxyCodeLine{       \mbox{\hyperlink{group__Ecore__Evas__Group_ga0c4c806d5873a4528334e398d28940d4}{ecore\_evas\_hide}}(ee);}
\DoxyCodeLine{   \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (c == \textcolor{charliteral}{'s'})}
\DoxyCodeLine{     \mbox{\hyperlink{group__Eina__List__Group_gac6efafc19f526d916cdb9757240a8773}{EINA\_LIST\_FOREACH}}(\mbox{\hyperlink{group__Ecore__Evas__Group_gae941cd1dca7354ef68e3137e76db6688}{ecore\_evas\_ecore\_evas\_list\_get}}(), l, ee)}
\DoxyCodeLine{       \mbox{\hyperlink{group__Ecore__Evas__Group_ga4953047ff97d4f1b0d75a7d513d4f317}{ecore\_evas\_show}}(ee);}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordflow}{return} \mbox{\hyperlink{group__Ecore__Main__Loop__Group_ga1ee9db07f9a46a8b20fb83e1c6dbed09}{ECORE\_CALLBACK\_RENEW}};}
\DoxyCodeLine{\}}

\end{DoxyCodeInclude}


Once all is done we run our main loop, and when that is done(application is exiting) we free our Ecore\+\_\+\+Evas and shutdown the ecore\+\_\+evas subsystem\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{   \mbox{\hyperlink{group__Ecore__Main__Loop__Group_gaf103b9f668bb3e4fed12e52c6180132d}{ecore\_main\_loop\_begin}}();}
\DoxyCodeLine{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Ecore__Evas__Group_gad3ec61f2aa03df4d3dbfd0d311e0c8dc}{ecore\_evas\_free}}(ee);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Ecore__Evas__Group_gab8fa311077f749190c9b622f672b2214}{ecore\_evas\_shutdown}}();}

\end{DoxyCodeInclude}


Here you have the full-\/source of the code\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{preprocessor}{\#include <Ecore.h>}}
\DoxyCodeLine{\textcolor{preprocessor}{\#include <\mbox{\hyperlink{Ecore__Evas_8h}{Ecore\_Evas.h}}>}}
\DoxyCodeLine{\textcolor{preprocessor}{\#include <unistd.h>}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static} \mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}}}
\DoxyCodeLine{\_stdin\_cb(\textcolor{keywordtype}{void} *data \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}}, \mbox{\hyperlink{group__Ecore__FD__Handler__Group_ga225121ed2123da4b52b76aa08d78c220}{Ecore\_Fd\_Handler}} *handler \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}})}
\DoxyCodeLine{\{}
\DoxyCodeLine{   \mbox{\hyperlink{struct__Eina__List}{Eina\_List}} *l;}
\DoxyCodeLine{   Ecore\_Evas *ee;}
\DoxyCodeLine{   \textcolor{keywordtype}{char} c;}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordtype}{int} ret = scanf(\textcolor{stringliteral}{"\%c"}, \&c);}
\DoxyCodeLine{   \textcolor{keywordflow}{if} (ret < 1) \textcolor{keywordflow}{return} \mbox{\hyperlink{group__Ecore__Main__Loop__Group_ga1ee9db07f9a46a8b20fb83e1c6dbed09}{ECORE\_CALLBACK\_RENEW}};}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordflow}{if} (c == \textcolor{charliteral}{'h'})}
\DoxyCodeLine{     \mbox{\hyperlink{group__Eina__List__Group_gac6efafc19f526d916cdb9757240a8773}{EINA\_LIST\_FOREACH}}(\mbox{\hyperlink{group__Ecore__Evas__Group_gae941cd1dca7354ef68e3137e76db6688}{ecore\_evas\_ecore\_evas\_list\_get}}(), l, ee)}
\DoxyCodeLine{       \mbox{\hyperlink{group__Ecore__Evas__Group_ga0c4c806d5873a4528334e398d28940d4}{ecore\_evas\_hide}}(ee);}
\DoxyCodeLine{   \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (c == \textcolor{charliteral}{'s'})}
\DoxyCodeLine{     \mbox{\hyperlink{group__Eina__List__Group_gac6efafc19f526d916cdb9757240a8773}{EINA\_LIST\_FOREACH}}(\mbox{\hyperlink{group__Ecore__Evas__Group_gae941cd1dca7354ef68e3137e76db6688}{ecore\_evas\_ecore\_evas\_list\_get}}(), l, ee)}
\DoxyCodeLine{       \mbox{\hyperlink{group__Ecore__Evas__Group_ga4953047ff97d4f1b0d75a7d513d4f317}{ecore\_evas\_show}}(ee);}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordflow}{return} \mbox{\hyperlink{group__Ecore__Main__Loop__Group_ga1ee9db07f9a46a8b20fb83e1c6dbed09}{ECORE\_CALLBACK\_RENEW}};}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static} \textcolor{keywordtype}{void}}
\DoxyCodeLine{\_on\_delete(Ecore\_Evas *ee)}
\DoxyCodeLine{\{}
\DoxyCodeLine{   free(\mbox{\hyperlink{group__Ecore__Evas__Group_gae00d4a4feb8aec5de03e464fe21a1d30}{ecore\_evas\_data\_get}}(ee, \textcolor{stringliteral}{"key"}));}
\DoxyCodeLine{   \mbox{\hyperlink{group__Ecore__Main__Loop__Group_ga95cf8e97dff0716433c2c5474d606a98}{ecore\_main\_loop\_quit}}();}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keywordtype}{int}}
\DoxyCodeLine{main(\textcolor{keywordtype}{void})}
\DoxyCodeLine{\{}
\DoxyCodeLine{   Ecore\_Evas *ee;}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Canvas_ga5ff87cc4ce6bc43e3b640a6d37f73043}{Evas}} *canvas;}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *bg;}
\DoxyCodeLine{   \mbox{\hyperlink{struct__Eina__List}{Eina\_List}} *engines, *l;}
\DoxyCodeLine{   \textcolor{keywordtype}{char} *data;}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordflow}{if} (\mbox{\hyperlink{group__Ecore__Evas__Group_ga32ddbb6457033ad435a177eb0c4fe235}{ecore\_evas\_init}}() <= 0)}
\DoxyCodeLine{     \textcolor{keywordflow}{return} 1;}
\DoxyCodeLine{}
\DoxyCodeLine{   engines = \mbox{\hyperlink{group__Ecore__Evas__Group_gab05620912f2d3ca276281efa774104d5}{ecore\_evas\_engines\_get}}();}
\DoxyCodeLine{   printf(\textcolor{stringliteral}{"Available engines:\(\backslash\)n"});}
\DoxyCodeLine{   \mbox{\hyperlink{group__Eina__List__Group_gac6efafc19f526d916cdb9757240a8773}{EINA\_LIST\_FOREACH}}(engines, l, data)}
\DoxyCodeLine{     printf(\textcolor{stringliteral}{"\%s\(\backslash\)n"}, data);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Ecore__Evas__Group_ga85538b892d449f5c7a056ca4d49e72a7}{ecore\_evas\_engines\_free}}(engines);}
\DoxyCodeLine{}
\DoxyCodeLine{   ee = \mbox{\hyperlink{group__Ecore__Evas__Group_gac7f2cdbcb79635c34317c1183dd04cb0}{ecore\_evas\_new}}(NULL, 0, 0, 200, 200, NULL);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Ecore__Evas__Group_ga3b2832e0373bbafae2bb7143618535c1}{ecore\_evas\_title\_set}}(ee, \textcolor{stringliteral}{"Ecore Evas basics Example"});}
\DoxyCodeLine{   \mbox{\hyperlink{group__Ecore__Evas__Group_ga4953047ff97d4f1b0d75a7d513d4f317}{ecore\_evas\_show}}(ee);}
\DoxyCodeLine{}
\DoxyCodeLine{   data = malloc(\textcolor{keyword}{sizeof}(\textcolor{keywordtype}{char}) * 6);}
\DoxyCodeLine{   sprintf(data, \textcolor{stringliteral}{"\%s"}, \textcolor{stringliteral}{"hello"});}
\DoxyCodeLine{   \mbox{\hyperlink{group__Ecore__Evas__Group_gaa86c5abd200a02711aced53d27b9ddb2}{ecore\_evas\_data\_set}}(ee, \textcolor{stringliteral}{"key"}, data);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Ecore__Evas__Group_ga3d478e975e2101b9b821ef24baf3dd9e}{ecore\_evas\_callback\_delete\_request\_set}}(ee, \_on\_delete);}
\DoxyCodeLine{}
\DoxyCodeLine{   printf(\textcolor{stringliteral}{"Using \%s engine!\(\backslash\)n"}, \mbox{\hyperlink{group__Ecore__Evas__Group_ga1e47d61067e45e24951b8b1d1f131be7}{ecore\_evas\_engine\_name\_get}}(ee));}
\DoxyCodeLine{}
\DoxyCodeLine{   canvas = \mbox{\hyperlink{group__Ecore__Evas__Group_ga75a7cc694b6069e78df47dab0b0f2d20}{ecore\_evas\_get}}(ee);}
\DoxyCodeLine{   \textcolor{keywordflow}{if} (\mbox{\hyperlink{group__Ecore__Evas__Group_ga81e49472d5b55809952bf9676daf6a82}{ecore\_evas\_ecore\_evas\_get}}(canvas) == ee)}
\DoxyCodeLine{     printf(\textcolor{stringliteral}{"Everything is sane!\(\backslash\)n"});}
\DoxyCodeLine{}
\DoxyCodeLine{   bg = \mbox{\hyperlink{group__Evas__Object__Rectangle_ga4d80fc32ad1cac28428cebd65d746751}{evas\_object\_rectangle\_add}}(canvas);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Object__Group__Basic_gae34bdcfd7f5100151f6ea8ef4a392949}{evas\_object\_color\_set}}(bg, 0, 0, 255, 255);}
\DoxyCodeLine{   evas\_object\_resize(bg, 200, 200);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}}(bg);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Ecore__Evas__Group_gac35627a5c3a766ee42762dbcc9eb733d}{ecore\_evas\_object\_associate}}(ee, bg, ECORE\_EVAS\_OBJECT\_ASSOCIATE\_BASE);}
\DoxyCodeLine{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Ecore__FD__Handler__Group_ga832e68eb7f15912abeadef816bb5d2f5}{ecore\_main\_fd\_handler\_add}}(STDIN\_FILENO, \mbox{\hyperlink{group__Ecore__FD__Handler__Group_ggab5644f471dfa3bd182619601d9b60608a1699f804eccf88e7e169a4a20f1d44e7}{ECORE\_FD\_READ}}, \_stdin\_cb, NULL, NULL, NULL);}
\DoxyCodeLine{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Ecore__Main__Loop__Group_gaf103b9f668bb3e4fed12e52c6180132d}{ecore\_main\_loop\_begin}}();}
\DoxyCodeLine{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Ecore__Evas__Group_gad3ec61f2aa03df4d3dbfd0d311e0c8dc}{ecore\_evas\_free}}(ee);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Ecore__Evas__Group_gab8fa311077f749190c9b622f672b2214}{ecore\_evas\_shutdown}}();}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordflow}{return} 0;}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\end{DoxyCodeInclude}
 