summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChunEon Park <hermet@hermet.pe.kr>2013-11-20 10:56:31 +0900
committerChunEon Park <hermet@hermet.pe.kr>2013-11-20 10:58:05 +0900
commitf86f394239a92983711f8a161b767f7231fad9d5 (patch)
tree35d8104172673213944661841bbb86001b913b29 /src
parentf45116c4f78303b9798aa9b4bdc91199532be410 (diff)
elementary/ctxpopup - fix T235 ctxpopup_example_01 can popup many times at once.
I know this is not fundamental fix but there is no solution at this moment unless fixing the evas.
Diffstat (limited to 'src')
-rw-r--r--src/bin/test_ctxpopup.c42
-rw-r--r--src/examples/ctxpopup_example_01.c29
2 files changed, 68 insertions, 3 deletions
diff --git a/src/bin/test_ctxpopup.c b/src/bin/test_ctxpopup.c
index f5164697c..03e394b08 100644
--- a/src/bin/test_ctxpopup.c
+++ b/src/bin/test_ctxpopup.c
@@ -3,7 +3,7 @@
3#endif 3#endif
4#include <Elementary.h> 4#include <Elementary.h>
5 5
6 6static int list_mouse_down = 0;
7 7
8static void 8static void
9_dismissed(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED) 9_dismissed(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
@@ -95,7 +95,6 @@ _ctxpopup_item_new(Evas_Object *obj, const char *label, const char *icon)
95 return it; 95 return it;
96} 96}
97 97
98
99static void 98static void
100_list_item_cb(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED) 99_list_item_cb(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
101{ 100{
@@ -103,6 +102,8 @@ _list_item_cb(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UN
103 Elm_Object_Item *it = NULL; 102 Elm_Object_Item *it = NULL;
104 Evas_Coord x,y; 103 Evas_Coord x,y;
105 104
105 if (list_mouse_down > 0) return;
106
106 ctxpopup = elm_ctxpopup_add(obj); 107 ctxpopup = elm_ctxpopup_add(obj);
107 evas_object_smart_callback_add(ctxpopup, "dismissed", _dismissed, NULL); 108 evas_object_smart_callback_add(ctxpopup, "dismissed", _dismissed, NULL);
108 109
@@ -129,6 +130,8 @@ _list_item_cb2(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_U
129 Elm_Object_Item *it = NULL; 130 Elm_Object_Item *it = NULL;
130 Evas_Coord x,y; 131 Evas_Coord x,y;
131 132
133 if (list_mouse_down > 0) return;
134
132 ctxpopup = elm_ctxpopup_add(obj); 135 ctxpopup = elm_ctxpopup_add(obj);
133 evas_object_smart_callback_add(ctxpopup, "dismissed", _dismissed, NULL); 136 evas_object_smart_callback_add(ctxpopup, "dismissed", _dismissed, NULL);
134 137
@@ -154,6 +157,8 @@ _list_item_cb3(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_U
154 Elm_Object_Item *it = NULL; 157 Elm_Object_Item *it = NULL;
155 Evas_Coord x,y; 158 Evas_Coord x,y;
156 159
160 if (list_mouse_down > 0) return;
161
157 ctxpopup = elm_ctxpopup_add(obj); 162 ctxpopup = elm_ctxpopup_add(obj);
158 evas_object_smart_callback_add(ctxpopup, "dismissed", _dismissed, NULL); 163 evas_object_smart_callback_add(ctxpopup, "dismissed", _dismissed, NULL);
159 164
@@ -177,6 +182,8 @@ _list_item_cb4(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_U
177 Evas_Object *ctxpopup; 182 Evas_Object *ctxpopup;
178 Evas_Coord x,y; 183 Evas_Coord x,y;
179 184
185 if (list_mouse_down > 0) return;
186
180 ctxpopup = elm_ctxpopup_add(obj); 187 ctxpopup = elm_ctxpopup_add(obj);
181 evas_object_smart_callback_add(ctxpopup, "dismissed", _dismissed, NULL); 188 evas_object_smart_callback_add(ctxpopup, "dismissed", _dismissed, NULL);
182 189
@@ -203,6 +210,8 @@ _list_item_cb5(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_U
203 Evas_Object *ctxpopup, *btn, *sc, *bx; 210 Evas_Object *ctxpopup, *btn, *sc, *bx;
204 Evas_Coord x,y; 211 Evas_Coord x,y;
205 212
213 if (list_mouse_down > 0) return;
214
206 bx = elm_box_add(obj); 215 bx = elm_box_add(obj);
207 evas_object_size_hint_min_set(bx, 150, 150); 216 evas_object_size_hint_min_set(bx, 150, 150);
208 217
@@ -240,6 +249,8 @@ _list_item_cb6(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_U
240 Evas_Object *ctxpopup, *btn, *sc, *bx; 249 Evas_Object *ctxpopup, *btn, *sc, *bx;
241 Evas_Coord x,y; 250 Evas_Coord x,y;
242 251
252 if (list_mouse_down > 0) return;
253
243 bx = elm_box_add(obj); 254 bx = elm_box_add(obj);
244 evas_object_size_hint_min_set(bx, 200, 150); 255 evas_object_size_hint_min_set(bx, 200, 150);
245 256
@@ -295,6 +306,7 @@ _list_item_cb7(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_U
295 Evas_Object *ctxpopup; 306 Evas_Object *ctxpopup;
296 Evas_Coord x,y; 307 Evas_Coord x,y;
297 308
309 if (list_mouse_down > 0) return;
298 ctxpopup = elm_ctxpopup_add(obj); 310 ctxpopup = elm_ctxpopup_add(obj);
299 evas_object_smart_callback_add(ctxpopup, "dismissed", _dismissed, NULL); 311 evas_object_smart_callback_add(ctxpopup, "dismissed", _dismissed, NULL);
300 312
@@ -309,20 +321,44 @@ _list_item_cb7(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_U
309 _print_current_dir(ctxpopup); 321 _print_current_dir(ctxpopup);
310} 322}
311 323
312static void _list_clicked(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info) 324static void
325_list_clicked(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
313{ 326{
314 elm_list_item_selected_set(event_info, EINA_FALSE); 327 elm_list_item_selected_set(event_info, EINA_FALSE);
315} 328}
316 329
330static void
331_list_mouse_down(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
332{
333 list_mouse_down++;
334}
335
336static void
337_list_mouse_up(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
338{
339 list_mouse_down--;
340}
341
342static void
343_win_del(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
344{
345 list_mouse_down = 0;
346}
347
317void 348void
318test_ctxpopup(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 349test_ctxpopup(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
319{ 350{
320 Evas_Object *win, *list; 351 Evas_Object *win, *list;
321 352
322 win = elm_win_util_standard_add("contextual-popup", "Contextual Popup"); 353 win = elm_win_util_standard_add("contextual-popup", "Contextual Popup");
354 evas_object_smart_callback_add(win, "delete,request", _win_del, NULL);
323 elm_win_autodel_set(win, EINA_TRUE); 355 elm_win_autodel_set(win, EINA_TRUE);
324 356
325 list = elm_list_add(win); 357 list = elm_list_add(win);
358 evas_object_event_callback_add(list, EVAS_CALLBACK_MOUSE_DOWN,
359 _list_mouse_down, NULL);
360 evas_object_event_callback_add(list, EVAS_CALLBACK_MOUSE_UP,
361 _list_mouse_up, NULL);
326 evas_object_size_hint_weight_set(list, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 362 evas_object_size_hint_weight_set(list, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
327 elm_win_resize_object_add(win, list); 363 elm_win_resize_object_add(win, list);
328 elm_list_mode_set(list, ELM_LIST_COMPRESS); 364 elm_list_mode_set(list, ELM_LIST_COMPRESS);
diff --git a/src/examples/ctxpopup_example_01.c b/src/examples/ctxpopup_example_01.c
index 9b998ace4..c0cf1643e 100644
--- a/src/examples/ctxpopup_example_01.c
+++ b/src/examples/ctxpopup_example_01.c
@@ -3,6 +3,8 @@
3 3
4#include <Elementary.h> 4#include <Elementary.h>
5 5
6static int list_mouse_down = 0;
7
6static void 8static void
7_dismissed_cb(void *data, Evas_Object *obj, void *event_info) 9_dismissed_cb(void *data, Evas_Object *obj, void *event_info)
8{ 10{
@@ -30,6 +32,8 @@ _list_item_cb(void *data, Evas_Object *obj, void *event_info)
30 Elm_Object_Item *it; 32 Elm_Object_Item *it;
31 Evas_Coord x,y; 33 Evas_Coord x,y;
32 34
35 if (list_mouse_down > 0) return;
36
33 ctxpopup = elm_ctxpopup_add(obj); 37 ctxpopup = elm_ctxpopup_add(obj);
34 evas_object_smart_callback_add(ctxpopup, "dismissed", _dismissed_cb, NULL); 38 evas_object_smart_callback_add(ctxpopup, "dismissed", _dismissed_cb, NULL);
35 39
@@ -56,6 +60,8 @@ _list_item_cb2(void *data, Evas_Object *obj, void *event_info)
56 Elm_Object_Item *it; 60 Elm_Object_Item *it;
57 Evas_Coord x,y; 61 Evas_Coord x,y;
58 62
63 if (list_mouse_down > 0) return;
64
59 ctxpopup = elm_ctxpopup_add(obj); 65 ctxpopup = elm_ctxpopup_add(obj);
60 evas_object_smart_callback_add(ctxpopup, "dismissed", _dismissed_cb, NULL); 66 evas_object_smart_callback_add(ctxpopup, "dismissed", _dismissed_cb, NULL);
61 elm_ctxpopup_horizontal_set(ctxpopup, EINA_TRUE); 67 elm_ctxpopup_horizontal_set(ctxpopup, EINA_TRUE);
@@ -75,6 +81,24 @@ _list_item_cb2(void *data, Evas_Object *obj, void *event_info)
75 elm_list_item_selected_set(event_info, EINA_FALSE); 81 elm_list_item_selected_set(event_info, EINA_FALSE);
76} 82}
77 83
84static void
85_list_mouse_down(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
86{
87 list_mouse_down++;
88}
89
90static void
91_list_mouse_up(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
92{
93 list_mouse_down--;
94}
95
96static void
97_win_del(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
98{
99 list_mouse_down = 0;
100}
101
78EAPI_MAIN int 102EAPI_MAIN int
79elm_main(int argc, char **argv) 103elm_main(int argc, char **argv)
80{ 104{
@@ -83,11 +107,16 @@ elm_main(int argc, char **argv)
83 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED); 107 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
84 108
85 win = elm_win_util_standard_add("Contextual Popup", "Contextual Popup"); 109 win = elm_win_util_standard_add("Contextual Popup", "Contextual Popup");
110 evas_object_smart_callback_add(win, "delete,request", _win_del, NULL);
86 elm_win_autodel_set(win, EINA_TRUE); 111 elm_win_autodel_set(win, EINA_TRUE);
87 evas_object_resize(win, 400, 400); 112 evas_object_resize(win, 400, 400);
88 evas_object_show(win); 113 evas_object_show(win);
89 114
90 list = elm_list_add(win); 115 list = elm_list_add(win);
116 evas_object_event_callback_add(list, EVAS_CALLBACK_MOUSE_DOWN,
117 _list_mouse_down, NULL);
118 evas_object_event_callback_add(list, EVAS_CALLBACK_MOUSE_UP,
119 _list_mouse_up, NULL);
91 evas_object_size_hint_weight_set(list, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 120 evas_object_size_hint_weight_set(list, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
92 elm_win_resize_object_add(win, list); 121 elm_win_resize_object_add(win, list);
93 elm_list_mode_set(list, ELM_LIST_COMPRESS); 122 elm_list_mode_set(list, ELM_LIST_COMPRESS);