04c14b14de933437eacf56b3af17d7472f641b7e
[framework/uifw/elementary.git] / src / bin / test_genlist.c
1 #include <Elementary.h>
2 #ifdef HAVE_CONFIG_H
3 # include "elementary_config.h"
4 #endif
5 #ifndef ELM_LIB_QUICKLAUNCH
6
7 /* Hint:
8  * In this example some calls to elm_genlist_item_append() are used which give the
9  * value of an int as 'item data' and 'func data' after casting into (void*). For
10  * sure this works only on architectures where sizeof(int)==sizeof(void*).
11  * For real world usage you should hold a data structure or value in your
12  * application and then give only a pointer to this data as data pointer.
13  */
14
15 typedef struct _Testitem
16 {
17    Elm_Genlist_Item *item;
18    int mode;
19    int onoff;
20 } Testitem;
21
22
23 static Elm_Genlist_Item_Class itc1;
24 char *gl_label_get(void *data, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
25 {
26    char buf[256];
27    snprintf(buf, sizeof(buf), "Item # %i", (int)(long)data);
28    return strdup(buf);
29 }
30
31 Evas_Object *gl_icon_get(void *data __UNUSED__, Evas_Object *obj, const char *part)
32 {
33    char buf[PATH_MAX];
34    Evas_Object *ic = elm_icon_add(obj);
35    if (!strcmp(part, "elm.swallow.end"))
36       snprintf(buf, sizeof(buf), "%s/images/bubble.png", PACKAGE_DATA_DIR);
37    else
38       snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR);
39    elm_icon_file_set(ic, buf, NULL);
40    evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
41    return ic;
42 }
43 Eina_Bool gl_state_get(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
44 {
45    return EINA_FALSE;
46 }
47 void gl_del(void *data __UNUSED__, Evas_Object *obj __UNUSED__)
48 {
49 }
50
51 static void
52 gl_sel(void *data, Evas_Object *obj, void *event_info)
53 {
54    printf("sel item data [%p] on genlist obj [%p], item pointer [%p]\n", data, obj, event_info);
55 }
56
57 static void
58 _move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
59 {
60    Evas_Object *gl = data;
61    Evas_Event_Mouse_Move *ev = event_info;
62    int where = 0;
63    Elm_Genlist_Item *gli;
64    gli = elm_genlist_at_xy_item_get(gl, ev->cur.canvas.x, ev->cur.canvas.y, &where);
65    if (gli)
66       printf("over %p, where %i\n", elm_genlist_item_data_get(gli), where);
67    else
68       printf("over none, where %i\n", where);
69 }
70
71 static void
72 _bt50_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
73 {
74    elm_genlist_item_bring_in(data);
75 }
76
77 static void
78 _bt1500_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
79 {
80    elm_genlist_item_middle_bring_in(data);
81 }
82
83 static void
84 _gl_selected(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
85 {
86    printf("selected: %p\n", event_info);
87 }
88
89 static void
90 _gl_double_clicked(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
91 {
92    printf("double clicked: %p\n", event_info);
93 }
94
95 static void
96 _gl_longpress(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
97 {
98    printf("longpress %p\n", event_info);
99 }
100
101 void
102 test_genlist(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
103 {
104    Evas_Object *win, *bg, *gl, *bt_50, *bt_1500, *bx;
105    Evas_Object *over;
106    Elm_Genlist_Item *gli;
107    int i;
108
109    win = elm_win_add(NULL, "genlist", ELM_WIN_BASIC);
110    elm_win_title_set(win, "Genlist");
111    elm_win_autodel_set(win, 1);
112
113    bg = elm_bg_add(win);
114    elm_win_resize_object_add(win, bg);
115    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
116    evas_object_show(bg);
117
118    bx = elm_box_add(win);
119    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
120    elm_win_resize_object_add(win, bx);
121    evas_object_show(bx);
122
123    gl = elm_genlist_add(win);
124    evas_object_smart_callback_add(gl, "selected", _gl_selected, NULL);
125    evas_object_smart_callback_add(gl, "clicked,double", _gl_double_clicked, NULL);
126    evas_object_smart_callback_add(gl, "longpressed", _gl_longpress, NULL);
127    // FIXME: This causes genlist to resize the horiz axis very slowly :(
128    // Reenable this and resize the window horizontally, then try to resize it back
129    //elm_genlist_horizontal_mode_set(gl, ELM_LIST_LIMIT);
130    evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
131    evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
132    elm_box_pack_end(bx, gl);
133    evas_object_show(gl);
134
135    over = evas_object_rectangle_add(evas_object_evas_get(win));
136    evas_object_color_set(over, 0, 0, 0, 0);
137    evas_object_event_callback_add(over, EVAS_CALLBACK_MOUSE_MOVE, _move, gl);
138    evas_object_repeat_events_set(over, 1);
139    evas_object_show(over);
140    evas_object_size_hint_weight_set(over, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
141    elm_win_resize_object_add(win, over);
142
143    itc1.item_style     = "default";
144    itc1.func.label_get = gl_label_get;
145    itc1.func.icon_get  = gl_icon_get;
146    itc1.func.state_get = gl_state_get;
147    itc1.func.del       = gl_del;
148
149    bt_50 = elm_button_add(win);
150    elm_button_label_set(bt_50, "Go to 50");
151    evas_object_show(bt_50);
152    elm_box_pack_end(bx, bt_50);
153
154    bt_1500 = elm_button_add(win);
155    elm_button_label_set(bt_1500, "Go to 1500");
156    evas_object_show(bt_1500);
157    elm_box_pack_end(bx, bt_1500);
158
159    for (i = 0; i < 2000; i++)
160      {
161         gli = elm_genlist_item_append(gl, &itc1,
162                                       (void *)(long)i/* item data */,
163                                       NULL/* parent */,
164                                       ELM_GENLIST_ITEM_NONE,
165                                       gl_sel/* func */,
166                                       (void *)(long)(i * 10)/* func data */);
167         if (i == 50)
168            evas_object_smart_callback_add(bt_50, "clicked", _bt50_cb, gli);
169         else if (i == 1500)
170            evas_object_smart_callback_add(bt_1500, "clicked", _bt1500_cb, gli);
171      }
172    evas_object_resize(win, 480, 800);
173    evas_object_show(win);
174 }
175
176 /*************/
177
178 static void
179 my_gl_clear(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
180 {
181    Evas_Object *gl = data;
182    elm_genlist_clear(gl);
183 }
184
185 static void
186 my_gl_add(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
187 {
188    Evas_Object *gl = data;
189    static int i = 0;
190
191    itc1.item_style     = "default";
192    itc1.func.label_get = gl_label_get;
193    itc1.func.icon_get  = gl_icon_get;
194    itc1.func.state_get = gl_state_get;
195    itc1.func.del       = gl_del;
196
197    elm_genlist_item_append(gl, &itc1,
198                            (void *)(long)i/* item data */,
199                            NULL/* parent */,
200                            ELM_GENLIST_ITEM_NONE,
201                            gl_sel/* func */,
202                            (void *)(long)(i * 10)/* func data */);
203    i++;
204 }
205
206 static void
207 my_gl_insert_before(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
208 {
209    Evas_Object *gl = data;
210    static int i = 0;
211    Elm_Genlist_Item *gli_selected;
212
213    itc1.item_style     = "default";
214    itc1.func.label_get = gl_label_get;
215    itc1.func.icon_get  = gl_icon_get;
216    itc1.func.state_get = gl_state_get;
217    itc1.func.del       = gl_del;
218
219    gli_selected = elm_genlist_selected_item_get(gl);
220    if(!gli_selected)
221      {
222         printf("no item selected\n");
223         return ;
224      }
225
226    elm_genlist_item_insert_before(gl, &itc1,
227                                   (void *)(long)i/* item data */,
228                                   NULL/* parent */,
229                                   gli_selected /* item before */,
230                                   ELM_GENLIST_ITEM_NONE,
231                                   gl_sel/* func */,
232                                   (void *)(long)(i * 10)/* func data */);
233    i++;
234 }
235
236 static void
237 my_gl_insert_after(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
238 {
239    Evas_Object *gl = data;
240    static int i = 0;
241    Elm_Genlist_Item *gli_selected;
242
243    itc1.item_style     = "default";
244    itc1.func.label_get = gl_label_get;
245    itc1.func.icon_get  = gl_icon_get;
246    itc1.func.state_get = gl_state_get;
247    itc1.func.del       = gl_del;
248
249    gli_selected = elm_genlist_selected_item_get(gl);
250    if(!gli_selected)
251      {
252         printf("no item selected\n");
253         return ;
254      }
255
256    elm_genlist_item_insert_after(gl, &itc1,
257                                  (void *)(long)i/* item data */,
258                                  NULL/* parent */,
259                                  gli_selected /* item after */,
260                                  ELM_GENLIST_ITEM_NONE,
261                                  gl_sel/* func */,
262                                  (void *)(long)(i * 10)/* func data */);
263    i++;
264 }
265
266 static void
267 my_gl_del(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
268 {
269    Evas_Object *gl = data;
270    Elm_Genlist_Item *gli = elm_genlist_selected_item_get(gl);
271    if (!gli)
272      {
273         printf("no item selected\n");
274         return;
275      }
276    elm_genlist_item_del(gli);
277 }
278
279 static void
280 my_gl_disable(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
281 {
282    Evas_Object *gl = data;
283    Elm_Genlist_Item *gli = elm_genlist_selected_item_get(gl);
284    if (!gli)
285      {
286         printf("no item selected\n");
287         return;
288      }
289    elm_genlist_item_disabled_set(gli, 1);
290    elm_genlist_item_selected_set(gli, 0);
291    elm_genlist_item_update(gli);
292 }
293
294 static void
295 my_gl_update_all(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
296 {
297    Evas_Object *gl = data;
298    int i = 0;
299    Elm_Genlist_Item *it = elm_genlist_first_item_get(gl);
300    while (it)
301      {
302         elm_genlist_item_update(it);
303         printf("%i\n", i);
304         i++;
305         it = elm_genlist_item_next_get(it);
306      }
307 }
308
309 static void
310 my_gl_first(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
311 {
312    Evas_Object *gl = data;
313    Elm_Genlist_Item *gli = elm_genlist_first_item_get(gl);
314    if (!gli) return;
315    elm_genlist_item_show(gli);
316    elm_genlist_item_selected_set(gli, 1);
317 }
318
319 static void
320 my_gl_last(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
321 {
322    Evas_Object *gl = data;
323    Elm_Genlist_Item *gli = elm_genlist_last_item_get(gl);
324    if (!gli) return;
325    elm_genlist_item_show(gli);
326    elm_genlist_item_selected_set(gli, 1);
327 }
328
329 static Eina_Bool
330 my_gl_flush_delay(void *data __UNUSED__)
331 {
332    elm_all_flush();
333    return ECORE_CALLBACK_CANCEL;
334 }
335
336 static void
337 my_gl_flush(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
338 {
339    ecore_timer_add(1.2, my_gl_flush_delay, NULL);
340 }
341
342 void
343 test_genlist2(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
344 {
345    Evas_Object *win, *bg, *gl, *bx, *bx2, *bx3, *bt;
346    Elm_Genlist_Item *gli[10];
347    char buf[PATH_MAX];
348
349    win = elm_win_add(NULL, "genlist2", ELM_WIN_BASIC);
350    elm_win_title_set(win, "Genlist 2");
351    elm_win_autodel_set(win, 1);
352
353    bg = elm_bg_add(win);
354    snprintf(buf, sizeof(buf), "%s/images/plant_01.jpg", PACKAGE_DATA_DIR);
355    elm_bg_file_set(bg, buf, NULL);
356    elm_win_resize_object_add(win, bg);
357    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
358    evas_object_show(bg);
359
360    bx = elm_box_add(win);
361    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
362    elm_win_resize_object_add(win, bx);
363    evas_object_show(bx);
364
365    gl = elm_genlist_add(win);
366    evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
367    evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
368    evas_object_show(gl);
369
370    itc1.item_style     = "default";
371    itc1.func.label_get = gl_label_get;
372    itc1.func.icon_get  = gl_icon_get;
373    itc1.func.state_get = gl_state_get;
374    itc1.func.del       = gl_del;
375
376    gli[0] = elm_genlist_item_append(gl, &itc1,
377                                     (void *)1001/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_NONE, gl_sel/* func */,
378                                     (void *)1001/* func data */);
379    gli[1] = elm_genlist_item_append(gl, &itc1,
380                                     (void *)1002/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_NONE, gl_sel/* func */,
381                                     (void *)1002/* func data */);
382    gli[2] = elm_genlist_item_append(gl, &itc1,
383                                     (void *)1003/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_NONE, gl_sel/* func */,
384                                     (void *)1003/* func data */);
385    gli[3] = elm_genlist_item_prepend(gl, &itc1,
386                                      (void *)1004/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_NONE, gl_sel/* func */,
387                                      (void *)1004/* func data */);
388    gli[4] = elm_genlist_item_prepend(gl, &itc1,
389                                      (void *)1005/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_NONE, gl_sel/* func */,
390                                      (void *)1005/* func data */);
391    gli[5] = elm_genlist_item_insert_before(gl, &itc1,
392                                            (void *)1006/* item data */, NULL/* parent */, gli[2]/* rel */, ELM_GENLIST_ITEM_NONE,
393                                            gl_sel/* func */, (void *)1006/* func data */);
394    gli[6] = elm_genlist_item_insert_after(gl, &itc1,
395                                           (void *)1007/* item data */, NULL/* parent */, gli[2]/* rel */, ELM_GENLIST_ITEM_NONE,
396                                           gl_sel/* func */, (void *)1007/* func data */);
397
398    elm_box_pack_end(bx, gl);
399
400    bx2 = elm_box_add(win);
401    elm_box_horizontal_set(bx2, EINA_TRUE);
402    elm_box_homogeneous_set(bx2, EINA_TRUE);
403    evas_object_size_hint_weight_set(bx2, EVAS_HINT_EXPAND, 0.0);
404    evas_object_size_hint_align_set(bx2, EVAS_HINT_FILL, EVAS_HINT_FILL);
405
406    bt = elm_button_add(win);
407    elm_button_label_set(bt, "/\\");
408    evas_object_smart_callback_add(bt, "clicked", my_gl_first, gl);
409    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
410    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
411    elm_box_pack_end(bx2, bt);
412    evas_object_show(bt);
413
414    bt = elm_button_add(win);
415    elm_button_label_set(bt, "\\/");
416    evas_object_smart_callback_add(bt, "clicked", my_gl_last, gl);
417    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
418    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
419    elm_box_pack_end(bx2, bt);
420    evas_object_show(bt);
421
422    bt = elm_button_add(win);
423    elm_button_label_set(bt, "#");
424    evas_object_smart_callback_add(bt, "clicked", my_gl_disable, gl);
425    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
426    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
427    elm_box_pack_end(bx2, bt);
428    evas_object_show(bt);
429
430    bt = elm_button_add(win);
431    elm_button_label_set(bt, "U");
432    evas_object_smart_callback_add(bt, "clicked", my_gl_update_all, gl);
433    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
434    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
435    elm_box_pack_end(bx2, bt);
436    evas_object_show(bt);
437
438    elm_box_pack_end(bx, bx2);
439    evas_object_show(bx2);
440
441    bx2 = elm_box_add(win);
442    elm_box_horizontal_set(bx2, EINA_TRUE);
443    elm_box_homogeneous_set(bx2, EINA_TRUE);
444    evas_object_size_hint_weight_set(bx2, EVAS_HINT_EXPAND, 0.0);
445    evas_object_size_hint_align_set(bx2, EVAS_HINT_FILL, EVAS_HINT_FILL);
446
447    bt = elm_button_add(win);
448    elm_button_label_set(bt, "X");
449    evas_object_smart_callback_add(bt, "clicked", my_gl_clear, gl);
450    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
451    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
452    elm_box_pack_end(bx2, bt);
453    evas_object_show(bt);
454
455    bt = elm_button_add(win);
456    elm_button_label_set(bt, "+");
457    evas_object_smart_callback_add(bt, "clicked", my_gl_add, gl);
458    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
459    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
460    elm_box_pack_end(bx2, bt);
461    evas_object_show(bt);
462
463    bt = elm_button_add(win);
464    elm_button_label_set(bt, "-");
465    evas_object_smart_callback_add(bt, "clicked", my_gl_del, gl);
466    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
467    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
468    elm_box_pack_end(bx2, bt);
469    evas_object_show(bt);
470
471    elm_box_pack_end(bx, bx2);
472    evas_object_show(bx2);
473
474    bx3 = elm_box_add(win);
475    elm_box_horizontal_set(bx3, EINA_TRUE);
476    elm_box_homogeneous_set(bx3, EINA_TRUE);
477    evas_object_size_hint_weight_set(bx3, EVAS_HINT_EXPAND, 0.0);
478    evas_object_size_hint_align_set(bx3, EVAS_HINT_FILL, EVAS_HINT_FILL);
479
480    bt = elm_button_add(win);
481    elm_button_label_set(bt, "+ before");
482    evas_object_smart_callback_add(bt, "clicked", my_gl_insert_before, gl);
483    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
484    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
485    elm_box_pack_end(bx3, bt);
486    evas_object_show(bt);
487
488    bt = elm_button_add(win);
489    elm_button_label_set(bt, "+ after");
490    evas_object_smart_callback_add(bt, "clicked", my_gl_insert_after, gl);
491    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
492    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
493    elm_box_pack_end(bx3, bt);
494    evas_object_show(bt);
495
496    bt = elm_button_add(win);
497    elm_button_label_set(bt, "Flush");
498    evas_object_smart_callback_add(bt, "clicked", my_gl_flush, gl);
499    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
500    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
501    elm_box_pack_end(bx3, bt);
502    evas_object_show(bt);
503
504    elm_box_pack_end(bx, bx3);
505    evas_object_show(bx3);
506
507
508    evas_object_resize(win, 320, 320);
509    evas_object_show(win);
510 }
511
512 /*************/
513
514 static Elm_Genlist_Item_Class itc2;
515 char *gl2_label_get(void *data, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
516 {
517    const Testitem *tit = data;
518    char buf[256];
519    snprintf(buf, sizeof(buf), "Item mode %i", tit->mode);
520    return strdup(buf);
521 }
522 Evas_Object *gl2_icon_get(void *data, Evas_Object *obj, const char *part)
523 {
524    const Testitem *tit = data;
525    char buf[PATH_MAX];
526    Evas_Object *ic = elm_icon_add(obj);
527    if (!strcmp(part, "elm.swallow.icon"))
528      {
529         if (!(tit->mode & 0x3))
530            snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR);
531         else if ((tit->mode & 0x3) == 1)
532            snprintf(buf, sizeof(buf), "%s/images/logo.png", PACKAGE_DATA_DIR);
533         else if ((tit->mode & 0x3) == 2)
534            snprintf(buf, sizeof(buf), "%s/images/panel_01.jpg", PACKAGE_DATA_DIR);
535         else if ((tit->mode & 0x3) == 3)
536            snprintf(buf, sizeof(buf), "%s/images/rock_01.jpg", PACKAGE_DATA_DIR);
537         elm_icon_file_set(ic, buf, NULL);
538      }
539    else if (!strcmp(part, "elm.swallow.end"))
540      {
541         if (!(tit->mode & 0x3))
542            snprintf(buf, sizeof(buf), "%s/images/sky_01.jpg", PACKAGE_DATA_DIR);
543         else if ((tit->mode & 0x3) == 1)
544            snprintf(buf, sizeof(buf), "%s/images/sky_02.jpg", PACKAGE_DATA_DIR);
545         else if ((tit->mode & 0x3) == 2)
546            snprintf(buf, sizeof(buf), "%s/images/sky_03.jpg", PACKAGE_DATA_DIR);
547         else if ((tit->mode & 0x3) == 3)
548            snprintf(buf, sizeof(buf), "%s/images/sky_04.jpg", PACKAGE_DATA_DIR);
549         elm_icon_file_set(ic, buf, NULL);
550      }
551    evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
552    return ic;
553 }
554 Eina_Bool gl2_state_get(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
555 {
556    return EINA_FALSE;
557 }
558 void gl2_del(void *data __UNUSED__, Evas_Object *obj __UNUSED__)
559 {
560 }
561
562 static void
563 my_gl_update(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
564 {
565    Testitem *tit = data;
566    tit->mode++;
567    elm_genlist_item_update(tit->item);
568 }
569
570 void
571 test_genlist3(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
572 {
573    Evas_Object *win, *bg, *gl, *bx, *bx2, *bt;
574    static Testitem tit[3];
575
576    win = elm_win_add(NULL, "genlist3", ELM_WIN_BASIC);
577    elm_win_title_set(win, "Genlist 3");
578    elm_win_autodel_set(win, 1);
579
580    bg = elm_bg_add(win);
581    elm_win_resize_object_add(win, bg);
582    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
583    evas_object_show(bg);
584
585    bx = elm_box_add(win);
586    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
587    elm_win_resize_object_add(win, bx);
588    evas_object_show(bx);
589
590    gl = elm_genlist_add(win);
591    evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
592    evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
593    evas_object_show(gl);
594
595    itc2.item_style     = "default";
596    itc2.func.label_get = gl2_label_get;
597    itc2.func.icon_get  = gl2_icon_get;
598    itc2.func.state_get = gl2_state_get;
599    itc2.func.del       = gl2_del;
600
601    tit[0].mode = 0;
602    tit[0].item = elm_genlist_item_append(gl, &itc2,
603                                          &(tit[0])/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_NONE, gl_sel/* func */,
604                                          NULL/* func data */);
605    tit[1].mode = 1;
606    tit[1].item = elm_genlist_item_append(gl, &itc2,
607                                          &(tit[1])/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_NONE, gl_sel/* func */,
608                                          NULL/* func data */);
609    tit[2].mode = 2;
610    tit[2].item = elm_genlist_item_append(gl, &itc2,
611                                          &(tit[2])/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_NONE, gl_sel/* func */,
612                                          NULL/* func data */);
613
614    elm_box_pack_end(bx, gl);
615    evas_object_show(bx);
616
617    bx2 = elm_box_add(win);
618    elm_box_horizontal_set(bx2, EINA_TRUE);
619    elm_box_homogeneous_set(bx2, EINA_TRUE);
620    evas_object_size_hint_weight_set(bx2, EVAS_HINT_EXPAND, 0.0);
621    evas_object_size_hint_align_set(bx2, EVAS_HINT_FILL, EVAS_HINT_FILL);
622
623    bt = elm_button_add(win);
624    elm_button_label_set(bt, "[1]");
625    evas_object_smart_callback_add(bt, "clicked", my_gl_update, &(tit[0]));
626    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
627    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
628    elm_box_pack_end(bx2, bt);
629    evas_object_show(bt);
630
631    bt = elm_button_add(win);
632    elm_button_label_set(bt, "[2]");
633    evas_object_smart_callback_add(bt, "clicked", my_gl_update, &(tit[1]));
634    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
635    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
636    elm_box_pack_end(bx2, bt);
637    evas_object_show(bt);
638
639    bt = elm_button_add(win);
640    elm_button_label_set(bt, "[3]");
641    evas_object_smart_callback_add(bt, "clicked", my_gl_update, &(tit[2]));
642    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
643    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
644    elm_box_pack_end(bx2, bt);
645    evas_object_show(bt);
646
647    elm_box_pack_end(bx, bx2);
648    evas_object_show(bx2);
649
650    evas_object_resize(win, 320, 320);
651    evas_object_show(win);
652 }
653
654 /*************/
655
656 static void
657 my_gl_item_check_changed(void *data, Evas_Object *obj, void *event_info __UNUSED__)
658 {
659    Testitem *tit = data;
660    tit->onoff = elm_check_state_get(obj);
661    printf("item %p onoff = %i\n", tit, tit->onoff);
662 }
663
664 static Elm_Genlist_Item_Class itc3;
665 char *gl3_label_get(void *data, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
666 {
667    const Testitem *tit = data;
668    char buf[256];
669    snprintf(buf, sizeof(buf), "Item mode %i", tit->mode);
670    return strdup(buf);
671 }
672 Evas_Object *gl3_icon_get(void *data, Evas_Object *obj, const char *part)
673 {
674    const Testitem *tit = data;
675    if (!strcmp(part, "elm.swallow.icon"))
676      {
677         Evas_Object *lb;
678
679         lb = elm_label_add(obj);
680         elm_label_line_wrap_set(lb, 1);
681         elm_label_wrap_width_set(lb, 201);
682         elm_label_label_set(lb, "ashj ascjscjh n asjkl hcjlh ls hzshnn zjh sh zxjcjsnd h dfw sdv edev efe fwefvv vsd cvs ws wf  fvwf wd fwe f  we wef we wfe rfwewef wfv wswf wefg sdfws w wsdcfwcf wsc vdv  sdsd sdcd cv wsc sdcv wsc d sdcdcsd sdcdsc wdvd sdcsd wscxcv wssvd sd");
683         return lb;
684      }
685    else if (!strcmp(part, "elm.swallow.end"))
686      {
687         Evas_Object *ck;
688         ck = elm_check_add(obj);
689         evas_object_propagate_events_set(ck, 0);
690         elm_check_state_set(ck, tit->onoff);
691         evas_object_smart_callback_add(ck, "changed", my_gl_item_check_changed, data);
692         return ck;
693      }
694    return NULL;
695 }
696 Eina_Bool gl3_state_get(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
697 {
698    return EINA_FALSE;
699 }
700 void gl3_del(void *data __UNUSED__, Evas_Object *obj __UNUSED__)
701 {
702 }
703
704 void
705 test_genlist4(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
706 {
707    Evas_Object *win, *bg, *gl, *bx, *bx2, *bt;
708    static Testitem tit[3];
709
710    win = elm_win_add(NULL, "genlist4", ELM_WIN_BASIC);
711    elm_win_title_set(win, "Genlist 4");
712    elm_win_autodel_set(win, 1);
713
714    bg = elm_bg_add(win);
715    elm_win_resize_object_add(win, bg);
716    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
717    evas_object_show(bg);
718
719    bx = elm_box_add(win);
720    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
721    elm_win_resize_object_add(win, bx);
722    evas_object_show(bx);
723
724    gl = elm_genlist_add(win);
725    elm_genlist_multi_select_set(gl, 1);
726    evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
727    evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
728    evas_object_show(gl);
729
730    itc3.item_style     = "default";
731    itc3.func.label_get = gl3_label_get;
732    itc3.func.icon_get  = gl3_icon_get;
733    itc3.func.state_get = gl3_state_get;
734    itc3.func.del       = gl3_del;
735
736    tit[0].mode = 0;
737    tit[0].item = elm_genlist_item_append(gl, &itc3,
738                                          &(tit[0])/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_NONE, gl_sel/* func */,
739                                          NULL/* func data */);
740    tit[1].mode = 1;
741    tit[1].item = elm_genlist_item_append(gl, &itc3,
742                                          &(tit[1])/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_NONE, gl_sel/* func */,
743                                          NULL/* func data */);
744    tit[2].mode = 2;
745    tit[2].item = elm_genlist_item_append(gl, &itc3,
746                                          &(tit[2])/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_NONE, gl_sel/* func */,
747                                          NULL/* func data */);
748
749    elm_box_pack_end(bx, gl);
750    evas_object_show(bx);
751
752    bx2 = elm_box_add(win);
753    elm_box_horizontal_set(bx2, EINA_TRUE);
754    elm_box_homogeneous_set(bx2, EINA_TRUE);
755    evas_object_size_hint_weight_set(bx2, EVAS_HINT_EXPAND, 0.0);
756    evas_object_size_hint_align_set(bx2, EVAS_HINT_FILL, EVAS_HINT_FILL);
757
758    bt = elm_button_add(win);
759    elm_button_label_set(bt, "[1]");
760    evas_object_smart_callback_add(bt, "clicked", my_gl_update, &(tit[0]));
761    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
762    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
763    elm_box_pack_end(bx2, bt);
764    evas_object_show(bt);
765
766    bt = elm_button_add(win);
767    elm_button_label_set(bt, "[2]");
768    evas_object_smart_callback_add(bt, "clicked", my_gl_update, &(tit[1]));
769    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
770    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
771    elm_box_pack_end(bx2, bt);
772    evas_object_show(bt);
773
774    bt = elm_button_add(win);
775    elm_button_label_set(bt, "[3]");
776    evas_object_smart_callback_add(bt, "clicked", my_gl_update, &(tit[2]));
777    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
778    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
779    elm_box_pack_end(bx2, bt);
780    evas_object_show(bt);
781
782    elm_box_pack_end(bx, bx2);
783    evas_object_show(bx2);
784
785    evas_object_resize(win, 320, 320);
786    evas_object_show(win);
787 }
788
789
790 /*************/
791 static void
792 my_gl_item_check_changed2(void *data, Evas_Object *obj, void *event_info __UNUSED__)
793 {
794    Testitem *tit = data;
795    tit->onoff = elm_check_state_get(obj);
796    printf("item %p onoff = %i\n", tit, tit->onoff);
797 }
798
799 static Elm_Genlist_Item_Class itc5;
800 char *gl5_label_get(void *data, Evas_Object *obj __UNUSED__, const char *part)
801 {
802    const Testitem *tit = data;
803    char buf[256];
804    if (!strcmp(part, "elm.text"))
805      {
806         snprintf(buf, sizeof(buf), "Item mode %i", tit->mode);
807      }
808    else if (!strcmp(part, "elm.text.sub"))
809      {
810         snprintf(buf, sizeof(buf), "%i bottles on the wall", tit->mode);
811      }
812    return strdup(buf);
813 }
814 Evas_Object *gl5_icon_get(void *data, Evas_Object *obj, const char *part)
815 {
816    const Testitem *tit = data;
817    char buf[PATH_MAX];
818    if (!strcmp(part, "elm.swallow.icon"))
819      {
820         Evas_Object *bx = elm_box_add(obj);
821         Evas_Object *ic;
822         elm_box_horizontal_set(bx, EINA_TRUE);
823         ic = elm_icon_add(obj);
824         snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR);
825         elm_icon_file_set(ic, buf, NULL);
826         elm_icon_scale_set(ic, 0, 0);
827         evas_object_show(ic);
828         elm_box_pack_end(bx, ic);
829         ic = elm_icon_add(obj);
830         elm_icon_file_set(ic, buf, NULL);
831         elm_icon_scale_set(ic, 0, 0);
832         evas_object_show(ic);
833         elm_box_pack_end(bx, ic);
834         elm_box_horizontal_set(bx, EINA_TRUE);
835         evas_object_show(bx);
836         return bx;
837      }
838    else if (!strcmp(part, "elm.swallow.end"))
839      {
840         Evas_Object *ck;
841         ck = elm_check_add(obj);
842         evas_object_propagate_events_set(ck, 0);
843         elm_check_state_set(ck, tit->onoff);
844         evas_object_smart_callback_add(ck, "changed", my_gl_item_check_changed2, data);
845         evas_object_show(ck);
846         return ck;
847      }
848    return NULL;
849 }
850 Eina_Bool gl5_state_get(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
851 {
852    return EINA_FALSE;
853 }
854 void gl5_del(void *data __UNUSED__, Evas_Object *obj __UNUSED__)
855 {
856 }
857
858 static void
859 item_drag_up(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
860 {
861    printf("drag up\n");
862 }
863
864 static void
865 item_drag_down(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
866 {
867    printf("drag down\n");
868 }
869
870 static void
871 item_drag_left(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
872 {
873    printf("drag left\n");
874 }
875
876 static void
877 item_drag_right(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
878 {
879    printf("drag right\n");
880 }
881
882 static void
883 scroll_top(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
884 {
885    printf("Top edge!\n");
886 }
887
888 static void
889 scroll_bottom(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
890 {
891    printf("Bottom edge!\n");
892 }
893
894 static void
895 scroll_left(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
896 {
897    printf("Left edge!\n");
898 }
899
900 static void
901 scroll_right(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
902 {
903    printf("Right edge!\n");
904 }
905
906 static void
907 item_drag(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
908 {
909    printf("drag\n");
910 }
911
912 static void
913 item_drag_stop(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
914 {
915    printf("drag stop\n");
916 }
917
918 static void
919 item_longpress(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
920 {
921    printf("longpress\n");
922 }
923
924 void
925 test_genlist5(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
926 {
927    Evas_Object *win, *bg, *gl, *bx, *bx2, *bt;
928    static Testitem tit[3];
929
930    win = elm_win_add(NULL, "genlist5", ELM_WIN_BASIC);
931    elm_win_title_set(win, "Genlist 5");
932    elm_win_autodel_set(win, 1);
933
934    bg = elm_bg_add(win);
935    elm_win_resize_object_add(win, bg);
936    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
937    evas_object_show(bg);
938
939    bx = elm_box_add(win);
940    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
941    elm_win_resize_object_add(win, bx);
942    evas_object_show(bx);
943
944    gl = elm_genlist_add(win);
945    elm_genlist_always_select_mode_set(gl, 1);
946    evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
947    evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
948    evas_object_show(gl);
949    itc5.item_style     = "double_label";
950    itc5.func.label_get = gl5_label_get;
951    itc5.func.icon_get  = gl5_icon_get;
952    itc5.func.state_get = gl5_state_get;
953    itc5.func.del       = gl5_del;
954
955    tit[0].mode = 0;
956    tit[0].item = elm_genlist_item_append(gl, &itc5,
957                                          &(tit[0])/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_NONE, gl_sel/* func */,
958                                          NULL/* func data */);
959    tit[1].mode = 1;
960    tit[1].item = elm_genlist_item_append(gl, &itc5,
961                                          &(tit[1])/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_NONE, gl_sel/* func */,
962                                          NULL/* func data */);
963    tit[2].mode = 2;
964    tit[2].item = elm_genlist_item_append(gl, &itc5,
965                                          &(tit[2])/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_NONE, gl_sel/* func */,
966                                          NULL/* func data */);
967
968    elm_box_pack_end(bx, gl);
969    evas_object_show(bx);
970
971    evas_object_smart_callback_add(gl, "drag,start,up", item_drag_up, NULL);
972    evas_object_smart_callback_add(gl, "drag,start,down", item_drag_down, NULL);
973    evas_object_smart_callback_add(gl, "drag,start,left", item_drag_left, NULL);
974    evas_object_smart_callback_add(gl, "drag,start,right", item_drag_right, NULL);
975    evas_object_smart_callback_add(gl, "scroll,edge,top", scroll_top, NULL);
976    evas_object_smart_callback_add(gl, "scroll,edge,bottom", scroll_bottom, NULL);
977    evas_object_smart_callback_add(gl, "scroll,edge,left", scroll_left, NULL);
978    evas_object_smart_callback_add(gl, "scroll,edge,right", scroll_right, NULL);
979    evas_object_smart_callback_add(gl, "drag", item_drag, NULL);
980    evas_object_smart_callback_add(gl, "drag,stop", item_drag_stop, NULL);
981    evas_object_smart_callback_add(gl, "longpressed", item_longpress, NULL);
982
983    bx2 = elm_box_add(win);
984    elm_box_horizontal_set(bx2, EINA_TRUE);
985    elm_box_homogeneous_set(bx2, EINA_TRUE);
986    evas_object_size_hint_weight_set(bx2, EVAS_HINT_EXPAND, 0.0);
987    evas_object_size_hint_align_set(bx2, EVAS_HINT_FILL, EVAS_HINT_FILL);
988
989    bt = elm_button_add(win);
990    elm_button_label_set(bt, "[1]");
991    evas_object_smart_callback_add(bt, "clicked", my_gl_update, &(tit[0]));
992    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
993    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
994    elm_box_pack_end(bx2, bt);
995    evas_object_show(bt);
996
997    bt = elm_button_add(win);
998    elm_button_label_set(bt, "[2]");
999    evas_object_smart_callback_add(bt, "clicked", my_gl_update, &(tit[1]));
1000    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
1001    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
1002    elm_box_pack_end(bx2, bt);
1003    evas_object_show(bt);
1004
1005    bt = elm_button_add(win);
1006    elm_button_label_set(bt, "[3]");
1007    evas_object_smart_callback_add(bt, "clicked", my_gl_update, &(tit[2]));
1008    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
1009    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
1010    elm_box_pack_end(bx2, bt);
1011    evas_object_show(bt);
1012
1013    elm_box_pack_end(bx, bx2);
1014    evas_object_show(bx2);
1015
1016    evas_object_resize(win, 320, 320);
1017    evas_object_show(win);
1018 }
1019
1020 /*************/
1021
1022 static Elm_Genlist_Item_Class itc4;
1023
1024 static void
1025 gl4_sel(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1026 {
1027    Elm_Genlist_Item *it = (Elm_Genlist_Item *)event_info;
1028    int depth = 0;
1029
1030    depth = elm_genlist_item_expanded_depth_get(it);
1031    printf("expanded depth for selected item is %d\n", depth);
1032
1033 }
1034 static void
1035 gl4_exp(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1036 {
1037    Elm_Genlist_Item *it = event_info;
1038    Evas_Object *gl = elm_genlist_item_genlist_get(it);
1039    int val = (int)(long)elm_genlist_item_data_get(it);
1040    val *= 10;
1041    elm_genlist_item_append(gl, &itc4,
1042                            (void *)(long)(val + 1)/* item data */, it/* parent */,
1043                            ELM_GENLIST_ITEM_NONE, gl4_sel/* func */,
1044                            NULL/* func data */);
1045    elm_genlist_item_append(gl, &itc4,
1046                            (void *)(long)(val + 2)/* item data */, it/* parent */,
1047                            ELM_GENLIST_ITEM_NONE, gl4_sel/* func */,
1048                            NULL/* func data */);
1049    elm_genlist_item_append(gl, &itc4,
1050                            (void *)(long)(val + 3)/* item data */, it/* parent */,
1051                            ELM_GENLIST_ITEM_SUBITEMS, gl4_sel/* func */,
1052                            NULL/* func data */);
1053 }
1054 static void
1055 gl4_con(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1056 {
1057    Elm_Genlist_Item *it = event_info;
1058    elm_genlist_item_subitems_clear(it);
1059 }
1060
1061 static void
1062 gl4_exp_req(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1063 {
1064    Elm_Genlist_Item *it = event_info;
1065    elm_genlist_item_expanded_set(it, 1);
1066 }
1067 static void
1068 gl4_con_req(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1069 {
1070    Elm_Genlist_Item *it = event_info;
1071    elm_genlist_item_expanded_set(it, 0);
1072 }
1073
1074 char *gl4_label_get(void *data, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
1075 {
1076    char buf[256];
1077    snprintf(buf, sizeof(buf), "Item mode %i", (int)(long)data);
1078    return strdup(buf);
1079 }
1080 Evas_Object *gl4_icon_get(void *data __UNUSED__, Evas_Object *obj, const char *part)
1081 {
1082    char buf[PATH_MAX];
1083    if (!strcmp(part, "elm.swallow.icon"))
1084      {
1085         Evas_Object *ic = elm_icon_add(obj);
1086         snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR);
1087         elm_icon_file_set(ic, buf, NULL);
1088         evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
1089         evas_object_show(ic);
1090         return ic;
1091      }
1092    else if (!strcmp(part, "elm.swallow.end"))
1093      {
1094         Evas_Object *ck;
1095         ck = elm_check_add(obj);
1096         evas_object_show(ck);
1097         return ck;
1098      }
1099    return NULL;
1100 }
1101 Eina_Bool gl4_state_get(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
1102 {
1103    return EINA_FALSE;
1104 }
1105 void gl4_del(void *data __UNUSED__, Evas_Object *obj __UNUSED__)
1106 {
1107 }
1108
1109 void
1110 test_genlist6(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1111 {
1112    Evas_Object *win, *bg, *gl, *bx, *bx2, *bt;
1113
1114    win = elm_win_add(NULL, "genlist-tree", ELM_WIN_BASIC);
1115    elm_win_title_set(win, "Genlist Tree");
1116    elm_win_autodel_set(win, 1);
1117
1118    bg = elm_bg_add(win);
1119    elm_win_resize_object_add(win, bg);
1120    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1121    evas_object_show(bg);
1122
1123    bx = elm_box_add(win);
1124    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1125    elm_win_resize_object_add(win, bx);
1126    evas_object_show(bx);
1127
1128    gl = elm_genlist_add(win);
1129    evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
1130    evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1131    evas_object_show(gl);
1132
1133    itc4.item_style     = "default";
1134    itc4.func.label_get = gl4_label_get;
1135    itc4.func.icon_get  = gl4_icon_get;
1136    itc4.func.state_get = gl4_state_get;
1137    itc4.func.del       = gl4_del;
1138
1139    elm_genlist_item_append(gl, &itc4,
1140                            (void *)1/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_SUBITEMS, gl4_sel/* func */,
1141                            NULL/* func data */);
1142    elm_genlist_item_append(gl, &itc4,
1143                            (void *)2/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_SUBITEMS, gl4_sel/* func */,
1144                            NULL/* func data */);
1145    elm_genlist_item_append(gl, &itc4,
1146                            (void *)3/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_NONE, gl4_sel/* func */,
1147                            NULL/* func data */);
1148
1149    evas_object_smart_callback_add(gl, "expand,request", gl4_exp_req, gl);
1150    evas_object_smart_callback_add(gl, "contract,request", gl4_con_req, gl);
1151    evas_object_smart_callback_add(gl, "expanded", gl4_exp, gl);
1152    evas_object_smart_callback_add(gl, "contracted", gl4_con, gl);
1153
1154    elm_box_pack_end(bx, gl);
1155    evas_object_show(bx);
1156
1157    bx2 = elm_box_add(win);
1158    elm_box_horizontal_set(bx2, EINA_TRUE);
1159    elm_box_homogeneous_set(bx2, EINA_TRUE);
1160    evas_object_size_hint_weight_set(bx2, EVAS_HINT_EXPAND, 0.0);
1161    evas_object_size_hint_align_set(bx2, EVAS_HINT_FILL, EVAS_HINT_FILL);
1162
1163    bt = elm_button_add(win);
1164    elm_button_label_set(bt, "[1]");
1165    //   evas_object_smart_callback_add(bt, "clicked", my_gl_update, &(tit[0]));
1166    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
1167    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
1168    elm_box_pack_end(bx2, bt);
1169    evas_object_show(bt);
1170
1171    bt = elm_button_add(win);
1172    elm_button_label_set(bt, "[2]");
1173    //   evas_object_smart_callback_add(bt, "clicked", my_gl_update, &(tit[1]));
1174    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
1175    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
1176    elm_box_pack_end(bx2, bt);
1177    evas_object_show(bt);
1178
1179    bt = elm_button_add(win);
1180    elm_button_label_set(bt, "[3]");
1181    //   evas_object_smart_callback_add(bt, "clicked", my_gl_update, &(tit[2]));
1182    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
1183    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
1184    elm_box_pack_end(bx2, bt);
1185    evas_object_show(bt);
1186
1187    elm_box_pack_end(bx, bx2);
1188    evas_object_show(bx2);
1189
1190    evas_object_resize(win, 320, 320);
1191    evas_object_show(win);
1192 }
1193
1194 /*************/
1195
1196 struct genlist7_data
1197 {
1198    Evas_Object *win, *pager;
1199 };
1200
1201 static Elm_Genlist_Item_Class itc7;
1202 static void
1203 gl_sel7(void *data, Evas_Object *obj, void *event_info)
1204 {
1205    if (!event_info) return;
1206    elm_genlist_item_item_class_update(event_info, &itc7);
1207    printf("sel item data [%p] on genlist obj [%p], item pointer [%p], new item style [%s] \n", data, obj, event_info, itc7.item_style);
1208 }
1209
1210 static void
1211 test_genlist7_back_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1212 {
1213    struct genlist7_data *info = data;
1214    if (!info) return;
1215
1216    elm_pager_content_pop(info->pager);
1217 }
1218
1219 static void
1220 test_genlist7_swipe(void *data, Evas_Object *obj __UNUSED__, void *event_info)
1221 {
1222    struct genlist7_data *info = data;
1223    Evas_Object *box, *entry, *button;
1224    char item_data[] = "Just a simple test";
1225
1226    if ((!event_info) || (!data)) return;
1227
1228    box = elm_box_add(info->win);
1229    elm_box_homogeneous_set(box, EINA_FALSE);
1230    evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1231    evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
1232    evas_object_show(box);
1233
1234    entry = elm_scrolled_entry_add(info->win);
1235    elm_scrolled_entry_editable_set(entry, EINA_FALSE);
1236    elm_scrolled_entry_entry_set(entry, item_data);
1237    evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1238    evas_object_size_hint_align_set(entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
1239    evas_object_show(entry);
1240
1241    button = elm_button_add(info->win);
1242    elm_button_label_set(button, "back");
1243    evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, 0);
1244    evas_object_size_hint_align_set(button, EVAS_HINT_FILL, 0);
1245    evas_object_smart_callback_add(button, "clicked", test_genlist7_back_cb,
1246                                   info);
1247    evas_object_show(button);
1248
1249    elm_box_pack_start(box, entry);
1250    elm_box_pack_end(box, button);
1251
1252    elm_pager_content_push(info->pager, box);
1253 }
1254
1255 void
1256 test_genlist7(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1257 {
1258    Evas_Object *win, *bg, *gl, *pager;
1259    static struct genlist7_data info;
1260    static Testitem tit[3];
1261
1262    win = elm_win_add(NULL, "genlist7", ELM_WIN_BASIC);
1263    elm_win_title_set(win, "Genlist 7");
1264    elm_win_autodel_set(win, 1);
1265    info.win = win;
1266
1267    bg = elm_bg_add(win);
1268    elm_win_resize_object_add(win, bg);
1269    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1270    evas_object_show(bg);
1271
1272    pager = elm_pager_add(win);
1273    elm_win_resize_object_add(win, pager);
1274    evas_object_size_hint_weight_set(pager, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1275    evas_object_size_hint_align_set(pager, EVAS_HINT_FILL, EVAS_HINT_FILL);
1276    evas_object_show(pager);
1277    info.pager = pager;
1278
1279    gl = elm_genlist_add(win);
1280    evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
1281    evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1282    evas_object_smart_callback_add(gl, "swipe", test_genlist7_swipe, &info);
1283    evas_object_show(gl);
1284    elm_pager_content_push(pager, gl);
1285
1286    itc2.item_style     = "default";
1287    itc2.func.label_get = gl2_label_get;
1288    itc2.func.icon_get  = gl2_icon_get;
1289    itc2.func.state_get = gl2_state_get;
1290    itc2.func.del       = gl2_del;
1291
1292    itc7.item_style     = "double_label";
1293    itc7.func.label_get = gl5_label_get;
1294    itc7.func.icon_get  = gl5_icon_get;
1295    itc7.func.state_get = gl5_state_get;
1296    itc7.func.del       = gl5_del;
1297
1298    tit[0].mode = 0;
1299    tit[0].item = elm_genlist_item_append(gl, &itc2,
1300                                          &(tit[0])/* item data */, NULL/* parent */,
1301                                          ELM_GENLIST_ITEM_NONE, gl_sel7/* func */,
1302                                          NULL/* func data */);
1303    tit[1].mode = 1;
1304    tit[1].item = elm_genlist_item_append(gl, &itc2,
1305                                          &(tit[1])/* item data */, NULL/* parent */,
1306                                          ELM_GENLIST_ITEM_NONE, gl_sel7/* func */,
1307                                          NULL/* func data */);
1308    tit[2].mode = 2;
1309    tit[2].item = elm_genlist_item_append(gl, &itc2,
1310                                          &(tit[2])/* item data */, NULL/* parent */,
1311                                          ELM_GENLIST_ITEM_NONE, gl_sel7/* func */,
1312                                          NULL/* func data */);
1313
1314    evas_object_resize(win, 320, 320);
1315    evas_object_show(win);
1316 }
1317
1318 /*************/
1319
1320 static Elm_Genlist_Item_Class itc_group;
1321 char *gl8_label_get(void *data, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
1322 {
1323    char buf[256];
1324    snprintf(buf, sizeof(buf), "Group Index # %i (Item # %i)",  (int)((long)data / 10), (int)(long)data);
1325    return strdup(buf);
1326 }
1327
1328 static void
1329 _bt_show_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1330 {
1331    elm_genlist_item_top_show(data);
1332    //elm_genlist_item_show(data);
1333    //elm_genlist_item_middle_show(data);
1334 }
1335 static void
1336 _bt_bring_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1337 {
1338    elm_genlist_item_top_bring_in(data);
1339    //elm_genlist_item_bring_in(data);
1340    //elm_genlist_item_middle_bring_in(data);
1341 }
1342
1343 void
1344 test_genlist8(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1345 {
1346    Evas_Object *win, *bg, *gl, *bt[8], *bx, *bx2, *bx3;
1347    Elm_Genlist_Item *gli = NULL, *git = NULL;
1348    int i, bt_count, bt_num;
1349
1350    win = elm_win_add(NULL, "genlist-group", ELM_WIN_BASIC);
1351    elm_win_title_set(win, "Genlist Group");
1352    elm_win_autodel_set(win, 1);
1353
1354    bg = elm_bg_add(win);
1355    elm_win_resize_object_add(win, bg);
1356    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1357    evas_object_show(bg);
1358
1359    bx = elm_box_add(win);
1360    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1361    elm_win_resize_object_add(win, bx);
1362    evas_object_show(bx);
1363
1364    gl = elm_genlist_add(win);
1365    evas_object_smart_callback_add(gl, "selected", _gl_selected, NULL);
1366    evas_object_smart_callback_add(gl, "clicked,double", _gl_double_clicked, NULL);
1367    evas_object_smart_callback_add(gl, "longpressed", _gl_longpress, NULL);
1368    evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1369    evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
1370    elm_box_pack_end(bx, gl);
1371    evas_object_show(gl);
1372
1373    itc1.item_style     = "default";
1374    itc1.func.label_get = gl_label_get;
1375    itc1.func.icon_get  = gl_icon_get;
1376    itc1.func.state_get = gl_state_get;
1377    itc1.func.del       = gl_del;
1378
1379    itc_group.item_style     = "group_index";
1380    itc_group.func.label_get = gl8_label_get;
1381    itc_group.func.icon_get  = NULL;
1382    itc_group.func.state_get = NULL;
1383    itc_group.func.del       = gl_del;
1384
1385    bx2 = elm_box_add(win);
1386    elm_box_horizontal_set(bx2, EINA_TRUE);
1387    elm_box_homogeneous_set(bx2, EINA_TRUE);
1388    evas_object_size_hint_weight_set(bx2, EVAS_HINT_EXPAND, 0.0);
1389    evas_object_size_hint_align_set(bx2, EVAS_HINT_FILL, EVAS_HINT_FILL);
1390
1391    bt_num = 0;
1392    bt[bt_num] = elm_button_add(win);
1393    elm_button_label_set(bt[bt_num], "Show 0");
1394    evas_object_size_hint_align_set(bt[bt_num], EVAS_HINT_FILL, EVAS_HINT_FILL);
1395    evas_object_size_hint_weight_set(bt[bt_num], EVAS_HINT_EXPAND, 0.0);
1396    evas_object_show(bt[bt_num]);
1397    elm_box_pack_end(bx2, bt[bt_num]);
1398
1399    bt[++bt_num] = elm_button_add(win);
1400    elm_button_label_set(bt[bt_num], "Show 26");
1401    evas_object_size_hint_align_set(bt[bt_num], EVAS_HINT_FILL, EVAS_HINT_FILL);
1402    evas_object_size_hint_weight_set(bt[bt_num], EVAS_HINT_EXPAND, 0.0);
1403    evas_object_show(bt[bt_num]);
1404    elm_box_pack_end(bx2, bt[bt_num]);
1405
1406    bt[++bt_num] = elm_button_add(win);
1407    elm_button_label_set(bt[bt_num], "Show 101");
1408    evas_object_size_hint_align_set(bt[bt_num], EVAS_HINT_FILL, EVAS_HINT_FILL);
1409    evas_object_size_hint_weight_set(bt[bt_num], EVAS_HINT_EXPAND, 0.0);
1410    evas_object_show(bt[bt_num]);
1411    elm_box_pack_end(bx2, bt[bt_num]);
1412
1413    bt[++bt_num] = elm_button_add(win);
1414    elm_button_label_set(bt[bt_num], "Show 480");
1415    evas_object_size_hint_align_set(bt[bt_num], EVAS_HINT_FILL, EVAS_HINT_FILL);
1416    evas_object_size_hint_weight_set(bt[bt_num], EVAS_HINT_EXPAND, 0.0);
1417    evas_object_show(bt[bt_num]);
1418    elm_box_pack_end(bx2, bt[bt_num]);
1419
1420    elm_box_pack_end(bx, bx2);
1421    evas_object_show(bx2);
1422
1423    bx3 = elm_box_add(win);
1424    elm_box_horizontal_set(bx3, EINA_TRUE);
1425    elm_box_homogeneous_set(bx3, EINA_TRUE);
1426    evas_object_size_hint_weight_set(bx3, EVAS_HINT_EXPAND, 0.0);
1427    evas_object_size_hint_align_set(bx3, EVAS_HINT_FILL, EVAS_HINT_FILL);
1428
1429    bt[++bt_num] = elm_button_add(win);
1430    elm_button_label_set(bt[bt_num], "Bring top 0");
1431    evas_object_size_hint_align_set(bt[bt_num], EVAS_HINT_FILL, EVAS_HINT_FILL);
1432    evas_object_size_hint_weight_set(bt[bt_num], EVAS_HINT_EXPAND, 0.0);
1433    evas_object_show(bt[bt_num]);
1434    elm_box_pack_end(bx3, bt[bt_num]);
1435
1436    bt[++bt_num] = elm_button_add(win);
1437    elm_button_label_set(bt[bt_num], "Bring top 31");
1438    evas_object_size_hint_align_set(bt[bt_num], EVAS_HINT_FILL, EVAS_HINT_FILL);
1439    evas_object_size_hint_weight_set(bt[bt_num], EVAS_HINT_EXPAND, 0.0);
1440    evas_object_show(bt[bt_num]);
1441    elm_box_pack_end(bx3, bt[bt_num]);
1442
1443    bt[++bt_num] = elm_button_add(win);
1444    elm_button_label_set(bt[bt_num], "Bring top 239");
1445    evas_object_size_hint_align_set(bt[bt_num], EVAS_HINT_FILL, EVAS_HINT_FILL);
1446    evas_object_size_hint_weight_set(bt[bt_num], EVAS_HINT_EXPAND, 0.0);
1447    evas_object_show(bt[bt_num]);
1448    elm_box_pack_end(bx3, bt[bt_num]);
1449
1450    bt[++bt_num] = elm_button_add(win);
1451    elm_button_label_set(bt[bt_num], "Bring top 477");
1452    evas_object_size_hint_align_set(bt[bt_num], EVAS_HINT_FILL, EVAS_HINT_FILL);
1453    evas_object_size_hint_weight_set(bt[bt_num], EVAS_HINT_EXPAND, 0.0);
1454    evas_object_show(bt[bt_num]);
1455    elm_box_pack_end(bx3, bt[bt_num]);
1456
1457    elm_box_pack_end(bx, bx3);
1458    evas_object_show(bx3);
1459
1460    bt_count = 0;
1461    for (i = 0; i < 500; i++)
1462      {
1463         if (!(i % 10))
1464           {
1465              gli = git = elm_genlist_item_append(gl, &itc_group,
1466                                                  (void *)(long)i/* item data */,
1467                                                  NULL/* parent */,
1468                                                  ELM_GENLIST_ITEM_GROUP,
1469                                                  gl_sel/* func */,
1470                                                  (void *)(long)(i * 10)/* func data */);
1471              elm_genlist_item_display_only_set(git, EINA_TRUE);
1472           }
1473         else if (git)
1474           {
1475              gli = elm_genlist_item_append(gl, &itc1,
1476                                            (void *)(long)i/* item data */,
1477                                            git/* parent */,
1478                                            ELM_GENLIST_ITEM_NONE,
1479                                            gl_sel/* func */,
1480                                            (void *)(long)(i * 10)/* func data */);
1481           }
1482         switch (i)
1483           {
1484            case 0:
1485               evas_object_smart_callback_add(bt[0], "clicked", _bt_show_cb, gli);
1486               evas_object_smart_callback_add(bt[4], "clicked", _bt_bring_cb, gli);
1487               break;
1488            case 26:
1489               evas_object_smart_callback_add(bt[1], "clicked", _bt_show_cb, gli);
1490               break;
1491            case 31:
1492               evas_object_smart_callback_add(bt[5], "clicked", _bt_bring_cb, gli);
1493               break;
1494            case 101:
1495               evas_object_smart_callback_add(bt[2], "clicked", _bt_show_cb, gli);
1496               break;
1497            case 239:
1498               evas_object_smart_callback_add(bt[6], "clicked", _bt_bring_cb, gli);
1499               break;
1500            case 477:
1501               evas_object_smart_callback_add(bt[7], "clicked", _bt_bring_cb, gli);
1502               break;
1503            case 480:
1504               evas_object_smart_callback_add(bt[3], "clicked", _bt_show_cb, gli);
1505               break;
1506           }
1507      }
1508
1509    evas_object_resize(win, 480, 800);
1510    evas_object_show(win);
1511 }
1512
1513 /*************/
1514
1515 static void
1516 gl9_exp(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1517 {
1518    Elm_Genlist_Item *it = event_info;
1519    Evas_Object *gl = elm_genlist_item_genlist_get(it);
1520    int val = (int)(long)elm_genlist_item_data_get(it);
1521    val *= 10;
1522    elm_genlist_item_append(gl, &itc1,
1523                            (void *)(long)(val + 1)/* item data */, it/* parent */,
1524                            ELM_GENLIST_ITEM_NONE, gl4_sel/* func */,
1525                            NULL/* func data */);
1526    elm_genlist_item_append(gl, &itc1,
1527                            (void *)(long)(val + 2)/* item data */, it/* parent */,
1528                            ELM_GENLIST_ITEM_NONE, gl4_sel/* func */,
1529                            NULL/* func data */);
1530    elm_genlist_item_append(gl, &itc1,
1531                            (void *)(long)(val + 3)/* item data */, it/* parent */,
1532                            ELM_GENLIST_ITEM_SUBITEMS, gl4_sel/* func */,
1533                            NULL/* func data */);
1534 }
1535 static void
1536 gl9_con(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1537 {
1538    Elm_Genlist_Item *it = event_info;
1539    elm_genlist_item_subitems_clear(it);
1540 }
1541
1542 static void
1543 gl9_exp_req(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1544 {
1545    Elm_Genlist_Item *it = event_info;
1546    elm_genlist_item_expanded_set(it, EINA_TRUE);
1547 }
1548 static void
1549 gl9_con_req(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1550 {
1551    Elm_Genlist_Item *it = event_info;
1552    elm_genlist_item_expanded_set(it, EINA_FALSE);
1553 }
1554
1555 void
1556 test_genlist9(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1557 {
1558    Evas_Object *win, *bg, *gl, *bx;
1559    Elm_Genlist_Item *git;
1560
1561    win = elm_win_add(NULL, "genlist-group-tree", ELM_WIN_BASIC);
1562    elm_win_title_set(win, "Genlist Group Tree");
1563    elm_win_autodel_set(win, 1);
1564
1565    bg = elm_bg_add(win);
1566    elm_win_resize_object_add(win, bg);
1567    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1568    evas_object_show(bg);
1569
1570    bx = elm_box_add(win);
1571    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1572    elm_win_resize_object_add(win, bx);
1573    evas_object_show(bx);
1574
1575    gl = elm_genlist_add(win);
1576    evas_object_smart_callback_add(gl, "selected", _gl_selected, NULL);
1577    evas_object_smart_callback_add(gl, "clicked,double", _gl_double_clicked, NULL);
1578    evas_object_smart_callback_add(gl, "longpressed", _gl_longpress, NULL);
1579    evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1580    evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
1581    elm_box_pack_end(bx, gl);
1582    evas_object_show(gl);
1583
1584    itc1.item_style     = "default";
1585    itc1.func.label_get = gl_label_get;
1586    itc1.func.icon_get  = gl_icon_get;
1587    itc1.func.state_get = gl_state_get;
1588    itc1.func.del       = gl_del;
1589
1590    itc_group.item_style     = "group_index";
1591    itc_group.func.label_get = gl8_label_get;
1592    itc_group.func.icon_get  = NULL;
1593    itc_group.func.state_get = NULL;
1594    itc_group.func.del       = gl_del;
1595
1596    git = elm_genlist_item_append(gl, &itc_group,
1597                                  (void *)0/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_GROUP, gl4_sel/* func */,
1598                                  NULL/* func data */);
1599    elm_genlist_item_display_only_set(git, EINA_TRUE);
1600    elm_genlist_item_append(gl, &itc1,
1601                            (void *)1/* item data */, git/* parent */, ELM_GENLIST_ITEM_SUBITEMS, gl4_sel/* func */,
1602                            NULL/* func data */);
1603    elm_genlist_item_append(gl, &itc1,
1604                            (void *)2/* item data */, git/* parent */, ELM_GENLIST_ITEM_NONE, gl4_sel/* func */,
1605                            NULL/* func data */);
1606    elm_genlist_item_append(gl, &itc1,
1607                            (void *)3/* item data */, git/* parent */, ELM_GENLIST_ITEM_SUBITEMS, gl4_sel/* func */,
1608                            NULL/* func data */);
1609    git = elm_genlist_item_append(gl, &itc_group,
1610                                  (void *)4/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_GROUP, gl4_sel/* func */,
1611                                  NULL/* func data */);
1612    elm_genlist_item_display_only_set(git, EINA_TRUE);
1613    elm_genlist_item_append(gl, &itc1,
1614                            (void *)5/* item data */, git/* parent */, ELM_GENLIST_ITEM_SUBITEMS, gl4_sel/* func */,
1615                            NULL/* func data */);
1616    elm_genlist_item_append(gl, &itc1,
1617                            (void *)6/* item data */, git/* parent */, ELM_GENLIST_ITEM_NONE, gl4_sel/* func */,
1618                            NULL/* func data */);
1619    elm_genlist_item_append(gl, &itc1,
1620                            (void *)7/* item data */, git/* parent */, ELM_GENLIST_ITEM_SUBITEMS, gl4_sel/* func */,
1621                            NULL/* func data */);
1622
1623    evas_object_smart_callback_add(gl, "expand,request", gl9_exp_req, gl);
1624    evas_object_smart_callback_add(gl, "contract,request", gl9_con_req, gl);
1625    evas_object_smart_callback_add(gl, "expanded", gl9_exp, gl);
1626    evas_object_smart_callback_add(gl, "contracted", gl9_con, gl);
1627
1628    evas_object_resize(win, 480, 800);
1629    evas_object_show(win);
1630 }
1631
1632 /*************/
1633
1634 static Elm_Genlist_Item_Class itc10;
1635 static char *mode_type[] = { "slide", "rotate" };
1636 char *gl10_label_get(void *data, Evas_Object *obj __UNUSED__, const char *part)
1637 {
1638    char buf[256];
1639    if (!strcmp(part, "elm.text.mode"))
1640      snprintf(buf, sizeof(buf), "Mode # %i", (int)(long)data);
1641    else
1642      snprintf(buf, sizeof(buf), "Item # %i", (int)(long)data);
1643    return strdup(buf);
1644 }
1645
1646 Evas_Object *gl10_icon_get(void *data __UNUSED__, Evas_Object *obj, const char *part)
1647 {
1648    char buf[PATH_MAX];
1649    Evas_Object *ic = elm_icon_add(obj);
1650    if (!strcmp(part, "elm.swallow.end"))
1651      snprintf(buf, sizeof(buf), "%s/images/bubble.png", PACKAGE_DATA_DIR);
1652    else
1653      snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR);
1654    elm_icon_file_set(ic, buf, NULL);
1655    evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
1656    return ic;
1657 }
1658 static void
1659 _gl_sel10(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1660 {
1661    if (!data) return;
1662    int v = elm_radio_value_get(data);
1663    if (v == 1)
1664      elm_genlist_item_mode_set(event_info, mode_type[v], EINA_TRUE);
1665 }
1666
1667 static void
1668 _my_gl_mode_right(void *data, Evas_Object *obj __UNUSED__, void *event_info)
1669 {
1670    if (!data) return;
1671    int v = elm_radio_value_get(data);
1672    if (v == 0)
1673      elm_genlist_item_mode_set(event_info, mode_type[v], EINA_TRUE);
1674 }
1675
1676 static void
1677 _my_gl_mode_left(void *data, Evas_Object *obj __UNUSED__, void *event_info)
1678 {
1679    if (!data) return;
1680    int v = elm_radio_value_get(data);
1681    if (v == 0)
1682      elm_genlist_item_mode_set(event_info, mode_type[v], EINA_FALSE);
1683 }
1684
1685 static void
1686 _my_gl_mode_cancel(void *data, Evas_Object *obj, void *event_info __UNUSED__)
1687 {
1688    fprintf(stderr, "drag\n");
1689    if (!data) return;
1690    int v = elm_radio_value_get(data);
1691    Elm_Genlist_Item *it = (Elm_Genlist_Item *)elm_genlist_mode_item_get(obj);
1692    if (it)
1693      elm_genlist_item_mode_set(it, mode_type[v], EINA_FALSE);
1694 }
1695
1696 void
1697 test_genlist10(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1698 {
1699    Evas_Object *win, *bg, *fr, *lb, *bx, *bx2, *bx3, *rd, *rdg, *gl;
1700    int i;
1701
1702    win = elm_win_add(NULL, "genlist10", ELM_WIN_BASIC);
1703    elm_win_title_set(win, "Genlist Mode");
1704    elm_win_autodel_set(win, 1);
1705
1706    bg = elm_bg_add(win);
1707    elm_win_resize_object_add(win, bg);
1708    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1709    evas_object_show(bg);
1710
1711    bx = elm_box_add(win);
1712    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1713    elm_win_resize_object_add(win, bx);
1714    evas_object_show(bx);
1715
1716    fr = elm_frame_add(win);
1717    elm_frame_label_set(fr, "Mode Type");
1718    elm_box_pack_end(bx, fr);
1719    evas_object_show(fr);
1720
1721    bx2 = elm_box_add(win);
1722    elm_frame_content_set(fr, bx2);
1723    evas_object_show(bx2);
1724
1725    lb = elm_label_add(win);
1726    elm_label_label_set(lb,
1727                        "Sweep genlist items to the right.<br>"
1728                        "Test this by changing Mode Type to Slide or Rotate.");
1729    elm_box_pack_end(bx2, lb);
1730    evas_object_show(lb);
1731
1732    bx3 = elm_box_add(win);
1733    elm_box_horizontal_set(bx3, EINA_TRUE);
1734    elm_box_pack_end(bx2, bx3);
1735    evas_object_show(bx3);
1736
1737    rd = elm_radio_add(win);
1738    evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1739    elm_radio_state_value_set(rd, 0);
1740    elm_radio_label_set(rd, "Slide  ");
1741    evas_object_show(rd);
1742    elm_box_pack_end(bx3, rd);
1743    rdg = rd;
1744
1745    rd = elm_radio_add(win);
1746    evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1747    elm_radio_state_value_set(rd, 1);
1748    elm_radio_label_set(rd, "Rotate");
1749    elm_radio_group_add(rd, rdg);
1750    evas_object_show(rd);
1751    elm_box_pack_end(bx3, rd);
1752
1753    gl = elm_genlist_add(win);
1754    evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
1755    evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1756    evas_object_smart_callback_add(gl, "drag,start,right", _my_gl_mode_right, rdg);
1757    evas_object_smart_callback_add(gl, "drag,start,left", _my_gl_mode_left, rdg);
1758    evas_object_smart_callback_add(gl, "drag,start,up", _my_gl_mode_cancel, rdg);
1759    evas_object_smart_callback_add(gl, "drag,start,down", _my_gl_mode_cancel, rdg);
1760    evas_object_show(gl);
1761
1762    itc10.item_style     = "default";
1763    itc10.func.label_get = gl10_label_get;
1764    itc10.func.icon_get  = gl10_icon_get;
1765    itc10.func.state_get = gl_state_get;
1766    itc10.func.del       = gl_del;
1767    itc10.mode_item_style = "mode";
1768
1769    for (i = 0; i < 50; i++)
1770      elm_genlist_item_append(gl,
1771                              &itc10,
1772                              (void *)(1000 + i)/* item data */,
1773                              NULL/* parent */,
1774                              ELM_GENLIST_ITEM_NONE/* flags */,
1775                              _gl_sel10/* func */,
1776                              rdg/* func data */);
1777
1778    elm_box_pack_end(bx, gl);
1779
1780    evas_object_resize(win, 520, 520);
1781    evas_object_show(win);
1782 }
1783
1784 /*************/
1785
1786 static void
1787 _reorder_tg_changed_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__)
1788 {
1789    elm_genlist_reorder_mode_set(data, elm_toggle_state_get(obj));
1790 }
1791
1792 /**
1793  * gl_moved is called after an item was reordered.
1794  * This is only called when reorder mode is enabled.
1795  *
1796  * @param obj          :  the genlist object.
1797  * @param item         :  the moved item.
1798  * @param rel_item     :  the relative item.
1799  * @param move_after   :  whether or not the rel_item is after item.
1800  *
1801  * If the move_after is true,
1802  *  the item(*item) had been moved after the given relative item(*rel_item) in list.
1803  * If the move_after is false,
1804  *  the item(*item) had been moved before the given relative item(*rel_item) in list.
1805  *
1806  */
1807 static void gl_moved(Evas_Object *obj __UNUSED__, Elm_Genlist_Item *item __UNUSED__, Elm_Genlist_Item *rel_item __UNUSED__, Eina_Bool move_after __UNUSED__)
1808 {
1809    // if needed, add application logic.
1810 }
1811
1812 void
1813 test_genlist11(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1814 {
1815    Evas_Object *win, *bg, *fr, *lb, *bx, *tg, *gl;
1816    int i;
1817
1818    win = elm_win_add(NULL, "genlist-reorder-mode", ELM_WIN_BASIC);
1819    elm_win_title_set(win, "Genlist Reorder Mode");
1820    elm_win_autodel_set(win, 1);
1821
1822    bg = elm_bg_add(win);
1823    elm_win_resize_object_add(win, bg);
1824    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1825    evas_object_show(bg);
1826
1827    bx = elm_box_add(win);
1828    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1829    elm_win_resize_object_add(win, bx);
1830    evas_object_show(bx);
1831
1832    fr = elm_frame_add(win);
1833
1834    elm_frame_label_set(fr, "Reorder Mode");
1835    elm_box_pack_end(bx, fr);
1836    evas_object_show(fr);
1837
1838    lb = elm_label_add(win);
1839    elm_label_label_set(lb,
1840                        "Enable reorder mode if you want to move item.<br>"
1841                        "Then long press and drag item.");
1842    elm_frame_content_set(fr, lb);
1843    evas_object_show(lb);
1844
1845    gl = elm_genlist_add(win);
1846    evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
1847    evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1848    evas_object_show(gl);
1849
1850    tg = elm_toggle_add(win);
1851    elm_toggle_label_set(tg, "Reorder Mode:");
1852    elm_toggle_state_set(tg, elm_mirrored_get());
1853    evas_object_smart_callback_add(tg, "changed", _reorder_tg_changed_cb, gl);
1854    elm_box_pack_end(bx, tg);
1855    evas_object_show(tg);
1856
1857    itc1.item_style     = "default";
1858    itc1.func.label_get = gl_label_get;
1859    itc1.func.icon_get  = gl_icon_get;
1860    itc1.func.state_get = gl_state_get;
1861    itc1.func.del       = gl_del;
1862    itc1.func.moved     = gl_moved;
1863
1864    for (i = 0; i < 50; i++)
1865      elm_genlist_item_append(gl,
1866                              &itc1,
1867                              (void *)(1 + i)/* item data */,
1868                              NULL/* parent */,
1869                              ELM_GENLIST_ITEM_NONE/* flags */,
1870                              NULL/* func */,
1871                              NULL/* func data */);
1872
1873    elm_box_pack_end(bx, gl);
1874
1875    evas_object_resize(win, 400, 500);
1876    evas_object_show(win);
1877 }
1878 #endif