2 * Simple Elementary's <b>progress bar widget</b> example, illustrating its
5 * See stdout/stderr for output. Compile with:
8 * gcc -g `pkg-config --cflags --libs elementary` progressbar_example.c -o progressbar_example
12 #include <Elementary.h>
14 typedef struct Progressbar_Example
17 Evas_Object *pb2; /* pulsing */
20 Evas_Object *pb5; /* pulsing */
22 Evas_Object *pb7; /* pulsing */
26 } Progressbar_Example;
28 static Progressbar_Example example_data;
31 _progressbar_example_value_set(void *data)
35 progress = elm_progressbar_value_get(example_data.pb1);
36 if (progress < 1.0) progress += 0.0123;
39 /* just the non-pulsing ones need an update */
40 elm_progressbar_value_set(example_data.pb1, progress);
41 elm_progressbar_value_set(example_data.pb3, progress);
42 elm_progressbar_value_set(example_data.pb4, progress);
43 elm_progressbar_value_set(example_data.pb6, progress);
45 if (progress < 1.0) return ECORE_CALLBACK_RENEW;
48 return ECORE_CALLBACK_CANCEL;
52 _progressbar_example_start(void *data,
56 elm_progressbar_pulse(example_data.pb2, EINA_TRUE);
57 elm_progressbar_pulse(example_data.pb5, EINA_TRUE);
58 elm_progressbar_pulse(example_data.pb7, EINA_TRUE);
60 if (!example_data.run)
62 example_data.timer = ecore_timer_add(
63 0.1, _progressbar_example_value_set, NULL);
64 example_data.run = EINA_TRUE;
70 _progressbar_example_stop(void *data,
74 elm_progressbar_pulse(example_data.pb2, EINA_FALSE);
75 elm_progressbar_pulse(example_data.pb5, EINA_FALSE);
76 elm_progressbar_pulse(example_data.pb7, EINA_FALSE);
80 ecore_timer_del(example_data.timer);
81 example_data.run = EINA_FALSE;
90 _progressbar_example_stop(NULL, NULL, NULL);
98 Evas_Object *win, *bg, *pb, *bx, *hbx, *bt, *bt_bx, *ic1, *ic2;
101 win = elm_win_add(NULL, "progressbar", ELM_WIN_BASIC);
102 elm_win_title_set(win, "Progress bar example");
103 evas_object_smart_callback_add(win, "delete,request", _on_done, NULL);
105 bg = elm_bg_add(win);
106 elm_win_resize_object_add(win, bg);
107 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
108 evas_object_show(bg);
110 bx = elm_box_add(win);
111 elm_win_resize_object_add(win, bx);
112 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
113 evas_object_show(bx);
115 /* pb with no label, default unit label and no icon */
116 pb = elm_progressbar_add(win);
117 evas_object_size_hint_weight_set(pb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
118 evas_object_size_hint_align_set(pb, EVAS_HINT_FILL, 0.5);
119 elm_box_pack_end(bx, pb);
120 evas_object_show(pb);
121 example_data.pb1 = pb;
123 /* pb with label, and set to pulse */
124 pb = elm_progressbar_add(win);
125 evas_object_size_hint_align_set(pb, EVAS_HINT_FILL, 0.5);
126 evas_object_size_hint_weight_set(pb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
127 elm_object_text_set(pb, "Infinite bounce");
128 elm_progressbar_pulse_set(pb, EINA_TRUE);
129 elm_box_pack_end(bx, pb);
130 evas_object_show(pb);
131 example_data.pb2 = pb;
133 ic1 = elm_icon_add(win);
134 snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR);
135 elm_icon_file_set(ic1, buf, NULL);
136 evas_object_size_hint_aspect_set(ic1, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
138 /* pb with label, icon, custom unit label and span size set */
139 pb = elm_progressbar_add(win);
140 elm_object_text_set(pb, "Label");
141 elm_object_part_content_set(pb, "icon", ic1);
142 elm_progressbar_inverted_set(pb, EINA_TRUE);
143 elm_progressbar_unit_format_set(pb, "%1.1f units");
144 elm_progressbar_span_size_set(pb, 200);
145 evas_object_size_hint_align_set(pb, EVAS_HINT_FILL, 0.5);
146 evas_object_size_hint_weight_set(pb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
147 elm_box_pack_end(bx, pb);
148 evas_object_show(ic1);
149 evas_object_show(pb);
150 example_data.pb3 = pb;
152 hbx = elm_box_add(win);
153 elm_box_horizontal_set(hbx, EINA_TRUE);
154 evas_object_size_hint_weight_set(hbx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
155 evas_object_size_hint_align_set(hbx, EVAS_HINT_FILL, EVAS_HINT_FILL);
156 elm_box_pack_end(bx, hbx);
157 evas_object_show(hbx);
160 pb = elm_progressbar_add(win);
161 elm_progressbar_horizontal_set(pb, EINA_FALSE);
162 evas_object_size_hint_align_set(pb, EVAS_HINT_FILL, EVAS_HINT_FILL);
163 evas_object_size_hint_weight_set(pb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
164 elm_box_pack_end(hbx, pb);
165 elm_object_text_set(pb, "percent");
166 evas_object_show(pb);
167 example_data.pb4 = pb;
169 /* vertical pb, with pulse and custom (small) span size */
170 pb = elm_progressbar_add(win);
171 elm_progressbar_horizontal_set(pb, EINA_FALSE);
172 evas_object_size_hint_align_set(pb, EVAS_HINT_FILL, 0.5);
173 evas_object_size_hint_weight_set(pb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
174 elm_progressbar_span_size_set(pb, 80);
175 elm_progressbar_pulse_set(pb, EINA_TRUE);
176 elm_progressbar_unit_format_set(pb, NULL);
177 elm_object_text_set(pb, "Infinite bounce");
178 elm_box_pack_end(hbx, pb);
179 evas_object_show(pb);
180 example_data.pb5 = pb;
182 ic2 = elm_icon_add(win);
183 elm_icon_file_set(ic2, buf, NULL);
184 evas_object_size_hint_aspect_set(ic2, EVAS_ASPECT_CONTROL_HORIZONTAL, 1, 1);
186 /* vertical pb, inverted, with custom unit format and icon*/
187 pb = elm_progressbar_add(win);
188 elm_progressbar_horizontal_set(pb, EINA_FALSE);
189 elm_object_text_set(pb, "Label");
190 elm_object_part_content_set(pb, "icon", ic2);
191 elm_progressbar_inverted_set(pb, EINA_TRUE);
192 elm_progressbar_unit_format_set(pb, "%1.2f%%");
193 elm_progressbar_span_size_set(pb, 200);
194 evas_object_size_hint_align_set(pb, EVAS_HINT_FILL, 0.5);
195 evas_object_size_hint_weight_set(pb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
196 elm_box_pack_end(hbx, pb);
197 evas_object_show(ic2);
198 evas_object_show(pb);
199 example_data.pb6 = pb;
201 /* "wheel" style progress bar */
202 pb = elm_progressbar_add(win);
203 elm_object_style_set(pb, "wheel");
204 elm_object_text_set(pb, "Style: wheel");
205 evas_object_size_hint_align_set(pb, EVAS_HINT_FILL, 0.5);
206 evas_object_size_hint_weight_set(pb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
207 elm_box_pack_end(bx, pb);
208 evas_object_show(pb);
209 example_data.pb7 = pb;
211 bt_bx = elm_box_add(win);
212 elm_box_horizontal_set(bt_bx, EINA_TRUE);
213 evas_object_size_hint_weight_set(bt_bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
214 elm_box_pack_end(bx, bt_bx);
215 evas_object_show(bt_bx);
217 bt = elm_button_add(win);
218 elm_object_text_set(bt, "Start");
219 evas_object_smart_callback_add(bt, "clicked", _progressbar_example_start,
221 elm_box_pack_end(bt_bx, bt);
222 evas_object_show(bt);
224 bt = elm_button_add(win);
225 elm_object_text_set(bt, "Stop");
226 evas_object_smart_callback_add(bt, "clicked", _progressbar_example_stop,
228 elm_box_pack_end(bt_bx, bt);
229 evas_object_show(bt);
231 evas_object_show(win);