summaryrefslogtreecommitdiff
path: root/legacy/ecore/examples/timer_example.c
blob: d50d13095cb1a6c687c2fe143c28f570f1770686 (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
/* Timer example.
 */

#include <Ecore.h>

#include <stdlib.h>
#include <stdio.h>
 
Ecore_Timer *timer1 = NULL;
Ecore_Timer *timer2 = NULL;
Ecore_Timer *timer3 = NULL;

char *data1 = "data1";
char *data2 = "data2";
char *data3 = "data3";
   
int timer3_tick(void *data) {
  printf("Tick timer %3.2f\n", ecore_time_get());
  return 1;
}
 
int timer2_tick(void *data) {
  printf("Repeat timer called at %3.2f seconds, data %p\n",
         ecore_time_get(), data);
  return 1;
}
 
int timer1_tick(void *data) {
  printf("Once only timer called at %3.2f seconds, data %p\n", 
          ecore_time_get(), data);
  ecore_timer_del(timer2);
  return 0;
}
 
int main(int argc, char **argv) {
  ecore_init();
  timer1 = ecore_timer_add(5.0, timer1_tick, data1);
  timer2 = ecore_timer_add(0.5, timer2_tick, data2);
  timer3 = ecore_timer_add(1.0, timer3_tick, data3);
  ecore_main_loop_begin();
  ecore_shutdown();
  return 0;
}