add ecore-signals example courtesy Ɓukasz Pankowski <lukpank@o2.pl>
[libeflvala.git] / examples / ecore-signals / ecore_signals.vala
blob3627a9408b121f66ca8f438d5bf2aab8a4e40b56
1 using Ecore;
4 bool sig_user(int type, void *event)
6 stdout.printf("USR%d\n", ((EventSignalUser *) event)->number);
7 return false;
10 bool sig_realtime(int type, void *event)
12 stdout.printf("num: %d\n", ((EventSignalRealtime *) event)->num);
13 return true;
16 bool sig_exit(int type, void *event)
18 var ev = (EventSignalExit *) event;
19 stdout.printf("[i: %u, q: %u, t: %u]\n",
20 ev->interrupt, ev->quit, ev->terminate);
21 if (ev->terminate != 0)
22 Ecore.MainLoop.quit();
23 return false;
26 void main()
28 Ecore.init();
29 var x = new EventHandler(EventType.SIGNAL_USER, sig_user);
30 var y = new EventHandler(EventType.SIGNAL_REALTIME, sig_realtime);
31 var z = new EventHandler(EventType.SIGNAL_EXIT, sig_exit);
32 Ecore.MainLoop.begin();
33 x = null; y = null; z = null; // required to avoid double free of the event
34 Ecore.shutdown();