summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2014-10-27 20:19:53 +0100
committerCedric BAIL <cedric@osg.samsung.com>2014-10-27 20:19:53 +0100
commita1e720a3338ed786285324362b4faf742e18f705 (patch)
treeccb48e4837617a43f1062748ab2450ecf6e5a720
parent42d0a4622f5e24ba62aec133035a6bc4872512ae (diff)
tests: add tests for filling up the genlist.
Strangely this doesn't work. Compositing an Entry work, but Genlist doesn't.
-rw-r--r--src/bin/test_combobox.c97
1 files changed, 90 insertions, 7 deletions
diff --git a/src/bin/test_combobox.c b/src/bin/test_combobox.c
index 975e1cfcf..757b9d9ae 100644
--- a/src/bin/test_combobox.c
+++ b/src/bin/test_combobox.c
@@ -35,10 +35,53 @@ _combobox_expanded_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
35 printf("'expanded' callback is called.\n"); 35 printf("'expanded' callback is called.\n");
36} 36}
37 37
38static char *
39gl_text_get(void *data, Evas_Object *obj EINA_UNUSED, const char *part EINA_UNUSED)
40{
41 char buf[256];
42 snprintf(buf, sizeof(buf), "Item # %i", (int)(uintptr_t)data);
43 return strdup(buf);
44}
45
46static Evas_Object *gl_content_get(void *data EINA_UNUSED, Evas_Object *obj, const char *part)
47{
48 char buf[PATH_MAX];
49 Evas_Object *ic = elm_icon_add(obj);
50 if (!strcmp(part, "elm.swallow.end"))
51 snprintf(buf, sizeof(buf), "%s/images/bubble.png", elm_app_data_dir_get());
52 else
53 snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
54 elm_image_file_set(ic, buf, NULL);
55 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
56 return ic;
57}
58
59static Eina_Bool gl_state_get(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, const char *part EINA_UNUSED)
60{
61 return EINA_FALSE;
62}
63
64static char *gl_group_text_get(void *data, Evas_Object *obj EINA_UNUSED, const char *part EINA_UNUSED)
65{
66 char buf[256];
67 snprintf(buf, sizeof(buf), "Group Index # %i (Item # %i)", (int)((uintptr_t)data / 10), (int)(uintptr_t)data);
68 return strdup(buf);
69}
70
71static void
72gl_sel(void *data, Evas_Object *obj, void *event_info)
73{
74 printf("sel item data [%p] on genlist obj [%p], item pointer [%p]\n", data, obj, event_info);
75}
76
38void 77void
39test_combobox(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 78test_combobox(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
40{ 79{
41 Evas_Object *win, *bx, *combobox; 80 Evas_Object *win, *bx, *combobox;
81 Elm_Genlist_Item_Class *itc;
82 Elm_Genlist_Item_Class *itg;
83 Elm_Object_Item *gli, *git = NULL;
84 int i;
42 85
43 win = elm_win_util_standard_add("combobox", "Combobox"); 86 win = elm_win_util_standard_add("combobox", "Combobox");
44 elm_win_autodel_set(win, EINA_TRUE); 87 elm_win_autodel_set(win, EINA_TRUE);
@@ -48,6 +91,20 @@ test_combobox(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_
48 elm_win_resize_object_add(win, bx); 91 elm_win_resize_object_add(win, bx);
49 evas_object_show(bx); 92 evas_object_show(bx);
50 93
94 itc = elm_genlist_item_class_new();
95 itc->item_style = "default";
96 itc->func.text_get = gl_text_get;
97 itc->func.content_get = gl_content_get;
98 itc->func.state_get = gl_state_get;
99 itc->func.del = NULL;
100
101 itg = elm_genlist_item_class_new();
102 itg->item_style = "group_index";
103 itg->func.text_get = gl_group_text_get;
104 itg->func.content_get = NULL;
105 itg->func.state_get = NULL;
106 itg->func.del = NULL;
107
51 combobox = elm_combobox_add(win); 108 combobox = elm_combobox_add(win);
52 evas_object_size_hint_weight_set(combobox, EVAS_HINT_EXPAND, 0); 109 evas_object_size_hint_weight_set(combobox, EVAS_HINT_EXPAND, 0);
53 evas_object_size_hint_align_set(combobox, EVAS_HINT_FILL, 0); 110 evas_object_size_hint_align_set(combobox, EVAS_HINT_FILL, 0);
@@ -55,7 +112,10 @@ test_combobox(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_
55// elm_combobox_horizontal_set(bt, EINA_TRUE); 112// elm_combobox_horizontal_set(bt, EINA_TRUE);
56 elm_combobox_hover_parent_set(combobox, win); 113 elm_combobox_hover_parent_set(combobox, win);
57 elm_object_text_set(combobox, "Labels"); 114 elm_object_text_set(combobox, "Labels");
58 // FIXME: add some item 115 for (i = 0; i < 10; i++)
116 gli = elm_genlist_item_append(combobox, itc, (void *)(uintptr_t)i,
117 NULL, ELM_GENLIST_ITEM_NONE, gl_sel,
118 (void*)(uintptr_t)(i * 10));
59 evas_object_smart_callback_add(combobox, "clicked", 119 evas_object_smart_callback_add(combobox, "clicked",
60 _combobox_clicked_cb, NULL); 120 _combobox_clicked_cb, NULL);
61 evas_object_smart_callback_add(combobox, "selected", 121 evas_object_smart_callback_add(combobox, "selected",
@@ -66,12 +126,14 @@ test_combobox(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_
66 _combobox_expanded_cb, NULL); 126 _combobox_expanded_cb, NULL);
67 elm_box_pack_end(bx, combobox); 127 elm_box_pack_end(bx, combobox);
68 evas_object_show(combobox); 128 evas_object_show(combobox);
129 fprintf(stderr, "done\n");
69 130
70 combobox = elm_combobox_add(win); 131 combobox = elm_combobox_add(win);
71 elm_combobox_hover_parent_set(combobox, win); 132 elm_combobox_hover_parent_set(combobox, win);
72 evas_object_size_hint_weight_set(combobox, EVAS_HINT_EXPAND, 0); 133 evas_object_size_hint_weight_set(combobox, EVAS_HINT_EXPAND, 0);
73 evas_object_size_hint_align_set(combobox, EVAS_HINT_FILL, 0); 134 evas_object_size_hint_align_set(combobox, EVAS_HINT_FILL, 0);
74 elm_object_text_set(combobox, "Some Icons"); 135 elm_object_text_set(combobox, "Simple genlist");
136
75 // FIXME: add some item 137 // FIXME: add some item
76 elm_box_pack_end(bx, combobox); 138 elm_box_pack_end(bx, combobox);
77 evas_object_show(combobox); 139 evas_object_show(combobox);
@@ -80,8 +142,29 @@ test_combobox(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_
80 elm_combobox_hover_parent_set(combobox, win); 142 elm_combobox_hover_parent_set(combobox, win);
81 evas_object_size_hint_weight_set(combobox, EVAS_HINT_EXPAND, 0); 143 evas_object_size_hint_weight_set(combobox, EVAS_HINT_EXPAND, 0);
82 evas_object_size_hint_align_set(combobox, EVAS_HINT_FILL, 0); 144 evas_object_size_hint_align_set(combobox, EVAS_HINT_FILL, 0);
83 elm_object_text_set(combobox, "All Icons"); 145 elm_object_text_set(combobox, "Group genlist");
84 // FIXME: add some item 146 for (i = 0; i < 200; i++)
147 {
148 if (!(i % 10))
149 {
150 git = gli = elm_genlist_item_append(combobox, itg,
151 (void*)(uintptr_t)i,
152 NULL,
153 ELM_GENLIST_ITEM_GROUP,
154 gl_sel,
155 (void*)(uintptr_t)(i * 10));
156 elm_genlist_item_select_mode_set(git, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
157 }
158 else
159 {
160 gli = elm_genlist_item_append(combobox, itc,
161 (void*)(uintptr_t)i,
162 git,
163 ELM_GENLIST_ITEM_NONE,
164 gl_sel,
165 (void*)(uintptr_t)(i * 10));
166 }
167 }
85 elm_box_pack_end(bx, combobox); 168 elm_box_pack_end(bx, combobox);
86 evas_object_show(combobox); 169 evas_object_show(combobox);
87 170
@@ -89,7 +172,7 @@ test_combobox(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_
89 elm_combobox_hover_parent_set(combobox, win); 172 elm_combobox_hover_parent_set(combobox, win);
90 evas_object_size_hint_weight_set(combobox, EVAS_HINT_EXPAND, 0); 173 evas_object_size_hint_weight_set(combobox, EVAS_HINT_EXPAND, 0);
91 evas_object_size_hint_align_set(combobox, EVAS_HINT_FILL, 0); 174 evas_object_size_hint_align_set(combobox, EVAS_HINT_FILL, 0);
92 elm_object_text_set(combobox, "All Icons"); 175 elm_object_text_set(combobox, "Tree genlist");
93 // FIXME: add some item 176 // FIXME: add some item
94 elm_box_pack_end(bx, combobox); 177 elm_box_pack_end(bx, combobox);
95 evas_object_show(combobox); 178 evas_object_show(combobox);
@@ -108,7 +191,7 @@ test_combobox(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_
108 elm_combobox_hover_parent_set(combobox, win); 191 elm_combobox_hover_parent_set(combobox, win);
109 evas_object_size_hint_weight_set(combobox, EVAS_HINT_EXPAND, 0); 192 evas_object_size_hint_weight_set(combobox, EVAS_HINT_EXPAND, 0);
110 evas_object_size_hint_align_set(combobox, EVAS_HINT_FILL, 0); 193 evas_object_size_hint_align_set(combobox, EVAS_HINT_FILL, 0);
111 elm_object_text_set(combobox, "Icon + Label"); 194 elm_object_text_set(combobox, "Empty genlist");
112 // FIXME: add some items with icon 195 // FIXME: add some items with icon
113 elm_box_pack_end(bx, combobox); 196 elm_box_pack_end(bx, combobox);
114 evas_object_show(combobox); 197 evas_object_show(combobox);
@@ -117,7 +200,7 @@ test_combobox(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_
117 elm_combobox_hover_parent_set(combobox, win); 200 elm_combobox_hover_parent_set(combobox, win);
118 evas_object_size_hint_weight_set(combobox, EVAS_HINT_EXPAND, 0); 201 evas_object_size_hint_weight_set(combobox, EVAS_HINT_EXPAND, 0);
119 evas_object_size_hint_align_set(combobox, EVAS_HINT_FILL, 0); 202 evas_object_size_hint_align_set(combobox, EVAS_HINT_FILL, 0);
120 elm_object_text_set(combobox, "Custom Item Style"); 203 elm_object_text_set(combobox, "A long list");
121 // FIXME: add custom style 204 // FIXME: add custom style
122 elm_box_pack_end(bx, combobox); 205 elm_box_pack_end(bx, combobox);
123 evas_object_show(combobox); 206 evas_object_show(combobox);