2 * Simple Elementary's <b>slide show widget</b> example, illustrating its
5 * See stdout/stderr for output. Compile with:
8 * gcc -g `pkg-config --cflags --libs elementary` slideshow_example.c -o slideshow_example
12 #include <Elementary.h>
14 # include "elementary_config.h"
17 # define PACKAGE_DATA_DIR "../../data"
21 _on_done(void *data __UNUSED__,
22 Evas_Object *obj __UNUSED__,
23 void *event_info __UNUSED__)
28 static Evas_Object *slideshow, *bt_start, *bt_stop;
29 static Elm_Slideshow_Item_Class itc;
31 static const char *img1 = PACKAGE_DATA_DIR "/images/logo.png";
32 static const char *img2 = PACKAGE_DATA_DIR "/images/plant_01.jpg";
33 static const char *img3 = PACKAGE_DATA_DIR "/images/rock_01.jpg";
34 static const char *img4 = PACKAGE_DATA_DIR "/images/rock_02.jpg";
35 static const char *img5 = PACKAGE_DATA_DIR "/images/sky_01.jpg";
36 static const char *img6 = PACKAGE_DATA_DIR "/images/sky_04.jpg";
37 static const char *img7 = PACKAGE_DATA_DIR "/images/wood_01.jpg";
38 static const char *img8 = PACKAGE_DATA_DIR "/images/mystrale.jpg";
39 static const char *img9 = PACKAGE_DATA_DIR "/images/mystrale_2.jpg";
42 _notify_show(void *data,
44 Evas_Object *obj __UNUSED__,
45 void *event_info __UNUSED__)
47 evas_object_show(data);
50 /* jump to next item, cyclically */
53 Evas_Object *obj __UNUSED__,
54 void *event_info __UNUSED__)
56 elm_slideshow_next(data);
61 Evas_Object *obj __UNUSED__,
62 void *event_info __UNUSED__)
64 elm_slideshow_previous(data);
69 Evas_Object *obj __UNUSED__,
70 void *event_info __UNUSED__)
73 elm_slideshow_show(data);
75 elm_slideshow_item_show(data);
76 >>>>>>> remotes/origin/upstream
81 Evas_Object *obj __UNUSED__,
82 void *event_info __UNUSED__)
85 elm_slideshow_show(data);
87 elm_slideshow_item_show(data);
88 >>>>>>> remotes/origin/upstream
94 Evas_Object *obj __UNUSED__,
95 void *event_info __UNUSED__)
97 elm_notify_timeout_set(data, 0.0);
98 evas_object_show(data);
102 _mouse_out(void *data,
104 Evas_Object *obj __UNUSED__,
105 void *event_info __UNUSED__)
107 elm_notify_timeout_set(data, 3.0);
110 /* transition changed */
112 _transition_select(void *data,
114 void *event_info __UNUSED__)
116 elm_slideshow_transition_set(slideshow, data);
117 elm_object_text_set(obj, data);
121 _layout_select(void *data,
123 void *event_info __UNUSED__)
125 elm_slideshow_layout_set(slideshow, data);
126 elm_object_text_set(obj, data);
129 /* start the show! */
132 Evas_Object *obj __UNUSED__,
133 void *event_info __UNUSED__)
135 elm_slideshow_timeout_set(slideshow, elm_spinner_value_get(data));
137 elm_object_disabled_set(bt_start, EINA_TRUE);
138 elm_object_disabled_set(bt_stop, EINA_FALSE);
142 _stop(void *data __UNUSED__,
143 Evas_Object *obj __UNUSED__,
144 void *event_info __UNUSED__)
146 elm_slideshow_timeout_set(slideshow, 0.0);
147 elm_object_disabled_set(bt_start, EINA_FALSE);
148 elm_object_disabled_set(bt_stop, EINA_TRUE);
151 /* slideshow transition time has changed */
154 Evas_Object *obj __UNUSED__,
155 void *event_info __UNUSED__)
157 if (elm_slideshow_timeout_get(slideshow) > 0)
158 elm_slideshow_timeout_set(slideshow, elm_spinner_value_get(data));
161 /* get our images to make slideshow items */
166 Evas_Object *photo = elm_photo_add(obj);
167 elm_photo_file_set(photo, data);
168 elm_photo_fill_inside_set(photo, EINA_TRUE);
169 elm_object_style_set(photo, "shadow");
174 /* ordering alphabetically */
176 _cmp_func(const void *data1,
179 const char *img_path1, *img_path2;
181 const Elm_Object_Item *slide_it1 = data1;
182 const Elm_Object_Item *slide_it2 = data2;
184 img_path1 = elm_object_item_data_get(slide_it1);
185 img_path2 = elm_object_item_data_get(slide_it2);
187 return strcasecmp(img_path1, img_path2);
191 elm_main(int argc __UNUSED__,
192 char **argv __UNUSED__)
194 Evas_Object *win, *bg, *notify, *bx, *bt, *hv, *spin;
195 Elm_Object_Item *slide_first, *slide_last, *slide_it;
196 const char *transition, *layout;
197 const Eina_List *l, *list;
199 win = elm_win_add(NULL, "slideshow", ELM_WIN_BASIC);
200 elm_win_title_set(win, "Slideshow example");
201 evas_object_smart_callback_add(win, "delete,request", _on_done, NULL);
203 bg = elm_bg_add(win);
204 elm_win_resize_object_add(win, bg);
205 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
206 evas_object_show(bg);
208 slideshow = elm_slideshow_add(win);
209 elm_slideshow_loop_set(slideshow, EINA_TRUE);
210 elm_win_resize_object_add(win, slideshow);
211 evas_object_size_hint_weight_set(slideshow,
212 EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
213 evas_object_show(slideshow);
218 slide_first = elm_slideshow_item_sorted_insert(slideshow, &itc, img1, _cmp_func);
219 elm_slideshow_item_sorted_insert(slideshow, &itc, img2, _cmp_func);
220 elm_slideshow_item_sorted_insert(slideshow, &itc, img3, _cmp_func);
221 elm_slideshow_item_sorted_insert(slideshow, &itc, img4, _cmp_func);
222 elm_slideshow_item_sorted_insert(slideshow, &itc, img5, _cmp_func);
223 elm_slideshow_item_sorted_insert(slideshow, &itc, img6, _cmp_func);
224 elm_slideshow_item_sorted_insert(slideshow, &itc, img7, _cmp_func);
225 elm_slideshow_item_sorted_insert(slideshow, &itc, img8, _cmp_func);
226 slide_last = elm_slideshow_item_add(slideshow, &itc, img9);
228 list = elm_slideshow_items_get(slideshow);
229 fprintf(stdout, "List of items in the slideshow:\n");
230 EINA_LIST_FOREACH(list, l, slide_it)
231 fprintf(stdout, "\t%s\n",
232 (const char *)elm_object_item_data_get(slide_it));
234 notify = elm_notify_add(win);
235 elm_notify_orient_set(notify, ELM_NOTIFY_ORIENT_BOTTOM);
236 elm_win_resize_object_add(win, notify);
237 elm_notify_timeout_set(notify, 3.0);
239 bx = elm_box_add(win);
240 elm_box_horizontal_set(bx, EINA_TRUE);
241 elm_object_content_set(notify, bx);
242 evas_object_show(bx);
244 evas_object_event_callback_add(bx, EVAS_CALLBACK_MOUSE_IN, _mouse_in,
246 evas_object_event_callback_add(bx, EVAS_CALLBACK_MOUSE_OUT, _mouse_out,
249 bt = elm_button_add(win);
250 elm_object_text_set(bt, "Previous");
251 evas_object_smart_callback_add(bt, "clicked", _previous, slideshow);
252 elm_box_pack_end(bx, bt);
253 evas_object_show(bt);
255 bt = elm_button_add(win);
256 elm_object_text_set(bt, "Next");
257 evas_object_smart_callback_add(bt, "clicked", _next, slideshow);
258 elm_box_pack_end(bx, bt);
259 evas_object_show(bt);
261 bt = elm_button_add(win);
262 elm_object_text_set(bt, "First");
263 evas_object_smart_callback_add(bt, "clicked", _first, slide_first);
264 elm_box_pack_end(bx, bt);
265 evas_object_show(bt);
267 bt = elm_button_add(win);
268 elm_object_text_set(bt, "Last");
269 evas_object_smart_callback_add(bt, "clicked", _last, slide_last);
270 elm_box_pack_end(bx, bt);
271 evas_object_show(bt);
273 hv = elm_hoversel_add(win);
274 elm_box_pack_end(bx, hv);
275 elm_hoversel_hover_parent_set(hv, win);
276 EINA_LIST_FOREACH(elm_slideshow_transitions_get(slideshow), l, transition)
277 elm_hoversel_item_add(hv, transition, NULL, 0, _transition_select,
279 elm_object_text_set(hv, eina_list_data_get(
280 elm_slideshow_transitions_get(slideshow)));
281 evas_object_show(hv);
283 hv = elm_hoversel_add(win);
284 elm_box_pack_end(bx, hv);
285 elm_hoversel_hover_parent_set(hv, win);
286 EINA_LIST_FOREACH(elm_slideshow_layouts_get(slideshow), l, layout)
287 elm_hoversel_item_add(hv, layout, NULL, 0, _layout_select, layout);
288 elm_object_text_set(hv, elm_slideshow_layout_get(slideshow));
289 evas_object_show(hv);
291 spin = elm_spinner_add(win);
292 elm_spinner_label_format_set(spin, "%2.0f s");
293 evas_object_smart_callback_add(spin, "changed", _spin, spin);
294 elm_spinner_step_set(spin, 1);
295 elm_spinner_min_max_set(spin, 1, 30);
296 elm_spinner_value_set(spin, 3);
297 elm_box_pack_end(bx, spin);
298 evas_object_show(spin);
300 bt = elm_button_add(win);
302 elm_object_text_set(bt, "Start");
303 evas_object_smart_callback_add(bt, "clicked", _start, spin);
304 elm_box_pack_end(bx, bt);
305 evas_object_show(bt);
307 bt = elm_button_add(win);
309 elm_object_text_set(bt, "Stop");
310 evas_object_smart_callback_add(bt, "clicked", _stop, spin);
311 elm_box_pack_end(bx, bt);
312 elm_object_disabled_set(bt, EINA_TRUE);
313 evas_object_show(bt);
315 evas_object_event_callback_add(slideshow, EVAS_CALLBACK_MOUSE_UP,
316 _notify_show, notify);
317 evas_object_event_callback_add(slideshow, EVAS_CALLBACK_MOUSE_MOVE,
318 _notify_show, notify);
320 _notify_show(notify, NULL, NULL, NULL);
322 evas_object_resize(win, 600, 400);
323 evas_object_show(win);