[JungWooHyun] doing merge job ~
[framework/uifw/elementary.git] / src / examples / genlist_example_01.c
1 //Compile with:
2 //gcc -g `pkg-config --cflags --libs elementary` genlist_example_01.c -o genlist_example_01
3
4 #include <Elementary.h>
5 #ifdef HAVE_CONFIG_H
6 # include "elementary_config.h"
7 #else
8 # define __UNUSED__
9 #endif
10
11 #define N_ITEMS 30
12
13 <<<<<<< HEAD
14 static Elm_Genlist_Item_Class _itc;
15
16 static char *
17 _item_text_get(void *data, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
18 =======
19 static Elm_Genlist_Item_Class *_itc = NULL;
20
21 static char *
22 _item_label_get(void *data, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
23 >>>>>>> remotes/origin/upstream
24 {
25    char buf[256];
26    snprintf(buf, sizeof(buf), "Item # %i", (int)(long)data);
27    return strdup(buf);
28 }
29
30 static Evas_Object *
31 _item_content_get(void *data __UNUSED__, Evas_Object *obj, const char *part)
32 {
33    Evas_Object *ic = elm_icon_add(obj);
34
35    if (!strcmp(part, "elm.swallow.icon"))
36      elm_icon_standard_set(ic, "clock");
37
38    evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
39    return ic;
40 }
41
42 static void
43 _item_sel_cb(void *data, Evas_Object *obj, void *event_info)
44 {
45    printf("sel item data [%p] on genlist obj [%p], item pointer [%p]\n",
46           data, obj, event_info);
47 }
48
49 int
50 elm_main(int argc __UNUSED__, char **argv __UNUSED__)
51 {
52    Evas_Object *win, *bg;
53    Evas_Object *list;
54    int i;
55
56    win = elm_win_add(NULL, "icon", ELM_WIN_BASIC);
57    elm_win_title_set(win, "Icon");
58    elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
59    elm_win_autodel_set(win, EINA_TRUE);
60
61    bg = elm_bg_add(win);
62    elm_bg_color_set(bg, 255,255 ,255);
63    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
64    elm_win_resize_object_add(win, bg);
65    evas_object_show(bg);
66
67 <<<<<<< HEAD
68    _itc.item_style = "default";
69    _itc.func.text_get = _item_text_get;
70    _itc.func.content_get = _item_content_get;
71    _itc.func.state_get = NULL;
72    _itc.func.del = NULL;
73 =======
74    if (!_itc)
75      {
76         _itc = elm_genlist_item_class_new();
77         _itc->item_style = "default";
78         _itc->func.text_get = _item_label_get;
79         _itc->func.content_get = _item_content_get;
80         _itc->func.state_get = NULL;
81         _itc->func.del = NULL;
82      }
83 >>>>>>> remotes/origin/upstream
84
85    list = elm_genlist_add(win);
86
87    for (i = 0; i < N_ITEMS; i++)
88      {
89 <<<<<<< HEAD
90         elm_genlist_item_append(list, &_itc,
91 =======
92         elm_genlist_item_append(list, _itc,
93 >>>>>>> remotes/origin/upstream
94                                 (void *)(long)i, NULL,
95                                 ELM_GENLIST_ITEM_NONE,
96                                 _item_sel_cb, NULL);
97      }
98
99    evas_object_size_hint_weight_set(list, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
100    elm_win_resize_object_add(win, list);
101    evas_object_show(list);
102
103    evas_object_size_hint_min_set(bg, 160, 160);
104    evas_object_size_hint_max_set(bg, 640, 640);
105    evas_object_resize(win, 320, 320);
106    evas_object_show(win);
107
108    elm_run();
109
110    return 0;
111 }
112
113 ELM_MAIN()