aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/elementary/src/bin/test_popup.c
diff options
context:
space:
mode:
authorDavid Walter Seikel2012-04-22 09:20:32 +1000
committerDavid Walter Seikel2012-04-22 09:20:32 +1000
commit3ad3455551be0d7859ecb02290376206d5e66498 (patch)
tree497917e12b4d7f458dff9765d9b53f64c4e03fc3 /libraries/elementary/src/bin/test_popup.c
parentUpdate EFL to latest beta. (diff)
downloadSledjHamr-3ad3455551be0d7859ecb02290376206d5e66498.zip
SledjHamr-3ad3455551be0d7859ecb02290376206d5e66498.tar.gz
SledjHamr-3ad3455551be0d7859ecb02290376206d5e66498.tar.bz2
SledjHamr-3ad3455551be0d7859ecb02290376206d5e66498.tar.xz
And actually include new files, plus elementary libraries.
Diffstat (limited to 'libraries/elementary/src/bin/test_popup.c')
-rw-r--r--libraries/elementary/src/bin/test_popup.c351
1 files changed, 351 insertions, 0 deletions
diff --git a/libraries/elementary/src/bin/test_popup.c b/libraries/elementary/src/bin/test_popup.c
new file mode 100644
index 0000000..723b3f0
--- /dev/null
+++ b/libraries/elementary/src/bin/test_popup.c
@@ -0,0 +1,351 @@
1#ifdef HAVE_CONFIG_H
2# include "elementary_config.h"
3#endif
4#include <Elementary.h>
5#ifndef ELM_LIB_QUICKLAUNCH
6
7static Evas_Object *g_popup = NULL;
8static int times = 0;
9
10static void
11_response_cb(void *data, Evas_Object *obj __UNUSED__,
12 void *event_info __UNUSED__)
13{
14 Evas_Object *popup_data = evas_object_data_get(data, "im");
15 if (popup_data) evas_object_del(popup_data);
16 evas_object_hide(data);
17 evas_object_del(data);
18}
19
20static void
21_g_popup_response_cb(void *data, Evas_Object *obj __UNUSED__,
22 void *event_info __UNUSED__)
23{
24 evas_object_hide(data);
25}
26
27static void
28_block_clicked_cb(void *data __UNUSED__, Evas_Object *obj,
29 void *event_info __UNUSED__)
30{
31 printf("\nblock,clicked callback\n");
32 Evas_Object *popup_data = evas_object_data_get(obj, "im");
33 if (popup_data) evas_object_del(popup_data);
34 evas_object_del(obj);
35}
36
37static void
38_item_selected_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__,
39 void *event_info)
40{
41 printf("popup item selected: %s\n", elm_object_item_text_get(event_info));
42}
43
44static void
45_list_click(void *data __UNUSED__, Evas_Object *obj,
46 void *event_info __UNUSED__)
47{
48 Elm_Object_Item *it = elm_list_selected_item_get(obj);
49 if (!it) return;
50 elm_list_item_selected_set(it, EINA_FALSE);
51}
52
53static void
54_popup_center_text_cb(void *data, Evas_Object *obj __UNUSED__,
55 void *event_info __UNUSED__)
56{
57 Evas_Object *popup;
58
59 popup = elm_popup_add(data);
60 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
61 elm_object_text_set(popup, "This Popup has content area and "
62 "timeout value is 3 seconds");
63 elm_popup_timeout_set(popup, 3.0);
64 evas_object_smart_callback_add(popup, "timeout", _response_cb, popup);
65 evas_object_show(popup);
66}
67
68static void
69_popup_center_text_1button_cb(void *data, Evas_Object *obj __UNUSED__,
70 void *event_info __UNUSED__)
71{
72 Evas_Object *popup;
73 Evas_Object *btn;
74
75 popup = elm_popup_add(data);
76 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
77 elm_object_text_set(popup, "This Popup has content area and "
78 "action area set, action area has one button Close");
79 btn = elm_button_add(popup);
80 elm_object_text_set(btn, "Close");
81 elm_object_part_content_set(popup, "button1", btn);
82 evas_object_smart_callback_add(btn, "clicked", _response_cb, popup);
83 evas_object_show(popup);
84}
85
86static void
87_popup_center_title_text_1button_cb(void *data, Evas_Object *obj __UNUSED__,
88 void *event_info __UNUSED__)
89{
90 Evas_Object *popup;
91 Evas_Object *btn;
92
93 popup = elm_popup_add(data);
94 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
95 elm_object_text_set(popup, "This Popup has title area, content area and "
96 "action area set, action area has one button Close");
97 elm_object_part_text_set(popup, "title,text", "Title");
98 btn = elm_button_add(popup);
99 elm_object_text_set(btn, "Close");
100 elm_object_part_content_set(popup, "button1", btn);
101 evas_object_smart_callback_add(btn, "clicked", _response_cb, popup);
102 evas_object_show(popup);
103}
104
105static void
106_popup_center_title_text_block_clicked_event_cb(void *data,
107 Evas_Object *obj __UNUSED__,
108 void *event_info __UNUSED__)
109{
110 Evas_Object *popup;
111
112 popup = elm_popup_add(data);
113 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
114 elm_object_text_set(popup, "This Popup has title area and content area. "
115 "When clicked on blocked event region, popup gets "
116 "deleted");
117 elm_object_part_text_set(popup, "title,text", "Title");
118 evas_object_smart_callback_add(popup, "block,clicked", _block_clicked_cb,
119 NULL);
120 evas_object_show(popup);
121}
122
123static void
124_popup_bottom_title_text_3button_cb(void *data, Evas_Object *obj __UNUSED__,
125 void *event_info __UNUSED__)
126{
127 Evas_Object *popup;
128 Evas_Object *icon, *btn1, *btn2, *btn3;
129 char buf[256];
130
131 popup = elm_popup_add(data);
132 elm_popup_orient_set(popup, ELM_POPUP_ORIENT_BOTTOM);
133 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
134 elm_object_text_set(popup, "This Popup has title area, content area and "
135 "action area set with content being character wrapped. "
136 "action area has three buttons OK, Cancel and Close");
137 elm_popup_content_text_wrap_type_set(popup, ELM_WRAP_CHAR);
138 elm_object_part_text_set(popup, "title,text", "Title");
139 icon = elm_icon_add(popup);
140 snprintf(buf, sizeof(buf), "%s/images/logo_small.png",
141 elm_app_data_dir_get());
142 elm_icon_file_set(icon, buf, NULL);
143 elm_object_part_content_set(popup, "title,icon", icon);
144 btn1 = elm_button_add(popup);
145 elm_object_text_set(btn1, "OK");
146 elm_object_part_content_set(popup, "button1", btn1);
147 btn2 = elm_button_add(popup);
148 elm_object_text_set(btn2, "Cancel");
149 elm_object_part_content_set(popup, "button2", btn2);
150 btn3 = elm_button_add(popup);
151 elm_object_text_set(btn3, "Close");
152 elm_object_part_content_set(popup, "button3", btn3);
153 evas_object_smart_callback_add(btn1, "clicked", _response_cb, popup);
154 evas_object_smart_callback_add(btn2, "clicked", _response_cb, popup);
155 evas_object_smart_callback_add(btn3, "clicked", _response_cb, popup);
156 evas_object_show(popup);
157}
158
159static void
160_popup_center_title_content_3button_cb(void *data, Evas_Object *obj __UNUSED__,
161 void *event_info __UNUSED__)
162{
163 Evas_Object *popup;
164 Evas_Object *icon, *btn, *btn1, *btn2, *btn3;
165 char buf[256];
166
167 popup = elm_popup_add(data);
168 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
169 btn = elm_button_add(popup);
170 elm_object_text_set(btn, "Content");
171 icon = elm_icon_add(btn);
172 snprintf(buf, sizeof(buf), "%s/images/logo_small.png",
173 elm_app_data_dir_get());
174 elm_icon_file_set(icon, buf, NULL);
175 elm_object_content_set(btn, icon);
176 elm_object_content_set(popup, btn);
177 elm_object_part_text_set(popup, "title,text", "Title");
178 btn1 = elm_button_add(popup);
179 elm_object_text_set(btn1, "OK");
180 elm_object_part_content_set(popup, "button1", btn1);
181 btn2 = elm_button_add(popup);
182 elm_object_text_set(btn2, "Cancel");
183 elm_object_part_content_set(popup, "button2", btn2);
184 btn3 = elm_button_add(popup);
185 elm_object_text_set(btn3, "Close");
186 elm_object_part_content_set(popup, "button3", btn3);
187 evas_object_smart_callback_add(btn1, "clicked", _response_cb, popup);
188 evas_object_smart_callback_add(btn2, "clicked", _response_cb, popup);
189 evas_object_smart_callback_add(btn3, "clicked", _response_cb, popup);
190 evas_object_show(popup);
191}
192
193static void
194_popup_center_title_item_3button_cb(void *data, Evas_Object *obj __UNUSED__,
195 void *event_info __UNUSED__)
196{
197 char buf[256];
198 unsigned int i;
199 Evas_Object *popup, *icon1, *btn1, *btn2, *btn3;
200
201 popup = elm_popup_add(data);
202 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
203 icon1 = elm_icon_add(popup);
204 elm_object_part_text_set(popup, "title,text", "Title");
205 snprintf(buf, sizeof(buf), "%s/images/logo_small.png",
206 elm_app_data_dir_get());
207 elm_icon_file_set(icon1, buf, NULL);
208 for (i = 0; i < 10; i++)
209 {
210 snprintf(buf, sizeof(buf), "Item%u", i+1);
211 if (i == 3)
212 elm_popup_item_append(popup, buf, icon1, _item_selected_cb, NULL);
213 else
214 elm_popup_item_append(popup, buf, NULL, _item_selected_cb, NULL);
215 }
216 btn1 = elm_button_add(popup);
217 elm_object_text_set(btn1, "OK");
218 elm_object_part_content_set(popup, "button1", btn1);
219 btn2 = elm_button_add(popup);
220 elm_object_text_set(btn2, "Cancel");
221 elm_object_part_content_set(popup, "button2", btn2);
222 btn3 = elm_button_add(popup);
223 elm_object_text_set(btn3, "Close");
224 elm_object_part_content_set(popup, "button3", btn3);
225 evas_object_smart_callback_add(btn1, "clicked", _response_cb, popup);
226 evas_object_smart_callback_add(btn2, "clicked", _response_cb, popup);
227 evas_object_smart_callback_add(btn3, "clicked", _response_cb, popup);
228 evas_object_show(popup);
229}
230
231static void
232_restack_btn_clicked(void *data, Evas_Object *obj, void *event_info __UNUSED__)
233{
234 Evas_Object *im;
235 char buf[PATH_MAX];
236 void *popup_data;
237
238 popup_data = evas_object_data_get(data, "im");
239 if (popup_data) return;
240
241 im = evas_object_image_filled_add(evas_object_evas_get(obj));
242 snprintf(buf, sizeof(buf), "%s/images/%s",
243 elm_app_data_dir_get(), "twofish.jpg");
244 evas_object_image_file_set(im, buf, NULL);
245 evas_object_move(im, 40, 40);
246 evas_object_resize(im, 320, 320);
247 evas_object_show(im);
248 evas_object_data_set((Evas_Object *)data, "im", im);
249
250 evas_object_raise((Evas_Object *)data);
251}
252
253static void
254_popup_center_title_text_2button_restack_cb(void *data, Evas_Object *obj __UNUSED__,
255 void *event_info __UNUSED__)
256{
257 Evas_Object *popup;
258 Evas_Object *btn, *btn2;
259
260 popup = elm_popup_add(data);
261 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
262 elm_object_text_set(popup, "When you click the 'Restack' button, "
263 "an image will be located under this popup");
264 elm_object_part_text_set(popup, "title,text", "Title");
265 btn = elm_button_add(popup);
266 elm_object_text_set(btn, "Restack");
267 elm_object_part_content_set(popup, "button1", btn);
268 evas_object_smart_callback_add(btn, "clicked", _restack_btn_clicked, popup);
269 evas_object_smart_callback_add(popup, "block,clicked", _block_clicked_cb,
270 NULL);
271
272 btn2 = elm_button_add(popup);
273 elm_object_text_set(btn2, "Close");
274 elm_object_part_content_set(popup, "button2", btn2);
275 evas_object_smart_callback_add(btn2, "clicked", _response_cb, popup);
276
277 evas_object_show(popup);
278}
279
280static void
281_popup_center_text_1button_hide_show_cb(void *data, Evas_Object *obj __UNUSED__,
282 void *event_info __UNUSED__)
283{
284 Evas_Object *btn;
285 char str[128];
286
287 times++;
288 if (g_popup)
289 {
290 sprintf(str, "You have checked this popup %d times.", times);
291 elm_object_text_set(g_popup, str);
292 evas_object_show(g_popup);
293 return;
294 }
295
296 g_popup = elm_popup_add(data);
297 evas_object_size_hint_weight_set(g_popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
298 elm_object_text_set(g_popup, "Hide this popup by using the button."
299 "When you click list item again, you can see this popup.");
300 btn = elm_button_add(g_popup);
301 elm_object_text_set(btn, "Hide");
302 elm_object_part_content_set(g_popup, "button1", btn);
303 evas_object_smart_callback_add(btn, "clicked", _g_popup_response_cb, g_popup);
304
305 evas_object_show(g_popup);
306}
307
308void
309test_popup(void *data __UNUSED__, Evas_Object *obj __UNUSED__,
310 void *event_info __UNUSED__)
311{
312 Evas_Object *win, *list;
313
314 win = elm_win_util_standard_add("popup", "Popup");
315 elm_win_autodel_set(win, EINA_TRUE);
316
317 list = elm_list_add(win);
318 elm_win_resize_object_add(win, list);
319 elm_list_mode_set(list, ELM_LIST_LIMIT);
320 evas_object_size_hint_weight_set(list, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
321 evas_object_smart_callback_add(list, "selected", _list_click, NULL);
322
323 elm_list_item_append(list, "popup-center-text", NULL, NULL,
324 _popup_center_text_cb, win);
325 elm_list_item_append(list, "popup-center-text + 1 button", NULL, NULL,
326 _popup_center_text_1button_cb, win);
327 elm_list_item_append(list, "popup-center-title + text + 1 button", NULL,
328 NULL, _popup_center_title_text_1button_cb, win);
329
330 elm_list_item_append(list,
331 "popup-center-title + text (block,clicked handling)",
332 NULL, NULL,
333 _popup_center_title_text_block_clicked_event_cb, win);
334 elm_list_item_append(list, "popup-bottom-title + text + 3 buttons", NULL,
335 NULL, _popup_bottom_title_text_3button_cb, win);
336 elm_list_item_append(list, "popup-center-title + content + 3 buttons", NULL,
337 NULL, _popup_center_title_content_3button_cb, win);
338 elm_list_item_append(list, "popup-center-title + items + 3 buttons", NULL,
339 NULL, _popup_center_title_item_3button_cb, win);
340 elm_list_item_append(list, "popup-center-title + text + 2 buttons (check restacking)", NULL, NULL,
341 _popup_center_title_text_2button_restack_cb, win);
342 elm_list_item_append(list, "popup-center-text + 1 button (check hide, show)", NULL, NULL,
343 _popup_center_text_1button_hide_show_cb, win);
344 elm_list_go(list);
345 evas_object_show(list);
346 evas_object_show(win);
347 evas_object_resize(win, 480, 800);
348}
349
350#endif
351