summaryrefslogtreecommitdiff
path: root/legacy/ecore/examples/event_handler_example.c
blob: 09bc3e769740690d4c68e38bd9d1a51f31f99941 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/* Ecore Event Handler Example. */
#include <Ecore.h>

#include <stdlib.h>
#include <stdio.h>
 
Ecore_Event_Handler *handler1 = NULL, *handler2 = NULL;
 
int event_hup(void *data, int ev_type, void *ev)
{
   printf("Hup signal! Remove the exit handler.\n");
   if (handler1)
     {
	ecore_event_handler_del(handler1);
	handler1 = NULL;
     }
   return 0;
}

int event_exit(void *data, int ev_type, void *ev)
{
   Ecore_Event_Signal_Exit *e;
   
   e = (Ecore_Event_Signal_Exit *)ev;
   printf("This callback handles event type: %i\n", ECORE_EVENT_SIGNAL_EXIT);
   printf("Event type recieved: %i\n", ev_type);
   if (e->interrupt) printf("Exit: interrupt\n");
   if (e->quit)      printf("Exit: quit\n");
   if (e->terminate) printf("Exit: terminate\n");
   ecore_main_loop_quit();
   return 1;
}

int main(int argc, char **argv)
{
   ecore_init();
   ecore_app_args_set(argc, (const char **) argv);
   handler1 = ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT, 
				      event_exit, NULL);
   handler2 = ecore_event_handler_add(ECORE_EVENT_SIGNAL_HUP, 
				      event_hup, NULL);
   ecore_main_loop_begin();
   ecore_shutdown();
   return 0;
}