This example shows the simplest possible way to register a handler for an ecore event, this way we can focus on the important aspects.

The example will start the main loop and quit it when it receives the ECORE\+\_\+\+EVENT\+\_\+\+SIGNAL\+\_\+\+EXIT event. This event is triggered by a SIGTERM(pressing ctrl+c).

So let\textquotesingle{}s start with the function we want called when we receive the event, instead of just stopping the main loop we\textquotesingle{}ll also print a message, that\textquotesingle{}s just so it\textquotesingle{}s clear that it got called\+:  
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\textcolor{keyword}{static} \mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}}}
\DoxyCodeLine{\_quitter(\textcolor{keywordtype}{void} *data \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}}, \textcolor{keywordtype}{int} ev\_type \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}}, \textcolor{keywordtype}{void} *event \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}})}
\DoxyCodeLine{\{}
\DoxyCodeLine{   printf(\textcolor{stringliteral}{"{}Leaving already?\(\backslash\)n"{}});}
\DoxyCodeLine{   \mbox{\hyperlink{group__Ecore__Main__Loop__Group_ga95cf8e97dff0716433c2c5474d606a98}{ecore\_main\_loop\_quit}}();}
\DoxyCodeLine{   \textcolor{keywordflow}{return} \mbox{\hyperlink{group__Ecore__Main__Loop__Group_ga780091d7d49a4bb6cb753f12e1a3b19d}{ECORE\_CALLBACK\_DONE}};}
\DoxyCodeLine{\}}

\end{DoxyCodeInclude}
\begin{DoxyNote}{Note}
We return ECORE\+\_\+\+CALLBACK\+\_\+\+DONE because we don\textquotesingle{}t want any other handlers for this event to be called, the program is quitting after all.
\end{DoxyNote}
We then have our main function and the obligatory initialization of ecore\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keywordtype}{int}}
\DoxyCodeLine{main(\textcolor{keywordtype}{void})}
\DoxyCodeLine{\{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Ecore__Init__Group_ga77757609684a2c922dc5ec398274751b}{ecore\_init}}();}

\end{DoxyCodeInclude}
 We then get to the one line of our example that makes everything work, the registering of the callback\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Ecore__Event__Group_ga886c90c3f917f87b3b4c931adcbc41c5}{ecore\_event\_handler\_add}}(\mbox{\hyperlink{group__Ecore__Event__Group_ga0dd1e36930ae8fa8decc97564d57f310}{ECORE\_EVENT\_SIGNAL\_EXIT}}, \_quitter, NULL);}

\end{DoxyCodeInclude}
\begin{DoxyNote}{Note}
The {\ttfamily NULL} there is because there is no need to pass data to the callback.
\end{DoxyNote}
And the all that is left to do is start the main loop\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{   \mbox{\hyperlink{group__Ecore__Main__Loop__Group_gaf103b9f668bb3e4fed12e52c6180132d}{ecore\_main\_loop\_begin}}();}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordflow}{return} 0;}
\DoxyCodeLine{\}}

\end{DoxyCodeInclude}
 Full source code for this example\+: \mbox{\hyperlink{ecore_event_example_01_8c-example}{ecore\+\_\+event\+\_\+example\+\_\+01.\+c}}. 