2 * Simple Elementary's <b>slide show widget</b> example, illustrating its
5 * See stdout/stderr for output. Compile with:
8 * gcc -o slideshow_example slideshow_example.c -g `pkg-config --cflags --libs elementary`
12 #include <Elementary.h>
13 #define PACKAGE_DATA_DIR "../../data"
23 static Evas_Object *slideshow, *bt_start, *bt_stop;
24 static Elm_Slideshow_Item_Class itc;
26 static const char *img1 = PACKAGE_DATA_DIR "/images/logo.png";
27 static const char *img2 = PACKAGE_DATA_DIR "/images/plant_01.jpg";
28 static const char *img3 = PACKAGE_DATA_DIR "/images/rock_01.jpg";
29 static const char *img4 = PACKAGE_DATA_DIR "/images/rock_02.jpg";
30 static const char *img5 = PACKAGE_DATA_DIR "/images/sky_01.jpg";
31 static const char *img6 = PACKAGE_DATA_DIR "/images/sky_04.jpg";
32 static const char *img7 = PACKAGE_DATA_DIR "/images/wood_01.jpg";
33 static const char *img8 = PACKAGE_DATA_DIR "/images/mystrale.jpg";
34 static const char *img9 = PACKAGE_DATA_DIR "/images/mystrale_2.jpg";
37 _notify_show(void *data,
42 evas_object_show(data);
45 /* jump to next item, cyclically */
51 elm_slideshow_next(data);
59 elm_slideshow_previous(data);
67 elm_slideshow_item_show(data);
75 elm_slideshow_item_show(data);
84 elm_notify_timeout_set(data, 0.0);
85 evas_object_show(data);
89 _mouse_out(void *data,
94 elm_notify_timeout_set(data, 3.0);
97 /* transition changed */
99 _transition_select(void *data,
103 elm_slideshow_transition_set(slideshow, data);
104 elm_object_text_set(obj, data);
108 _layout_select(void *data,
112 elm_slideshow_layout_set(slideshow, data);
113 elm_object_text_set(obj, data);
116 /* start the show! */
122 elm_slideshow_timeout_set(slideshow, elm_spinner_value_get(data));
124 elm_object_disabled_set(bt_start, EINA_TRUE);
125 elm_object_disabled_set(bt_stop, EINA_FALSE);
133 elm_slideshow_timeout_set(slideshow, 0.0);
134 elm_object_disabled_set(bt_start, EINA_FALSE);
135 elm_object_disabled_set(bt_stop, EINA_TRUE);
138 /* slideshow transition time has changed */
144 if (elm_slideshow_timeout_get(slideshow) > 0)
145 elm_slideshow_timeout_set(slideshow, elm_spinner_value_get(data));
148 /* get our images to make slideshow items */
153 Evas_Object *photo = elm_photo_add(obj);
154 elm_photo_file_set(photo, data);
155 elm_photo_fill_inside_set(photo, EINA_TRUE);
156 elm_object_style_set(photo, "shadow");
161 /* ordering alphabetically */
163 _cmp_func(const void *data1,
166 const char *img_path1, *img_path2;
168 const Elm_Object_Item *slide_it1 = data1;
169 const Elm_Object_Item *slide_it2 = data2;
171 img_path1 = elm_object_item_data_get(slide_it1);
172 img_path2 = elm_object_item_data_get(slide_it2);
174 return strcasecmp(img_path1, img_path2);
181 Evas_Object *win, *bg, *notify, *bx, *bt, *hv, *spin;
182 Elm_Object_Item *slide_first, *slide_last, *slide_it;
183 const char *transition, *layout;
184 const Eina_List *l, *list;
186 win = elm_win_add(NULL, "slideshow", ELM_WIN_BASIC);
187 elm_win_title_set(win, "Slideshow example");
188 evas_object_smart_callback_add(win, "delete,request", _on_done, NULL);
189 elm_win_autodel_set(win, EINA_TRUE);
190 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
191 evas_object_resize(win, 600, 400);
192 evas_object_show(win);
194 bg = elm_bg_add(win);
195 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
196 elm_win_resize_object_add(win, bg);
197 evas_object_show(bg);
199 slideshow = elm_slideshow_add(win);
200 elm_slideshow_loop_set(slideshow, EINA_TRUE);
201 evas_object_size_hint_weight_set(slideshow,
202 EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
203 elm_win_resize_object_add(win, slideshow);
204 evas_object_show(slideshow);
209 slide_first = elm_slideshow_item_sorted_insert(slideshow, &itc, img1, _cmp_func);
210 elm_slideshow_item_sorted_insert(slideshow, &itc, img2, _cmp_func);
211 elm_slideshow_item_sorted_insert(slideshow, &itc, img3, _cmp_func);
212 elm_slideshow_item_sorted_insert(slideshow, &itc, img4, _cmp_func);
213 elm_slideshow_item_sorted_insert(slideshow, &itc, img5, _cmp_func);
214 elm_slideshow_item_sorted_insert(slideshow, &itc, img6, _cmp_func);
215 elm_slideshow_item_sorted_insert(slideshow, &itc, img7, _cmp_func);
216 elm_slideshow_item_sorted_insert(slideshow, &itc, img8, _cmp_func);
217 slide_last = elm_slideshow_item_add(slideshow, &itc, img9);
219 list = elm_slideshow_items_get(slideshow);
220 fprintf(stdout, "List of items in the slideshow:\n");
221 EINA_LIST_FOREACH(list, l, slide_it)
222 fprintf(stdout, "\t%s\n",
223 (const char *)elm_object_item_data_get(slide_it));
225 notify = elm_notify_add(win);
226 elm_notify_orient_set(notify, ELM_NOTIFY_ORIENT_BOTTOM);
227 evas_object_size_hint_weight_set(notify, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
228 elm_win_resize_object_add(win, notify);
229 elm_notify_timeout_set(notify, 3.0);
231 bx = elm_box_add(win);
232 elm_box_horizontal_set(bx, EINA_TRUE);
233 elm_object_content_set(notify, bx);
234 evas_object_show(bx);
236 evas_object_event_callback_add(bx, EVAS_CALLBACK_MOUSE_IN, _mouse_in,
238 evas_object_event_callback_add(bx, EVAS_CALLBACK_MOUSE_OUT, _mouse_out,
241 bt = elm_button_add(win);
242 elm_object_text_set(bt, "Previous");
243 evas_object_smart_callback_add(bt, "clicked", _previous, slideshow);
244 elm_box_pack_end(bx, bt);
245 evas_object_show(bt);
247 bt = elm_button_add(win);
248 elm_object_text_set(bt, "Next");
249 evas_object_smart_callback_add(bt, "clicked", _next, slideshow);
250 elm_box_pack_end(bx, bt);
251 evas_object_show(bt);
253 bt = elm_button_add(win);
254 elm_object_text_set(bt, "First");
255 evas_object_smart_callback_add(bt, "clicked", _first, slide_first);
256 elm_box_pack_end(bx, bt);
257 evas_object_show(bt);
259 bt = elm_button_add(win);
260 elm_object_text_set(bt, "Last");
261 evas_object_smart_callback_add(bt, "clicked", _last, slide_last);
262 elm_box_pack_end(bx, bt);
263 evas_object_show(bt);
265 hv = elm_hoversel_add(win);
266 elm_box_pack_end(bx, hv);
267 elm_hoversel_hover_parent_set(hv, win);
268 EINA_LIST_FOREACH(elm_slideshow_transitions_get(slideshow), l, transition)
269 elm_hoversel_item_add(hv, transition, NULL, 0, _transition_select,
271 elm_object_text_set(hv, eina_list_data_get(
272 elm_slideshow_transitions_get(slideshow)));
273 evas_object_show(hv);
275 hv = elm_hoversel_add(win);
276 elm_box_pack_end(bx, hv);
277 elm_hoversel_hover_parent_set(hv, win);
278 EINA_LIST_FOREACH(elm_slideshow_layouts_get(slideshow), l, layout)
279 elm_hoversel_item_add(hv, layout, NULL, 0, _layout_select, layout);
280 elm_object_text_set(hv, elm_slideshow_layout_get(slideshow));
281 evas_object_show(hv);
283 spin = elm_spinner_add(win);
284 elm_spinner_label_format_set(spin, "%2.0f s");
285 evas_object_smart_callback_add(spin, "changed", _spin, spin);
286 elm_spinner_step_set(spin, 1);
287 elm_spinner_min_max_set(spin, 1, 30);
288 elm_spinner_value_set(spin, 3);
289 elm_box_pack_end(bx, spin);
290 evas_object_show(spin);
292 bt = elm_button_add(win);
294 elm_object_text_set(bt, "Start");
295 evas_object_smart_callback_add(bt, "clicked", _start, spin);
296 elm_box_pack_end(bx, bt);
297 evas_object_show(bt);
299 bt = elm_button_add(win);
301 elm_object_text_set(bt, "Stop");
302 evas_object_smart_callback_add(bt, "clicked", _stop, spin);
303 elm_box_pack_end(bx, bt);
304 elm_object_disabled_set(bt, EINA_TRUE);
305 evas_object_show(bt);
307 evas_object_event_callback_add(slideshow, EVAS_CALLBACK_MOUSE_UP,
308 _notify_show, notify);
309 evas_object_event_callback_add(slideshow, EVAS_CALLBACK_MOUSE_MOVE,
310 _notify_show, notify);
312 _notify_show(notify, NULL, NULL, NULL);