forked from enlightenment/efl
parent
56c4d96737
commit
d39d9de182
|
@ -1,39 +1,41 @@
|
||||||
/* Ecore Event Handler Example.
|
/* Ecore Event Handler Example. */
|
||||||
*/
|
|
||||||
|
|
||||||
#include <Ecore.h>
|
#include <Ecore.h>
|
||||||
|
|
||||||
Ecore_Event_Handler *handler1 = NULL, *handler2 = NULL;
|
Ecore_Event_Handler *handler1 = NULL, *handler2 = NULL;
|
||||||
|
|
||||||
int event_hup(void *data, int ev_type, void *ev)
|
int event_hup(void *data, int ev_type, void *ev)
|
||||||
{
|
{
|
||||||
printf("Hup signal! Remove the exit handler.\n");
|
printf("Hup signal! Remove the exit handler.\n");
|
||||||
ecore_event_handler_del(handler1);
|
if (handler1)
|
||||||
return 0;
|
{
|
||||||
|
ecore_event_handler_del(handler1);
|
||||||
|
handler1 = NULL;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int event_exit(void *data, int ev_type, void *ev)
|
int event_exit(void *data, int ev_type, void *ev)
|
||||||
{
|
{
|
||||||
Ecore_Event_Signal_Exit *e;
|
Ecore_Event_Signal_Exit *e;
|
||||||
|
|
||||||
e = (Ecore_Event_Signal_Exit *)ev;
|
e = (Ecore_Event_Signal_Exit *)ev;
|
||||||
printf("This callback handles event type: %i\n", ECORE_EVENT_SIGNAL_EXIT);
|
printf("This callback handles event type: %i\n", ECORE_EVENT_SIGNAL_EXIT);
|
||||||
printf("Event type recieved: %i\n", ev_type);
|
printf("Event type recieved: %i\n", ev_type);
|
||||||
if (e->interrupt) printf("Exit: interrupt\n");
|
if (e->interrupt) printf("Exit: interrupt\n");
|
||||||
if (e->quit) printf("Exit: quit\n");
|
if (e->quit) printf("Exit: quit\n");
|
||||||
if (e->terminate) printf("Exit: terminate\n");
|
if (e->terminate) printf("Exit: terminate\n");
|
||||||
ecore_main_loop_quit();
|
ecore_main_loop_quit();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
ecore_init();
|
ecore_init();
|
||||||
ecore_app_args_set(argc, argv);
|
ecore_app_args_set(argc, argv);
|
||||||
handler1 = ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT,
|
handler1 = ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT,
|
||||||
event_exit, NULL);
|
event_exit, NULL);
|
||||||
handler2 = ecore_event_handler_add(ECORE_EVENT_SIGNAL_HUP,
|
handler2 = ecore_event_handler_add(ECORE_EVENT_SIGNAL_HUP,
|
||||||
event_hup, NULL);
|
event_hup, NULL);
|
||||||
ecore_main_loop_begin();
|
ecore_main_loop_begin();
|
||||||
ecore_shutdown();
|
ecore_shutdown();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue