summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Hacohen <tom@stosb.com>2014-09-25 09:42:23 +0100
committerTom Hacohen <tom@stosb.com>2014-09-25 09:45:38 +0100
commitf8c74d567417a7837966d633da1963e84438b78c (patch)
tree6c9fc7b02fcd0959b42dc01ea596771c27965000
parenta3e2ab90e6cd2b0e0afc41b0c416a8862f90f3cd (diff)
Fix timer and improve handling.
-rw-r--r--src/bin/main.c39
1 files changed, 34 insertions, 5 deletions
diff --git a/src/bin/main.c b/src/bin/main.c
index b6c2c33..d988db1 100644
--- a/src/bin/main.c
+++ b/src/bin/main.c
@@ -64,7 +64,19 @@ _countdown_timer_tick(void *data EINA_UNUSED)
64} 64}
65 65
66static void 66static void
67_countdown_timer_start(void) 67_countdown_timer_pause(void)
68{
69 ecore_timer_freeze(ctx.countdown);
70}
71
72static void
73_countdown_timer_continue(void)
74{
75 ecore_timer_thaw(ctx.countdown);
76}
77
78static void
79_countdown_timer_init(void)
68{ 80{
69 /* FIXME: Timer ticks are not guarenteed, better to keep track of time too. */ 81 /* FIXME: Timer ticks are not guarenteed, better to keep track of time too. */
70 double interval = 1.0; 82 double interval = 1.0;
@@ -75,14 +87,14 @@ _countdown_timer_start(void)
75 } 87 }
76 else 88 else
77 { 89 {
78 ctx.countdown = eo_add(ECORE_TIMER_CLASS, ctx.preview.win, 90 ctx.countdown = eo_add_custom(ECORE_TIMER_CLASS, ctx.preview.win,
79 ecore_obj_timer_constructor(interval, _countdown_timer_tick, NULL)); 91 ecore_obj_timer_constructor(interval, _countdown_timer_tick, NULL));
92 _countdown_timer_pause();
93 eo_unref(ctx.countdown);
80 } 94 }
81 95
82 ctx.remaining_time = ctx.total_time + 1; 96 ctx.remaining_time = ctx.total_time + 1;
83 _countdown_timer_tick(NULL); 97 _countdown_timer_tick(NULL);
84
85 eo_unref(ctx.countdown);
86} 98}
87 99
88static void 100static void
@@ -134,6 +146,7 @@ _global_key_down_cb(void *data EINA_UNUSED, Eo *eo_obj EINA_UNUSED, const Eo_Eve
134 { 146 {
135 ctx.page++; 147 ctx.page++;
136 _pdf_page_set_all(ctx.page); 148 _pdf_page_set_all(ctx.page);
149 _countdown_timer_continue();
137 } 150 }
138 } 151 }
139 else if (!strcmp(ev->key, "Left")) 152 else if (!strcmp(ev->key, "Left"))
@@ -142,12 +155,28 @@ _global_key_down_cb(void *data EINA_UNUSED, Eo *eo_obj EINA_UNUSED, const Eo_Eve
142 { 155 {
143 ctx.page--; 156 ctx.page--;
144 _pdf_page_set_all(ctx.page); 157 _pdf_page_set_all(ctx.page);
158 _countdown_timer_continue();
145 } 159 }
146 } 160 }
147 else if (!strcmp(ev->key, "f")) 161 else if (!strcmp(ev->key, "f"))
148 { 162 {
149 eo_do(ctx.main.win, elm_obj_win_fullscreen_set(!elm_obj_win_fullscreen_get())); 163 eo_do(ctx.main.win, elm_obj_win_fullscreen_set(!elm_obj_win_fullscreen_get()));
150 } 164 }
165 else if (!strcmp(ev->key, "r"))
166 {
167 _countdown_timer_init();
168 }
169 else if (!strcmp(ev->key, "p"))
170 {
171 if (ecore_timer_freeze_get(ctx.countdown))
172 {
173 _countdown_timer_continue();
174 }
175 else
176 {
177 _countdown_timer_pause();
178 }
179 }
151 else if (!strcmp(ev->key, "Escape")) 180 else if (!strcmp(ev->key, "Escape"))
152 { 181 {
153 elm_exit(); 182 elm_exit();
@@ -326,7 +355,7 @@ main(int argc, char *argv[])
326 evas_object_resize(ctx.main.win, w, h); 355 evas_object_resize(ctx.main.win, w, h);
327 evas_object_resize(ctx.preview.win, w, h); 356 evas_object_resize(ctx.preview.win, w, h);
328 357
329 _countdown_timer_start(); 358 _countdown_timer_init();
330 359
331 elm_run(); 360 elm_run();
332 361