Added per-window profile to support multi-head display.
[framework/uifw/elementary.git] / src / bin / test_genlist.c
1 #include <Elementary_Cursor.h>
2 #include "test.h"
3 #ifdef HAVE_CONFIG_H
4 #include "elementary_config.h"
5 #endif
6 #include <Elementary.h>
7 #ifndef ELM_LIB_QUICKLAUNCH
8 struct _api_data
9 {
10    unsigned int state;  /* What state we are testing       */
11    void *box;           /* Use this to get box content     */
12 };
13 typedef struct _api_data api_data;
14
15 enum _api_state
16 {
17    HORIZONTAL_SET,
18    NO_SELECT_MODE_SET,
19    COMPRESS_MODE_SET,
20    BOUNCE_SET,
21    HOMOGENEOUS_SET,
22    SCROLLER_POLICY_SET,
23    TOOLTIP_TEXT_SET,
24    ITEM_CURSOR_SET,
25    API_STATE_LAST
26 };
27 typedef enum _api_state api_state;
28
29 static void
30 set_api_state(api_data *api)
31 {
32    const Eina_List *items = elm_box_children_get(api->box);
33    if (!eina_list_count(items))
34      return;
35
36    Evas_Object *gl = eina_list_nth(items, 0); /* Genlist is the first item */
37    /* use elm_box_children_get() to get list of children */
38    switch(api->state)
39      {/* Put all api-changes under switch */
40       case HORIZONTAL_SET: /* 0 */
41          elm_genlist_mode_set(gl, ELM_LIST_LIMIT);
42          break;
43
44       case NO_SELECT_MODE_SET: /* 1 */
45          elm_genlist_select_mode_set(gl, ELM_OBJECT_SELECT_MODE_NONE);
46          elm_genlist_mode_set(gl, ELM_LIST_SCROLL); /* Back to default */
47          break;
48
49       case COMPRESS_MODE_SET: /* 2 */
50          elm_genlist_select_mode_set(gl, ELM_OBJECT_SELECT_MODE_DEFAULT);
51          elm_genlist_mode_set(gl, ELM_LIST_COMPRESS);
52          break;
53
54       case BOUNCE_SET: /* 3 */
55          elm_genlist_bounce_set(gl, EINA_FALSE, EINA_FALSE);
56          break;
57
58       case HOMOGENEOUS_SET: /* 4 */
59          elm_genlist_bounce_set(gl, EINA_TRUE, EINA_TRUE); /* Back to default */
60          elm_genlist_homogeneous_set(gl, EINA_TRUE);
61          break;
62
63       case SCROLLER_POLICY_SET: /* 5 */
64          elm_genlist_homogeneous_set(gl, EINA_FALSE); /* Back to default */
65          elm_genlist_scroller_policy_set(gl, ELM_SCROLLER_POLICY_ON, ELM_SCROLLER_POLICY_ON);
66          break;
67
68       case TOOLTIP_TEXT_SET: /* 6 */
69            {
70               elm_genlist_item_tooltip_text_set(elm_genlist_first_item_get(gl), "Tooltip text from API");
71               elm_genlist_item_bring_in(elm_genlist_first_item_get(gl),
72                                          ELM_GENLIST_ITEM_SCROLLTO_IN);
73            }
74          break;
75
76       case ITEM_CURSOR_SET: /* 7 */
77          elm_genlist_item_cursor_set(elm_genlist_first_item_get(gl), ELM_CURSOR_HAND2);
78          break;
79
80       default:
81          return;
82      }
83 }
84
85 static void
86 _api_bt_clicked(void *data, Evas_Object *obj, void *event_info __UNUSED__)
87 {  /* Will add here a SWITCH command containing code to modify test-object */
88    /* in accordance a->state value. */
89    api_data *a = data;
90    char str[128];
91
92    printf("clicked event on API Button: api_state=<%d>\n", a->state);
93    set_api_state(a);
94    a->state++;
95    sprintf(str, "Next API function (%u)", a->state);
96    elm_object_text_set(obj, str);
97    elm_object_disabled_set(obj, a->state == API_STATE_LAST);
98 }
99 /* Hint:
100  * In this example some calls to elm_genlist_item_append() are used which give the
101  * value of an int as 'item data' and 'func data' after casting into (void*). For
102  * sure this works only on architectures where sizeof(int)==sizeof(void*).
103  * For real world usage you should hold a data structure or value in your
104  * application and then give only a pointer to this data as data pointer.
105  */
106
107 typedef struct _Testitem
108 {
109    Elm_Object_Item *item;
110    int mode;
111    int onoff;
112    Eina_Bool checked;
113 } Testitem;
114
115 static Elm_Genlist_Item_Class *itc1;
116 char *gl_text_get(void *data, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
117 {
118    char buf[256];
119    snprintf(buf, sizeof(buf), "Item # %i", (int)(long)data);
120    return strdup(buf);
121 }
122
123 Evas_Object *gl_content_get(void *data __UNUSED__, Evas_Object *obj, const char *part)
124 {
125    char buf[PATH_MAX];
126    Evas_Object *ic = elm_icon_add(obj);
127    if (!strcmp(part, "elm.swallow.end"))
128      snprintf(buf, sizeof(buf), "%s/images/bubble.png", elm_app_data_dir_get());
129    else
130      snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
131    elm_icon_file_set(ic, buf, NULL);
132    evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
133    return ic;
134 }
135
136 Eina_Bool gl_state_get(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
137 {
138    return EINA_FALSE;
139 }
140
141 static void
142 gl_sel(void *data, Evas_Object *obj, void *event_info)
143 {
144    printf("sel item data [%p] on genlist obj [%p], item pointer [%p]\n", data, obj, event_info);
145 }
146
147 static void
148 _move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
149 {
150    Evas_Object *gl = data;
151    Evas_Event_Mouse_Move *ev = event_info;
152    int where = 0;
153    Elm_Object_Item *gli;
154    gli = elm_genlist_at_xy_item_get(gl, ev->cur.canvas.x, ev->cur.canvas.y, &where);
155    if (gli)
156      printf("over %p, where %i\n", elm_object_item_data_get(gli), where);
157    else
158      printf("over none, where %i\n", where);
159 }
160
161 static void
162 _bt50_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
163 {
164    elm_genlist_item_bring_in(data, ELM_GENLIST_ITEM_SCROLLTO_IN);
165 }
166
167 static void
168 _bt1500_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
169 {
170    elm_genlist_item_bring_in(data, ELM_GENLIST_ITEM_SCROLLTO_MIDDLE);
171 }
172
173 static void
174 _gl_selected(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
175 {
176    printf("selected: %p\n", event_info);
177 }
178
179 static void
180 _gl_double_clicked(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
181 {
182    printf("double clicked: %p\n", event_info);
183 }
184
185 static void
186 _gl_longpress(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
187 {
188    printf("longpress %p\n", event_info);
189 }
190
191 static void
192 _cleanup_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
193 {
194    free(data);
195 }
196
197 void
198 test_genlist(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
199 {
200    Evas_Object *win, *gl, *bt_50, *bt_1500, *bx, *bxx, *bt;
201    Evas_Object *over;
202    Elm_Object_Item *gli;
203    int i;
204    api_data *api = calloc(1, sizeof(api_data));
205
206    win = elm_win_util_standard_add("genlist", "Genlist");
207    elm_win_autodel_set(win, EINA_TRUE);
208    evas_object_event_callback_add(win, EVAS_CALLBACK_FREE, _cleanup_cb, api);
209
210    bxx = elm_box_add(win);
211    elm_win_resize_object_add(win, bxx);
212    evas_object_size_hint_weight_set(bxx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
213    evas_object_show(bxx);
214
215    bx = elm_box_add(win);
216    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
217    evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
218    api->box = bx;
219    evas_object_show(bx);
220
221    bt = elm_button_add(win);
222    elm_object_text_set(bt, "Next API function");
223    evas_object_smart_callback_add(bt, "clicked", _api_bt_clicked, (void *) api);
224    elm_box_pack_end(bxx, bt);
225    elm_object_disabled_set(bt, api->state == API_STATE_LAST);
226    evas_object_show(bt);
227
228    elm_box_pack_end(bxx, bx);
229
230    gl = elm_genlist_add(win);
231    evas_object_smart_callback_add(gl, "selected", _gl_selected, NULL);
232    evas_object_smart_callback_add(gl, "clicked,double", _gl_double_clicked, NULL);
233    evas_object_smart_callback_add(gl, "longpressed", _gl_longpress, NULL);
234    // FIXME: This causes genlist to resize the horiz axis very slowly :(
235    // Reenable this and resize the window horizontally, then try to resize it back
236    //elm_genlist_mode_set(gl, ELM_LIST_LIMIT);
237    evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
238    evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
239    elm_box_pack_end(bx, gl);
240    evas_object_show(gl);
241
242    over = evas_object_rectangle_add(evas_object_evas_get(win));
243    evas_object_color_set(over, 0, 0, 0, 0);
244    evas_object_event_callback_add(over, EVAS_CALLBACK_MOUSE_MOVE, _move, gl);
245    evas_object_repeat_events_set(over, 1);
246    evas_object_show(over);
247    evas_object_size_hint_weight_set(over, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
248    elm_win_resize_object_add(win, over);
249
250    itc1 = elm_genlist_item_class_new();
251    itc1->item_style     = "default";
252    itc1->func.text_get = gl_text_get;
253    itc1->func.content_get  = gl_content_get;
254    itc1->func.state_get = gl_state_get;
255    itc1->func.del       = NULL;
256
257    bt_50 = elm_button_add(win);
258    elm_object_text_set(bt_50, "Go to 50");
259    evas_object_show(bt_50);
260    elm_box_pack_end(bx, bt_50);
261
262    bt_1500 = elm_button_add(win);
263    elm_object_text_set(bt_1500, "Go to 1500");
264    evas_object_show(bt_1500);
265    elm_box_pack_end(bx, bt_1500);
266
267    for (i = 0; i < 2000; i++)
268      {
269         gli = elm_genlist_item_append(gl, itc1,
270                                       (void *)(long)i/* item data */,
271                                       NULL/* parent */,
272                                       ELM_GENLIST_ITEM_NONE,
273                                       gl_sel/* func */,
274                                       (void *)(long)(i * 10)/* func data */);
275         if (i == 50)
276           evas_object_smart_callback_add(bt_50, "clicked", _bt50_cb, gli);
277         else if (i == 1500)
278           evas_object_smart_callback_add(bt_1500, "clicked", _bt1500_cb, gli);
279      }
280    elm_genlist_item_class_free(itc1);
281
282    evas_object_resize(win, 480, 800);
283    evas_object_show(win);
284 }
285
286 /*************/
287
288 static void
289 my_gl_clear(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
290 {
291    Evas_Object *gl = data;
292    elm_genlist_clear(gl);
293 }
294
295 static void
296 my_gl_add(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
297 {
298    Evas_Object *gl = data;
299    static int i = 0;
300
301    itc1->item_style     = "default";
302    itc1->func.text_get = gl_text_get;
303    itc1->func.content_get  = gl_content_get;
304    itc1->func.state_get = gl_state_get;
305    itc1->func.del       = NULL;
306
307    elm_genlist_item_append(gl, itc1,
308                            (void *)(long)i/* item data */,
309                            NULL/* parent */,
310                            ELM_GENLIST_ITEM_NONE,
311                            gl_sel/* func */,
312                            (void *)(long)(i * 10)/* func data */);
313    i++;
314 }
315
316 static void
317 my_gl_insert_before(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
318 {
319    Evas_Object *gl = data;
320    static int i = 0;
321    Elm_Object_Item *gli_selected;
322
323    itc1->item_style     = "default";
324    itc1->func.text_get = gl_text_get;
325    itc1->func.content_get  = gl_content_get;
326    itc1->func.state_get = gl_state_get;
327    itc1->func.del       = NULL;
328
329    gli_selected = elm_genlist_selected_item_get(gl);
330    if (!gli_selected)
331      {
332         printf("no item selected\n");
333         return ;
334      }
335
336    elm_genlist_item_insert_before(gl, itc1,
337                                   (void *)(long)i/* item data */,
338                                   NULL/* parent */,
339                                   gli_selected /* item before */,
340                                   ELM_GENLIST_ITEM_NONE,
341                                   gl_sel/* func */,
342                                   (void *)(long)(i * 10)/* func data */);
343    i++;
344 }
345
346 static void
347 my_gl_insert_after(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
348 {
349    Evas_Object *gl = data;
350    static int i = 0;
351    Elm_Object_Item *gli_selected;
352
353    itc1->item_style     = "default";
354    itc1->func.text_get = gl_text_get;
355    itc1->func.content_get  = gl_content_get;
356    itc1->func.state_get = gl_state_get;
357    itc1->func.del       = NULL;
358
359    gli_selected = elm_genlist_selected_item_get(gl);
360    if (!gli_selected)
361      {
362         printf("no item selected\n");
363         return ;
364      }
365
366    elm_genlist_item_insert_after(gl, itc1,
367                                  (void *)(long)i/* item data */,
368                                  NULL/* parent */,
369                                  gli_selected /* item after */,
370                                  ELM_GENLIST_ITEM_NONE,
371                                  gl_sel/* func */,
372                                  (void *)(long)(i * 10)/* func data */);
373    i++;
374 }
375
376 static void
377 my_gl_del(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
378 {
379    Evas_Object *gl = data;
380    Elm_Object_Item *gli = elm_genlist_selected_item_get(gl);
381    if (!gli)
382      {
383         printf("no item selected\n");
384         return;
385      }
386    elm_object_item_del(gli);
387 }
388
389 static void
390 my_gl_disable(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
391 {
392    Evas_Object *gl = data;
393    Elm_Object_Item *gli = elm_genlist_selected_item_get(gl);
394    if (!gli)
395      {
396         printf("no item selected\n");
397         return;
398      }
399    elm_object_item_disabled_set(gli, EINA_TRUE);
400    elm_genlist_item_selected_set(gli, EINA_FALSE);
401    elm_genlist_item_update(gli);
402 }
403
404 static void
405 my_gl_update_all(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
406 {
407    Evas_Object *gl = data;
408    int i = 0;
409    Elm_Object_Item *it = elm_genlist_first_item_get(gl);
410    while (it)
411      {
412         elm_genlist_item_update(it);
413         printf("%i\n", i);
414         i++;
415         it = elm_genlist_item_next_get(it);
416      }
417 }
418
419 static void
420 my_gl_first(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
421 {
422    Evas_Object *gl = data;
423    Elm_Object_Item *gli = elm_genlist_first_item_get(gl);
424    if (!gli) return;
425    elm_genlist_item_show(gli, ELM_GENLIST_ITEM_SCROLLTO_IN);
426    elm_genlist_item_selected_set(gli, 1);
427 }
428
429 static void
430 my_gl_last(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
431 {
432    Evas_Object *gl = data;
433    Elm_Object_Item *gli = elm_genlist_last_item_get(gl);
434    if (!gli) return;
435    elm_genlist_item_show(gli, ELM_GENLIST_ITEM_SCROLLTO_IN);
436    elm_genlist_item_selected_set(gli, 1);
437 }
438
439 static Eina_Bool
440 my_gl_flush_delay(void *data __UNUSED__)
441 {
442    elm_cache_all_flush();
443    return ECORE_CALLBACK_CANCEL;
444 }
445
446 static void
447 my_gl_flush(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
448 {
449    ecore_timer_add(1.2, my_gl_flush_delay, NULL);
450 }
451
452 void
453 test_genlist2(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
454 {
455    Evas_Object *win, *bg, *gl, *bx, *bx2, *bx3, *bt;
456    Elm_Object_Item *gli[10];
457    char buf[PATH_MAX];
458
459    win = elm_win_add(NULL, "genlist2", ELM_WIN_BASIC);
460    elm_win_title_set(win, "Genlist 2");
461    elm_win_autodel_set(win, EINA_TRUE);
462
463    bg = elm_bg_add(win);
464    snprintf(buf, sizeof(buf), "%s/images/plant_01.jpg", elm_app_data_dir_get());
465    elm_bg_file_set(bg, buf, NULL);
466    elm_win_resize_object_add(win, bg);
467    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
468    evas_object_show(bg);
469
470    bx = elm_box_add(win);
471    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
472    elm_win_resize_object_add(win, bx);
473    evas_object_show(bx);
474
475    gl = elm_genlist_add(win);
476    evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
477    evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
478    evas_object_show(gl);
479
480    itc1 = elm_genlist_item_class_new();
481    itc1->item_style     = "default";
482    itc1->func.text_get = gl_text_get;
483    itc1->func.content_get  = gl_content_get;
484    itc1->func.state_get = gl_state_get;
485    itc1->func.del       = NULL;
486
487    gli[0] = elm_genlist_item_append(gl, itc1,
488                                     (void *)1001/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_NONE, gl_sel/* func */,
489                                     (void *)1001/* func data */);
490    gli[1] = elm_genlist_item_append(gl, itc1,
491                                     (void *)1002/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_NONE, gl_sel/* func */,
492                                     (void *)1002/* func data */);
493    gli[2] = elm_genlist_item_append(gl, itc1,
494                                     (void *)1003/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_NONE, gl_sel/* func */,
495                                     (void *)1003/* func data */);
496    gli[3] = elm_genlist_item_prepend(gl, itc1,
497                                      (void *)1004/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_NONE, gl_sel/* func */,
498                                      (void *)1004/* func data */);
499    gli[4] = elm_genlist_item_prepend(gl, itc1,
500                                      (void *)1005/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_NONE, gl_sel/* func */,
501                                      (void *)1005/* func data */);
502    gli[5] = elm_genlist_item_insert_before(gl, itc1,
503                                            (void *)1006/* item data */, NULL/* parent */, gli[2]/* rel */, ELM_GENLIST_ITEM_NONE,
504                                            gl_sel/* func */, (void *)1006/* func data */);
505    gli[6] = elm_genlist_item_insert_after(gl, itc1,
506                                           (void *)1007/* item data */, NULL/* parent */, gli[2]/* rel */, ELM_GENLIST_ITEM_NONE,
507                                           gl_sel/* func */, (void *)1007/* func data */);
508    elm_box_pack_end(bx, gl);
509
510    bx2 = elm_box_add(win);
511    elm_box_horizontal_set(bx2, EINA_TRUE);
512    elm_box_homogeneous_set(bx2, EINA_TRUE);
513    evas_object_size_hint_weight_set(bx2, EVAS_HINT_EXPAND, 0.0);
514    evas_object_size_hint_align_set(bx2, EVAS_HINT_FILL, EVAS_HINT_FILL);
515
516    bt = elm_button_add(win);
517    elm_object_text_set(bt, "/\\");
518    evas_object_smart_callback_add(bt, "clicked", my_gl_first, gl);
519    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
520    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
521    elm_box_pack_end(bx2, bt);
522    evas_object_show(bt);
523
524    bt = elm_button_add(win);
525    elm_object_text_set(bt, "\\/");
526    evas_object_smart_callback_add(bt, "clicked", my_gl_last, gl);
527    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
528    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
529    elm_box_pack_end(bx2, bt);
530    evas_object_show(bt);
531
532    bt = elm_button_add(win);
533    elm_object_text_set(bt, "#");
534    evas_object_smart_callback_add(bt, "clicked", my_gl_disable, gl);
535    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
536    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
537    elm_box_pack_end(bx2, bt);
538    evas_object_show(bt);
539
540    bt = elm_button_add(win);
541    elm_object_text_set(bt, "U");
542    evas_object_smart_callback_add(bt, "clicked", my_gl_update_all, gl);
543    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
544    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
545    elm_box_pack_end(bx2, bt);
546    evas_object_show(bt);
547
548    elm_box_pack_end(bx, bx2);
549    evas_object_show(bx2);
550
551    bx2 = elm_box_add(win);
552    elm_box_horizontal_set(bx2, EINA_TRUE);
553    elm_box_homogeneous_set(bx2, EINA_TRUE);
554    evas_object_size_hint_weight_set(bx2, EVAS_HINT_EXPAND, 0.0);
555    evas_object_size_hint_align_set(bx2, EVAS_HINT_FILL, EVAS_HINT_FILL);
556
557    bt = elm_button_add(win);
558    elm_object_text_set(bt, "X");
559    evas_object_smart_callback_add(bt, "clicked", my_gl_clear, gl);
560    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
561    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
562    elm_box_pack_end(bx2, bt);
563    evas_object_show(bt);
564
565    bt = elm_button_add(win);
566    elm_object_text_set(bt, "+");
567    evas_object_smart_callback_add(bt, "clicked", my_gl_add, gl);
568    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
569    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
570    elm_box_pack_end(bx2, bt);
571    evas_object_show(bt);
572
573    bt = elm_button_add(win);
574    elm_object_text_set(bt, "-");
575    evas_object_smart_callback_add(bt, "clicked", my_gl_del, gl);
576    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
577    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
578    elm_box_pack_end(bx2, bt);
579    evas_object_show(bt);
580
581    elm_box_pack_end(bx, bx2);
582    evas_object_show(bx2);
583
584    bx3 = elm_box_add(win);
585    elm_box_horizontal_set(bx3, EINA_TRUE);
586    elm_box_homogeneous_set(bx3, EINA_TRUE);
587    evas_object_size_hint_weight_set(bx3, EVAS_HINT_EXPAND, 0.0);
588    evas_object_size_hint_align_set(bx3, EVAS_HINT_FILL, EVAS_HINT_FILL);
589
590    bt = elm_button_add(win);
591    elm_object_text_set(bt, "+ before");
592    evas_object_smart_callback_add(bt, "clicked", my_gl_insert_before, gl);
593    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
594    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
595    elm_box_pack_end(bx3, bt);
596    evas_object_show(bt);
597
598    bt = elm_button_add(win);
599    elm_object_text_set(bt, "+ after");
600    evas_object_smart_callback_add(bt, "clicked", my_gl_insert_after, gl);
601    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
602    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
603    elm_box_pack_end(bx3, bt);
604    evas_object_show(bt);
605
606    bt = elm_button_add(win);
607    elm_object_text_set(bt, "Flush");
608    evas_object_smart_callback_add(bt, "clicked", my_gl_flush, gl);
609    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
610    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
611    elm_box_pack_end(bx3, bt);
612    evas_object_show(bt);
613
614    elm_box_pack_end(bx, bx3);
615    evas_object_show(bx3);
616
617    /* item_class_ref is needed for itc1. some items can be added in callbacks */
618    elm_genlist_item_class_ref(itc1);
619    elm_genlist_item_class_free(itc1);
620
621    evas_object_resize(win, 320, 320);
622    evas_object_show(win);
623 }
624
625 /*************/
626
627 static Elm_Genlist_Item_Class itc2;
628
629 char *gl2_text_get(void *data, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
630 {
631    const Testitem *tit = data;
632    char buf[256];
633    snprintf(buf, sizeof(buf), "Item mode %i", tit->mode);
634    return strdup(buf);
635 }
636
637 Evas_Object *gl2_content_get(void *data, Evas_Object *obj, const char *part)
638 {
639    const Testitem *tit = data;
640    char buf[PATH_MAX];
641    Evas_Object *ic = elm_icon_add(obj);
642    if (!strcmp(part, "elm.swallow.icon"))
643      {
644         if (!(tit->mode & 0x3))
645           snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
646         else if ((tit->mode & 0x3) == 1)
647           snprintf(buf, sizeof(buf), "%s/images/logo.png", elm_app_data_dir_get());
648         else if ((tit->mode & 0x3) == 2)
649           snprintf(buf, sizeof(buf), "%s/images/panel_01.jpg", elm_app_data_dir_get());
650         else if ((tit->mode & 0x3) == 3)
651           snprintf(buf, sizeof(buf), "%s/images/rock_01.jpg", elm_app_data_dir_get());
652         elm_icon_file_set(ic, buf, NULL);
653      }
654    else if (!strcmp(part, "elm.swallow.end"))
655      {
656         if (!(tit->mode & 0x3))
657           snprintf(buf, sizeof(buf), "%s/images/sky_01.jpg", elm_app_data_dir_get());
658         else if ((tit->mode & 0x3) == 1)
659           snprintf(buf, sizeof(buf), "%s/images/sky_02.jpg", elm_app_data_dir_get());
660         else if ((tit->mode & 0x3) == 2)
661           snprintf(buf, sizeof(buf), "%s/images/sky_03.jpg", elm_app_data_dir_get());
662         else if ((tit->mode & 0x3) == 3)
663           snprintf(buf, sizeof(buf), "%s/images/sky_04.jpg", elm_app_data_dir_get());
664         elm_icon_file_set(ic, buf, NULL);
665      }
666    evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
667    return ic;
668 }
669
670 Eina_Bool gl2_state_get(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
671 {
672    return EINA_FALSE;
673 }
674
675 static void
676 my_gl_update(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
677 {
678    Testitem *tit = data;
679    tit->mode++;
680    elm_genlist_item_update(tit->item);
681 }
682
683 static void
684 my_gl_labels_update(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
685 {
686    Testitem *tit = data;
687    tit->mode++;
688    elm_genlist_item_fields_update(tit->item, "*", ELM_GENLIST_ITEM_FIELD_TEXT);
689 }
690
691 static void
692 my_gl_contents_update(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
693 {
694    Testitem *tit = data;
695    tit->mode++;
696    elm_genlist_item_fields_update(tit->item, "*", ELM_GENLIST_ITEM_FIELD_CONTENT);
697 }
698
699 void
700 test_genlist3(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
701 {
702    Evas_Object *win, *gl, *bx, *bx2, *bt;
703    static Testitem tit[3];
704
705    win = elm_win_util_standard_add("genlist3", "Genlist 3");
706    elm_win_autodel_set(win, EINA_TRUE);
707
708    bx = elm_box_add(win);
709    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
710    elm_win_resize_object_add(win, bx);
711    evas_object_show(bx);
712
713    gl = elm_genlist_add(win);
714    evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
715    evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
716    evas_object_show(gl);
717
718    itc2.item_style     = "default";
719    itc2.func.text_get = gl2_text_get;
720    itc2.func.content_get  = gl2_content_get;
721    itc2.func.state_get = gl2_state_get;
722    itc2.func.del       = NULL;
723
724    tit[0].mode = 0;
725    tit[0].item = elm_genlist_item_append(gl, &itc2,
726                                          &(tit[0])/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_NONE, gl_sel/* func */,
727                                          NULL/* func data */);
728    tit[1].mode = 1;
729    tit[1].item = elm_genlist_item_append(gl, &itc2,
730                                          &(tit[1])/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_NONE, gl_sel/* func */,
731                                          NULL/* func data */);
732    tit[2].mode = 2;
733    tit[2].item = elm_genlist_item_append(gl, &itc2,
734                                          &(tit[2])/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_NONE, gl_sel/* func */,
735                                          NULL/* func data */);
736
737    elm_box_pack_end(bx, gl);
738    evas_object_show(bx);
739
740    bx2 = elm_box_add(win);
741    elm_box_horizontal_set(bx2, EINA_TRUE);
742    elm_box_homogeneous_set(bx2, EINA_TRUE);
743    evas_object_size_hint_weight_set(bx2, EVAS_HINT_EXPAND, 0.0);
744    evas_object_size_hint_align_set(bx2, EVAS_HINT_FILL, EVAS_HINT_FILL);
745
746    bt = elm_button_add(win);
747    elm_object_text_set(bt, "[1]");
748    evas_object_smart_callback_add(bt, "clicked", my_gl_update, &(tit[0]));
749    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
750    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
751    elm_box_pack_end(bx2, bt);
752    evas_object_show(bt);
753
754    bt = elm_button_add(win);
755    elm_object_text_set(bt, "labels");
756    evas_object_smart_callback_add(bt, "clicked", my_gl_labels_update, &(tit[1]));
757    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
758    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
759    elm_box_pack_end(bx2, bt);
760    evas_object_show(bt);
761
762    bt = elm_button_add(win);
763    elm_object_text_set(bt, "contents");
764    evas_object_smart_callback_add(bt, "clicked", my_gl_contents_update, &(tit[2]));
765    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
766    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
767    elm_box_pack_end(bx2, bt);
768    evas_object_show(bt);
769
770    elm_box_pack_end(bx, bx2);
771    evas_object_show(bx2);
772
773    evas_object_resize(win, 320, 320);
774    evas_object_show(win);
775 }
776
777 /*************/
778
779 static void
780 my_gl_item_check_changed(void *data, Evas_Object *obj, void *event_info __UNUSED__)
781 {
782    Testitem *tit = data;
783    tit->onoff = elm_check_state_get(obj);
784    printf("item %p onoff = %i\n", tit, tit->onoff);
785 }
786
787 static Elm_Genlist_Item_Class itc3;
788
789 char *gl3_text_get(void *data, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
790 {
791    const Testitem *tit = data;
792    char buf[256];
793    snprintf(buf, sizeof(buf), "Item mode %i", tit->mode);
794    return strdup(buf);
795 }
796
797 Evas_Object *gl3_content_get(void *data, Evas_Object *obj, const char *part)
798 {
799    const Testitem *tit = data;
800    if (!strcmp(part, "elm.swallow.icon"))
801      {
802         Evas_Object *lb;
803
804         lb = elm_label_add(obj);
805         elm_label_line_wrap_set(lb, ELM_WRAP_CHAR);
806         elm_label_wrap_width_set(lb, 201);
807         elm_object_text_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");
808         return lb;
809      }
810    else if (!strcmp(part, "elm.swallow.end"))
811      {
812         Evas_Object *ck;
813         ck = elm_check_add(obj);
814         evas_object_propagate_events_set(ck, EINA_FALSE);
815         elm_check_state_set(ck, tit->onoff);
816         evas_object_smart_callback_add(ck, "changed", my_gl_item_check_changed, data);
817         return ck;
818      }
819    return NULL;
820 }
821
822 Eina_Bool gl3_state_get(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
823 {
824    return EINA_FALSE;
825 }
826
827 void
828 test_genlist4(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
829 {
830    Evas_Object *win, *gl, *bx, *bx2, *bt;
831    static Testitem tit[3];
832
833    win = elm_win_util_standard_add("genlist4", "Genlist 4");
834    elm_win_autodel_set(win, EINA_TRUE);
835
836    bx = elm_box_add(win);
837    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
838    elm_win_resize_object_add(win, bx);
839    evas_object_show(bx);
840
841    gl = elm_genlist_add(win);
842    elm_genlist_mode_set(gl, ELM_LIST_COMPRESS);
843    elm_genlist_multi_select_set(gl, 1);
844    evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
845    evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
846    evas_object_show(gl);
847
848    itc3.item_style     = "default";
849    itc3.func.text_get = gl3_text_get;
850    itc3.func.content_get  = gl3_content_get;
851    itc3.func.state_get = gl3_state_get;
852    itc3.func.del       = NULL;
853
854    tit[0].mode = 0;
855    tit[0].item = elm_genlist_item_append(gl, &itc3,
856                                          &(tit[0])/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_NONE, gl_sel/* func */,
857                                          NULL/* func data */);
858    tit[1].mode = 1;
859    tit[1].item = elm_genlist_item_append(gl, &itc3,
860                                          &(tit[1])/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_NONE, gl_sel/* func */,
861                                          NULL/* func data */);
862    tit[2].mode = 2;
863    tit[2].item = elm_genlist_item_append(gl, &itc3,
864                                          &(tit[2])/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_NONE, gl_sel/* func */,
865                                          NULL/* func data */);
866
867    elm_box_pack_end(bx, gl);
868    evas_object_show(bx);
869
870    bx2 = elm_box_add(win);
871    elm_box_horizontal_set(bx2, EINA_TRUE);
872    elm_box_homogeneous_set(bx2, EINA_TRUE);
873    evas_object_size_hint_weight_set(bx2, EVAS_HINT_EXPAND, 0.0);
874    evas_object_size_hint_align_set(bx2, EVAS_HINT_FILL, EVAS_HINT_FILL);
875
876    bt = elm_button_add(win);
877    elm_object_text_set(bt, "[1]");
878    evas_object_smart_callback_add(bt, "clicked", my_gl_update, &(tit[0]));
879    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
880    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
881    elm_box_pack_end(bx2, bt);
882    evas_object_show(bt);
883
884    bt = elm_button_add(win);
885    elm_object_text_set(bt, "[2]");
886    evas_object_smart_callback_add(bt, "clicked", my_gl_update, &(tit[1]));
887    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
888    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
889    elm_box_pack_end(bx2, bt);
890    evas_object_show(bt);
891
892    bt = elm_button_add(win);
893    elm_object_text_set(bt, "[3]");
894    evas_object_smart_callback_add(bt, "clicked", my_gl_update, &(tit[2]));
895    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
896    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
897    elm_box_pack_end(bx2, bt);
898    evas_object_show(bt);
899
900    elm_box_pack_end(bx, bx2);
901    evas_object_show(bx2);
902
903    evas_object_resize(win, 320, 320);
904    evas_object_show(win);
905 }
906
907
908 /*************/
909 static void
910 my_gl_item_check_changed2(void *data, Evas_Object *obj, void *event_info __UNUSED__)
911 {
912    Testitem *tit = data;
913    tit->onoff = elm_check_state_get(obj);
914    printf("item %p onoff = %i\n", tit, tit->onoff);
915 }
916
917 static Elm_Genlist_Item_Class itc5;
918
919 char *gl5_text_get(void *data, Evas_Object *obj __UNUSED__, const char *part)
920 {
921    const Testitem *tit = data;
922    char buf[256];
923    if (!strcmp(part, "elm.text"))
924      {
925         snprintf(buf, sizeof(buf), "Item mode %i", tit->mode);
926      }
927    else if (!strcmp(part, "elm.text.sub"))
928      {
929         snprintf(buf, sizeof(buf), "%i bottles on the wall", tit->mode);
930      }
931    return strdup(buf);
932 }
933
934 Evas_Object *gl5_content_get(void *data, Evas_Object *obj, const char *part)
935 {
936    const Testitem *tit = data;
937    char buf[PATH_MAX];
938    if (!strcmp(part, "elm.swallow.icon"))
939      {
940         Evas_Object *bx = elm_box_add(obj);
941         Evas_Object *ic;
942         elm_box_horizontal_set(bx, EINA_TRUE);
943         ic = elm_icon_add(obj);
944         snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
945         elm_icon_file_set(ic, buf, NULL);
946         elm_icon_resizable_set(ic, 0, 0);
947         evas_object_show(ic);
948         elm_box_pack_end(bx, ic);
949         ic = elm_icon_add(obj);
950         elm_icon_file_set(ic, buf, NULL);
951         elm_icon_resizable_set(ic, 0, 0);
952         evas_object_show(ic);
953         elm_box_pack_end(bx, ic);
954         elm_box_horizontal_set(bx, EINA_TRUE);
955         evas_object_show(bx);
956         return bx;
957      }
958    else if (!strcmp(part, "elm.swallow.end"))
959      {
960         Evas_Object *ck;
961         ck = elm_check_add(obj);
962         evas_object_propagate_events_set(ck, EINA_FALSE);
963         elm_check_state_set(ck, tit->onoff);
964         evas_object_smart_callback_add(ck, "changed", my_gl_item_check_changed2, data);
965         evas_object_show(ck);
966         return ck;
967      }
968    return NULL;
969 }
970
971 Eina_Bool gl5_state_get(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
972 {
973    return EINA_FALSE;
974 }
975
976 static void
977 item_drag_up(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
978 {
979    printf("drag up\n");
980 }
981
982 static void
983 item_drag_down(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
984 {
985    printf("drag down\n");
986 }
987
988 static void
989 item_drag_left(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
990 {
991    printf("drag left\n");
992 }
993
994 static void
995 item_drag_right(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
996 {
997    printf("drag right\n");
998 }
999
1000 static void
1001 scroll_top(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1002 {
1003    printf("Top edge!\n");
1004 }
1005
1006 static void
1007 scroll_bottom(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1008 {
1009    printf("Bottom edge!\n");
1010 }
1011
1012 static void
1013 scroll_left(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1014 {
1015    printf("Left edge!\n");
1016 }
1017
1018 static void
1019 scroll_right(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1020 {
1021    printf("Right edge!\n");
1022 }
1023
1024 static void
1025 item_drag(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1026 {
1027    printf("drag\n");
1028 }
1029
1030 static void
1031 item_drag_stop(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1032 {
1033    printf("drag stop\n");
1034 }
1035
1036 static void
1037 item_longpress(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1038 {
1039    printf("longpress\n");
1040 }
1041
1042 void
1043 test_genlist5(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1044 {
1045    Evas_Object *win, *gl, *bx, *bx2, *bt;
1046    static Testitem tit[3];
1047
1048    win = elm_win_util_standard_add("genlist5", "Genlist 5");
1049    elm_win_autodel_set(win, EINA_TRUE);
1050
1051    bx = elm_box_add(win);
1052    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1053    elm_win_resize_object_add(win, bx);
1054    evas_object_show(bx);
1055
1056    gl = elm_genlist_add(win);
1057    elm_genlist_select_mode_set(gl, ELM_OBJECT_SELECT_MODE_ALWAYS);
1058    evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
1059    evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1060    evas_object_show(gl);
1061    itc5.item_style     = "double_label";
1062    itc5.func.text_get = gl5_text_get;
1063    itc5.func.content_get  = gl5_content_get;
1064    itc5.func.state_get = gl5_state_get;
1065    itc5.func.del       = NULL;
1066
1067    tit[0].mode = 0;
1068    tit[0].item = elm_genlist_item_append(gl, &itc5,
1069                                          &(tit[0])/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_NONE, gl_sel/* func */,
1070                                          NULL/* func data */);
1071    tit[1].mode = 1;
1072    tit[1].item = elm_genlist_item_append(gl, &itc5,
1073                                          &(tit[1])/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_NONE, gl_sel/* func */,
1074                                          NULL/* func data */);
1075    tit[2].mode = 2;
1076    tit[2].item = elm_genlist_item_append(gl, &itc5,
1077                                          &(tit[2])/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_NONE, gl_sel/* func */,
1078                                          NULL/* func data */);
1079
1080    elm_box_pack_end(bx, gl);
1081    evas_object_show(bx);
1082
1083    evas_object_smart_callback_add(gl, "drag,start,up", item_drag_up, NULL);
1084    evas_object_smart_callback_add(gl, "drag,start,down", item_drag_down, NULL);
1085    evas_object_smart_callback_add(gl, "drag,start,left", item_drag_left, NULL);
1086    evas_object_smart_callback_add(gl, "drag,start,right", item_drag_right, NULL);
1087    evas_object_smart_callback_add(gl, "scroll,edge,top", scroll_top, NULL);
1088    evas_object_smart_callback_add(gl, "scroll,edge,bottom", scroll_bottom, NULL);
1089    evas_object_smart_callback_add(gl, "scroll,edge,left", scroll_left, NULL);
1090    evas_object_smart_callback_add(gl, "scroll,edge,right", scroll_right, NULL);
1091    evas_object_smart_callback_add(gl, "drag", item_drag, NULL);
1092    evas_object_smart_callback_add(gl, "drag,stop", item_drag_stop, NULL);
1093    evas_object_smart_callback_add(gl, "longpressed", item_longpress, NULL);
1094
1095    bx2 = elm_box_add(win);
1096    elm_box_horizontal_set(bx2, EINA_TRUE);
1097    elm_box_homogeneous_set(bx2, EINA_TRUE);
1098    evas_object_size_hint_weight_set(bx2, EVAS_HINT_EXPAND, 0.0);
1099    evas_object_size_hint_align_set(bx2, EVAS_HINT_FILL, EVAS_HINT_FILL);
1100
1101    bt = elm_button_add(win);
1102    elm_object_text_set(bt, "[1]");
1103    evas_object_smart_callback_add(bt, "clicked", my_gl_update, &(tit[0]));
1104    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
1105    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
1106    elm_box_pack_end(bx2, bt);
1107    evas_object_show(bt);
1108
1109    bt = elm_button_add(win);
1110    elm_object_text_set(bt, "[2]");
1111    evas_object_smart_callback_add(bt, "clicked", my_gl_update, &(tit[1]));
1112    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
1113    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
1114    elm_box_pack_end(bx2, bt);
1115    evas_object_show(bt);
1116
1117    bt = elm_button_add(win);
1118    elm_object_text_set(bt, "[3]");
1119    evas_object_smart_callback_add(bt, "clicked", my_gl_update, &(tit[2]));
1120    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
1121    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
1122    elm_box_pack_end(bx2, bt);
1123    evas_object_show(bt);
1124
1125    elm_box_pack_end(bx, bx2);
1126    evas_object_show(bx2);
1127
1128    evas_object_resize(win, 320, 320);
1129    evas_object_show(win);
1130 }
1131
1132 /*************/
1133
1134 static Elm_Genlist_Item_Class *itc4;
1135
1136 static void
1137 gl4_sel(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1138 {
1139    Elm_Object_Item *glit = event_info;
1140    int depth = elm_genlist_item_expanded_depth_get(glit);
1141    printf("expanded depth for selected item is %d\n", depth);
1142 }
1143
1144 static void
1145 gl4_exp(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1146 {
1147    Elm_Object_Item *glit = event_info;
1148    Evas_Object *gl = elm_object_item_widget_get(glit);
1149    int val = (int)(long) elm_object_item_data_get(glit);
1150    val *= 10;
1151    elm_genlist_item_append(gl, itc4,
1152                            (void *)(long) (val + 1)/* item data */,
1153                            glit/* parent */, ELM_GENLIST_ITEM_NONE,
1154                            gl4_sel/* func */,
1155                            NULL/* func data */);
1156    elm_genlist_item_append(gl, itc4,
1157                            (void *)(long) (val + 2)/* item data */,
1158                            glit/* parent */, ELM_GENLIST_ITEM_NONE,
1159                            gl4_sel/* func */,
1160                            NULL/* func data */);
1161    elm_genlist_item_append(gl, itc4,
1162                            (void *)(long) (val + 3)/* item data */,
1163                            glit/* parent */,
1164                            ELM_GENLIST_ITEM_TREE, gl4_sel/* func */,
1165                            NULL/* func data */);
1166 }
1167 static void
1168 gl4_con(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1169 {
1170    Elm_Object_Item *glit = event_info;
1171    elm_genlist_item_subitems_clear(glit);
1172 }
1173
1174 static void
1175 gl4_exp_req(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1176 {
1177    Elm_Object_Item *glit = event_info;
1178    elm_genlist_item_expanded_set(glit, EINA_TRUE);
1179 }
1180
1181 static void
1182 gl4_con_req(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1183 {
1184    Elm_Object_Item *glit = event_info;
1185    elm_genlist_item_expanded_set(glit, EINA_FALSE);
1186 }
1187
1188 char *gl4_text_get(void *data, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
1189 {
1190    char buf[256];
1191    snprintf(buf, sizeof(buf), "Item mode %i", (int)(long)data);
1192    return strdup(buf);
1193 }
1194
1195 Evas_Object *gl4_content_get(void *data __UNUSED__, Evas_Object *obj, const char *part)
1196 {
1197    char buf[PATH_MAX];
1198    if (!strcmp(part, "elm.swallow.icon"))
1199      {
1200         Evas_Object *ic = elm_icon_add(obj);
1201         snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
1202         elm_icon_file_set(ic, buf, NULL);
1203         evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
1204         evas_object_show(ic);
1205         return ic;
1206      }
1207    else if (!strcmp(part, "elm.swallow.end"))
1208      {
1209         Evas_Object *ck;
1210         ck = elm_check_add(obj);
1211         evas_object_propagate_events_set(ck, EINA_FALSE);
1212         evas_object_show(ck);
1213         return ck;
1214      }
1215    return NULL;
1216 }
1217
1218 Eina_Bool gl4_state_get(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
1219 {
1220    return EINA_FALSE;
1221 }
1222
1223 void gl4_del(void *data __UNUSED__, Evas_Object *obj __UNUSED__)
1224 {
1225    printf("item deleted.\n");
1226 }
1227
1228 void
1229 test_genlist6(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1230 {
1231    Evas_Object *win, *gl, *bx, *bx2, *bt;
1232
1233    win = elm_win_util_standard_add("genlist-tree", "Genlist Tree");
1234    elm_win_autodel_set(win, EINA_TRUE);
1235
1236    bx = elm_box_add(win);
1237    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1238    elm_win_resize_object_add(win, bx);
1239    evas_object_show(bx);
1240
1241    gl = elm_genlist_add(win);
1242    evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
1243    evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1244    evas_object_show(gl);
1245
1246    itc4 = elm_genlist_item_class_new();
1247    itc4->item_style     = "default";
1248    itc4->func.text_get = gl4_text_get;
1249    itc4->func.content_get  = gl4_content_get;
1250    itc4->func.state_get = gl4_state_get;
1251    itc4->func.del       = gl4_del;
1252
1253    elm_genlist_item_append(gl, itc4,
1254                            (void *)1/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_TREE, gl4_sel/* func */,
1255                            NULL/* func data */);
1256    elm_genlist_item_append(gl, itc4,
1257                            (void *)2/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_TREE, gl4_sel/* func */,
1258                            NULL/* func data */);
1259    elm_genlist_item_append(gl, itc4,
1260                            (void *)3/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_NONE, gl4_sel/* func */,
1261                            NULL/* func data */);
1262    elm_genlist_item_class_free(itc4);
1263    evas_object_smart_callback_add(gl, "expand,request", gl4_exp_req, gl);
1264    evas_object_smart_callback_add(gl, "contract,request", gl4_con_req, gl);
1265    evas_object_smart_callback_add(gl, "expanded", gl4_exp, gl);
1266    evas_object_smart_callback_add(gl, "contracted", gl4_con, gl);
1267
1268    elm_box_pack_end(bx, gl);
1269    evas_object_show(bx);
1270
1271    bx2 = elm_box_add(win);
1272    elm_box_horizontal_set(bx2, EINA_TRUE);
1273    elm_box_homogeneous_set(bx2, EINA_TRUE);
1274    evas_object_size_hint_weight_set(bx2, EVAS_HINT_EXPAND, 0.0);
1275    evas_object_size_hint_align_set(bx2, EVAS_HINT_FILL, EVAS_HINT_FILL);
1276
1277    bt = elm_button_add(win);
1278    elm_object_text_set(bt, "[1]");
1279    //   evas_object_smart_callback_add(bt, "clicked", my_gl_update, &(tit[0]));
1280    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
1281    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
1282    elm_box_pack_end(bx2, bt);
1283    evas_object_show(bt);
1284
1285    bt = elm_button_add(win);
1286    elm_object_text_set(bt, "[2]");
1287    //   evas_object_smart_callback_add(bt, "clicked", my_gl_update, &(tit[1]));
1288    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
1289    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
1290    elm_box_pack_end(bx2, bt);
1291    evas_object_show(bt);
1292
1293    bt = elm_button_add(win);
1294    elm_object_text_set(bt, "[3]");
1295    //   evas_object_smart_callback_add(bt, "clicked", my_gl_update, &(tit[2]));
1296    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
1297    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
1298    elm_box_pack_end(bx2, bt);
1299    evas_object_show(bt);
1300
1301    elm_box_pack_end(bx, bx2);
1302    evas_object_show(bx2);
1303
1304    evas_object_resize(win, 320, 320);
1305    evas_object_show(win);
1306 }
1307
1308 /*************/
1309
1310 struct genlist7_data
1311 {
1312    Evas_Object *win, *naviframe;
1313 };
1314
1315 static Elm_Genlist_Item_Class itc7;
1316
1317 static void
1318 gl_sel7(void *data, Evas_Object *obj, void *event_info)
1319 {
1320    if (!event_info) return;
1321    elm_genlist_item_item_class_update(event_info, &itc7);
1322    printf("sel item data [%p] on genlist obj [%p], item pointer [%p], new item style [%s] \n", data, obj, event_info, itc7.item_style);
1323 }
1324
1325 static void
1326 test_genlist7_back_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1327 {
1328    struct genlist7_data *info = data;
1329    if (!info) return;
1330
1331    elm_naviframe_item_pop(info->naviframe);
1332 }
1333
1334 static void
1335 test_genlist7_swipe(void *data, Evas_Object *obj __UNUSED__, void *event_info)
1336 {
1337    struct genlist7_data *info = data;
1338    Evas_Object *box, *entry, *button;
1339    char item_data[] = "Just a simple test";
1340
1341    if ((!event_info) || (!data)) return;
1342
1343    box = elm_box_add(info->win);
1344    elm_box_homogeneous_set(box, EINA_FALSE);
1345    evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1346    evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
1347    evas_object_show(box);
1348
1349    entry = elm_entry_add(info->win);
1350    elm_entry_scrollable_set(entry, EINA_TRUE);
1351    elm_entry_editable_set(entry, EINA_FALSE);
1352    elm_object_text_set(entry, item_data);
1353    evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1354    evas_object_size_hint_align_set(entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
1355    evas_object_show(entry);
1356
1357    button = elm_button_add(info->win);
1358    elm_object_text_set(button, "back");
1359    evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, 0);
1360    evas_object_size_hint_align_set(button, EVAS_HINT_FILL, 0);
1361    evas_object_smart_callback_add(button, "clicked", test_genlist7_back_cb,
1362                                   info);
1363    evas_object_show(button);
1364
1365    elm_box_pack_start(box, entry);
1366    elm_box_pack_end(box, button);
1367
1368    elm_naviframe_item_simple_push(info->naviframe, box);
1369 }
1370
1371 void
1372 test_genlist7(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1373 {
1374    Evas_Object *win, *gl, *naviframe;
1375    static struct genlist7_data info;
1376    static Testitem tit[3];
1377
1378    win = elm_win_util_standard_add("genlist7", "Genlist 7");
1379    elm_win_autodel_set(win, EINA_TRUE);
1380    info.win = win;
1381
1382    naviframe = elm_naviframe_add(win);
1383    elm_win_resize_object_add(win, naviframe);
1384    evas_object_size_hint_weight_set(naviframe, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1385    evas_object_size_hint_align_set(naviframe, EVAS_HINT_FILL, EVAS_HINT_FILL);
1386    evas_object_show(naviframe);
1387    info.naviframe = naviframe;
1388
1389    gl = elm_genlist_add(win);
1390    evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
1391    evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1392    evas_object_smart_callback_add(gl, "swipe", test_genlist7_swipe, &info);
1393    evas_object_show(gl);
1394    elm_naviframe_item_simple_push(naviframe, gl);
1395
1396    itc2.item_style     = "default";
1397    itc2.func.text_get = gl2_text_get;
1398    itc2.func.content_get  = gl2_content_get;
1399    itc2.func.state_get = gl2_state_get;
1400    itc2.func.del       = NULL;
1401
1402    itc7.item_style     = "double_label";
1403    itc7.func.text_get = gl5_text_get;
1404    itc7.func.content_get  = gl5_content_get;
1405    itc7.func.state_get = gl5_state_get;
1406    itc7.func.del       = NULL;
1407
1408    tit[0].mode = 0;
1409    tit[0].item = elm_genlist_item_append(gl, &itc2,
1410                                          &(tit[0])/* item data */, NULL/* parent */,
1411                                          ELM_GENLIST_ITEM_NONE, gl_sel7/* func */,
1412                                          NULL/* func data */);
1413    tit[1].mode = 1;
1414    tit[1].item = elm_genlist_item_append(gl, &itc2,
1415                                          &(tit[1])/* item data */, NULL/* parent */,
1416                                          ELM_GENLIST_ITEM_NONE, gl_sel7/* func */,
1417                                          NULL/* func data */);
1418    tit[2].mode = 2;
1419    tit[2].item = elm_genlist_item_append(gl, &itc2,
1420                                          &(tit[2])/* item data */, NULL/* parent */,
1421                                          ELM_GENLIST_ITEM_NONE, gl_sel7/* func */,
1422                                          NULL/* func data */);
1423
1424    evas_object_resize(win, 320, 320);
1425    evas_object_show(win);
1426 }
1427
1428 /*************/
1429
1430 static Elm_Genlist_Item_Class itc_group;
1431
1432 char *gl8_text_get(void *data, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
1433 {
1434    char buf[256];
1435    snprintf(buf, sizeof(buf), "Group Index # %i (Item # %i)",  (int)((long)data / 10), (int)(long)data);
1436    return strdup(buf);
1437 }
1438
1439 static void
1440 _bt_show_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1441 {
1442    elm_genlist_item_show(data, ELM_GENLIST_ITEM_SCROLLTO_TOP);
1443 }
1444
1445 static void
1446 _bt_bring_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1447 {
1448    elm_genlist_item_bring_in(data, ELM_GENLIST_ITEM_SCROLLTO_TOP);
1449 }
1450
1451 void
1452 test_genlist8(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1453 {
1454    Evas_Object *win, *gl, *bt[8], *bx, *bx2, *bx3;
1455    Elm_Object_Item *gli = NULL, *git = NULL;
1456    int i, bt_num;
1457
1458    win = elm_win_util_standard_add("genlist-group", "Genlist Group");
1459    elm_win_autodel_set(win, EINA_TRUE);
1460
1461    bx = elm_box_add(win);
1462    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1463    elm_win_resize_object_add(win, bx);
1464    evas_object_show(bx);
1465
1466    gl = elm_genlist_add(win);
1467    evas_object_smart_callback_add(gl, "selected", _gl_selected, NULL);
1468    evas_object_smart_callback_add(gl, "clicked,double", _gl_double_clicked, NULL);
1469    evas_object_smart_callback_add(gl, "longpressed", _gl_longpress, NULL);
1470    evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1471    evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
1472    elm_box_pack_end(bx, gl);
1473    evas_object_show(gl);
1474
1475    itc1 = elm_genlist_item_class_new();
1476    itc1->item_style     = "default";
1477    itc1->func.text_get = gl_text_get;
1478    itc1->func.content_get  = gl_content_get;
1479    itc1->func.state_get = gl_state_get;
1480    itc1->func.del       = NULL;
1481
1482    itc_group.item_style     = "group_index";
1483    itc_group.func.text_get = gl8_text_get;
1484    itc_group.func.content_get  = NULL;
1485    itc_group.func.state_get = NULL;
1486    itc_group.func.del       = NULL;
1487
1488    bx2 = elm_box_add(win);
1489    elm_box_horizontal_set(bx2, EINA_TRUE);
1490    elm_box_homogeneous_set(bx2, EINA_TRUE);
1491    evas_object_size_hint_weight_set(bx2, EVAS_HINT_EXPAND, 0.0);
1492    evas_object_size_hint_align_set(bx2, EVAS_HINT_FILL, EVAS_HINT_FILL);
1493
1494    bt_num = 0;
1495    bt[bt_num] = elm_button_add(win);
1496    elm_object_text_set(bt[bt_num], "Show 0");
1497    evas_object_size_hint_align_set(bt[bt_num], EVAS_HINT_FILL, EVAS_HINT_FILL);
1498    evas_object_size_hint_weight_set(bt[bt_num], EVAS_HINT_EXPAND, 0.0);
1499    evas_object_show(bt[bt_num]);
1500    elm_box_pack_end(bx2, bt[bt_num]);
1501
1502    bt[++bt_num] = elm_button_add(win);
1503    elm_object_text_set(bt[bt_num], "Show 26");
1504    evas_object_size_hint_align_set(bt[bt_num], EVAS_HINT_FILL, EVAS_HINT_FILL);
1505    evas_object_size_hint_weight_set(bt[bt_num], EVAS_HINT_EXPAND, 0.0);
1506    evas_object_show(bt[bt_num]);
1507    elm_box_pack_end(bx2, bt[bt_num]);
1508
1509    bt[++bt_num] = elm_button_add(win);
1510    elm_object_text_set(bt[bt_num], "Show 101");
1511    evas_object_size_hint_align_set(bt[bt_num], EVAS_HINT_FILL, EVAS_HINT_FILL);
1512    evas_object_size_hint_weight_set(bt[bt_num], EVAS_HINT_EXPAND, 0.0);
1513    evas_object_show(bt[bt_num]);
1514    elm_box_pack_end(bx2, bt[bt_num]);
1515
1516    bt[++bt_num] = elm_button_add(win);
1517    elm_object_text_set(bt[bt_num], "Show 480");
1518    evas_object_size_hint_align_set(bt[bt_num], EVAS_HINT_FILL, EVAS_HINT_FILL);
1519    evas_object_size_hint_weight_set(bt[bt_num], EVAS_HINT_EXPAND, 0.0);
1520    evas_object_show(bt[bt_num]);
1521    elm_box_pack_end(bx2, bt[bt_num]);
1522
1523    elm_box_pack_end(bx, bx2);
1524    evas_object_show(bx2);
1525
1526    bx3 = elm_box_add(win);
1527    elm_box_horizontal_set(bx3, EINA_TRUE);
1528    elm_box_homogeneous_set(bx3, EINA_TRUE);
1529    evas_object_size_hint_weight_set(bx3, EVAS_HINT_EXPAND, 0.0);
1530    evas_object_size_hint_align_set(bx3, EVAS_HINT_FILL, EVAS_HINT_FILL);
1531
1532    bt[++bt_num] = elm_button_add(win);
1533    elm_object_text_set(bt[bt_num], "Bring top 0");
1534    evas_object_size_hint_align_set(bt[bt_num], EVAS_HINT_FILL, EVAS_HINT_FILL);
1535    evas_object_size_hint_weight_set(bt[bt_num], EVAS_HINT_EXPAND, 0.0);
1536    evas_object_show(bt[bt_num]);
1537    elm_box_pack_end(bx3, bt[bt_num]);
1538
1539    bt[++bt_num] = elm_button_add(win);
1540    elm_object_text_set(bt[bt_num], "Bring top 31");
1541    evas_object_size_hint_align_set(bt[bt_num], EVAS_HINT_FILL, EVAS_HINT_FILL);
1542    evas_object_size_hint_weight_set(bt[bt_num], EVAS_HINT_EXPAND, 0.0);
1543    evas_object_show(bt[bt_num]);
1544    elm_box_pack_end(bx3, bt[bt_num]);
1545
1546    bt[++bt_num] = elm_button_add(win);
1547    elm_object_text_set(bt[bt_num], "Bring top 239");
1548    evas_object_size_hint_align_set(bt[bt_num], EVAS_HINT_FILL, EVAS_HINT_FILL);
1549    evas_object_size_hint_weight_set(bt[bt_num], EVAS_HINT_EXPAND, 0.0);
1550    evas_object_show(bt[bt_num]);
1551    elm_box_pack_end(bx3, bt[bt_num]);
1552
1553    bt[++bt_num] = elm_button_add(win);
1554    elm_object_text_set(bt[bt_num], "Bring top 477");
1555    evas_object_size_hint_align_set(bt[bt_num], EVAS_HINT_FILL, EVAS_HINT_FILL);
1556    evas_object_size_hint_weight_set(bt[bt_num], EVAS_HINT_EXPAND, 0.0);
1557    evas_object_show(bt[bt_num]);
1558    elm_box_pack_end(bx3, bt[bt_num]);
1559
1560    elm_box_pack_end(bx, bx3);
1561    evas_object_show(bx3);
1562
1563    for (i = 0; i < 500; i++)
1564      {
1565         if (!(i % 10))
1566           {
1567              gli = git = elm_genlist_item_append(gl, &itc_group,
1568                                                  (void *)(long)i/* item data */,
1569                                                  NULL/* parent */,
1570                                                  ELM_GENLIST_ITEM_GROUP,
1571                                                  gl_sel/* func */,
1572                                                  (void *)(long)(i * 10)/* func data */);
1573              elm_genlist_item_select_mode_set(git, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1574           }
1575         else if (git)
1576           {
1577              gli = elm_genlist_item_append(gl, itc1,
1578                                            (void *)(long)i/* item data */,
1579                                            git/* parent */,
1580                                            ELM_GENLIST_ITEM_NONE,
1581                                            gl_sel/* func */,
1582                                            (void *)(long)(i * 10)/* func data */);
1583           }
1584         switch (i)
1585           {
1586            case 0:
1587               evas_object_smart_callback_add(bt[0], "clicked", _bt_show_cb, gli);
1588               evas_object_smart_callback_add(bt[4], "clicked", _bt_bring_cb, gli);
1589               break;
1590            case 26:
1591               evas_object_smart_callback_add(bt[1], "clicked", _bt_show_cb, gli);
1592               break;
1593            case 31:
1594               evas_object_smart_callback_add(bt[5], "clicked", _bt_bring_cb, gli);
1595               break;
1596            case 101:
1597               evas_object_smart_callback_add(bt[2], "clicked", _bt_show_cb, gli);
1598               break;
1599            case 239:
1600               evas_object_smart_callback_add(bt[6], "clicked", _bt_bring_cb, gli);
1601               break;
1602            case 477:
1603               evas_object_smart_callback_add(bt[7], "clicked", _bt_bring_cb, gli);
1604               break;
1605            case 480:
1606               evas_object_smart_callback_add(bt[3], "clicked", _bt_show_cb, gli);
1607               break;
1608           }
1609      }
1610    elm_genlist_item_class_free(itc1);
1611
1612    evas_object_resize(win, 480, 800);
1613    evas_object_show(win);
1614 }
1615
1616 /*************/
1617
1618 static void
1619 gl9_exp(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1620 {
1621    Elm_Object_Item *glit = event_info;
1622    Evas_Object *gl = elm_object_item_widget_get(glit);
1623    int val = (int)(long) elm_object_item_data_get(glit);
1624    val *= 10;
1625    elm_genlist_item_append(gl, itc1,
1626                            (void *)(long) (val + 1)/* item data */,
1627                            glit/* parent */,
1628                            ELM_GENLIST_ITEM_NONE, gl4_sel/* func */,
1629                            NULL/* func data */);
1630    elm_genlist_item_append(gl, itc1,
1631                            (void *)(long) (val + 2)/* item data */,
1632                            glit/* parent */,
1633                            ELM_GENLIST_ITEM_NONE, gl4_sel/* func */,
1634                            NULL/* func data */);
1635    elm_genlist_item_append(gl, itc1,
1636                            (void *)(long) (val + 3)/* item data */,
1637                            glit/* parent */,
1638                            ELM_GENLIST_ITEM_TREE, gl4_sel/* func */,
1639                            NULL/* func data */);
1640 }
1641
1642 static void
1643 gl9_con(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1644 {
1645    Elm_Object_Item *glit = event_info;
1646    elm_genlist_item_subitems_clear(glit);
1647 }
1648
1649 static void
1650 gl9_exp_req(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1651 {
1652    Elm_Object_Item *glit = event_info;
1653    elm_genlist_item_expanded_set(glit, EINA_TRUE);
1654 }
1655
1656 static void
1657 gl9_con_req(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1658 {
1659    Elm_Object_Item *glit = event_info;
1660    elm_genlist_item_expanded_set(glit, EINA_FALSE);
1661 }
1662
1663 void
1664 test_genlist9(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1665 {
1666    Evas_Object *win, *gl, *bx;
1667    Elm_Object_Item *git;
1668
1669    win = elm_win_util_standard_add("genlist-group-tree", "Genlist Group Tree");
1670    elm_win_autodel_set(win, EINA_TRUE);
1671
1672    bx = elm_box_add(win);
1673    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1674    elm_win_resize_object_add(win, bx);
1675    evas_object_show(bx);
1676
1677    gl = elm_genlist_add(win);
1678    evas_object_smart_callback_add(gl, "selected", _gl_selected, NULL);
1679    evas_object_smart_callback_add(gl, "clicked,double", _gl_double_clicked, NULL);
1680    evas_object_smart_callback_add(gl, "longpressed", _gl_longpress, NULL);
1681    evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1682    evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
1683    elm_box_pack_end(bx, gl);
1684    evas_object_show(gl);
1685
1686    itc1 = elm_genlist_item_class_new();
1687    itc1->item_style     = "default";
1688    itc1->func.text_get = gl_text_get;
1689    itc1->func.content_get  = gl_content_get;
1690    itc1->func.state_get = gl_state_get;
1691    itc1->func.del       = NULL;
1692
1693    itc_group.item_style     = "group_index";
1694    itc_group.func.text_get = gl8_text_get;
1695    itc_group.func.content_get  = NULL;
1696    itc_group.func.state_get = NULL;
1697    itc_group.func.del       = NULL;
1698
1699    git = elm_genlist_item_append(gl, &itc_group,
1700                                  (void *)0/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_GROUP, gl4_sel/* func */,
1701                                  NULL/* func data */);
1702    elm_genlist_item_select_mode_set(git, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1703
1704    elm_genlist_item_append(gl, itc1,
1705                            (void *)1/* item data */, git/* parent */, ELM_GENLIST_ITEM_TREE, gl4_sel/* func */,
1706                            NULL/* func data */);
1707    elm_genlist_item_append(gl, itc1,
1708                            (void *)2/* item data */, git/* parent */, ELM_GENLIST_ITEM_NONE, gl4_sel/* func */,
1709                            NULL/* func data */);
1710    elm_genlist_item_append(gl, itc1,
1711                            (void *)3/* item data */, git/* parent */, ELM_GENLIST_ITEM_TREE, gl4_sel/* func */,
1712                            NULL/* func data */);
1713    git = elm_genlist_item_append(gl, &itc_group,
1714                                  (void *)4/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_GROUP, gl4_sel/* func */,
1715                                  NULL/* func data */);
1716    elm_genlist_item_select_mode_set(git, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1717
1718    elm_genlist_item_append(gl, itc1,
1719                            (void *)5/* item data */, git/* parent */, ELM_GENLIST_ITEM_TREE, gl4_sel/* func */,
1720                            NULL/* func data */);
1721    elm_genlist_item_append(gl, itc1,
1722                            (void *)6/* item data */, git/* parent */, ELM_GENLIST_ITEM_NONE, gl4_sel/* func */,
1723                            NULL/* func data */);
1724    elm_genlist_item_append(gl, itc1,
1725                            (void *)7/* item data */, git/* parent */, ELM_GENLIST_ITEM_TREE, gl4_sel/* func */,
1726                            NULL/* func data */);
1727    elm_genlist_item_class_free(itc1);
1728
1729    evas_object_smart_callback_add(gl, "expand,request", gl9_exp_req, gl);
1730    evas_object_smart_callback_add(gl, "contract,request", gl9_con_req, gl);
1731    evas_object_smart_callback_add(gl, "expanded", gl9_exp, gl);
1732    evas_object_smart_callback_add(gl, "contracted", gl9_con, gl);
1733
1734    evas_object_resize(win, 480, 800);
1735    evas_object_show(win);
1736 }
1737
1738 /*************/
1739
1740 static Elm_Genlist_Item_Class itc10;
1741 static char *mode_type[] = { "slide", "rotate" };
1742
1743 char *gl10_text_get(void *data, Evas_Object *obj __UNUSED__, const char *part)
1744 {
1745    char buf[256];
1746    if (!strcmp(part, "elm.text.mode"))
1747      snprintf(buf, sizeof(buf), "Mode # %i", (int)(long)data);
1748    else
1749      snprintf(buf, sizeof(buf), "Item # %i", (int)(long)data);
1750    return strdup(buf);
1751 }
1752
1753 Evas_Object *gl10_content_get(void *data __UNUSED__, Evas_Object *obj, const char *part)
1754 {
1755    char buf[PATH_MAX];
1756    Evas_Object *ic = elm_icon_add(obj);
1757    if (!strcmp(part, "elm.swallow.end"))
1758      snprintf(buf, sizeof(buf), "%s/images/bubble.png", elm_app_data_dir_get());
1759    else
1760      snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
1761    elm_icon_file_set(ic, buf, NULL);
1762    evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
1763    return ic;
1764 }
1765
1766 static void
1767 _gl_sel10(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1768 {
1769    if (!data) return;
1770    int v = elm_radio_value_get(data);
1771    if (v == 1)
1772      elm_genlist_item_decorate_mode_set(event_info, mode_type[v], EINA_TRUE);
1773 }
1774
1775 static void
1776 _my_gl_mode_right(void *data, Evas_Object *obj __UNUSED__, void *event_info)
1777 {
1778    if (!data) return;
1779    int v = elm_radio_value_get(data);
1780    if (v == 0)
1781      elm_genlist_item_decorate_mode_set(event_info, mode_type[v], EINA_TRUE);
1782 }
1783
1784 static void
1785 _my_gl_mode_left(void *data, Evas_Object *obj __UNUSED__, void *event_info)
1786 {
1787    if (!data) return;
1788    int v = elm_radio_value_get(data);
1789    if (v == 0)
1790      elm_genlist_item_decorate_mode_set(event_info, mode_type[v], EINA_FALSE);
1791 }
1792
1793 static void
1794 _my_gl_mode_cancel(void *data, Evas_Object *obj, void *event_info __UNUSED__)
1795 {
1796    fprintf(stderr, "drag\n");
1797    if (!data) return;
1798    int v = elm_radio_value_get(data);
1799    Elm_Object_Item *glit = (Elm_Object_Item *) elm_genlist_decorated_item_get(obj);
1800    if (glit) elm_genlist_item_decorate_mode_set(glit, mode_type[v], EINA_FALSE);
1801 }
1802
1803 void
1804 test_genlist10(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1805 {
1806    Evas_Object *win, *fr, *bx, *bx2, *rd, *rdg, *gl;
1807    int i;
1808
1809    win = elm_win_util_standard_add("genlist-decorate-item-mode", "Genlist Decorate Item Mode");
1810    elm_win_autodel_set(win, EINA_TRUE);
1811
1812    bx = elm_box_add(win);
1813    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1814    elm_win_resize_object_add(win, bx);
1815    evas_object_show(bx);
1816
1817    fr = elm_frame_add(win);
1818    elm_object_text_set(fr, "Decorate Mode Type");
1819    elm_box_pack_end(bx, fr);
1820    evas_object_show(fr);
1821
1822    bx2 = elm_box_add(win);
1823    elm_object_content_set(fr, bx2);
1824    evas_object_show(bx2);
1825
1826    rd = elm_radio_add(win);
1827    evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1828    elm_radio_state_value_set(rd, 0);
1829    elm_object_text_set(rd, "Slide : Sweep genlist items to the right.");
1830    evas_object_show(rd);
1831    elm_box_pack_end(bx2, rd);
1832    rdg = rd;
1833
1834    rd = elm_radio_add(win);
1835    evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1836    elm_radio_state_value_set(rd, 1);
1837    elm_object_text_set(rd, "Rotate : Click each item.");
1838    elm_radio_group_add(rd, rdg);
1839    evas_object_show(rd);
1840    elm_box_pack_end(bx2, rd);
1841
1842    gl = elm_genlist_add(win);
1843    evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
1844    evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1845    evas_object_smart_callback_add(gl, "drag,start,right", _my_gl_mode_right, rdg);
1846    evas_object_smart_callback_add(gl, "drag,start,left", _my_gl_mode_left, rdg);
1847    evas_object_smart_callback_add(gl, "drag,start,up", _my_gl_mode_cancel, rdg);
1848    evas_object_smart_callback_add(gl, "drag,start,down", _my_gl_mode_cancel, rdg);
1849    evas_object_show(gl);
1850
1851    itc10.item_style     = "default";
1852    itc10.decorate_item_style = "mode";
1853    itc10.func.text_get = gl10_text_get;
1854    itc10.func.content_get  = gl10_content_get;
1855    itc10.func.state_get = gl_state_get;
1856    itc10.func.del       = NULL;
1857
1858    for (i = 0; i < 50; i++)
1859      elm_genlist_item_append(gl,
1860                              &itc10,
1861                              (void *)(long)(1000 + i)/* item data */,
1862                              NULL/* parent */,
1863                              ELM_GENLIST_ITEM_NONE/* flags */,
1864                              _gl_sel10/* func */,
1865                              rdg/* func data */);
1866
1867    elm_box_pack_end(bx, gl);
1868
1869    evas_object_resize(win, 520, 520);
1870    evas_object_show(win);
1871 }
1872
1873 /*************/
1874
1875 static void
1876 _reorder_tg_changed_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__)
1877 {
1878    elm_genlist_reorder_mode_set(data, elm_check_state_get(obj));
1879 }
1880
1881 /**
1882  * gl_moved is called after an item was reordered.
1883  * This is only called when reorder mode is enabled.
1884  *
1885  * @param data         :  the genlist object passed as data.
1886  * @param obj          :  the genlist object.
1887  * @param item         :  the moved item.
1888  *
1889  *  the item(*item) had been moved
1890  *
1891  */
1892 static void gl_moved(Evas_Object *data __UNUSED__, Evas_Object *obj __UNUSED__, Elm_Object_Item *item __UNUSED__)
1893 {
1894    // if needed, add application logic.
1895 }
1896
1897 /**
1898  * gl_moved_after is called after an item was reordered.
1899  * This is only called when reorder mode is enabled.
1900  *
1901  * @param data         :  the genlist object passed as data.
1902  * @param obj          :  the genlist object.
1903  * @param item         :  the moved item.
1904  *
1905  *  the item(*item) had been moved after the given relative item(*rel_item) in list.
1906  *
1907  */
1908 static void gl_moved_after(Evas_Object *data __UNUSED__, Evas_Object *obj __UNUSED__, Elm_Object_Item *item __UNUSED__)
1909 {
1910    // if needed, add application logic.
1911    Elm_Object_Item *it;
1912    it = elm_genlist_item_prev_get(item);
1913    printf("it=%p, prev_it=%p\n",item,it);
1914 }
1915
1916 /**
1917  * gl_moved_before is called after an item was reordered.
1918  * This is only called when reorder mode is enabled.
1919  *
1920  * @param data         :  the genlist object passed as data.
1921  * @param obj          :  the genlist object.
1922  * @param item         :  the moved item.
1923  *
1924  *  the item(*item) had been moved before the given relative item(*rel_item) in list.
1925  *
1926  */
1927 static void gl_moved_before(Evas_Object *data __UNUSED__, Evas_Object *obj __UNUSED__, Elm_Object_Item *item __UNUSED__)
1928 {
1929    // if needed, add application logic.
1930    Elm_Object_Item *it;
1931    it = elm_genlist_item_next_get(item);
1932    printf("it=%p, next_it=%p\n",item,it);
1933 }
1934
1935 void
1936 test_genlist11(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1937 {
1938    Evas_Object *win, *fr, *lb, *bx, *tg, *gl;
1939    int i;
1940
1941    win = elm_win_util_standard_add("genlist-reorder-mode", "Genlist Reorder Mode");
1942    elm_win_autodel_set(win, EINA_TRUE);
1943
1944    bx = elm_box_add(win);
1945    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1946    elm_win_resize_object_add(win, bx);
1947    evas_object_show(bx);
1948
1949    fr = elm_frame_add(win);
1950
1951    elm_object_text_set(fr, "Reorder Mode");
1952    elm_box_pack_end(bx, fr);
1953    evas_object_show(fr);
1954
1955    lb = elm_label_add(win);
1956    elm_object_text_set(lb,
1957                        "Enable reorder mode if you want to move item.<br/>"
1958                        "Then long press and drag item.");
1959    elm_object_content_set(fr, lb);
1960    evas_object_show(lb);
1961
1962    gl = elm_genlist_add(win);
1963    evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
1964    evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1965    evas_object_show(gl);
1966
1967    tg = elm_check_add(win);
1968    elm_object_style_set(tg, "toggle");
1969    elm_object_text_set(tg, "Reorder Mode:");
1970    elm_check_state_set(tg, elm_config_mirrored_get());
1971    evas_object_smart_callback_add(tg, "changed", _reorder_tg_changed_cb, gl);
1972    elm_box_pack_end(bx, tg);
1973    evas_object_show(tg);
1974
1975    itc1 = elm_genlist_item_class_new();
1976    itc1->item_style     = "default";
1977    itc1->func.text_get = gl_text_get;
1978    itc1->func.content_get  = gl_content_get;
1979    itc1->func.state_get = gl_state_get;
1980    itc1->func.del       = NULL;
1981    evas_object_smart_callback_add(gl, "moved", (Evas_Smart_Cb)gl_moved, gl);
1982    evas_object_smart_callback_add(gl, "moved,after", (Evas_Smart_Cb)gl_moved_after, gl);
1983    evas_object_smart_callback_add(gl, "moved,before", (Evas_Smart_Cb)gl_moved_before, gl);
1984
1985    for (i = 0; i < 50; i++)
1986      elm_genlist_item_append(gl,
1987                              itc1,
1988                              (void *)(long)(1 + i)/* item data */,
1989                              NULL/* parent */,
1990                              ELM_GENLIST_ITEM_NONE/* flags */,
1991                              NULL/* func */,
1992                              NULL/* func data */);
1993
1994    elm_genlist_item_class_free(itc1);
1995
1996    elm_box_pack_end(bx, gl);
1997
1998    evas_object_resize(win, 400, 500);
1999    evas_object_show(win);
2000 }
2001
2002 char *gl12_text_get(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
2003 {
2004    return strdup("Enlightenment is not just a window manager for Linux/X11 and others, but also a whole suite of libraries to help you create beautiful user interfaces with much less work than doing it the old fashioned way and fighting with traditional toolkits, not to mention a traditional window manager. It covers uses from small mobile devices like phones all the way to powerful multi-core desktops (which are the primary development environment).");
2005 }
2006
2007 void
2008 test_genlist12(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2009 {
2010    Evas_Object *win, *bx, *gl;
2011    int i;
2012
2013    win = elm_win_util_standard_add("genlist-textblock", "Genlist Textblock");
2014    elm_win_autodel_set(win, EINA_TRUE);
2015
2016    bx = elm_box_add(win);
2017    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2018    elm_win_resize_object_add(win, bx);
2019    evas_object_show(bx);
2020
2021    gl = elm_genlist_add(win);
2022    elm_genlist_mode_set(gl, ELM_LIST_COMPRESS);
2023    evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2024    evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
2025    elm_box_pack_end(bx, gl);
2026    evas_object_show(gl);
2027
2028    itc1 = elm_genlist_item_class_new();
2029    itc1->item_style     = "message";
2030    itc1->func.text_get = gl12_text_get;
2031    itc1->func.content_get  = gl_content_get;
2032    itc1->func.state_get = gl_state_get;
2033    itc1->func.del       = NULL;
2034
2035    for (i = 0; i < 1000; i++)
2036      {
2037         elm_genlist_item_append(gl, itc1,
2038                                 (void *)(long)i/* item data */,
2039                                 NULL/* parent */,
2040                                 ELM_GENLIST_ITEM_NONE,
2041                                 gl_sel/* func */,
2042                                 (void *)(long)(i * 10)/* func data */);
2043      }
2044    elm_genlist_item_class_free(itc1);
2045
2046    evas_object_resize(win, 400, 500);
2047    evas_object_show(win);
2048 }
2049
2050 static int
2051 gl13_cmp(const void *pa, const void *pb)
2052 {
2053    const Elm_Object_Item *ia = pa, *ib = pb;
2054    int a = (int)(long) elm_object_item_data_get(ia);
2055    int b = (int)(long) elm_object_item_data_get(ib);
2056    return a - b;
2057 }
2058
2059 void
2060 test_genlist13(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2061 {
2062    Elm_Object_Item *pi[6];
2063    Evas_Object *win, *bx, *gl; int i, base, idx[3] = {1, 10, 15};
2064
2065    win = elm_win_util_standard_add("genlist-tree-insert-sorted", "Genlist Tree, Insert Sorted");
2066    elm_win_autodel_set(win, EINA_TRUE);
2067
2068    bx = elm_box_add(win);
2069    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2070    elm_win_resize_object_add(win, bx);
2071    evas_object_show(bx);
2072
2073    gl = elm_genlist_add(win);
2074    evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
2075    evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2076    evas_object_show(gl);
2077
2078    itc4 = elm_genlist_item_class_new();
2079    itc4->item_style = "default";
2080    itc4->func.text_get = gl4_text_get;
2081    itc4->func.content_get = NULL;
2082    itc4->func.state_get = NULL;
2083    itc4->func.del = NULL;
2084
2085    /* mixed order to test insert sorted */
2086
2087    for (i = 0; i < 3; i++)
2088      {
2089         pi[i] = elm_genlist_item_sorted_insert
2090           (gl, itc4, (void *)(long)idx[i]/* item data */, NULL/* parent */,
2091            ELM_GENLIST_ITEM_TREE, gl13_cmp/* cmp */,
2092            NULL/* func */, NULL/* func data */);
2093      }
2094
2095    for (i = 0, base = 100; i < 3; i++, base += 100)
2096      {
2097         int j;
2098         for (j = 0; j < 3; j++)
2099           {
2100              elm_genlist_item_sorted_insert
2101                (gl, itc4, (void *)(long)(idx[j] + base)/* item data */,
2102                 pi[i]/* parent */, ELM_GENLIST_ITEM_NONE,
2103                 gl13_cmp/* cmp */, NULL/* func */, NULL/* func data */);
2104           }
2105      }
2106
2107    for (i = 0; i < 3; i++)
2108      {
2109         pi[i + 3] = elm_genlist_item_sorted_insert
2110           (gl, itc4, (void *)(long)(idx[i] * 2)/* item data */, NULL/* parent */,
2111            ELM_GENLIST_ITEM_TREE, gl13_cmp/* cmp */, NULL/* func */,
2112            NULL/* func data */);
2113      }
2114
2115
2116    for (i = 0, base = 10000; i < 3; i++, base += 10000)
2117      {
2118         int j;
2119         for (j = 0; j < 3; j++)
2120           {
2121              elm_genlist_item_sorted_insert
2122                (gl, itc4, (void *)(long)(idx[j] + base)/* item data */,
2123                 pi[i + 3]/* parent */, ELM_GENLIST_ITEM_NONE,
2124                 gl13_cmp/* cmp */, NULL/* func */, NULL/* func data */);
2125           }
2126      }
2127    elm_genlist_item_class_free(itc4);
2128    elm_box_pack_end(bx, gl);
2129    evas_object_show(bx);
2130
2131    evas_object_resize(win, 320, 320);
2132    evas_object_show(win);
2133 }
2134
2135 static void
2136 my_gl_insert_before_rel(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2137 {
2138    Evas_Object *gl = data;
2139    static int i = 1000;
2140    Elm_Object_Item *gli_selected;
2141
2142    itc1->item_style = "default";
2143    itc1->func.text_get = gl_text_get;
2144    itc1->func.content_get = NULL;
2145    itc1->func.state_get = NULL;
2146    itc1->func.del = NULL;
2147
2148    gli_selected = elm_genlist_selected_item_get(gl);
2149    if (!gli_selected)
2150      {
2151         printf("no item selected\n");
2152         return;
2153      }
2154
2155    elm_genlist_item_insert_before(gl, itc1,
2156                                   (void *)(long)i/* item data */,
2157                                   elm_genlist_item_parent_get(gli_selected),
2158                                   gli_selected/* item before */,
2159                                   ELM_GENLIST_ITEM_NONE,
2160                                   NULL/* func */, NULL/* func data */);
2161    i++;
2162 }
2163
2164 static void
2165 my_gl_insert_after_rel(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2166 {
2167    Evas_Object *gl = data;
2168    static int i = 0;
2169    Elm_Object_Item *gli_selected;
2170
2171    itc1->item_style = "default";
2172    itc1->func.text_get = gl_text_get;
2173    itc1->func.content_get = NULL;
2174    itc1->func.state_get = NULL;
2175    itc1->func.del = NULL;
2176
2177    gli_selected = elm_genlist_selected_item_get(gl);
2178    if (!gli_selected)
2179      {
2180         printf("no item selected\n");
2181         return;
2182      }
2183
2184    elm_genlist_item_insert_after(gl, itc1,
2185                                   (void *)(long)i/* item data */,
2186                                   elm_genlist_item_parent_get(gli_selected),
2187                                   gli_selected/* item after */,
2188                                   ELM_GENLIST_ITEM_NONE,
2189                                   NULL/* func */, NULL/* func data */);
2190    i++;
2191 }
2192
2193 void
2194 test_genlist14(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2195 {
2196    Elm_Object_Item *pi[6];
2197    Evas_Object *win, *bx, *bx2, *bt, *gl;
2198    int i, base;
2199    /* index: 0,  1,  2,  3,  4,  5
2200     * items: 1, 15, 11,  2, 33, 21
2201     * final: 1,  2, 11, 15, 21, 33
2202     */
2203    const int idx[6] = {1, 15, 11, 2, 33, 21};
2204    const int relative[6] = {
2205       0, /* item  '1' -  not used */
2206       0, /* item '15' - insert after pi[0], item '1' */
2207      -1, /* item '11' - insert before pi[1], item '15' */
2208      -2, /* item  '2' - insert before pi[2], item '11' */
2209       1, /* item '33' - insert after pi[1], item '15' */
2210      -4  /* item '21' - insert before pi[4], item '33' */
2211    };
2212
2213    win = elm_win_util_standard_add("genlist-tree-insert-relative", "Genlist Tree, Insert Relative");
2214    elm_win_autodel_set(win, EINA_TRUE);
2215
2216    bx = elm_box_add(win);
2217    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2218    elm_win_resize_object_add(win, bx);
2219    evas_object_show(bx);
2220
2221    gl = elm_genlist_add(win);
2222    evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
2223    evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2224    evas_object_show(gl);
2225
2226    itc4 = elm_genlist_item_class_new();
2227    itc4->item_style = "default";
2228    itc4->func.text_get = gl4_text_get;
2229    itc4->func.content_get = NULL;
2230    itc4->func.state_get = NULL;
2231    itc4->func.del = NULL;
2232
2233    /* mixed order to test insert sorted */
2234
2235    // BUG1: should be able to insert before=NULL, prepend
2236    // BUG2: should be able to insert after=NULL, append
2237
2238    pi[0] = elm_genlist_item_append
2239      (gl, itc4, (void *)(long)idx[0]/* item data */,
2240       NULL/* parent */,
2241       ELM_GENLIST_ITEM_TREE, NULL/* func */, NULL/* func data */);
2242
2243    for (i = 1; i < 3; i++)
2244      {
2245         if (relative[i] < 0)
2246           pi[i] = elm_genlist_item_insert_before
2247             (gl, itc4, (void *)(long)idx[i]/* item data */,
2248              NULL/* parent */, pi[-relative[i]],
2249              ELM_GENLIST_ITEM_TREE, NULL/* func */, NULL/* func data */);
2250         else
2251           pi[i] = elm_genlist_item_insert_after
2252             (gl, itc4, (void *)(long)idx[i]/* item data */,
2253              NULL/* parent */, pi[relative[i]],
2254              ELM_GENLIST_ITEM_TREE, NULL/* func */, NULL/* func data */);
2255      }
2256
2257    for (i = 0; i < 3; i++)
2258      {
2259         Elm_Object_Item *sub_glit[6];
2260         int j;
2261
2262         base = 1000 * (int)(long) elm_object_item_data_get(pi[i]);
2263
2264         sub_glit[0] = elm_genlist_item_append
2265           (gl, itc4, (void *)(long) (idx[0] + base)/* item data */, pi[i]/* parent */,
2266            ELM_GENLIST_ITEM_TREE, NULL/* func */, NULL/* func data */);
2267
2268         for (j = 1; j < 6; j++) {
2269            if (relative[j] < 0)
2270              sub_glit[j] = elm_genlist_item_insert_before
2271                (gl, itc4, (void *)(long) (idx[j] + base)/* item data */,
2272                 pi[i]/* parent */, sub_glit[-relative[j]],
2273                 ELM_GENLIST_ITEM_TREE, NULL/* func */, NULL/* func data */);
2274            else
2275              sub_glit[j] = elm_genlist_item_insert_after
2276                (gl, itc4, (void *)(long) (idx[j] + base)/* item data */,
2277                 pi[i]/* parent */, sub_glit[relative[j]],
2278                 ELM_GENLIST_ITEM_TREE, NULL/* func */, NULL/* func data */);
2279         }
2280      }
2281
2282    for (i = 3; i < 6; i++)
2283      {
2284         if (relative[i] < 0)
2285           pi[i] = elm_genlist_item_insert_before
2286             (gl, itc4, (void *)(long) idx[i]/* item data */,
2287              NULL/* parent */, pi[-relative[i]],
2288              ELM_GENLIST_ITEM_TREE, NULL/* func */, NULL/* func data */);
2289         else
2290           pi[i] = elm_genlist_item_insert_after
2291             (gl, itc4, (void *)(long) idx[i]/* item data */,
2292              NULL/* parent */, pi[relative[i]],
2293              ELM_GENLIST_ITEM_TREE, NULL/* func */, NULL/* func data */);
2294      }
2295
2296    for (i = 3; i < 6; i++)
2297      {
2298         Elm_Object_Item *sub_glit[6];
2299         int j;
2300
2301         base = 1000 * (int)(long) elm_object_item_data_get(pi[i]);
2302
2303         sub_glit[0] = elm_genlist_item_append
2304           (gl, itc4, (void *)(long) (idx[0] + base)/* item data */, pi[i]/* parent */,
2305            ELM_GENLIST_ITEM_TREE, NULL/* func */, NULL/* func data */);
2306
2307         for (j = 1; j < 6; j++) {
2308            if (relative[j] < 0)
2309              sub_glit[j] = elm_genlist_item_insert_before
2310                (gl, itc4, (void *)(long) (idx[j] + base)/* item data */,
2311                 pi[i]/* parent */, sub_glit[-relative[j]],
2312                 ELM_GENLIST_ITEM_TREE, NULL/* func */, NULL/* func data */);
2313            else
2314              sub_glit[j] = elm_genlist_item_insert_after
2315                (gl, itc4, (void *)(long) (idx[j] + base)/* item data */,
2316                 pi[i]/* parent */, sub_glit[relative[j]],
2317                 ELM_GENLIST_ITEM_TREE, NULL/* func */, NULL/* func data */);
2318         }
2319      }
2320
2321    elm_box_pack_end(bx, gl);
2322    evas_object_show(bx);
2323
2324    bx2 = elm_box_add(win);
2325    elm_box_horizontal_set(bx2, EINA_TRUE);
2326    elm_box_homogeneous_set(bx2, EINA_TRUE);
2327    evas_object_size_hint_weight_set(bx2, EVAS_HINT_EXPAND, 0.0);
2328    evas_object_size_hint_align_set(bx2, EVAS_HINT_FILL, EVAS_HINT_FILL);
2329
2330    bt = elm_button_add(win);
2331    elm_object_text_set(bt, "+ before");
2332    evas_object_smart_callback_add(bt, "clicked", my_gl_insert_before_rel, gl);
2333    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
2334    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
2335    elm_box_pack_end(bx2, bt);
2336    evas_object_show(bt);
2337
2338    bt = elm_button_add(win);
2339    elm_object_text_set(bt, "+ after");
2340    evas_object_smart_callback_add(bt, "clicked", my_gl_insert_after_rel, gl);
2341    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
2342    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
2343    elm_box_pack_end(bx2, bt);
2344    evas_object_show(bt);
2345
2346    elm_box_pack_end(bx, bx2);
2347    evas_object_show(bx2);
2348
2349    /* item_class_ref is needed for itc4. some items can be added in callbacks */
2350    elm_genlist_item_class_ref(itc4);
2351    elm_genlist_item_class_free(itc4);
2352
2353    evas_object_resize(win, 320, 320);
2354    evas_object_show(win);
2355 }
2356
2357 static void _edit_icon_clicked_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2358 {
2359    Elm_Object_Item *item = (Elm_Object_Item *)data;
2360    elm_object_item_del(item);
2361 }
2362
2363 char *gl15_text_get(void *data, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
2364 {
2365    const Testitem *tit = data;
2366    char buf[256];
2367    snprintf(buf, sizeof(buf), "Item #%i", tit->mode);
2368    return strdup(buf);
2369 }
2370
2371 Evas_Object *gl15_content_get(void *data, Evas_Object *obj, const char *part)
2372 {
2373    Testitem *tit = data;
2374    char buf[PATH_MAX];
2375
2376    // "decorate_default" EDC layout is like below. each part is swallow part.
2377    // the existing item is swllowed to elm.swallow.edit.content part.
2378    // ----------------------------------------------------------------
2379    // | elm.decorate.icon.1 | elm.swallow.decorate.content | elm.decorate.icon,2 |
2380    // ----------------------------------------------------------------
2381
2382    if (!strcmp(part, "elm.swallow.end"))
2383      {
2384         Evas_Object *ic = elm_icon_add(obj);
2385         snprintf(buf, sizeof(buf), "%s/images/bubble.png", PACKAGE_DATA_DIR);
2386         elm_icon_file_set(ic, buf, NULL);
2387         evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
2388         return ic;
2389      }
2390    else if (!strcmp(part, "elm.decorate.icon.1"))
2391      {
2392         Evas_Object *ck;
2393         ck = elm_check_add(obj);
2394         elm_check_state_pointer_set(ck, &tit->checked);
2395         evas_object_propagate_events_set(ck, EINA_FALSE);
2396         evas_object_show(ck);
2397         return ck;
2398      }
2399    else if (!strcmp(part, "elm.decorate.icon.2"))
2400      {
2401         Evas_Object *icn = elm_icon_add(obj);
2402         snprintf(buf, sizeof(buf), "%s/images/icon_06.png", PACKAGE_DATA_DIR);
2403         elm_icon_file_set(icn, buf, NULL);
2404         evas_object_propagate_events_set(icn, EINA_FALSE);
2405         evas_object_size_hint_aspect_set(icn, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
2406         evas_object_smart_callback_add(icn, "clicked", _edit_icon_clicked_cb, (void *)tit->item);
2407         return icn;
2408      }
2409    else return NULL;
2410 }
2411
2412 static void
2413 gl15_sel(void *data, Evas_Object *obj, void *event_info __UNUSED__)
2414 {
2415    Testitem *tit = data;
2416    if (elm_genlist_decorate_mode_get(obj))
2417      {
2418         if (!tit->checked) tit->checked = EINA_TRUE;
2419         else tit->checked = EINA_FALSE;
2420      }
2421    elm_genlist_item_update(tit->item);
2422 }
2423
2424 static void
2425 gl15_deco_all_mode(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2426 {
2427    elm_genlist_decorate_mode_set(data, EINA_TRUE);
2428    elm_genlist_select_mode_set(data, ELM_OBJECT_SELECT_MODE_ALWAYS);
2429 }
2430
2431 static void
2432 gl15_normal_mode(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2433 {
2434    elm_genlist_decorate_mode_set(data, EINA_FALSE);
2435    elm_genlist_select_mode_set(data, ELM_OBJECT_SELECT_MODE_DEFAULT);
2436 }
2437
2438 void gl15_del(void *data __UNUSED__, Evas_Object *obj __UNUSED__)
2439 {
2440    printf("item deleted.\n");
2441 }
2442
2443 static Elm_Genlist_Item_Class *itc15;
2444 void
2445 test_genlist15(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2446 {
2447    Evas_Object *win, *bx, *bx2, *bt, *gl;
2448    int i;
2449    static Testitem tit[100];
2450
2451    win = elm_win_util_standard_add("genlist-decorate-all-mode", "Genlist Decorate All Mode");
2452    elm_win_autodel_set(win, EINA_TRUE);
2453
2454    bx = elm_box_add(win);
2455    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2456    elm_win_resize_object_add(win, bx);
2457    evas_object_show(bx);
2458
2459    gl = elm_genlist_add(win);
2460    evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
2461    evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2462    evas_object_show(gl);
2463
2464    itc15 = elm_genlist_item_class_new();
2465    itc15->item_style     = "default";
2466    itc15->func.text_get = gl15_text_get;
2467    itc15->func.content_get  = gl15_content_get;
2468    itc15->func.state_get = gl_state_get;
2469    itc15->func.del       = gl15_del;
2470    itc15->decorate_all_item_style = "edit";
2471
2472    for (i = 0; i < 100; i++)
2473      {
2474         tit[i].mode = i;
2475         tit[i].item = elm_genlist_item_append(gl, itc15,
2476                                               &(tit[i])/* item data */,
2477                                               NULL/* parent */,
2478                                               ELM_GENLIST_ITEM_NONE/* flags */,
2479                                               gl15_sel/* func */,
2480                                               (void *)(long)&(tit[i])/* func data */);
2481      }
2482    elm_genlist_item_class_free(itc15);
2483    elm_box_pack_end(bx, gl);
2484    evas_object_show(bx);
2485
2486    bx2 = elm_box_add(win);
2487    elm_box_horizontal_set(bx2, EINA_TRUE);
2488    elm_box_homogeneous_set(bx2, EINA_TRUE);
2489    evas_object_size_hint_weight_set(bx2, EVAS_HINT_EXPAND, 0.0);
2490    evas_object_size_hint_align_set(bx2, EVAS_HINT_FILL, EVAS_HINT_FILL);
2491
2492    bt = elm_button_add(win);
2493    elm_object_text_set(bt, "Decorate All mode");
2494    evas_object_smart_callback_add(bt, "clicked", gl15_deco_all_mode, gl);
2495    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
2496    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
2497    elm_box_pack_end(bx2, bt);
2498    evas_object_show(bt);
2499
2500    bt = elm_button_add(win);
2501    elm_object_text_set(bt, "Normal mode");
2502    evas_object_smart_callback_add(bt, "clicked", gl15_normal_mode,gl);
2503    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
2504    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
2505    elm_box_pack_end(bx2, bt);
2506    evas_object_show(bt);
2507
2508    elm_box_pack_end(bx, bx2);
2509    evas_object_show(bx2);
2510
2511    evas_object_resize(win, 520, 520);
2512    evas_object_show(win);
2513 }
2514
2515 static void _flip_icon_clicked_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2516 {
2517    const Testitem *tit = data;
2518
2519    if (elm_genlist_item_flip_get(tit->item))
2520      elm_genlist_item_flip_set(tit->item, EINA_FALSE);
2521    else
2522      elm_genlist_item_flip_set(tit->item, EINA_TRUE);
2523 }
2524
2525 char *gl16_text_get(void *data, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
2526 {
2527    const Testitem *tit = data;
2528    char buf[256];
2529    snprintf(buf, sizeof(buf), "Item #%i", tit->mode);
2530    return strdup(buf);
2531 }
2532
2533 Evas_Object *gl16_content_get(void *data, Evas_Object *obj, const char *part)
2534 {
2535    Testitem *tit = data;
2536    char buf[PATH_MAX];
2537
2538    if (!strcmp(part, "elm.text.flip"))
2539      {
2540         Evas_Object *btn = elm_button_add(obj);
2541         elm_object_text_set(btn, "flipped content placement");
2542         evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
2543         evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, 0.0);
2544         evas_object_smart_callback_add(btn, "clicked", _flip_icon_clicked_cb, (void *)tit);
2545         evas_object_show(btn);
2546         return btn;
2547      }
2548    else if (!strcmp(part, "elm.decorate.icon.1"))
2549      {
2550         Evas_Object *icn = elm_icon_add(obj);
2551         snprintf(buf, sizeof(buf), "%s/images/icon_04.png", PACKAGE_DATA_DIR);
2552         elm_icon_file_set(icn, buf, NULL);
2553         evas_object_propagate_events_set(icn, EINA_FALSE);
2554         evas_object_size_hint_aspect_set(icn, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
2555         return icn;
2556      }
2557    else if (!strcmp(part, "elm.decorate.icon.2"))
2558      {
2559         Evas_Object *icn = elm_icon_add(obj);
2560         snprintf(buf, sizeof(buf), "%s/images/icon_09.png", PACKAGE_DATA_DIR);
2561         elm_icon_file_set(icn, buf, NULL);
2562         evas_object_propagate_events_set(icn, EINA_FALSE);
2563         evas_object_size_hint_aspect_set(icn, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
2564         evas_object_smart_callback_add(icn, "clicked", _flip_icon_clicked_cb, (void *)tit);
2565         return icn;
2566      }
2567    else return NULL;
2568 }
2569
2570 void
2571 test_genlist16(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2572 {
2573    Evas_Object *win, *bx, *gl;
2574    int i;
2575    static Testitem tit[100];
2576
2577    win = elm_win_util_standard_add("genlist-flip-mode", "Genlist Flip Mode");
2578    elm_win_autodel_set(win, EINA_TRUE);
2579
2580    bx = elm_box_add(win);
2581    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2582    elm_win_resize_object_add(win, bx);
2583    evas_object_show(bx);
2584
2585    gl = elm_genlist_add(win);
2586    evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
2587    evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2588    evas_object_show(gl);
2589
2590    /* note: flip mode can be used with/without edit mode */
2591    elm_genlist_decorate_mode_set(gl, EINA_TRUE);
2592    elm_genlist_select_mode_set(gl, ELM_OBJECT_SELECT_MODE_ALWAYS);
2593
2594    itc15 = elm_genlist_item_class_new();
2595    itc15->item_style     = "default";
2596    itc15->func.text_get = gl16_text_get;
2597    itc15->func.content_get = gl16_content_get;
2598    itc15->func.state_get = gl_state_get;
2599    itc15->func.del       = NULL;
2600    itc15->decorate_all_item_style = "edit";
2601
2602    for (i = 0; i < 100; i++)
2603      {
2604         tit[i].mode = i;
2605         tit[i].item = elm_genlist_item_append(gl, itc15,
2606                                               &(tit[i])/* item data */,
2607                                               NULL/* parent */,
2608                                               ELM_GENLIST_ITEM_NONE/* flags */,
2609                                               gl_sel/* func */,
2610                                               (void *)(long)&(tit[i])/* func data */);
2611      }
2612    elm_genlist_item_class_free(itc15);
2613    elm_box_pack_end(bx, gl);
2614    evas_object_show(bx);
2615
2616    evas_object_resize(win, 520, 520);
2617    evas_object_show(win);
2618 }
2619
2620 static Elm_Genlist_Item_Class itc17;
2621
2622 static void
2623 gl17_sel(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
2624 {
2625    Elm_Object_Item *glit = event_info;
2626    int depth = elm_genlist_item_expanded_depth_get(glit);
2627    printf("expanded depth for selected item is %d\n", depth);
2628 }
2629
2630 static void
2631 gl17_exp(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
2632 {
2633    Elm_Object_Item *glit = event_info;
2634    Evas_Object *gl = elm_object_item_widget_get(glit);
2635    int val = (int)(long) elm_object_item_data_get(glit);
2636    val *= 10;
2637    elm_genlist_item_append(gl, &itc17,
2638                            (void *)(long) (val + 1)/* item data */,
2639                            glit/* parent */,
2640                            ELM_GENLIST_ITEM_TREE, gl17_sel/* func */,
2641                            NULL/* func data */);
2642    elm_genlist_item_append(gl, &itc17,
2643                            (void *)(long) (val + 2)/* item data */,
2644                            glit/* parent */,
2645                            ELM_GENLIST_ITEM_TREE, gl17_sel/* func */,
2646                            NULL/* func data */);
2647    elm_genlist_item_append(gl, &itc17,
2648                            (void *)(long) (val + 3)/* item data */,
2649                            glit/* parent */,
2650                            ELM_GENLIST_ITEM_TREE, gl17_sel/* func */,
2651                            NULL/* func data */);
2652    elm_genlist_item_append(gl, &itc17,
2653                            (void *)(long) (val + 4)/* item data */,
2654                            glit/* parent */,
2655                            ELM_GENLIST_ITEM_TREE, gl17_sel/* func */,
2656                            NULL/* func data */);
2657    elm_genlist_item_append(gl, &itc17,
2658                            (void *)(long) (val + 5)/* item data */,
2659                            glit/* parent */,
2660                            ELM_GENLIST_ITEM_TREE, gl17_sel/* func */,
2661                            NULL/* func data */);
2662    elm_genlist_item_append(gl, &itc17,
2663                            (void *)(long) (val + 6)/* item data */,
2664                            glit/* parent */,
2665                            ELM_GENLIST_ITEM_TREE, gl17_sel/* func */,
2666                            NULL/* func data */);
2667 }
2668
2669 static void
2670 gl17_con(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
2671 {
2672    Elm_Object_Item *glit = event_info;
2673    elm_genlist_item_subitems_clear(glit);
2674 }
2675
2676 static void
2677 gl17_exp_req(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
2678 {
2679    Elm_Object_Item *glit = event_info;
2680    elm_genlist_item_expanded_set(glit, EINA_TRUE);
2681 }
2682
2683 static void
2684 gl17_con_req(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
2685 {
2686    Elm_Object_Item *glit = event_info;
2687    elm_genlist_item_expanded_set(glit, EINA_FALSE);
2688 }
2689
2690 char *gl17_text_get(void *data, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
2691 {
2692    char buf[256];
2693    snprintf(buf, sizeof(buf), "Item mode %i", (int)(long)data);
2694    return strdup(buf);
2695 }
2696
2697 Evas_Object *gl17_content_get(void *data __UNUSED__, Evas_Object *obj, const char *part)
2698 {
2699    char buf[PATH_MAX];
2700    if (!strcmp(part, "elm.swallow.icon"))
2701      {
2702         Evas_Object *ic = elm_icon_add(obj);
2703         snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
2704         elm_icon_file_set(ic, buf, NULL);
2705         evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
2706         evas_object_show(ic);
2707         return ic;
2708      }
2709    else if (!strcmp(part, "elm.swallow.end"))
2710      {
2711         Evas_Object *ck;
2712         ck = elm_check_add(obj);
2713         evas_object_propagate_events_set(ck, EINA_FALSE);
2714         evas_object_show(ck);
2715         return ck;
2716      }
2717    return NULL;
2718 }
2719
2720 Eina_Bool gl17_state_get(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
2721 {
2722    return EINA_FALSE;
2723 }
2724
2725 void gl17_del(void *data __UNUSED__, Evas_Object *obj __UNUSED__)
2726 {
2727    printf("item deleted.\n");
2728 }
2729
2730 static void
2731 gl17_enabled_set(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2732 {
2733    elm_genlist_tree_effect_enabled_set(data, EINA_TRUE);
2734 }
2735
2736 static void
2737 gl17_disabled_set(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2738 {
2739    elm_genlist_tree_effect_enabled_set(data, EINA_FALSE);
2740 }
2741         
2742 void
2743 test_genlist17(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2744 {
2745    Evas_Object *win, *gl, *bx, *bx2, *bt;
2746
2747    win = elm_win_util_standard_add("genlist17", "Genlist Tree Effect");
2748    elm_win_autodel_set(win, EINA_TRUE);
2749
2750    bx = elm_box_add(win);
2751    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2752    elm_win_resize_object_add(win, bx);
2753    evas_object_show(bx);
2754
2755    gl = elm_genlist_add(win);
2756    evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
2757    evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2758    evas_object_show(gl);
2759
2760    elm_genlist_tree_effect_enabled_set(gl,EINA_TRUE);
2761
2762    itc17.item_style     = "tree_effect";
2763    itc17.func.text_get = gl17_text_get;
2764    itc17.func.content_get  = gl17_content_get;
2765    itc17.func.state_get = gl17_state_get;
2766    itc17.func.del       = gl17_del;
2767
2768    elm_genlist_item_append(gl, &itc17,
2769                            (void *)1/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_TREE, gl17_sel/* func */,
2770                            NULL/* func data */);
2771    elm_genlist_item_append(gl, &itc17,
2772                            (void *)2/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_TREE, gl17_sel/* func */,
2773                            NULL/* func data */);
2774    elm_genlist_item_append(gl, &itc17,
2775                            (void *)3/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_TREE, gl17_sel/* func */,
2776                            NULL/* func data */);
2777
2778    evas_object_smart_callback_add(gl, "expand,request", gl17_exp_req, gl);
2779    evas_object_smart_callback_add(gl, "contract,request", gl17_con_req, gl);
2780    evas_object_smart_callback_add(gl, "expanded", gl17_exp, gl);
2781    evas_object_smart_callback_add(gl, "contracted", gl17_con, gl);
2782
2783    elm_box_pack_end(bx, gl);
2784    evas_object_show(bx);
2785
2786    bx2 = elm_box_add(win);
2787    elm_box_horizontal_set(bx2, EINA_TRUE);
2788    elm_box_homogeneous_set(bx2, EINA_TRUE);
2789    evas_object_size_hint_weight_set(bx2, EVAS_HINT_EXPAND, 0.0);
2790    evas_object_size_hint_align_set(bx2, EVAS_HINT_FILL, EVAS_HINT_FILL);
2791
2792    bt = elm_button_add(win);
2793    elm_object_text_set(bt, "Enable");
2794    evas_object_smart_callback_add(bt, "clicked", gl17_enabled_set, gl);
2795    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
2796    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
2797    elm_box_pack_end(bx2, bt);
2798    evas_object_show(bt);
2799
2800    bt = elm_button_add(win);
2801    elm_object_text_set(bt, "Disable");
2802    evas_object_smart_callback_add(bt, "clicked", gl17_disabled_set, gl);
2803    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
2804    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
2805    elm_box_pack_end(bx2, bt);
2806    evas_object_show(bt);
2807
2808    elm_box_pack_end(bx, bx2);
2809    evas_object_show(bx2);
2810
2811    evas_object_resize(win, 320, 320);
2812    evas_object_show(win);
2813 }
2814 #endif