summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <marcel-hollerbach@t-online.de>2015-07-26 21:13:48 +0200
committerMarcel Hollerbach <marcel-hollerbach@t-online.de>2015-07-26 21:13:48 +0200
commit36a56ed4e0dc9e3c7e141b2514c72caddff96fef (patch)
tree09774596edc91bdb4131748f33c9db39692a685a
parent3f2e54eeabe0378f2f893bdc6fba545bea5585d1 (diff)
Forgot file ...
-rw-r--r--src/test/list/list_expand.c143
1 files changed, 143 insertions, 0 deletions
diff --git a/src/test/list/list_expand.c b/src/test/list/list_expand.c
new file mode 100644
index 0000000..1ebd3d1
--- /dev/null
+++ b/src/test/list/list_expand.c
@@ -0,0 +1,143 @@
1#define EFL_BETA_API_SUPPORT
2#define EFL_EO_API_SUPPORT
3
4#include <Efl.h>
5#include <Elementary.h>
6#include <Elm_Items.h>
7
8static Eina_Bool pause_realize = EINA_TRUE;
9
10static Evas_Object *spinner;
11static void
12on_done(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
13{
14 // quit the mainloop (elm_run function will return)
15 elm_exit();
16}
17
18static Eina_Bool
19_realize(void *data EINA_UNUSED, Eo *obj, const Eo_Event_Description2 *desc EINA_UNUSED, void *event EINA_UNUSED)
20{
21 Eo *btn;
22 struct timespec tim;
23 btn = elm_label_add(obj);
24 elm_object_text_set(btn, "text");
25
26 eo_do(obj, elm_items_item_content_set(btn));
27
28 if (pause_realize)
29 {
30 tim.tv_sec = 0;
31 tim.tv_nsec = 10000000;
32 nanosleep(&tim, NULL);
33 }
34
35 evas_object_show(btn);
36
37 printf("REALIZE %p\n", obj);
38
39 return EINA_TRUE;
40}
41
42static Eina_Bool
43_unrealize(void *data EINA_UNUSED, Eo *obj, const Eo_Event_Description2 *desc EINA_UNUSED, void *event EINA_UNUSED)
44{
45 Eo *content;
46
47 eo_do(obj, content = elm_items_item_content_get();
48 elm_items_item_content_set(NULL););
49 evas_object_hide(content);
50
51 printf("UNREALIZE %p\n", obj);
52 return EINA_TRUE;
53}
54
55static void
56on_click(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
57{
58 Eina_List *selected;
59 Eo *item, *it, *root;
60 int number;
61
62 number = elm_spinner_value_get(spinner);
63
64 eo_do(data, selected = elm_items_display_selected_get());
65
66 eo_do(eina_list_data_get(selected), root = elm_items_item_get());
67
68 if (!root)
69 eo_do(data, root = elm_items_display_tree_get());
70
71 eo_do(eina_list_data_get(selected), elm_items_item_expandable_set(ELM_ITEMS_EXPANDABLE_YES));
72 eo_do(eina_list_data_get(selected), elm_items_item_expanded_set(EINA_TRUE));
73
74 for(int i = 0; i < number; i++)
75 {
76 item = eo_add(ELM_ITEMS_ITEM_CLASS, data);
77 eo_do(item, eo_event_callback_add(ELM_ITEMS_ITEM_EVENT_REALIZE, _realize, NULL);
78 eo_event_callback_add(ELM_ITEMS_ITEM_EVENT_UNREALIZE, _unrealize, NULL));
79 eo_do(item, it = elm_items_item_get());
80 eo_do(root, efl_tree_base_append(it, NULL));
81 evas_object_show(item);
82 }
83
84}
85
86EAPI_MAIN int
87elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
88{
89 Evas_Object *win, *list, *bx, *toolbox, *o;
90
91 elm_need_ethumb();
92 elm_need_efreet();
93
94 elm_items_init();
95
96 win = elm_win_util_standard_add("efm", "efm - Jesus");
97 evas_object_smart_callback_add(win, "delete,request", on_done, NULL);
98
99 bx = elm_box_add(win);
100 evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
101 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
102 evas_object_show(bx);
103
104 list = eo_add(ELM_ITEMS_LIST_CLASS, win);
105 evas_object_size_hint_align_set(list, EVAS_HINT_FILL, EVAS_HINT_FILL);
106 evas_object_size_hint_weight_set(list, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
107 evas_object_show(list);
108 elm_box_pack_end(bx, list);
109
110 toolbox = elm_box_add(win);
111 elm_box_horizontal_set(toolbox, EINA_TRUE);
112 evas_object_size_hint_weight_set(toolbox, EVAS_HINT_EXPAND, 0);
113 evas_object_size_hint_align_set(toolbox, EVAS_HINT_FILL, 0);
114 evas_object_show(toolbox);
115 elm_box_pack_end(bx, toolbox);
116
117 o = elm_check_add(toolbox);
118 elm_object_text_set(o, "Long time realize");
119 elm_check_state_pointer_set(o, &pause_realize);
120 evas_object_show(o);
121 elm_box_pack_end(bx, o);
122
123 spinner = o = elm_spinner_add(toolbox);
124 elm_spinner_value_set(o, 20);
125 elm_spinner_min_max_set(o, 1, 10000);
126 elm_spinner_editable_set(o, EINA_TRUE);
127 evas_object_show(o);
128 elm_box_pack_end(bx, o);
129
130 o = elm_button_add(toolbox);
131 elm_object_text_set(o, "Add to selected");
132 evas_object_show(o);
133 evas_object_smart_callback_add(o, "clicked", on_click, list);
134 elm_box_pack_end(bx, o);
135
136 elm_win_resize_object_add(win, bx);
137 evas_object_resize(win, 200,200);
138 evas_object_show(win);
139
140 elm_run();
141 return 0;
142}
143ELM_MAIN()