Elm button: Fix the tests to use the new elm_object_text_set/get API.
[framework/uifw/elementary.git] / src / bin / test_list.c
1 #include <Elementary.h>
2 #ifdef HAVE_CONFIG_H
3 # include "elementary_config.h"
4 #endif
5 #ifndef ELM_LIB_QUICKLAUNCH
6 static void
7 my_show_it(void        *data,
8            Evas_Object *obj __UNUSED__,
9            void        *event_info __UNUSED__)
10 {
11    elm_list_item_show(data);
12 }
13
14 static void
15 scroll_top(void        *data __UNUSED__,
16            Evas_Object *obj __UNUSED__,
17            void        *event_info __UNUSED__)
18 {
19    printf("Top edge!\n");
20 }
21
22 static void
23 scroll_bottom(void        *data __UNUSED__,
24               Evas_Object *obj __UNUSED__,
25               void        *event_info __UNUSED__)
26 {
27    printf("Bottom edge!\n");
28 }
29
30 static void
31 scroll_left(void        *data __UNUSED__,
32             Evas_Object *obj __UNUSED__,
33             void        *event_info __UNUSED__)
34 {
35    printf("Left edge!\n");
36 }
37
38 static void
39 scroll_right(void        *data __UNUSED__,
40              Evas_Object *obj __UNUSED__,
41              void        *event_info __UNUSED__)
42 {
43    printf("Right edge!\n");
44 }
45
46 void
47 test_list(void        *data __UNUSED__,
48           Evas_Object *obj __UNUSED__,
49           void        *event_info __UNUSED__)
50 {
51    Evas_Object *win, *bg, *li, *ic, *ic2, *bx, *tb2, *bt;
52    char buf[PATH_MAX];
53    Elm_List_Item *it1, *it2, *it3, *it4, *it5;
54
55    win = elm_win_add(NULL, "list", ELM_WIN_BASIC);
56    elm_win_title_set(win, "List");
57    elm_win_autodel_set(win, 1);
58
59    bg = elm_bg_add(win);
60    elm_win_resize_object_add(win, bg);
61    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
62    evas_object_show(bg);
63
64    li = elm_list_add(win);
65    elm_win_resize_object_add(win, li);
66    elm_list_mode_set(li, ELM_LIST_LIMIT);
67    evas_object_size_hint_weight_set(li, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
68
69    ic = elm_icon_add(win);
70    snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR);
71    elm_icon_file_set(ic, buf, NULL);
72    elm_icon_scale_set(ic, 1, 1);
73    it1 = elm_list_item_append(li, "Hello", ic, NULL, NULL, NULL);
74    ic = elm_icon_add(win);
75    snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR);
76    elm_icon_scale_set(ic, 0, 0);
77    elm_icon_file_set(ic, buf, NULL);
78    elm_list_item_append(li, "world", ic, NULL, NULL, NULL);
79    ic = elm_icon_add(win);
80    elm_icon_standard_set(ic, "edit");
81    elm_icon_scale_set(ic, 0, 0);
82    elm_list_item_append(li, ".", ic, NULL, NULL, NULL);
83
84    ic = elm_icon_add(win);
85    elm_icon_standard_set(ic, "delete");
86    elm_icon_scale_set(ic, 0, 0);
87    ic2 = elm_icon_add(win);
88    elm_icon_standard_set(ic2, "clock");
89    elm_icon_scale_set(ic2, 0, 0);
90    it2 = elm_list_item_append(li, "How", ic, ic2, NULL, NULL);
91
92    bx = elm_box_add(win);
93    elm_box_horizontal_set(bx, EINA_TRUE);
94
95    ic = elm_icon_add(win);
96    snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR);
97    elm_icon_file_set(ic, buf, NULL);
98    elm_icon_scale_set(ic, 0, 0);
99    evas_object_size_hint_align_set(ic, 0.5, 0.5);
100    elm_box_pack_end(bx, ic);
101    evas_object_show(ic);
102
103    ic = elm_icon_add(win);
104    snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR);
105    elm_icon_file_set(ic, buf, NULL);
106    elm_icon_scale_set(ic, 0, 0);
107    evas_object_size_hint_align_set(ic, 0.5, 0.0);
108    elm_box_pack_end(bx, ic);
109    evas_object_show(ic);
110
111    ic = elm_icon_add(win);
112    snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR);
113    elm_icon_file_set(ic, buf, NULL);
114    elm_icon_scale_set(ic, 0, 0);
115    evas_object_size_hint_align_set(ic, 0.0, EVAS_HINT_EXPAND);
116    elm_box_pack_end(bx, ic);
117    evas_object_show(ic);
118    elm_list_item_append(li, "are", bx, NULL, NULL, NULL);
119
120    elm_list_item_append(li, "you", NULL, NULL, NULL, NULL);
121    it3 = elm_list_item_append(li, "doing", NULL, NULL, NULL, NULL);
122    elm_list_item_append(li, "out", NULL, NULL, NULL, NULL);
123    elm_list_item_append(li, "there", NULL, NULL, NULL, NULL);
124    elm_list_item_append(li, "today", NULL, NULL, NULL, NULL);
125    elm_list_item_append(li, "?", NULL, NULL, NULL, NULL);
126    it4 = elm_list_item_append(li, "Here", NULL, NULL, NULL, NULL);
127    elm_list_item_append(li, "are", NULL, NULL, NULL, NULL);
128    elm_list_item_append(li, "some", NULL, NULL, NULL, NULL);
129    elm_list_item_append(li, "more", NULL, NULL, NULL, NULL);
130    elm_list_item_append(li, "items", NULL, NULL, NULL, NULL);
131    elm_list_item_append(li, "Is this label long enough?", NULL, NULL, NULL, NULL);
132    it5 = elm_list_item_append(li, "Maybe this one is even longer so we can test long long items.", NULL, NULL, NULL, NULL);
133
134    elm_list_go(li);
135
136    evas_object_show(li);
137
138    tb2 = elm_table_add(win);
139    evas_object_size_hint_weight_set(tb2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
140    elm_win_resize_object_add(win, tb2);
141
142    bt = elm_button_add(win);
143    elm_object_text_set(bt, "Hello");
144    evas_object_smart_callback_add(bt, "clicked", my_show_it, it1);
145    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
146    evas_object_size_hint_align_set(bt, 0.9, 0.5);
147    elm_table_pack(tb2, bt, 0, 0, 1, 1);
148    evas_object_show(bt);
149
150    bt = elm_button_add(win);
151    elm_object_text_set(bt, "How");
152    evas_object_smart_callback_add(bt, "clicked", my_show_it, it2);
153    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
154    evas_object_size_hint_align_set(bt, 0.9, 0.5);
155    elm_table_pack(tb2, bt, 0, 1, 1, 1);
156    evas_object_show(bt);
157
158    bt = elm_button_add(win);
159    elm_object_text_set(bt, "doing");
160    evas_object_smart_callback_add(bt, "clicked", my_show_it, it3);
161    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
162    evas_object_size_hint_align_set(bt, 0.9, 0.5);
163    elm_table_pack(tb2, bt, 0, 2, 1, 1);
164    evas_object_show(bt);
165
166    bt = elm_button_add(win);
167    elm_object_text_set(bt, "Here");
168    evas_object_smart_callback_add(bt, "clicked", my_show_it, it4);
169    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
170    evas_object_size_hint_align_set(bt, 0.9, 0.5);
171    elm_table_pack(tb2, bt, 0, 3, 1, 1);
172    evas_object_show(bt);
173
174    bt = elm_button_add(win);
175    elm_object_text_set(bt, "Maybe this...");
176    evas_object_smart_callback_add(bt, "clicked", my_show_it, it5);
177    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
178    evas_object_size_hint_align_set(bt, 0.9, 0.5);
179    elm_table_pack(tb2, bt, 0, 4, 1, 1);
180    evas_object_show(bt);
181
182    evas_object_show(tb2);
183
184    evas_object_resize(win, 320, 300);
185    evas_object_show(win);
186
187    evas_object_smart_callback_add(li, "scroll,edge,top", scroll_top, NULL);
188    evas_object_smart_callback_add(li, "scroll,edge,bottom", scroll_bottom, NULL);
189    evas_object_smart_callback_add(li, "scroll,edge,left", scroll_left, NULL);
190    evas_object_smart_callback_add(li, "scroll,edge,right", scroll_right, NULL);
191 }
192
193 void
194 test_list_horizontal(void        *data __UNUSED__,
195                      Evas_Object *obj __UNUSED__,
196                      void        *event_info __UNUSED__)
197 {
198    Evas_Object *win, *bg, *li, *ic, *ic2, *bx, *tb2, *bt;
199    char buf[PATH_MAX];
200    Elm_List_Item *it1, *it2, *it3, *it4;
201
202    win = elm_win_add(NULL, "list-horizontal", ELM_WIN_BASIC);
203    elm_win_title_set(win, "List Horizontal");
204    elm_win_autodel_set(win, EINA_TRUE);
205
206    bg = elm_bg_add(win);
207    elm_win_resize_object_add(win, bg);
208    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
209    evas_object_show(bg);
210
211    li = elm_list_add(win);
212    elm_list_horizontal_set(li, EINA_TRUE);
213    elm_list_mode_set(li, ELM_LIST_LIMIT);
214    elm_win_resize_object_add(win, li);
215    evas_object_size_hint_weight_set(li, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
216
217    ic = elm_icon_add(win);
218    snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR);
219    elm_icon_file_set(ic, buf, NULL);
220    elm_icon_scale_set(ic, 1, 1);
221    it1 = elm_list_item_append(li, "Hello", ic, NULL, NULL, NULL);
222    ic = elm_icon_add(win);
223    snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR);
224    elm_icon_scale_set(ic, 0, 0);
225    elm_icon_file_set(ic, buf, NULL);
226    elm_list_item_append(li, "world", ic, NULL, NULL, NULL);
227    ic = elm_icon_add(win);
228    elm_icon_standard_set(ic, "edit");
229    elm_icon_scale_set(ic, 0, 0);
230    elm_list_item_append(li, ".", ic, NULL, NULL, NULL);
231
232    ic = elm_icon_add(win);
233    elm_icon_standard_set(ic, "delete");
234    elm_icon_scale_set(ic, 0, 0);
235    ic2 = elm_icon_add(win);
236    elm_icon_standard_set(ic2, "clock");
237    elm_icon_scale_set(ic2, 0, 0);
238    it2 = elm_list_item_append(li, "How", ic, ic2, NULL, NULL);
239
240    bx = elm_box_add(win);
241
242    ic = elm_icon_add(win);
243    snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR);
244    elm_icon_file_set(ic, buf, NULL);
245    elm_icon_scale_set(ic, 0, 0);
246    evas_object_size_hint_align_set(ic, 0.5, 0.5);
247    elm_box_pack_end(bx, ic);
248    evas_object_show(ic);
249
250    ic = elm_icon_add(win);
251    snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR);
252    elm_icon_file_set(ic, buf, NULL);
253    elm_icon_scale_set(ic, 0, 0);
254    evas_object_size_hint_align_set(ic, 0.5, 0.0);
255    elm_box_pack_end(bx, ic);
256    evas_object_show(ic);
257
258    elm_list_item_append(li, "are", bx, NULL, NULL, NULL);
259
260    elm_list_item_append(li, "you", NULL, NULL, NULL, NULL);
261    it3 = elm_list_item_append(li, "doing", NULL, NULL, NULL, NULL);
262    elm_list_item_append(li, "out", NULL, NULL, NULL, NULL);
263    elm_list_item_append(li, "there", NULL, NULL, NULL, NULL);
264    elm_list_item_append(li, "today", NULL, NULL, NULL, NULL);
265    elm_list_item_append(li, "?", NULL, NULL, NULL, NULL);
266
267    it4 = elm_list_item_append(li, "And", NULL, NULL, NULL, NULL);
268    elm_list_item_append(li, "here", NULL, NULL, NULL, NULL);
269    elm_list_item_append(li, "we", NULL, NULL, NULL, NULL);
270    elm_list_item_append(li, "are", NULL, NULL, NULL, NULL);
271    elm_list_item_append(li, "done", NULL, NULL, NULL, NULL);
272    elm_list_item_append(li, "with", NULL, NULL, NULL, NULL);
273    elm_list_item_append(li, "items.", NULL, NULL, NULL, NULL);
274
275    elm_list_go(li);
276
277    evas_object_show(li);
278
279    tb2 = elm_table_add(win);
280    evas_object_size_hint_weight_set(tb2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
281    elm_win_resize_object_add(win, tb2);
282
283    bt = elm_button_add(win);
284    elm_object_text_set(bt, "Hello");
285    evas_object_smart_callback_add(bt, "clicked", my_show_it, it1);
286    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
287    evas_object_size_hint_align_set(bt, 0.5, 0.9);
288    elm_table_pack(tb2, bt, 0, 0, 1, 1);
289    evas_object_show(bt);
290
291    bt = elm_button_add(win);
292    elm_object_text_set(bt, "How");
293    evas_object_smart_callback_add(bt, "clicked", my_show_it, it2);
294    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
295    evas_object_size_hint_align_set(bt, 0.5, 0.9);
296    elm_table_pack(tb2, bt, 1, 0, 1, 1);
297    evas_object_show(bt);
298
299    bt = elm_button_add(win);
300    elm_object_text_set(bt, "doing");
301    evas_object_smart_callback_add(bt, "clicked", my_show_it, it3);
302    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
303    evas_object_size_hint_align_set(bt, 0.5, 0.9);
304    elm_table_pack(tb2, bt, 2, 0, 1, 1);
305    evas_object_show(bt);
306
307    bt = elm_button_add(win);
308    elm_object_text_set(bt, "And");
309    evas_object_smart_callback_add(bt, "clicked", my_show_it, it4);
310    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
311    evas_object_size_hint_align_set(bt, 0.5, 0.9);
312    elm_table_pack(tb2, bt, 3, 0, 1, 1);
313    evas_object_show(bt);
314
315    evas_object_show(tb2);
316
317    evas_object_resize(win, 320, 300);
318    evas_object_show(win);
319 }
320
321 /***********/
322
323 static void
324 my_li2_clear(void        *data,
325              Evas_Object *obj __UNUSED__,
326              void        *event_info __UNUSED__)
327 {
328    elm_list_clear(data);
329 }
330
331 static void
332 my_li2_sel(void        *data __UNUSED__,
333            Evas_Object *obj,
334            void        *event_info __UNUSED__)
335 {
336    Elm_List_Item *it = elm_list_selected_item_get(obj);
337    elm_list_item_selected_set(it, 0);
338 //   elm_list_item_selected_set(event_info, 0);
339 }
340
341 void
342 test_list2(void        *data __UNUSED__,
343            Evas_Object *obj __UNUSED__,
344            void        *event_info __UNUSED__)
345 {
346    Evas_Object *win, *bg, *li, *ic, *ic2, *bx, *bx2, *bt;
347    char buf[PATH_MAX];
348    Elm_List_Item *it;
349
350    win = elm_win_add(NULL, "list2", ELM_WIN_BASIC);
351    elm_win_title_set(win, "List 2");
352    elm_win_autodel_set(win, 1);
353
354    bg = elm_bg_add(win);
355    snprintf(buf, sizeof(buf), "%s/images/plant_01.jpg", PACKAGE_DATA_DIR);
356    elm_bg_file_set(bg, buf, NULL);
357    elm_win_resize_object_add(win, bg);
358    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
359    evas_object_show(bg);
360
361    bx = elm_box_add(win);
362    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
363    elm_win_resize_object_add(win, bx);
364    evas_object_show(bx);
365
366    li = elm_list_add(win);
367    evas_object_size_hint_align_set(li, EVAS_HINT_FILL, EVAS_HINT_FILL);
368    evas_object_size_hint_weight_set(li, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
369    elm_list_mode_set(li, ELM_LIST_LIMIT);
370 //   elm_list_multi_select_set(li, 1);
371
372    ic = elm_icon_add(win);
373    snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR);
374    elm_icon_file_set(ic, buf, NULL);
375    it = elm_list_item_append(li, "Hello", ic, NULL, my_li2_sel, NULL);
376    elm_list_item_selected_set(it, 1);
377    ic = elm_icon_add(win);
378    snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR);
379    elm_icon_scale_set(ic, 0, 0);
380    elm_icon_file_set(ic, buf, NULL);
381    elm_list_item_append(li, "world", ic, NULL, NULL, NULL);
382    ic = elm_icon_add(win);
383    elm_icon_standard_set(ic, "edit");
384    elm_icon_scale_set(ic, 0, 0);
385    elm_list_item_append(li, ".", ic, NULL, NULL, NULL);
386
387    ic = elm_icon_add(win);
388    elm_icon_standard_set(ic, "delete");
389    elm_icon_scale_set(ic, 0, 0);
390    ic2 = elm_icon_add(win);
391    elm_icon_standard_set(ic2, "clock");
392    elm_icon_scale_set(ic2, 0, 0);
393    elm_list_item_append(li, "How", ic, ic2, NULL, NULL);
394
395    bx2 = elm_box_add(win);
396    elm_box_horizontal_set(bx2, EINA_TRUE);
397
398    ic = elm_icon_add(win);
399    snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR);
400    elm_icon_file_set(ic, buf, NULL);
401    elm_icon_scale_set(ic, 0, 0);
402    evas_object_size_hint_align_set(ic, 0.5, 0.5);
403    elm_box_pack_end(bx2, ic);
404    evas_object_show(ic);
405
406    ic = elm_icon_add(win);
407    snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR);
408    elm_icon_file_set(ic, buf, NULL);
409    elm_icon_scale_set(ic, 0, 0);
410    evas_object_size_hint_align_set(ic, 0.5, 0.0);
411    elm_box_pack_end(bx2, ic);
412    evas_object_show(ic);
413    elm_list_item_append(li, "are", bx2, NULL, NULL, NULL);
414
415    elm_list_item_append(li, "you", NULL, NULL, NULL, NULL);
416    elm_list_item_append(li, "doing", NULL, NULL, NULL, NULL);
417    elm_list_item_append(li, "out", NULL, NULL, NULL, NULL);
418    elm_list_item_append(li, "there", NULL, NULL, NULL, NULL);
419    elm_list_item_append(li, "today", NULL, NULL, NULL, NULL);
420    elm_list_item_append(li, "?", NULL, NULL, NULL, NULL);
421    elm_list_item_append(li, "Here", NULL, NULL, NULL, NULL);
422    elm_list_item_append(li, "are", NULL, NULL, NULL, NULL);
423    elm_list_item_append(li, "some", NULL, NULL, NULL, NULL);
424    elm_list_item_append(li, "more", NULL, NULL, NULL, NULL);
425    elm_list_item_append(li, "items", NULL, NULL, NULL, NULL);
426    elm_list_item_append(li, "Longer label.", NULL, NULL, NULL, NULL);
427
428    elm_list_go(li);
429
430    elm_box_pack_end(bx, li);
431    evas_object_show(li);
432
433    bx2 = elm_box_add(win);
434    elm_box_horizontal_set(bx2, EINA_TRUE);
435    elm_box_homogeneous_set(bx2, EINA_TRUE);
436    evas_object_size_hint_weight_set(bx2, EVAS_HINT_EXPAND, 0.0);
437    evas_object_size_hint_align_set(bx2, EVAS_HINT_FILL, EVAS_HINT_FILL);
438
439    bt = elm_button_add(win);
440    elm_object_text_set(bt, "Clear");
441    evas_object_smart_callback_add(bt, "clicked", my_li2_clear, li);
442    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
443    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
444    elm_box_pack_end(bx2, bt);
445    evas_object_show(bt);
446
447    elm_box_pack_end(bx, bx2);
448    evas_object_show(bx2);
449
450    evas_object_resize(win, 320, 300);
451    evas_object_show(win);
452 }
453
454 /***********/
455
456 static void
457 _bt_clicked(void        *data __UNUSED__,
458             Evas_Object *obj __UNUSED__,
459             void        *event_info __UNUSED__)
460 {
461    printf("button was clicked\n");
462 }
463
464 static void
465 _it_clicked(void        *data __UNUSED__,
466             Evas_Object *obj __UNUSED__,
467             void        *event_info __UNUSED__)
468 {
469    printf("item was clicked\n");
470 }
471
472 void
473 test_list3(void        *data __UNUSED__,
474            Evas_Object *obj __UNUSED__,
475            void        *event_info __UNUSED__)
476 {
477    Evas_Object *win, *bg, *li, *ic, *ic2, *bx;
478    char buf[PATH_MAX];
479
480    win = elm_win_add(NULL, "list3", ELM_WIN_BASIC);
481    elm_win_title_set(win, "List 3");
482    elm_win_autodel_set(win, 1);
483
484    bg = elm_bg_add(win);
485    elm_win_resize_object_add(win, bg);
486    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
487    evas_object_show(bg);
488
489    li = elm_list_add(win);
490    elm_win_resize_object_add(win, li);
491    evas_object_size_hint_weight_set(li, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
492    elm_list_mode_set(li, ELM_LIST_COMPRESS);
493
494    ic = elm_icon_add(win);
495    snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR);
496    elm_icon_scale_set(ic, 0, 0);
497    elm_icon_file_set(ic, buf, NULL);
498    ic2 = elm_button_add(win);
499    elm_object_text_set(ic2, "Click me");
500    evas_object_smart_callback_add(ic2, "clicked", _bt_clicked, NULL);
501    evas_object_propagate_events_set(ic2, 0);
502    elm_list_item_append(li, "Hello", ic, ic2, _it_clicked, NULL);
503
504    ic = elm_icon_add(win);
505    snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR);
506    elm_icon_scale_set(ic, 0, 0);
507    elm_icon_file_set(ic, buf, NULL);
508    ic2 = elm_button_add(win);
509    elm_object_text_set(ic2, "Click me");
510    evas_object_smart_callback_add(ic2, "clicked", _bt_clicked, NULL);
511    elm_list_item_append(li, "world", ic, ic2, _it_clicked, NULL);
512
513    ic = elm_icon_add(win);
514    elm_icon_standard_set(ic, "edit");
515    elm_icon_scale_set(ic, 0, 0);
516    elm_list_item_append(li, ".", ic, NULL, NULL, NULL);
517
518    ic = elm_icon_add(win);
519    elm_icon_standard_set(ic, "delete");
520    elm_icon_scale_set(ic, 0, 0);
521    ic2 = elm_icon_add(win);
522    elm_icon_standard_set(ic2, "clock");
523    elm_icon_scale_set(ic2, 0, 0);
524    elm_list_item_append(li, "How", ic, ic2, NULL, NULL);
525
526    bx = elm_box_add(win);
527    elm_box_horizontal_set(bx, EINA_TRUE);
528
529    ic = elm_icon_add(win);
530    snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR);
531    elm_icon_file_set(ic, buf, NULL);
532    elm_icon_scale_set(ic, 0, 0);
533    evas_object_size_hint_align_set(ic, 0.5, 0.5);
534    elm_box_pack_end(bx, ic);
535    evas_object_show(ic);
536
537    ic = elm_icon_add(win);
538    snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR);
539    elm_icon_file_set(ic, buf, NULL);
540    elm_icon_scale_set(ic, 0, 0);
541    evas_object_size_hint_align_set(ic, 0.5, 0.0);
542    elm_box_pack_end(bx, ic);
543    evas_object_show(ic);
544
545    ic = elm_icon_add(win);
546    snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR);
547    elm_icon_file_set(ic, buf, NULL);
548    elm_icon_scale_set(ic, 0, 0);
549    evas_object_size_hint_align_set(ic, 0.0, EVAS_HINT_EXPAND);
550    elm_box_pack_end(bx, ic);
551    evas_object_show(ic);
552
553    elm_list_item_append(li, "are", bx, NULL, NULL, NULL);
554    elm_list_item_append(li, "you", NULL, NULL, NULL, NULL);
555    elm_list_item_append(li, "doing", NULL, NULL, NULL, NULL);
556    elm_list_item_append(li, "out", NULL, NULL, NULL, NULL);
557    elm_list_item_append(li, "there", NULL, NULL, NULL, NULL);
558    elm_list_item_append(li, "today", NULL, NULL, NULL, NULL);
559    elm_list_item_append(li, "?", NULL, NULL, NULL, NULL);
560    elm_list_item_append(li, "Here", NULL, NULL, NULL, NULL);
561    elm_list_item_append(li, "are", NULL, NULL, NULL, NULL);
562    elm_list_item_append(li, "some", NULL, NULL, NULL, NULL);
563    elm_list_item_append(li, "more", NULL, NULL, NULL, NULL);
564    elm_list_item_append(li, "items", NULL, NULL, NULL, NULL);
565    elm_list_item_append(li, "Is this label long enough?", NULL, NULL, NULL, NULL);
566    elm_list_item_append(li, "Maybe this one is even longer so we can test long long items.", NULL, NULL, NULL, NULL);
567
568    elm_list_go(li);
569
570    evas_object_show(li);
571
572    evas_object_resize(win, 320, 300);
573    evas_object_show(win);
574 }
575
576 ///////////////////////////////////////////////////////////////////////////////////////
577
578 struct Pginfo
579 {
580    Evas_Object *pager, *win;
581 };
582
583 static void
584 test_list4_back_cb(void        *data,
585                    Evas_Object *obj __UNUSED__,
586                    void        *event_info __UNUSED__)
587 {
588    struct Pginfo *info = data;
589    if (!info) return;
590
591    elm_pager_content_pop(info->pager);
592 }
593
594 static void
595 test_list4_swipe(void        *data,
596                  Evas_Object *obj __UNUSED__,
597                  void        *event_info)
598 {
599    Evas_Object *box, *entry, *button;
600    struct Pginfo *info = data;
601    char *item_data;
602    if ((!event_info) || (!data)) return;
603
604    item_data = elm_list_item_data_get(event_info);
605
606    box = elm_box_add(info->win);
607    elm_box_horizontal_set(box, EINA_FALSE);
608    elm_box_homogeneous_set(box, EINA_FALSE);
609    evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
610    evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
611    evas_object_show(box);
612
613    entry = elm_entry_add(info->win);
614    elm_entry_scrollable_set(entry, EINA_TRUE);
615    elm_entry_editable_set(entry, EINA_FALSE);
616    elm_entry_entry_set(entry, item_data);
617    evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
618    evas_object_size_hint_align_set(entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
619    evas_object_show(entry);
620
621    button = elm_button_add(info->win);
622    elm_object_text_set(button, "back");
623    evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, 0);
624    evas_object_size_hint_align_set(button, EVAS_HINT_FILL, 0);
625    evas_object_smart_callback_add(button, "clicked", test_list4_back_cb, info);
626    evas_object_show(button);
627
628    elm_box_pack_start(box, entry);
629    elm_box_pack_end(box, button);
630
631    elm_pager_content_push(info->pager, box);
632 }
633
634 void
635 test_list4(void        *data __UNUSED__,
636            Evas_Object *obj __UNUSED__,
637            void        *event_info __UNUSED__)
638 {
639    Evas_Object *win, *bg, *li, *ic, *ic2, *pager;
640    static struct Pginfo info = {NULL, NULL};
641    char buf[PATH_MAX];
642
643    win = elm_win_add(NULL, "list4", ELM_WIN_BASIC);
644    elm_win_title_set(win, "List 4");
645    elm_win_autodel_set(win, 1);
646    info.win = win;
647
648    bg = elm_bg_add(win);
649    elm_win_resize_object_add(win, bg);
650    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
651    evas_object_show(bg);
652
653    pager = elm_pager_add(win);
654    elm_win_resize_object_add(win, pager);
655    evas_object_size_hint_weight_set(pager, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
656    evas_object_size_hint_align_set(pager, EVAS_HINT_FILL, EVAS_HINT_FILL);
657    evas_object_show(pager);
658    info.pager = pager;
659
660    li = elm_list_add(win);
661    evas_object_size_hint_weight_set(li, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
662    elm_list_mode_set(li, ELM_LIST_COMPRESS);
663    evas_object_smart_callback_add(li, "swipe", test_list4_swipe, &info);
664    elm_pager_content_push(pager, li);
665
666    static char pf_data[] = "Pink Floyd were formed in 1965, and originally consisted of university"                       \
667                            "students Roger Waters, Nick Mason, Richard Wright, and Syd Barrett. The group were a popular" \
668                            "fixture on London's underground music scene, and under Barrett's leadership released two "    \
669                            "charting singles, \"Arnold Layne\" and \"See Emily Play\", and a successful debut album, "    \
670                            "ThePiper at the Gates of Dawn. In 1968, guitarist and singer David Gilmour joined the "       \
671                            "line-up. Barrett was soon removed, due to his increasingly erratic behaviour. Following "     \
672                            "Barrett's departure, bass player and singer Roger Waters became the band's lyricist and "     \
673                            "conceptual leader, with Gilmour assuming lead guitar and much of the vocals. With this "      \
674                            "line-up, Floyd went on to achieve worldwide critical and commercial success with the "        \
675                            "conceptalbums The Dark Side of the Moon, Wish You Were Here, Animals, and The Wall.";
676    ic = elm_icon_add(win);
677    snprintf(buf, sizeof(buf), "%s/images/mystrale.jpg", PACKAGE_DATA_DIR);
678    elm_icon_scale_set(ic, 0, 0);
679    elm_icon_file_set(ic, buf, NULL);
680    elm_list_item_append(li, "Pink Floyd", ic, NULL, NULL, &pf_data);
681
682    static char ds_data[] = "Dire Straits were a British rock band, formed by Mark Knopfler "                          \
683                            "(lead vocals and lead guitar), his younger brother David Knopfler (rhythm guitar and "    \
684                            "backing vocals), John Illsley (bass guitar and backing vocals), and Pick Withers (drums " \
685                            "and percussion), and managed by Ed Bicknell, active between 1977 and 1995. Although the " \
686                            "band was formed in an era when punk rock was at the forefront, Dire Straits played a more "
687                            "bluesy style, albeit with a stripped-down sound that appealed to audiences weary of the "   \
688                            "overproduced stadium rock of the 1970s.[citation needed] In their early days, Mark and "    \
689                            "David requested that pub owners turn down their sound so that patrons could converse "      \
690                            "while the band played, an indication of their unassuming demeanor. Despite this oddly "     \
691                            "self-effacing approach to rock and roll, Dire Straits soon became hugely successful, with " \
692                            "their first album going multi-platinum globally.";
693    ic = elm_icon_add(win);
694    snprintf(buf, sizeof(buf), "%s/images/mystrale_2.jpg", PACKAGE_DATA_DIR);
695    elm_icon_scale_set(ic, 0, 0);
696    elm_icon_file_set(ic, buf, NULL);
697    elm_list_item_append(li, "Dire Straits", ic, NULL, NULL, &ds_data);
698
699    static char uh_data[] = "Uriah Heep are an English hard rock band. The band released several "                       \
700                            "commercially successful albums in the 1970s such as Uriah Heep Live (1973), but their "     \
701                            "audience declined by the 1980s, to the point where they became essentially a cult band in " \
702                            "the United States and United Kingdom. Uriah Heep maintain a significant following in "      \
703                            "Germany, the Netherlands, Scandinavia, the Balkans, Japan and Russia, where they still "    \
704                            "perform at stadium-sized venues.";
705    ic = elm_icon_add(win);
706    snprintf(buf, sizeof(buf), "%s/images/icon_17.png", PACKAGE_DATA_DIR);
707    elm_icon_scale_set(ic, 1, 1);
708    elm_icon_file_set(ic, buf, NULL);
709    elm_list_item_append(li, "Uriah Heep", ic, NULL, NULL, &uh_data);
710
711    static char r_data[] = "Rush is a Canadian rock band formed in August 1968, in the Willowdale "                       \
712                           "neighbourhood of Toronto, Ontario. The band is composed of bassist, keyboardist, and lead "   \
713                           "vocalist Geddy Lee, guitarist Alex Lifeson, and drummer and lyricist Neil Peart. The band "   \
714                           "and its membership went through a number of re-configurations between 1968 and 1974, "        \
715                           "achieving their current form when Peart replaced original drummer John Rutsey in July 1974, " \
716                           "two weeks before the group's first United States tour.";
717    ic = elm_icon_add(win);
718    snprintf(buf, sizeof(buf), "%s/images/icon_21.png", PACKAGE_DATA_DIR);
719    elm_icon_scale_set(ic, 0, 0);
720    elm_icon_file_set(ic, buf, NULL);
721    ic2 = elm_icon_add(win);
722    elm_icon_standard_set(ic2, "clock");
723    elm_icon_scale_set(ic2, 0, 0);
724    elm_list_item_append(li, "Rush", ic, ic2, NULL, &r_data);
725
726    elm_list_go(li);
727
728    evas_object_show(li);
729    evas_object_resize(win, 320, 300);
730    evas_object_show(win);
731 }
732
733 /////////////////////////////////////////////////////////////////////////////////////////
734 struct list5_data_cb
735 {
736    Evas_Object *win, *list;
737 };
738
739 static void
740 test_list5_item_del(void        *data,
741                     Evas_Object *obj __UNUSED__,
742                     void        *event_info __UNUSED__)
743 {
744    elm_list_item_del(data);
745 }
746
747 static void
748 test_list5_swipe(void        *data __UNUSED__,
749                  Evas_Object *obj __UNUSED__,
750                  void        *event_info)
751 {
752    Evas_Object *button;
753    struct list5_data_cb *info = elm_list_item_data_get(event_info);
754
755    if (elm_list_item_end_get(event_info)) return;
756
757    button = elm_button_add(info->win);
758    elm_object_text_set(button, "delete");
759    evas_object_propagate_events_set(button, 0);
760    evas_object_smart_callback_add(button, "clicked", test_list5_item_del,
761                                   event_info);
762    elm_list_item_end_set(event_info, button);
763 }
764
765 void
766 test_list5(void        *data __UNUSED__,
767            Evas_Object *obj __UNUSED__,
768            void        *event_info __UNUSED__)
769 {
770    Evas_Object *win, *bg, *li;
771    static struct list5_data_cb info;
772
773    win = elm_win_add(NULL, "list5", ELM_WIN_BASIC);
774    elm_win_title_set(win, "List 5");
775    elm_win_autodel_set(win, 1);
776    info.win = win;
777
778    bg = elm_bg_add(win);
779    elm_win_resize_object_add(win, bg);
780    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
781    evas_object_show(bg);
782
783    li = elm_list_add(win);
784    evas_object_size_hint_weight_set(li, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
785    elm_list_mode_set(li, ELM_LIST_COMPRESS);
786    evas_object_smart_callback_add(li, "swipe", test_list5_swipe, NULL);
787    elm_win_resize_object_add(win, li);
788    evas_object_show(li);
789    info.list = li;
790
791    elm_list_item_append(li, "Network", NULL, NULL, NULL, &info);
792    elm_list_item_append(li, "Audio", NULL, NULL, NULL, &info);
793
794    elm_list_go(li);
795    evas_object_resize(win, 320, 300);
796    evas_object_show(win);
797 }
798
799 #endif