4 struct context // helper struct to give some context to the callbacks
7 Ecore_Idle_Enterer *enterer;
9 Ecore_Idle_Exiter *exiter;
10 Ecore_Event_Handler *handler;
14 static _event_type = 0; // a new type of event will be defined and stored here
17 _enterer_cb(void *data) // the idle enterer callback
19 printf("IDLE ENTERER: Ecore entering in idle state.\n");
21 return ECORE_CALLBACK_RENEW; // same as EINA_TRUE
25 _exiter_cb(void *data) // the idle exiter callback
27 printf("IDLE EXITER: Ecore exiting idle state.\n");
29 return ECORE_CALLBACK_RENEW; // same as EINA_TRUE
33 _idler_cb(void *data) // the idler callback - ran while the mainloop is idle
35 struct context *ctxt = data;
36 printf("IDLER: executing idler callback while in idle state.\n");
40 /* each 10 times that the callback gets called, generate an event that
41 * will wake up the main loop, triggering idle enterers, exiters, etc. */
42 if ((ctxt->count % 10) == 0)
43 ecore_event_add(_event_type, NULL, NULL, NULL);
45 return ECORE_CALLBACK_RENEW; // same as EINA_TRUE
49 _event_handler_cb(void *data, int type, void *event) // event callback
51 struct context *ctxt = data;
53 printf("EVENT: processing callback for the event received.\n");
55 if (ctxt->count > 100)
57 ecore_idle_enterer_del(ctxt->enterer);
58 ecore_idle_exiter_del(ctxt->exiter);
59 ecore_idler_del(ctxt->idler);
67 ecore_timer_del(ctxt->timer);
71 ecore_main_loop_quit();
74 return ECORE_CALLBACK_DONE; // same as EINA_FALSE
80 struct context *ctxt = data;
81 printf("TIMER: timer callback called.\n");
86 return ECORE_CALLBACK_CANCEL; // same as EINA_FALSE
90 main(int argc, char **argv)
92 struct context ctxt = {0};
96 printf("ERROR: Cannot init Ecore!\n");
100 _event_type = ecore_event_type_new();
102 ctxt.enterer = ecore_idle_enterer_add(_enterer_cb, &ctxt);
103 ctxt.exiter = ecore_idle_exiter_add(_exiter_cb, &ctxt);
104 ctxt.idler = ecore_idler_add(_idler_cb, &ctxt);
105 ctxt.handler = ecore_event_handler_add(_event_type,
108 ctxt.timer = ecore_timer_add(0.0005, _timer_cb, &ctxt);
110 ecore_main_loop_begin();