summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDave Andreoli <dave@gurumeditation.it>2018-04-21 11:39:26 +0200
committerDave Andreoli <dave@gurumeditation.it>2018-04-21 11:46:29 +0200
commit558f4c36ac7fa67fe47b5088d0ef61d66ddd2dc4 (patch)
tree226e6cdd3ed78910ea72979be299eff6a4eb8df3 /src
parent8bd47cf83c88bb5f333cd4c4996a61d76b9b0d1d (diff)
Genlist: visual test for item next/prev/first/last
Added 4 buttons to the "genlist group tree" to perform item next/prev/first/last. This test works correctly by reverting fd82c2521ebb but it still in contrast with the item_next() docs, that say item_next should not descend in item childs. I think that the docs is also wrong, as I never saw the behaviour that is explained there.
Diffstat (limited to 'src')
-rw-r--r--src/bin/elementary/test_genlist.c80
1 files changed, 77 insertions, 3 deletions
diff --git a/src/bin/elementary/test_genlist.c b/src/bin/elementary/test_genlist.c
index 56ae76061b..98ffb221c2 100644
--- a/src/bin/elementary/test_genlist.c
+++ b/src/bin/elementary/test_genlist.c
@@ -2092,10 +2092,56 @@ gl9_con_req(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_in
2092 elm_genlist_item_expanded_set(glit, EINA_FALSE); 2092 elm_genlist_item_expanded_set(glit, EINA_FALSE);
2093} 2093}
2094 2094
2095static void
2096gl9_item_next(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
2097{
2098 api_data *api = data;
2099 Elm_Object_Item *it;
2100
2101 it = elm_genlist_selected_item_get(api->gl);
2102 it = elm_genlist_item_next_get(it);
2103 elm_genlist_item_selected_set(it, EINA_TRUE);
2104 printf("Next item: #%d\n", (int)(uintptr_t)elm_object_item_data_get(it));
2105}
2106
2107static void
2108gl9_item_prev(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
2109{
2110 api_data *api = data;
2111 Elm_Object_Item *it;
2112
2113 it = elm_genlist_selected_item_get(api->gl);
2114 it = elm_genlist_item_prev_get(it);
2115 elm_genlist_item_selected_set(it, EINA_TRUE);
2116 printf("Prev item: #%d\n", (int)(uintptr_t)elm_object_item_data_get(it));
2117}
2118
2119static void
2120gl9_item_first(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
2121{
2122 api_data *api = data;
2123 Elm_Object_Item *it;
2124
2125 it = elm_genlist_first_item_get(api->gl);
2126 elm_genlist_item_selected_set(it, EINA_TRUE);
2127 printf("First item: #%d\n", (int)(uintptr_t)elm_object_item_data_get(it));
2128}
2129
2130static void
2131gl9_item_last(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
2132{
2133 api_data *api = data;
2134 Elm_Object_Item *it;
2135
2136 it = elm_genlist_last_item_get(api->gl);
2137 elm_genlist_item_selected_set(it, EINA_TRUE);
2138 printf("Last item: #%d\n", (int)(uintptr_t)elm_object_item_data_get(it));
2139}
2140
2095void 2141void
2096test_genlist9(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 2142test_genlist9(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
2097{ 2143{
2098 Evas_Object *win, *gl, *bx; 2144 Evas_Object *win, *gl, *bx, *bx2, *bt;
2099 Elm_Object_Item *git; 2145 Elm_Object_Item *git;
2100 2146
2101 api_data *api = calloc(1, sizeof(api_data)); 2147 api_data *api = calloc(1, sizeof(api_data));
@@ -2135,7 +2181,6 @@ test_genlist9(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_
2135 git = elm_genlist_item_append(gl, api->itc2, 2181 git = elm_genlist_item_append(gl, api->itc2,
2136 (void *)0/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_GROUP, gl4_sel/* func */, 2182 (void *)0/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_GROUP, gl4_sel/* func */,
2137 NULL/* func data */); 2183 NULL/* func data */);
2138 elm_genlist_item_select_mode_set(git, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
2139 2184
2140 elm_genlist_item_append(gl, api->itc1, 2185 elm_genlist_item_append(gl, api->itc1,
2141 (void *)1/* item data */, git/* parent */, ELM_GENLIST_ITEM_TREE, gl4_sel/* func */, 2186 (void *)1/* item data */, git/* parent */, ELM_GENLIST_ITEM_TREE, gl4_sel/* func */,
@@ -2149,7 +2194,6 @@ test_genlist9(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_
2149 git = elm_genlist_item_append(gl, api->itc2, 2194 git = elm_genlist_item_append(gl, api->itc2,
2150 (void *)4/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_GROUP, gl4_sel/* func */, 2195 (void *)4/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_GROUP, gl4_sel/* func */,
2151 NULL/* func data */); 2196 NULL/* func data */);
2152 elm_genlist_item_select_mode_set(git, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
2153 2197
2154 elm_genlist_item_append(gl, api->itc1, 2198 elm_genlist_item_append(gl, api->itc1,
2155 (void *)5/* item data */, git/* parent */, ELM_GENLIST_ITEM_TREE, gl4_sel/* func */, 2199 (void *)5/* item data */, git/* parent */, ELM_GENLIST_ITEM_TREE, gl4_sel/* func */,
@@ -2168,6 +2212,36 @@ test_genlist9(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_
2168 evas_object_smart_callback_add(gl, "expanded", gl9_exp, api); 2212 evas_object_smart_callback_add(gl, "expanded", gl9_exp, api);
2169 evas_object_smart_callback_add(gl, "contracted", gl9_con, api); 2213 evas_object_smart_callback_add(gl, "contracted", gl9_con, api);
2170 2214
2215 bx2 = elm_box_add(win);
2216 elm_box_horizontal_set(bx2, EINA_TRUE);
2217 elm_box_pack_end(bx, bx2);
2218 evas_object_show(bx2);
2219
2220 bt = elm_button_add(bx2);
2221 elm_object_text_set(bt, "First item");
2222 evas_object_smart_callback_add(bt, "clicked", gl9_item_first, api);
2223 elm_box_pack_end(bx2, bt);
2224 evas_object_show(bt);
2225
2226 bt = elm_button_add(bx2);
2227 elm_object_text_set(bt, "Next item");
2228 evas_object_smart_callback_add(bt, "clicked", gl9_item_next, api);
2229 elm_box_pack_end(bx2, bt);
2230 evas_object_show(bt);
2231 bt = elm_button_add(bx2);
2232
2233 bt = elm_button_add(bx2);
2234 elm_object_text_set(bt, "Prev item");
2235 evas_object_smart_callback_add(bt, "clicked", gl9_item_prev, api);
2236 elm_box_pack_end(bx2, bt);
2237 evas_object_show(bt);
2238
2239 bt = elm_button_add(bx2);
2240 elm_object_text_set(bt, "Last item");
2241 evas_object_smart_callback_add(bt, "clicked", gl9_item_last, api);
2242 elm_box_pack_end(bx2, bt);
2243 evas_object_show(bt);
2244
2171 evas_object_resize(win, 480, 800); 2245 evas_object_resize(win, 480, 800);
2172 evas_object_show(win); 2246 evas_object_show(win);
2173} 2247}