summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Juyung Seo <seojuyung2@gmail.com>2013-09-12 01:18:26 +0900
committerDaniel Juyung Seo <seojuyung2@gmail.com>2013-09-12 01:18:26 +0900
commit8a0d6f67cfb0ca587a7dc9b887673e65f12b519a (patch)
tree0200c76f3d7f85b32ceef25e01c8720a203aa41a
parente431326ea8f44379c05f4040e2deb2d20014db84 (diff)
test_progressbar.c: refactoring. moved code to the better place.
-rw-r--r--src/bin/test_progressbar.c112
1 files changed, 56 insertions, 56 deletions
diff --git a/src/bin/test_progressbar.c b/src/bin/test_progressbar.c
index 5de8100fb..f53e92c0d 100644
--- a/src/bin/test_progressbar.c
+++ b/src/bin/test_progressbar.c
@@ -37,29 +37,6 @@ _my_progressbar_value_set(void *data)
37 return ECORE_CALLBACK_CANCEL; 37 return ECORE_CALLBACK_CANCEL;
38} 38}
39 39
40static Eina_Bool
41_my_progressbar_value_set2(void *data)
42{
43 Progressbar_Data *pd = data;
44 if (!pd) return ECORE_CALLBACK_CANCEL;
45
46 double progress;
47
48 progress = elm_progressbar_value_get (pd->pb1);
49 if (progress < 1.0) progress += 0.0123;
50 else progress = 0.0;
51 elm_progressbar_part_value_set(pd->pb1, "elm.cur.progressbar", progress);
52 elm_progressbar_value_set(pd->pb2, progress);
53 elm_progressbar_part_value_set(pd->pb2, "elm.cur.progressbar1", progress-0.15);
54 elm_progressbar_part_value_set(pd->pb3, "elm.cur.progressbar", progress);
55 elm_progressbar_part_value_set(pd->pb3, "elm.cur.progressbar1", progress-0.15);
56
57 if (progress < 1.0) return ECORE_CALLBACK_RENEW;
58
59 pd->timer = NULL;
60 return ECORE_CALLBACK_CANCEL;
61}
62
63static void 40static void
64my_progressbar_test_start(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 41my_progressbar_test_start(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
65{ 42{
@@ -82,21 +59,6 @@ my_progressbar_test_start(void *data, Evas_Object *obj EINA_UNUSED, void *event_
82} 59}
83 60
84static void 61static void
85my_progressbar_test_start2(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
86{
87 Progressbar_Data *pd = data;
88 if (!pd) return;
89
90 fprintf(stderr, "s1\n");
91
92 elm_object_disabled_set(pd->btn_start, EINA_TRUE);
93 elm_object_disabled_set(pd->btn_stop, EINA_FALSE);
94
95 if (!pd->timer)
96 pd->timer = ecore_timer_add(0.1, _my_progressbar_value_set2, pd);
97}
98
99static void
100my_progressbar_test_stop(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 62my_progressbar_test_stop(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
101{ 63{
102 Progressbar_Data *pd = data; 64 Progressbar_Data *pd = data;
@@ -116,22 +78,6 @@ my_progressbar_test_stop(void *data, Evas_Object *obj EINA_UNUSED, void *event_i
116} 78}
117 79
118static void 80static void
119my_progressbar_test_stop2(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
120{
121 Progressbar_Data *pd = data;
122 if (!pd) return;
123
124 elm_object_disabled_set(pd->btn_start, EINA_FALSE);
125 elm_object_disabled_set(pd->btn_stop, EINA_TRUE);
126
127 if (pd->timer)
128 {
129 ecore_timer_del(pd->timer);
130 pd->timer = NULL;
131 }
132}
133
134static void
135_progressbar_destroy_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED) 81_progressbar_destroy_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
136{ 82{
137 Progressbar_Data *pd = data; 83 Progressbar_Data *pd = data;
@@ -290,6 +236,60 @@ test_progressbar(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *eve
290 evas_object_show(win); 236 evas_object_show(win);
291} 237}
292 238
239static Eina_Bool
240_progressbar2_timer_cb(void *data)
241{
242 Progressbar_Data *pd = data;
243 if (!pd) return ECORE_CALLBACK_CANCEL;
244
245 double progress;
246
247 progress = elm_progressbar_value_get (pd->pb1);
248 if (progress < 1.0) progress += 0.0123;
249 else progress = 0.0;
250 elm_progressbar_part_value_set(pd->pb1, "elm.cur.progressbar", progress);
251 elm_progressbar_value_set(pd->pb2, progress);
252 elm_progressbar_part_value_set(pd->pb2, "elm.cur.progressbar1", progress-0.15);
253 elm_progressbar_part_value_set(pd->pb3, "elm.cur.progressbar", progress);
254 elm_progressbar_part_value_set(pd->pb3, "elm.cur.progressbar1", progress-0.15);
255
256 if (progress < 1.0) return ECORE_CALLBACK_RENEW;
257
258 pd->timer = NULL;
259 return ECORE_CALLBACK_CANCEL;
260}
261
262static void
263_pg2_start_btn_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
264{
265 Progressbar_Data *pd = data;
266 if (!pd) return;
267
268 fprintf(stderr, "s1\n");
269
270 elm_object_disabled_set(pd->btn_start, EINA_TRUE);
271 elm_object_disabled_set(pd->btn_stop, EINA_FALSE);
272
273 if (!pd->timer)
274 pd->timer = ecore_timer_add(0.1, _progressbar2_timer_cb, pd);
275}
276
277static void
278_pg2_stop_btn_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
279{
280 Progressbar_Data *pd = data;
281 if (!pd) return;
282
283 elm_object_disabled_set(pd->btn_start, EINA_FALSE);
284 elm_object_disabled_set(pd->btn_stop, EINA_TRUE);
285
286 if (pd->timer)
287 {
288 ecore_timer_del(pd->timer);
289 pd->timer = NULL;
290 }
291}
292
293void 293void
294test_progressbar2(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) 294test_progressbar2(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
295{ 295{
@@ -345,7 +345,7 @@ test_progressbar2(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *even
345 345
346 bt = elm_button_add(win); 346 bt = elm_button_add(win);
347 elm_object_text_set(bt, "Start"); 347 elm_object_text_set(bt, "Start");
348 evas_object_smart_callback_add(bt, "clicked", my_progressbar_test_start2, pd); 348 evas_object_smart_callback_add(bt, "clicked", _pg2_start_btn_clicked_cb, pd);
349 elm_box_pack_end(bt_bx, bt); 349 elm_box_pack_end(bt_bx, bt);
350 evas_object_show(bt); 350 evas_object_show(bt);
351 pd->btn_start = bt; 351 pd->btn_start = bt;
@@ -353,7 +353,7 @@ test_progressbar2(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *even
353 bt = elm_button_add(win); 353 bt = elm_button_add(win);
354 elm_object_text_set(bt, "Stop"); 354 elm_object_text_set(bt, "Stop");
355 elm_object_disabled_set(bt, EINA_TRUE); 355 elm_object_disabled_set(bt, EINA_TRUE);
356 evas_object_smart_callback_add(bt, "clicked", my_progressbar_test_stop2, pd); 356 evas_object_smart_callback_add(bt, "clicked", _pg2_stop_btn_clicked_cb, pd);
357 elm_box_pack_end(bt_bx, bt); 357 elm_box_pack_end(bt_bx, bt);
358 evas_object_show(bt); 358 evas_object_show(bt);
359 pd->btn_stop = bt; 359 pd->btn_stop = bt;