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 E\+C\+O\+R\+E\+\_\+\+E\+V\+E\+N\+T\+\_\+\+S\+I\+G\+N\+A\+L\+\_\+\+E\+X\+I\+T event. This event is triggered by a S\+I\+G\+T\+E\+R\+M(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}
\textcolor{keyword}{static} \hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}
\_quitter(\textcolor{keywordtype}{void} *data EINA\_UNUSED, \textcolor{keywordtype}{int} ev\_type EINA\_UNUSED, \textcolor{keywordtype}{void} *event EINA\_UNUSED)
\{
   printf(\textcolor{stringliteral}{"Leaving already?\(\backslash\)n"});
   \hyperlink{group__Ecore__Main__Loop__Group_ga95cf8e97dff0716433c2c5474d606a98}{ecore\_main\_loop\_quit}();
   \textcolor{keywordflow}{return} \hyperlink{group__Ecore__Main__Loop__Group_ga780091d7d49a4bb6cb753f12e1a3b19d}{ECORE\_CALLBACK\_DONE};
\}

\end{DoxyCodeInclude}
 \begin{DoxyNote}{Note}
We return E\+C\+O\+R\+E\+\_\+\+C\+A\+L\+L\+B\+A\+C\+K\+\_\+\+D\+O\+N\+E 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}

\textcolor{keywordtype}{int}
main(\textcolor{keywordtype}{void})
\{
   \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}

   \hyperlink{group__Ecore__Event__Group_gae75b0b1b2c50e73b8e42afc628b00a62}{ecore\_event\_handler\_add}(\hyperlink{group__Ecore__Event__Group_ga0dd1e36930ae8fa8decc97564d57f310}{ECORE\_EVENT\_SIGNAL\_EXIT}, \_quitter,
       NULL);

\end{DoxyCodeInclude}
 \begin{DoxyNote}{Note}
The {\ttfamily N\+U\+L\+L} 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}
   \hyperlink{group__Ecore__Main__Loop__Group_gaf103b9f668bb3e4fed12e52c6180132d}{ecore\_main\_loop\_begin}();

   \textcolor{keywordflow}{return} 0;
\}

\end{DoxyCodeInclude}


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