summaryrefslogtreecommitdiff
path: root/legacy/elementary/src/bin/test_progressbar.c
diff options
context:
space:
mode:
authorDavide Andreoli <dave@gurumeditation.it>2009-08-13 22:41:43 +0000
committerDavide Andreoli <dave@gurumeditation.it>2009-08-13 22:41:43 +0000
commitcf6f01b171e2434c139cc9c34da23dd31757d28a (patch)
tree50510a3effef269a921800c12521bfe39c0b762d /legacy/elementary/src/bin/test_progressbar.c
parent163d1ce7562de52a4b00aebef4944f536d51ea9b (diff)
* Split up elementary test.c in several files, one per widget
SVN revision: 41749
Diffstat (limited to 'legacy/elementary/src/bin/test_progressbar.c')
-rw-r--r--legacy/elementary/src/bin/test_progressbar.c187
1 files changed, 187 insertions, 0 deletions
diff --git a/legacy/elementary/src/bin/test_progressbar.c b/legacy/elementary/src/bin/test_progressbar.c
new file mode 100644
index 0000000..510a6d5
--- /dev/null
+++ b/legacy/elementary/src/bin/test_progressbar.c
@@ -0,0 +1,187 @@
1#include <Elementary.h>
2
3typedef struct Progressbar
4{
5 Evas_Object *pb1;
6 Evas_Object *pb2;
7 Evas_Object *pb3;
8 Evas_Object *pb4;
9 Evas_Object *pb5;
10 Evas_Object *pb6;
11 Eina_Bool run;
12 Ecore_Timer *timer;
13} Progressbar;
14
15static Progressbar _test_progressbar;
16
17static int
18_my_bt_39_progressbar_value_set (void *data)
19{
20 double progress;
21
22 progress = elm_progressbar_value_get (_test_progressbar.pb1);
23 if (progress < 1.0) progress += 0.0123;
24 else progress = 0.0;
25 elm_progressbar_value_set(_test_progressbar.pb1, progress);
26 elm_progressbar_value_set(_test_progressbar.pb4, progress);
27 elm_progressbar_value_set(_test_progressbar.pb3, progress);
28 elm_progressbar_value_set(_test_progressbar.pb6, progress);
29 if (progress < 1.0) return ECORE_CALLBACK_RENEW;
30 _test_progressbar.run = 0;
31 return ECORE_CALLBACK_CANCEL;
32}
33
34static void
35my_bt_39_test_start(void *data, Evas_Object *obj, void *event_info)
36{
37 elm_progressbar_pulse(_test_progressbar.pb2, EINA_TRUE);
38 elm_progressbar_pulse(_test_progressbar.pb5, EINA_TRUE);
39 if (!_test_progressbar.run)
40 {
41 _test_progressbar.timer = ecore_timer_add(0.1, _my_bt_39_progressbar_value_set, NULL);
42 _test_progressbar.run = EINA_TRUE;
43 }
44}
45
46static void
47my_bt_39_test_stop(void *data, Evas_Object *obj, void *event_info)
48{
49 elm_progressbar_pulse(_test_progressbar.pb2, EINA_FALSE);
50 elm_progressbar_pulse(_test_progressbar.pb5, EINA_FALSE);
51 if (_test_progressbar.run)
52 {
53 ecore_timer_del(_test_progressbar.timer);
54 _test_progressbar.run = EINA_FALSE;
55 }
56}
57
58static void
59my_bt_39_destroy(void *data, Evas_Object *obj, void *event_info)
60{
61 my_bt_39_test_stop(NULL, NULL, NULL);
62 evas_object_del(obj);
63}
64
65void
66test_progressbar(void *data, Evas_Object *obj, void *event_info)
67{
68 Evas_Object *win, *bg, *pb, *bx, *pbx, *hbx, *bt, *bt_bx, *ic1, *ic2;
69 Progressbar *test;
70 char buf[PATH_MAX];
71
72 win = elm_win_add(NULL, "progressbar", ELM_WIN_BASIC);
73 elm_win_title_set(win, "Progressbar");
74 evas_object_smart_callback_add(win, "delete-request", my_bt_39_destroy, test);
75
76 bg = elm_bg_add(win);
77 elm_win_resize_object_add(win, bg);
78 evas_object_size_hint_weight_set(bg, 1.0, 1.0);
79 evas_object_show(bg);
80
81 bx = elm_box_add(win);
82 elm_win_resize_object_add(win, bx);
83 evas_object_size_hint_weight_set(bx, 1.0, 1.0);
84 evas_object_show(bx);
85
86 pb = elm_progressbar_add(win);
87 evas_object_size_hint_weight_set(pb, 1.0, 1.0);
88 evas_object_size_hint_align_set(pb, -1.0, 0.5);
89 elm_box_pack_end(bx, pb);
90// elm_progressbar_horizontal_set(pb, EINA_TRUE);
91// elm_progressbar_label_set(pb, "Progression %");
92// elm_progressbar_unit_format_set(pb, NULL);
93 evas_object_show(pb);
94 _test_progressbar.pb1 = pb;
95
96 pb = elm_progressbar_add(win);
97 evas_object_size_hint_align_set(pb, -1.0, 0.5);
98 evas_object_size_hint_weight_set(pb, 1.0, 1.0);
99 elm_progressbar_label_set(pb, "Infinite bounce");
100 elm_progressbar_pulse_set(pb, EINA_TRUE);
101 elm_box_pack_end(bx, pb);
102 evas_object_show(pb);
103 _test_progressbar.pb2 = pb;
104
105 ic1 = elm_icon_add(win);
106 snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR);
107 elm_icon_file_set(ic1, buf, NULL);
108 evas_object_size_hint_aspect_set(ic1, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
109 pb = elm_progressbar_add(win);
110 elm_progressbar_label_set(pb, "Label");
111 elm_progressbar_icon_set(pb, ic1);
112 elm_progressbar_inverted_set(pb, 1);
113 elm_progressbar_unit_format_set(pb, "%1.1f units");
114 elm_progressbar_span_size_set(pb, 200);
115 evas_object_size_hint_align_set(pb, -1.0, 0.5);
116 evas_object_size_hint_weight_set(pb, 1.0, 1.0);
117 elm_box_pack_end(bx, pb);
118 evas_object_show(ic1);
119 evas_object_show(pb);
120 _test_progressbar.pb3 = pb;
121
122 hbx = elm_box_add(win);
123 elm_box_horizontal_set(hbx, EINA_TRUE);
124 evas_object_size_hint_weight_set(hbx, 1.0, 1.0);
125 evas_object_size_hint_align_set(hbx, -1.0, -1.0);
126 elm_box_pack_end(bx, hbx);
127 evas_object_show(hbx);
128
129 pb = elm_progressbar_add(win);
130 elm_progressbar_horizontal_set(pb, EINA_FALSE);
131 evas_object_size_hint_align_set(pb, -1.0, -1.0);
132 evas_object_size_hint_weight_set(pb, 1.0, 1.0);
133 elm_box_pack_end(hbx, pb);
134 elm_progressbar_span_size_set(pb, 60);
135 elm_progressbar_label_set(pb, "percent");
136 evas_object_show(pb);
137 _test_progressbar.pb4 = pb;
138
139 pb = elm_progressbar_add(win);
140 elm_progressbar_horizontal_set(pb, EINA_FALSE);
141 evas_object_size_hint_align_set(pb, -1.0, 0.5);
142 evas_object_size_hint_weight_set(pb, 1.0, 1.0);
143 elm_progressbar_span_size_set(pb, 80);
144 elm_progressbar_pulse_set(pb, EINA_TRUE);
145 elm_progressbar_unit_format_set(pb, NULL);
146 elm_progressbar_label_set(pb, "Infinite bounce");
147 elm_box_pack_end(hbx, pb);
148 evas_object_show(pb);
149 _test_progressbar.pb5 = pb;
150
151 ic2 = elm_icon_add(win);
152 elm_icon_file_set(ic2, buf, NULL);
153 evas_object_size_hint_aspect_set(ic2, EVAS_ASPECT_CONTROL_HORIZONTAL, 1, 1);
154 pb = elm_progressbar_add(win);
155 elm_progressbar_horizontal_set(pb, EINA_FALSE);
156 elm_progressbar_label_set(pb, "Label");
157 elm_progressbar_icon_set(pb, ic2);
158 elm_progressbar_inverted_set(pb, 1);
159 elm_progressbar_unit_format_set(pb, "%1.2f%%");
160 elm_progressbar_span_size_set(pb, 200);
161 evas_object_size_hint_align_set(pb, -1.0, 0.5);
162 evas_object_size_hint_weight_set(pb, 1.0, 1.0);
163 elm_box_pack_end(hbx, pb);
164 evas_object_show(ic2);
165 evas_object_show(pb);
166 _test_progressbar.pb6 = pb;
167
168 bt_bx = elm_box_add(win);
169 elm_box_horizontal_set(bt_bx, 1);
170 evas_object_size_hint_weight_set(bt_bx, 1.0, 1.0);
171 elm_box_pack_end(bx, bt_bx);
172 evas_object_show(bt_bx);
173
174 bt = elm_button_add(win);
175 elm_button_label_set(bt, "Start");
176 evas_object_smart_callback_add(bt, "clicked", my_bt_39_test_start, NULL);
177 elm_box_pack_end(bt_bx, bt);
178 evas_object_show(bt);
179
180 bt = elm_button_add(win);
181 elm_button_label_set(bt, "Stop");
182 evas_object_smart_callback_add(bt, "clicked", my_bt_39_test_stop, NULL);
183 elm_box_pack_end(bt_bx, bt);
184 evas_object_show(bt);
185
186 evas_object_show(win);
187}