This example will show you how to load an image using evas and fill a swallow with it.

It\textquotesingle{}s basically almost like the last example, but with a minor change.

This variables are used to store the name of the image that is going to be used, the path to it and a variable that will store the error cause if something goes wrong.

Here it is\+:  
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{   \textcolor{keyword}{const} \textcolor{keywordtype}{char}  *edje\_file = PACKAGE\_DATA\_DIR\textcolor{stringliteral}{"{}/swallow.edj"{}};}
\DoxyCodeLine{   \textcolor{keyword}{const} \textcolor{keywordtype}{char}  *img\_file = PACKAGE\_SOURCE\_DATA\_DIR\textcolor{stringliteral}{"{}/bubble.png"{}};}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Image_ga17a0211044defa51aa3ceaadaa4e53c2}{Evas\_Load\_Error}} err;}

\end{DoxyCodeInclude}


Then we load the image with this command\+:


\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{   img = \mbox{\hyperlink{group__Evas__Object__Image_gafb52be265f315186a28d43af2d559ec6}{evas\_object\_image\_filled\_add}}(evas);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Object__Image_gac2e588476b16b04f85ca9a594c140c1d}{evas\_object\_image\_file\_set}}(img, img\_file, NULL);}

\end{DoxyCodeInclude}
 To check if we had some problem we use\+:


\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{   err = \mbox{\hyperlink{group__Evas__Object__Image_ga10a0117fbd14e665a988cd4913c324d9}{evas\_object\_image\_load\_error\_get}}(img);}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordflow}{if} (err != \mbox{\hyperlink{group__Evas__Image_gga17a0211044defa51aa3ceaadaa4e53c2a016233a6ae27765a3aa2759753c112ac}{EVAS\_LOAD\_ERROR\_NONE}})}
\DoxyCodeLine{   \{}
\DoxyCodeLine{      fprintf(stderr, \textcolor{stringliteral}{"{}could not load image '\%s'. error string is \(\backslash\)"{}\%s\(\backslash\)"{}\(\backslash\)n"{}},}
\DoxyCodeLine{              img\_file, \mbox{\hyperlink{group__Evas__Utils_gaa067ec9b15e558d510a7ac373f700348}{evas\_load\_error\_str}}(err));}
\DoxyCodeLine{     \textcolor{keywordflow}{goto} shutdown\_edje;}
\DoxyCodeLine{   \}}

\end{DoxyCodeInclude}
 Now we are going to swallow it and check if worked. If you notice we are using \char`\"{}part\+\_\+one\char`\"{} as argument. We do this because we must explicit what part of our .edc file we want to swallow\+:


\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{   \mbox{\hyperlink{group__Edje__Object__Part_ga97d1419f89bff20ba971e47c78641271}{edje\_object\_part\_swallow}}(edje\_obj, \textcolor{stringliteral}{"{}part\_one"{}}, img);}
\DoxyCodeLine{}
\DoxyCodeLine{   obj = \mbox{\hyperlink{group__Edje__Object__Part_gabbb9c38b34a9d4ca193eac7bf552cf59}{edje\_object\_part\_swallow\_get}}(edje\_obj, \textcolor{stringliteral}{"{}part\_one"{}});}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordflow}{if}(obj == img)}
\DoxyCodeLine{      printf(\textcolor{stringliteral}{"{}Swallowing worked!\(\backslash\)n"{}});}

\end{DoxyCodeInclude}
 The example\textquotesingle{}s window should look like this picture\+:

  
\begin{DoxyImageNoCaption}
  \mbox{\includegraphics[width=\textwidth]{swallow2final}}
\end{DoxyImageNoCaption}


