summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Juyung Seo <seojuyung2@gmail.com>2014-01-22 12:32:32 +0900
committerDaniel Juyung Seo <seojuyung2@gmail.com>2014-01-22 12:32:32 +0900
commit8e178f2cabddc689da418cb888bbd8d87d6246f5 (patch)
tree773883fa1a0f9273530dee4ed11dc112f8a0f864
parente6ae0898501cac239a648725e896b50c6cac693b (diff)
test_conform_indicator: Refactor internal code of conform_indicator test
code. - removed unnecessary casting. - removed unnecessary internal variables. - removed wrong window resize object addition. - changed parent parameter correctly. - fixed wrong grammar in command line message. - fixed resource leak. - enhanced comments. - removed unnecessary size hint align set. - removed unnecessary parameter passing.
-rw-r--r--src/bin/test_conform_indicator.c65
1 files changed, 33 insertions, 32 deletions
diff --git a/src/bin/test_conform_indicator.c b/src/bin/test_conform_indicator.c
index 8cda21b8a..d7c13b9e7 100644
--- a/src/bin/test_conform_indicator.c
+++ b/src/bin/test_conform_indicator.c
@@ -51,8 +51,9 @@ _rot_270(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
51static void 51static void
52_visible_change_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 52_visible_change_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
53{ 53{
54 printf("visible change before=%d\n",vis); 54 Evas_Object *win = data;
55 Evas_Object *win = (Evas_Object *) data; 55
56 printf("visible change before = %d\n", vis);
56 if (vis == 0) 57 if (vis == 0)
57 { 58 {
58 elm_win_indicator_mode_set(win, ELM_WIN_INDICATOR_SHOW); 59 elm_win_indicator_mode_set(win, ELM_WIN_INDICATOR_SHOW);
@@ -63,8 +64,9 @@ _visible_change_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EI
63 elm_win_indicator_mode_set(win, ELM_WIN_INDICATOR_HIDE); 64 elm_win_indicator_mode_set(win, ELM_WIN_INDICATOR_HIDE);
64 vis = 0; 65 vis = 0;
65 } 66 }
67
66 /*Add App code here*/ 68 /*Add App code here*/
67 printf("visible change after=%d\n",vis); 69 printf("visible change after = %d\n", vis);
68} 70}
69 71
70static void 72static void
@@ -74,8 +76,6 @@ _launch_conformant_indicator_window_btn_cb(void *data EINA_UNUSED,
74{ 76{
75 Evas_Object *win, *conform, *bt, *bx; 77 Evas_Object *win, *conform, *bt, *bx;
76 Evas_Object *plug_port = NULL, *plug_land = NULL; 78 Evas_Object *plug_port = NULL, *plug_land = NULL;
77 char *svr_name_port = "elm_indicator_portrait";
78 char *svr_name_land = "elm_indicator_landscape";
79 79
80 win = elm_win_util_standard_add("conformant-indicator", 80 win = elm_win_util_standard_add("conformant-indicator",
81 "Conformant Indicator"); 81 "Conformant Indicator");
@@ -89,11 +89,10 @@ _launch_conformant_indicator_window_btn_cb(void *data EINA_UNUSED,
89 evas_object_show(conform); 89 evas_object_show(conform);
90 90
91 bx = elm_box_add(conform); 91 bx = elm_box_add(conform);
92 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 92 elm_object_content_set(conform, bx);
93 elm_win_resize_object_add(win, bx);
94 evas_object_show(bx); 93 evas_object_show(bx);
95 94
96 bt = elm_button_add(win); 95 bt = elm_button_add(bx);
97 elm_object_text_set(bt, "Rot 0"); 96 elm_object_text_set(bt, "Rot 0");
98 evas_object_smart_callback_add(bt, "clicked", _rot_0, win); 97 evas_object_smart_callback_add(bt, "clicked", _rot_0, win);
99 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0); 98 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
@@ -101,7 +100,7 @@ _launch_conformant_indicator_window_btn_cb(void *data EINA_UNUSED,
101 elm_box_pack_end(bx, bt); 100 elm_box_pack_end(bx, bt);
102 evas_object_show(bt); 101 evas_object_show(bt);
103 102
104 bt = elm_button_add(win); 103 bt = elm_button_add(bx);
105 elm_object_text_set(bt, "Rot 90"); 104 elm_object_text_set(bt, "Rot 90");
106 evas_object_smart_callback_add(bt, "clicked", _rot_90, win); 105 evas_object_smart_callback_add(bt, "clicked", _rot_90, win);
107 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0); 106 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
@@ -109,7 +108,7 @@ _launch_conformant_indicator_window_btn_cb(void *data EINA_UNUSED,
109 elm_box_pack_end(bx, bt); 108 elm_box_pack_end(bx, bt);
110 evas_object_show(bt); 109 evas_object_show(bt);
111 110
112 bt = elm_button_add(win); 111 bt = elm_button_add(bx);
113 elm_object_text_set(bt, "Rot 180"); 112 elm_object_text_set(bt, "Rot 180");
114 evas_object_smart_callback_add(bt, "clicked", _rot_180, win); 113 evas_object_smart_callback_add(bt, "clicked", _rot_180, win);
115 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0); 114 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
@@ -117,7 +116,7 @@ _launch_conformant_indicator_window_btn_cb(void *data EINA_UNUSED,
117 elm_box_pack_end(bx, bt); 116 elm_box_pack_end(bx, bt);
118 evas_object_show(bt); 117 evas_object_show(bt);
119 118
120 bt = elm_button_add(win); 119 bt = elm_button_add(bx);
121 elm_object_text_set(bt, "Rot 270"); 120 elm_object_text_set(bt, "Rot 270");
122 evas_object_smart_callback_add(bt, "clicked", _rot_270, win); 121 evas_object_smart_callback_add(bt, "clicked", _rot_270, win);
123 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0); 122 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
@@ -126,16 +125,18 @@ _launch_conformant_indicator_window_btn_cb(void *data EINA_UNUSED,
126 evas_object_show(bt); 125 evas_object_show(bt);
127 126
128 /* portrait plug */ 127 /* portrait plug */
129 plug_port = elm_plug_add(win); 128 plug_port = elm_plug_add(bx);
130 if (!plug_port) 129 if (!plug_port)
131 { 130 {
132 printf("fail to create plug to server[%s]\n", svr_name_port); 131 printf("fail to create plug to server [elm_indicator_portrait]\n");
132 evas_object_del(win);
133 return; 133 return;
134 } 134 }
135 135
136 if (!elm_plug_connect(plug_port, svr_name_port, 0, EINA_FALSE)) 136 if (!elm_plug_connect(plug_port, "elm_indicator_portrait", 0, EINA_FALSE))
137 { 137 {
138 printf("fail to connect to server[%s]\n", svr_name_port); 138 printf("fail to connect to server [elm_indicator_portraits]\n");
139 evas_object_del(win);
139 return; 140 return;
140 } 141 }
141 evas_object_size_hint_weight_set(plug_port, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 142 evas_object_size_hint_weight_set(plug_port, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
@@ -144,15 +145,17 @@ _launch_conformant_indicator_window_btn_cb(void *data EINA_UNUSED,
144 elm_box_pack_end(bx, plug_port); 145 elm_box_pack_end(bx, plug_port);
145 146
146 /* landscape plug */ 147 /* landscape plug */
147 plug_land = elm_plug_add(win); 148 plug_land = elm_plug_add(bx);
148 if (!plug_land) 149 if (!plug_land)
149 { 150 {
150 printf("fail to create plug to server[%s]\n", svr_name_land); 151 printf("fail to create plug to server [elm_indicator_landscape]\n");
152 evas_object_del(win);
151 return; 153 return;
152 } 154 }
153 if (!elm_plug_connect(plug_land, svr_name_land, 0, EINA_FALSE)) 155 if (!elm_plug_connect(plug_land, "elm_indicator_landscape", 0, EINA_FALSE))
154 { 156 {
155 printf("fail to connect to server[%s]\n", svr_name_land); 157 printf("fail to connect to server [elm_indicator_landscape]\n");
158 evas_object_del(win);
156 return; 159 return;
157 } 160 }
158 evas_object_size_hint_weight_set(plug_land, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 161 evas_object_size_hint_weight_set(plug_land, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
@@ -160,7 +163,7 @@ _launch_conformant_indicator_window_btn_cb(void *data EINA_UNUSED,
160 evas_object_show(plug_land); 163 evas_object_show(plug_land);
161 elm_box_pack_end(bx, plug_land); 164 elm_box_pack_end(bx, plug_land);
162 165
163 bt = elm_button_add(win); 166 bt = elm_button_add(bx);
164 elm_object_text_set(bt, "Show/Hide"); 167 elm_object_text_set(bt, "Show/Hide");
165 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0); 168 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0);
166 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL); 169 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
@@ -168,8 +171,6 @@ _launch_conformant_indicator_window_btn_cb(void *data EINA_UNUSED,
168 evas_object_show(bt); 171 evas_object_show(bt);
169 evas_object_smart_callback_add(bt, "clicked", _visible_change_cb, win); 172 evas_object_smart_callback_add(bt, "clicked", _visible_change_cb, win);
170 173
171 elm_object_content_set(conform, bx);
172
173 evas_object_resize(win, 400, 600); 174 evas_object_resize(win, 400, 600);
174 evas_object_show(win); 175 evas_object_show(win);
175} 176}
@@ -219,7 +220,7 @@ _fill_portrait(Evas_Object *win)
219 evas_object_move(btn, 260, 0); 220 evas_object_move(btn, 260, 0);
220 evas_object_show(btn); 221 evas_object_show(btn);
221 222
222 // This check: indicator get mouse event well from application 223 // This checks whether the indicator gets mouse event from application correctly
223 evas_object_event_callback_add(bg, EVAS_CALLBACK_MOUSE_DOWN, _mouse_down_cb, btn); 224 evas_object_event_callback_add(bg, EVAS_CALLBACK_MOUSE_DOWN, _mouse_down_cb, btn);
224 evas_object_event_callback_add(bg, EVAS_CALLBACK_MOUSE_MOVE, _mouse_move_cb, btn); 225 evas_object_event_callback_add(bg, EVAS_CALLBACK_MOUSE_MOVE, _mouse_move_cb, btn);
225} 226}
@@ -247,7 +248,7 @@ _fill_landscape(Evas_Object *win)
247 evas_object_move(btn, 580, 0); 248 evas_object_move(btn, 580, 0);
248 evas_object_show(btn); 249 evas_object_show(btn);
249 250
250 // This check: indicator get mouse event well from application 251 // This checks whether the indicator gets mouse event from application correctly
251 evas_object_event_callback_add(bg, EVAS_CALLBACK_MOUSE_DOWN, _mouse_down_cb, btn); 252 evas_object_event_callback_add(bg, EVAS_CALLBACK_MOUSE_DOWN, _mouse_down_cb, btn);
252 evas_object_event_callback_add(bg, EVAS_CALLBACK_MOUSE_MOVE, _mouse_move_cb, btn); 253 evas_object_event_callback_add(bg, EVAS_CALLBACK_MOUSE_MOVE, _mouse_move_cb, btn);
253} 254}
@@ -260,7 +261,7 @@ _create_portrait(void)
260 win_port = elm_win_add(NULL, "portrait_indicator", ELM_WIN_SOCKET_IMAGE); 261 win_port = elm_win_add(NULL, "portrait_indicator", ELM_WIN_SOCKET_IMAGE);
261 if (!win_port) 262 if (!win_port)
262 { 263 {
263 printf("fail to elm_win_add:port\n"); 264 printf("fail to create a portrait indicator window\n");
264 return NULL; 265 return NULL;
265 } 266 }
266 elm_win_autodel_set(win_port, EINA_TRUE); 267 elm_win_autodel_set(win_port, EINA_TRUE);
@@ -268,13 +269,13 @@ _create_portrait(void)
268 port_indi_name = elm_config_indicator_service_get(0); 269 port_indi_name = elm_config_indicator_service_get(0);
269 if (!port_indi_name) 270 if (!port_indi_name)
270 { 271 {
271 printf("indicator cannot portrait service name: use default name\n"); 272 printf("indicator has no portrait service name: use default name\n");
272 port_indi_name = "elm_indicator_portrait"; 273 port_indi_name = "elm_indicator_portrait";
273 } 274 }
274 275
275 if (!elm_win_socket_listen(win_port, port_indi_name, 0, EINA_FALSE)) 276 if (!elm_win_socket_listen(win_port, port_indi_name, 0, EINA_FALSE))
276 { 277 {
277 printf("fail to elm_win_socket_listen():port \n"); 278 printf("failed to listen portrait window socket.\n");
278 evas_object_del(win_port); 279 evas_object_del(win_port);
279 return NULL; 280 return NULL;
280 } 281 }
@@ -286,6 +287,7 @@ _create_portrait(void)
286 evas_object_resize(win_port, 720, 60); 287 evas_object_resize(win_port, 720, 60);
287 288
288 _fill_portrait(win_port); 289 _fill_portrait(win_port);
290
289 return win_port; 291 return win_port;
290} 292}
291 293
@@ -297,7 +299,7 @@ _create_landscape(void)
297 win_land = elm_win_add(NULL, "win_socket_test:land", ELM_WIN_SOCKET_IMAGE); 299 win_land = elm_win_add(NULL, "win_socket_test:land", ELM_WIN_SOCKET_IMAGE);
298 if (!win_land) 300 if (!win_land)
299 { 301 {
300 printf("fail to elm_win_add:land\n"); 302 printf("fail to create a landscape indicator window\n");
301 return NULL; 303 return NULL;
302 } 304 }
303 elm_win_autodel_set(win_land, EINA_TRUE); 305 elm_win_autodel_set(win_land, EINA_TRUE);
@@ -305,13 +307,13 @@ _create_landscape(void)
305 land_indi_name = elm_config_indicator_service_get(90); 307 land_indi_name = elm_config_indicator_service_get(90);
306 if (!land_indi_name) 308 if (!land_indi_name)
307 { 309 {
308 printf("indicator cannot landscape service name: use default name\n"); 310 printf("indicator has no landscape service name: use default name\n");
309 land_indi_name = "elm_indicator_landscape"; 311 land_indi_name = "elm_indicator_landscape";
310 } 312 }
311 313
312 if (!elm_win_socket_listen(win_land, land_indi_name, 0, 0)) 314 if (!elm_win_socket_listen(win_land, land_indi_name, 0, 0))
313 { 315 {
314 printf("fail to elm_win_socket_listen():land\n"); 316 printf("fail to listen landscape window socket.\n");
315 evas_object_del(win_land); 317 evas_object_del(win_land);
316 return NULL; 318 return NULL;
317 } 319 }
@@ -356,7 +358,6 @@ test_conformant_indicator(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
356 358
357 bx = elm_box_add(win); 359 bx = elm_box_add(win);
358 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 360 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
359 evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
360 elm_win_resize_object_add(win, bx); 361 elm_win_resize_object_add(win, bx);
361 evas_object_show(bx); 362 evas_object_show(bx);
362 363
@@ -376,7 +377,7 @@ test_conformant_indicator(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
376 elm_box_pack_end(bx, btn); 377 elm_box_pack_end(bx, btn);
377 evas_object_show(btn); 378 evas_object_show(btn);
378 evas_object_smart_callback_add(btn, "clicked", 379 evas_object_smart_callback_add(btn, "clicked",
379 _launch_conformant_indicator_window_btn_cb, win); 380 _launch_conformant_indicator_window_btn_cb, NULL);
380 381
381 evas_object_resize(win, 200, 200); 382 evas_object_resize(win, 200, 200);
382 evas_object_show(win); 383 evas_object_show(win);