The complete .edc file\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{collections \{}
\DoxyCodeLine{   group \{}
\DoxyCodeLine{      name: "{}example\_group"{};}
\DoxyCodeLine{      max: 500 500;}
\DoxyCodeLine{      min: 50 50;}
\DoxyCodeLine{}
\DoxyCodeLine{      parts \{}
\DoxyCodeLine{         part \{}
\DoxyCodeLine{            name: "{}part\_one"{};}
\DoxyCodeLine{            type: SWALLOW;}
\DoxyCodeLine{            description \{}
\DoxyCodeLine{               min: 50 50;}
\DoxyCodeLine{               state: "{}default"{} 0.0;}
\DoxyCodeLine{               rel1.relative: 0.0 0.0;}
\DoxyCodeLine{               rel2.relative: 1.0 1.0;}
\DoxyCodeLine{            \}}
\DoxyCodeLine{         \}}
\DoxyCodeLine{      \}}
\DoxyCodeLine{}
\DoxyCodeLine{   \}}
\DoxyCodeLine{\}}

\end{DoxyCodeInclude}


And the source code\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{preprocessor}{\#ifdef HAVE\_CONFIG\_H}}
\DoxyCodeLine{\textcolor{preprocessor}{\# include "{}config.h"{}}}
\DoxyCodeLine{\textcolor{preprocessor}{\#else}}
\DoxyCodeLine{\textcolor{preprocessor}{\# define EINA\_UNUSED}}
\DoxyCodeLine{\textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{preprocessor}{\#ifndef PACKAGE\_DATA\_DIR}}
\DoxyCodeLine{\textcolor{preprocessor}{\#define PACKAGE\_DATA\_DIR "{}."{}}}
\DoxyCodeLine{\textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{preprocessor}{\#ifndef PACKAGE\_SOURCE\_DATA\_DIR}}
\DoxyCodeLine{\textcolor{preprocessor}{\#define PACKAGE\_SOURCE\_DATA\_DIR "{}."{}}}
\DoxyCodeLine{\textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{preprocessor}{\#include <Ecore.h>}}
\DoxyCodeLine{\textcolor{preprocessor}{\#include <\mbox{\hyperlink{Ecore__Evas_8h}{Ecore\_Evas.h}}>}}
\DoxyCodeLine{\textcolor{preprocessor}{\#include <\mbox{\hyperlink{Edje_8h}{Edje.h}}>}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{preprocessor}{\#define WIDTH  (300)}}
\DoxyCodeLine{\textcolor{preprocessor}{\#define HEIGHT (300)}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static} \textcolor{keywordtype}{void}}
\DoxyCodeLine{\_on\_delete(Ecore\_Evas *ee \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}})}
\DoxyCodeLine{\{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Ecore__Main__Loop__Group_ga95cf8e97dff0716433c2c5474d606a98}{ecore\_main\_loop\_quit}}();}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keywordtype}{int}}
\DoxyCodeLine{main(\textcolor{keywordtype}{int} argc \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}}, \textcolor{keywordtype}{char} *argv[] \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}})}
\DoxyCodeLine{\{}
\DoxyCodeLine{   \textcolor{keyword}{const} \textcolor{keywordtype}{char}  *edje\_file = PACKAGE\_DATA\_DIR\textcolor{stringliteral}{"{}/swallow.edj"{}};}
\DoxyCodeLine{   \textcolor{keyword}{const} \textcolor{keywordtype}{char}  *img\_file = PACKAGE\_SOURCE\_DATA\_DIR\textcolor{stringliteral}{"{}/bubble.png"{}};}
\DoxyCodeLine{   Ecore\_Evas  *ee;}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Canvas_ga5ff87cc4ce6bc43e3b640a6d37f73043}{Evas}}        *evas;}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *bg;}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *img;}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *obj;}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *edje\_obj;}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Image_ga17a0211044defa51aa3ceaadaa4e53c2}{Evas\_Load\_Error}} err;}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordflow}{if} (!\mbox{\hyperlink{group__Ecore__Evas__Group_ga32ddbb6457033ad435a177eb0c4fe235}{ecore\_evas\_init}}())}
\DoxyCodeLine{     \textcolor{keywordflow}{return} EXIT\_FAILURE;}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordflow}{if} (!\mbox{\hyperlink{group__Edje__General__Group_ga1c9c6594f38023c29fbfb2d0c8c675db}{edje\_init}}())}
\DoxyCodeLine{     \textcolor{keywordflow}{goto} shutdown\_ecore\_evas;}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{comment}{/* this will give you a window with an Evas canvas under the first}}
\DoxyCodeLine{\textcolor{comment}{    * engine available */}}
\DoxyCodeLine{   ee = \mbox{\hyperlink{group__Ecore__Evas__Group_gaaa770b6f2f1395f9eeb0e50e26c3f933}{ecore\_evas\_new}}(NULL, 0, 0, WIDTH, HEIGHT, NULL);}
\DoxyCodeLine{   \textcolor{keywordflow}{if} (!ee) \textcolor{keywordflow}{goto} shutdown\_edje;}
\DoxyCodeLine{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Ecore__Evas__Group_ga3d478e975e2101b9b821ef24baf3dd9e}{ecore\_evas\_callback\_delete\_request\_set}}(ee, \_on\_delete);}
\DoxyCodeLine{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Ecore__Evas__Group_ga3b2832e0373bbafae2bb7143618535c1}{ecore\_evas\_title\_set}}(ee, \textcolor{stringliteral}{"{}Edje Swallow Example"{}});}
\DoxyCodeLine{}
\DoxyCodeLine{   evas = \mbox{\hyperlink{group__Ecore__Evas__Group_ga6f8d214cd55bc940d7cc62fecd8dbc06}{ecore\_evas\_get}}(ee);}
\DoxyCodeLine{}
\DoxyCodeLine{   bg = \mbox{\hyperlink{group__Evas__Object__Rectangle_ga1b7a9d8e6ce240590c1734da5f3449d2}{evas\_object\_rectangle\_add}}(evas);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Object__Group__Basic_gab751e9d24c16e74af6f7c08ea5b930c2}{evas\_object\_color\_set}}(bg, 255, 255, 255, 255); \textcolor{comment}{/* white bg */}}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Object__Group_ga335c8ee6eaeaac9710656af4f8b0db91}{evas\_object\_move}}(bg, 0, 0); \textcolor{comment}{/* at canvas' origin */}}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Object__Group_gacad94595f83580c18908cb3b69b08d1a}{evas\_object\_resize}}(bg, WIDTH, HEIGHT); \textcolor{comment}{/* covers full canvas */}}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga07208fcafd4739de606bc35fff684bf5}{evas\_object\_show}}(bg);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Ecore__Evas__Group_gaa86c5abd200a02711aced53d27b9ddb2}{ecore\_evas\_data\_set}}(ee, \textcolor{stringliteral}{"{}background"{}}, bg);}
\DoxyCodeLine{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Ecore__Evas__Group_gac35627a5c3a766ee42762dbcc9eb733d}{ecore\_evas\_object\_associate}}(ee,bg, ECORE\_EVAS\_OBJECT\_ASSOCIATE\_BASE);}
\DoxyCodeLine{}
\DoxyCodeLine{   edje\_obj = \mbox{\hyperlink{group__Edje__Object__Group_ga5548cef32568746f40df9bd0be339bea}{edje\_object\_add}}(evas);}
\DoxyCodeLine{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Edje__Object__Group_gaec1edd24b5bd8e82823759a8dddc1996}{edje\_object\_file\_set}}(edje\_obj, edje\_file, \textcolor{stringliteral}{"{}example\_group"{}});}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Object__Group_ga335c8ee6eaeaac9710656af4f8b0db91}{evas\_object\_move}}(edje\_obj, 20, 20);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Object__Group_gacad94595f83580c18908cb3b69b08d1a}{evas\_object\_resize}}(edje\_obj, WIDTH -\/ 40, HEIGHT -\/ 40);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga07208fcafd4739de606bc35fff684bf5}{evas\_object\_show}}(edje\_obj);}
\DoxyCodeLine{}
\DoxyCodeLine{   img = \mbox{\hyperlink{group__Evas__Object__Image_gafb52be265f315186a28d43af2d559ec6}{evas\_object\_image\_filled\_add}}(evas);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Object__Image_gac2e588476b16b04f85ca9a594c140c1d}{evas\_object\_image\_file\_set}}(img, img\_file, NULL);}
\DoxyCodeLine{}
\DoxyCodeLine{   err = \mbox{\hyperlink{group__Evas__Object__Image_ga10a0117fbd14e665a988cd4913c324d9}{evas\_object\_image\_load\_error\_get}}(img);}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordflow}{if} (err != \mbox{\hyperlink{group__Evas__Image_gga17a0211044defa51aa3ceaadaa4e53c2a016233a6ae27765a3aa2759753c112ac}{EVAS\_LOAD\_ERROR\_NONE}})}
\DoxyCodeLine{   \{}
\DoxyCodeLine{      fprintf(stderr, \textcolor{stringliteral}{"{}could not load image '\%s'. error string is \(\backslash\)"{}\%s\(\backslash\)"{}\(\backslash\)n"{}},}
\DoxyCodeLine{              img\_file, \mbox{\hyperlink{group__Evas__Utils_gaa067ec9b15e558d510a7ac373f700348}{evas\_load\_error\_str}}(err));}
\DoxyCodeLine{     \textcolor{keywordflow}{goto} shutdown\_edje;}
\DoxyCodeLine{   \}}
\DoxyCodeLine{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Edje__Object__Part_ga97d1419f89bff20ba971e47c78641271}{edje\_object\_part\_swallow}}(edje\_obj, \textcolor{stringliteral}{"{}part\_one"{}}, img);}
\DoxyCodeLine{}
\DoxyCodeLine{   obj = \mbox{\hyperlink{group__Edje__Object__Part_gabbb9c38b34a9d4ca193eac7bf552cf59}{edje\_object\_part\_swallow\_get}}(edje\_obj, \textcolor{stringliteral}{"{}part\_one"{}});}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordflow}{if}(obj == img)}
\DoxyCodeLine{      printf(\textcolor{stringliteral}{"{}Swallowing worked!\(\backslash\)n"{}});}
\DoxyCodeLine{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Ecore__Evas__Group_ga4953047ff97d4f1b0d75a7d513d4f317}{ecore\_evas\_show}}(ee);}
\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{   \mbox{\hyperlink{group__Edje__General__Group_ga01041f6702f2d81bf10c3e41899805cb}{edje\_shutdown}}();}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordflow}{return} EXIT\_SUCCESS;}
\DoxyCodeLine{}
\DoxyCodeLine{ shutdown\_edje:}
\DoxyCodeLine{   \mbox{\hyperlink{group__Edje__General__Group_ga01041f6702f2d81bf10c3e41899805cb}{edje\_shutdown}}();}
\DoxyCodeLine{ shutdown\_ecore\_evas:}
\DoxyCodeLine{   \mbox{\hyperlink{group__Ecore__Evas__Group_gab8fa311077f749190c9b622f672b2214}{ecore\_evas\_shutdown}}();}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordflow}{return} EXIT\_FAILURE;}
\DoxyCodeLine{\}}

\end{DoxyCodeInclude}


To compile use this command\+: \begin{DoxyVerb}* gcc -o edje-swallow2 edje-swallow2.c -DPACKAGE_BIN_DIR=\"/Where/enlightenment/is/installed/bin\"
* -DPACKAGE_LIB_DIR=\"/Where/enlightenment/is/installed/lib\"
* -DPACKAGE_DATA_DIR=\"/Where/enlightenment/is/installed/share\"
* `pkg-config --cflags --libs evas ecore ecore-evas edje`
*
* edje_cc swallow.edc
* \end{DoxyVerb}
 