summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYakov Goldberg <yakov.g@samsung.com>2013-12-23 13:31:03 +0200
committerYakov Goldberg <yakov.g@samsung.com>2013-12-23 13:31:03 +0200
commit209baa0411d1d3689738f498b262f3621dcd15ab (patch)
treeebcc1882f05059e155832105a62f3e816061e92f
parenta0d56c35f58e49b370f219387ce3701e68658352 (diff)
parentb96a5e0ad507c77573a0dda4e3762d7569128ae8 (diff)
Merge 'develop':v0.2.2
- add rotation of target in simulation mode; - fixes according to coverage testing;
-rw-r--r--src/bin/egui_gui/egui_logic.c2
-rw-r--r--src/bin/main.c7
-rw-r--r--src/lib/database.c6
-rw-r--r--src/lib/eina_json.c6
-rw-r--r--src/lib/ffi_abstraction.c5
-rw-r--r--src/lib/ffi_glue.c2
-rw-r--r--src/lib/generator.c20
-rw-r--r--src/lib/gui_parser.c22
-rw-r--r--src/lib/gui_widget.c13
-rw-r--r--src/lib/gui_widget.h4
-rw-r--r--src/lib/simulator.c79
11 files changed, 138 insertions, 28 deletions
diff --git a/src/bin/egui_gui/egui_logic.c b/src/bin/egui_gui/egui_logic.c
index 1e4a3f5..40eedb9 100644
--- a/src/bin/egui_gui/egui_logic.c
+++ b/src/bin/egui_gui/egui_logic.c
@@ -413,6 +413,8 @@ _sub_wins_hide_show_cb(void *data, Evas_Object *_obj EINA_UNUSED, void *event_in
413 case PROPERTIES_VIEW: 413 case PROPERTIES_VIEW:
414 eo_do(g->right_panel_box, elm_obj_box_pack_end(obj)); 414 eo_do(g->right_panel_box, elm_obj_box_pack_end(obj));
415 break; 415 break;
416 default:
417 break;
416 } 418 }
417 } 419 }
418 else 420 else
diff --git a/src/bin/main.c b/src/bin/main.c
index d6a84b7..4641149 100644
--- a/src/bin/main.c
+++ b/src/bin/main.c
@@ -11,7 +11,7 @@
11#include "egui_logic.h" 11#include "egui_logic.h"
12#endif 12#endif
13 13
14static int 14static Eina_Bool
15_generate(const char *filename, const char* path, const char *project) 15_generate(const char *filename, const char* path, const char *project)
16{ 16{
17 Gui_Context *ctx; 17 Gui_Context *ctx;
@@ -19,19 +19,20 @@ _generate(const char *filename, const char* path, const char *project)
19 if (!ctx) 19 if (!ctx)
20 { 20 {
21 ERR("Can not create context: %p", ctx); 21 ERR("Can not create context: %p", ctx);
22 return EINA_FALSE;
22 } 23 }
23 24
24 if (!gui_parser_json_file_read(ctx, filename)) 25 if (!gui_parser_json_file_read(ctx, filename))
25 { 26 {
26 gui_context_del(ctx); 27 gui_context_del(ctx);
27 return 0; 28 return EINA_FALSE;
28 } 29 }
29 30
30 gui_context_validate(ctx); 31 gui_context_validate(ctx);
31 32
32 generator_ctx_source_generate(ctx, path, project); 33 generator_ctx_source_generate(ctx, path, project);
33 gui_context_del(ctx); 34 gui_context_del(ctx);
34 return 0; 35 return EINA_TRUE;
35} 36}
36 37
37static void 38static void
diff --git a/src/lib/database.c b/src/lib/database.c
index 4fe76e1..9215d46 100644
--- a/src/lib/database.c
+++ b/src/lib/database.c
@@ -480,18 +480,18 @@ db_op_desc_param_number_get(const Op_Desc *p)
480Op_Flag 480Op_Flag
481db_op_desc_flag_get(const Op_Desc *op_desc) 481db_op_desc_flag_get(const Op_Desc *op_desc)
482{ 482{
483 return op_desc->op_flag; 483 return (op_desc?op_desc->op_flag:EGUI_NO_CALL);
484} 484}
485 485
486/* Get Eo op id for current op*/ 486/* Get Eo op id for current op*/
487Eo_Op 487Eo_Op
488db_op_desc_op_id_get(const Op_Desc *op_desc) 488db_op_desc_op_id_get(const Op_Desc *op_desc)
489{ 489{
490 if ((op_desc) && (!op_desc->base_op_id)) 490 if (!op_desc || (!op_desc->base_op_id))
491 { 491 {
492 return -1; 492 return -1;
493 } 493 }
494 return *op_desc->base_op_id + op_desc->relative_op_id; 494 return *(op_desc->base_op_id) + op_desc->relative_op_id;
495} 495}
496 496
497/* Get func name for current op*/ 497/* Get func name for current op*/
diff --git a/src/lib/eina_json.c b/src/lib/eina_json.c
index 9de6bd6..3e14cd0 100644
--- a/src/lib/eina_json.c
+++ b/src/lib/eina_json.c
@@ -1197,7 +1197,11 @@ eina_json_object_value_get_internal(Eina_Json_Value *obj, ...)
1197 va_start(vl, obj); 1197 va_start(vl, obj);
1198 while ((jkey = va_arg(vl, char*))) 1198 while ((jkey = va_arg(vl, char*)))
1199 { 1199 {
1200 if (jval->type != EINA_JSON_TYPE_OBJECT) return NULL; 1200 if (jval->type != EINA_JSON_TYPE_OBJECT)
1201 {
1202 va_end(vl);
1203 return NULL;
1204 }
1201 for (l = jval->lst; l; l = l->next) 1205 for (l = jval->lst; l; l = l->next)
1202 { 1206 {
1203 jval = EINA_INLIST_CONTAINER_GET(l, Eina_Json_Value); 1207 jval = EINA_INLIST_CONTAINER_GET(l, Eina_Json_Value);
diff --git a/src/lib/ffi_abstraction.c b/src/lib/ffi_abstraction.c
index 5ac43bc..dc264cf 100644
--- a/src/lib/ffi_abstraction.c
+++ b/src/lib/ffi_abstraction.c
@@ -195,7 +195,10 @@ _ffi_eo_add(const Gui_Session *session, const Gui_Widget *wdg)
195 { 195 {
196 parent_eo = session_eo_get(session, parent_wdg); 196 parent_eo = session_eo_get(session, parent_wdg);
197 if (!parent_eo) 197 if (!parent_eo)
198 return NULL; 198 {
199 ret = NULL;
200 goto end;
201 }
199 } 202 }
200 203
201 types[3] = &ffi_type_pointer; 204 types[3] = &ffi_type_pointer;
diff --git a/src/lib/ffi_glue.c b/src/lib/ffi_glue.c
index 9e2114d..ed33e6e 100644
--- a/src/lib/ffi_glue.c
+++ b/src/lib/ffi_glue.c
@@ -106,7 +106,7 @@ Eina_Bool
106manager_widget_create(Gui_Session *session, const Gui_Widget *wdg, Action_Mode mode, void *data) 106manager_widget_create(Gui_Session *session, const Gui_Widget *wdg, Action_Mode mode, void *data)
107{ 107{
108 EINA_SAFETY_ON_NULL_RETURN_VAL(wdg, EINA_FALSE); 108 EINA_SAFETY_ON_NULL_RETURN_VAL(wdg, EINA_FALSE);
109 Eina_Bool ret; 109 Eina_Bool ret = EINA_TRUE;
110 110
111 if (_modes_functions[mode].wdg_add) 111 if (_modes_functions[mode].wdg_add)
112 { 112 {
diff --git a/src/lib/generator.c b/src/lib/generator.c
index 7f29b34..14204c5 100644
--- a/src/lib/generator.c
+++ b/src/lib/generator.c
@@ -269,12 +269,13 @@ _wdg_add_generate(Gui_Session *session, const Gui_Widget *wdg, void *data)
269{ 269{
270 char *parent_id, *constr_id; 270 char *parent_id, *constr_id;
271 Eina_Stringshare *class_id; 271 Eina_Stringshare *class_id;
272
272 char *ret = calloc(1000, 1); 273 char *ret = calloc(1000, 1);
273 274
274 if (!wdg) 275 if (!wdg)
275 { 276 {
276 WRN("Wdg is NULL"); 277 WRN("Wdg is NULL");
277 return EINA_FALSE; 278 goto bad_end;
278 } 279 }
279 280
280 parent_id = wdg_parent_name_get(wdg); 281 parent_id = wdg_parent_name_get(wdg);
@@ -284,7 +285,7 @@ _wdg_add_generate(Gui_Session *session, const Gui_Widget *wdg, void *data)
284 if (!class_id) 285 if (!class_id)
285 { 286 {
286 ERR("Property \"class\" is missing in widget: \"%s\"\n", wdg_name_get(wdg)); 287 ERR("Property \"class\" is missing in widget: \"%s\"\n", wdg_name_get(wdg));
287 return EINA_FALSE; 288 goto bad_end;
288 } 289 }
289 290
290 /* if there is no property "constructor", it means - using eo constr */ 291 /* if there is no property "constructor", it means - using eo constr */
@@ -308,7 +309,7 @@ _wdg_add_generate(Gui_Session *session, const Gui_Widget *wdg, void *data)
308 if (!op_desc) 309 if (!op_desc)
309 { 310 {
310 ERR("Constructor: \"%s\" was not found in hash table.\n", constr_id); 311 ERR("Constructor: \"%s\" was not found in hash table.\n", constr_id);
311 return EINA_FALSE; 312 goto bad_end;
312 } 313 }
313 314
314 values_lst = prop_value_get(wdg_prop_get(wdg, constr_id)); 315 values_lst = prop_value_get(wdg_prop_get(wdg, constr_id));
@@ -320,7 +321,7 @@ _wdg_add_generate(Gui_Session *session, const Gui_Widget *wdg, void *data)
320 if (!format_string) 321 if (!format_string)
321 { 322 {
322 ERR("calloc failed"); 323 ERR("calloc failed");
323 return EINA_FALSE; 324 goto bad_end;
324 } 325 }
325 326
326 p_fs = format_string; 327 p_fs = format_string;
@@ -350,6 +351,9 @@ _wdg_add_generate(Gui_Session *session, const Gui_Widget *wdg, void *data)
350 351
351 session_wdg_existence_set(session, wdg, EINA_TRUE); 352 session_wdg_existence_set(session, wdg, EINA_TRUE);
352 return EINA_TRUE; 353 return EINA_TRUE;
354bad_end:
355 free(ret);
356 return EINA_FALSE;
353} 357}
354 358
355/* Recursively generate context for widget and its children. */ 359/* Recursively generate context for widget and its children. */
@@ -642,8 +646,6 @@ _ctx_to_file_save(Gui_Context *ctx, const char *path, const char *project)
642 "#endif"); 646 "#endif");
643 } 647 }
644 648
645 fclose(fp_c);
646 fclose(fp_h);
647 free(gl_gen_ctx.buf); 649 free(gl_gen_ctx.buf);
648 eina_array_free(gl_gen_ctx.global_names); 650 eina_array_free(gl_gen_ctx.global_names);
649 eina_hash_free(gl_gen_ctx.created_sequences_hash); 651 eina_hash_free(gl_gen_ctx.created_sequences_hash);
@@ -651,8 +653,10 @@ _ctx_to_file_save(Gui_Context *ctx, const char *path, const char *project)
651 session_del(session); 653 session_del(session);
652 654
653end: 655end:
654 free(filename_c); 656 if (fp_c) fclose(fp_c);
655 free(filename_h); 657 if (fp_h) fclose(fp_h);
658 free(filename_c);
659 free(filename_h);
656} 660}
657 661
658void 662void
diff --git a/src/lib/gui_parser.c b/src/lib/gui_parser.c
index 6d29524..153cc5b 100644
--- a/src/lib/gui_parser.c
+++ b/src/lib/gui_parser.c
@@ -16,7 +16,7 @@ char*
16gui_parser_file_string_get(const char *filename) 16gui_parser_file_string_get(const char *filename)
17{ 17{
18 char *file_data = NULL; 18 char *file_data = NULL;
19 size_t file_size; 19 int file_size;
20 FILE *fp = fopen(filename, "r"); 20 FILE *fp = fopen(filename, "r");
21 if (!fp) 21 if (!fp)
22 { 22 {
@@ -26,6 +26,12 @@ gui_parser_file_string_get(const char *filename)
26 26
27 fseek(fp, 0, SEEK_END); 27 fseek(fp, 0, SEEK_END);
28 file_size = ftell(fp); 28 file_size = ftell(fp);
29 if (file_size == -1)
30 {
31 fclose(fp);
32 printf("Can not ftell file: \"%s\".\n", filename);
33 return NULL;
34 }
29 rewind(fp); 35 rewind(fp);
30 file_data = (char *) calloc(1, file_size + 1); 36 file_data = (char *) calloc(1, file_size + 1);
31 if (!file_data) 37 if (!file_data)
@@ -34,8 +40,14 @@ gui_parser_file_string_get(const char *filename)
34 ERR("Calloc failed"); 40 ERR("Calloc failed");
35 return NULL; 41 return NULL;
36 } 42 }
37 fread(file_data, file_size, 1, fp); 43 int res = fread(file_data, file_size, 1, fp);
38 fclose(fp); 44 fclose(fp);
45 if (!res)
46 {
47 free(file_data);
48 file_data = NULL;
49 ERR("fread failed");
50 }
39 return file_data; 51 return file_data;
40} 52}
41 53
@@ -339,7 +351,10 @@ _json_arr_to_eina_list(Eina_Json_Value *jv)
339 } 351 }
340 break; 352 break;
341 default: 353 default:
342 ERR("default case"); 354 {
355 g_type = GUI_TYPE_NONE;
356 ERR("default case");
357 }
343 } 358 }
344 gui_value_set(g_val, g_type, p_value); 359 gui_value_set(g_val, g_type, p_value);
345 values = eina_list_append(values, g_val); 360 values = eina_list_append(values, g_val);
@@ -364,6 +379,7 @@ _widget_parse(Gui_Context *gui_ctx, const char *widget_name, Eina_Json_Value *wi
364 /* Get "class" from json */ 379 /* Get "class" from json */
365 Eina_Json_Value *j = EINA_JSON_OBJECT_VALUE_GET(widget_js, "Desc", "class"); 380 Eina_Json_Value *j = EINA_JSON_OBJECT_VALUE_GET(widget_js, "Desc", "class");
366 Eina_Json_Value *tmp = NULL; 381 Eina_Json_Value *tmp = NULL;
382 if (!j) goto bad_end;
367 class_name = eina_json_string_get(j); 383 class_name = eina_json_string_get(j);
368 wdg_class_name_set(wdg, class_name); 384 wdg_class_name_set(wdg, class_name);
369 385
diff --git a/src/lib/gui_widget.c b/src/lib/gui_widget.c
index 99d3d02..bbdb986 100644
--- a/src/lib/gui_widget.c
+++ b/src/lib/gui_widget.c
@@ -639,19 +639,20 @@ wdg_lst_get(const Gui_Context *ctx)
639void 639void
640wdg_class_name_set(Gui_Widget *wdg, const char *class_name) 640wdg_class_name_set(Gui_Widget *wdg, const char *class_name)
641{ 641{
642 wdg->class_name = eina_stringshare_add(class_name); 642 if (wdg)
643 wdg->class_name = eina_stringshare_add(class_name);
643} 644}
644 645
645Eina_Stringshare* 646Eina_Stringshare*
646wdg_class_name_get(const Gui_Widget *wdg) 647wdg_class_name_get(const Gui_Widget *wdg)
647{ 648{
648 return wdg->class_name; 649 return (wdg?wdg->class_name:NULL);
649} 650}
650 651
651const Gui_Widget* 652const Gui_Widget*
652wdg_parent_get(const Gui_Widget *wdg) 653wdg_parent_get(const Gui_Widget *wdg)
653{ 654{
654 return wdg->parent; 655 return (wdg?wdg->parent:NULL);
655} 656}
656 657
657char* 658char*
@@ -1720,6 +1721,12 @@ session_target_view_pop(Gui_Session *session)
1720 return ret; 1721 return ret;
1721} 1722}
1722 1723
1724const Gui_Widget*
1725session_target_view_top(Gui_Session *session)
1726{
1727 return eina_list_data_get(session->views);
1728}
1729
1723void session_target_local_geometry_set(Gui_Session *session, int w, int h) 1730void session_target_local_geometry_set(Gui_Session *session, int w, int h)
1724{ 1731{
1725 session->target_local_w = w; 1732 session->target_local_w = w;
diff --git a/src/lib/gui_widget.h b/src/lib/gui_widget.h
index 88dfe62..e8e8055 100644
--- a/src/lib/gui_widget.h
+++ b/src/lib/gui_widget.h
@@ -538,4 +538,8 @@ session_target_view_push(Gui_Session *session, const Gui_Widget* view);
538const Gui_Widget* 538const Gui_Widget*
539session_target_view_pop(Gui_Session *session); 539session_target_view_pop(Gui_Session *session);
540 540
541/* Get currently top window from stack of views. */
542const Gui_Widget*
543session_target_view_top(Gui_Session *session);
544
541#endif 545#endif
diff --git a/src/lib/simulator.c b/src/lib/simulator.c
index 0e771df..b0c0dd4 100644
--- a/src/lib/simulator.c
+++ b/src/lib/simulator.c
@@ -147,6 +147,18 @@ _widget_add(Gui_Session *session, const Gui_Widget *wdg, void *data EINA_UNUSED)
147 parent_win = target; 147 parent_win = target;
148 win_type = ELM_WIN_INLINED_IMAGE; 148 win_type = ELM_WIN_INLINED_IMAGE;
149 o = eo_add_custom(ELM_OBJ_WIN_CLASS, parent_win, elm_obj_win_constructor(NULL, win_type)); 149 o = eo_add_custom(ELM_OBJ_WIN_CLASS, parent_win, elm_obj_win_constructor(NULL, win_type));
150
151 /* Hide currently top window, because following window could be resized. */
152 {
153 const Gui_Widget *top_wdg = session_target_view_top(session);
154 if (top_wdg)
155 {
156 Eo *top_o;
157 top_o = session_eo_get(session, top_wdg);
158 eo_do(top_o, evas_obj_visibility_set(EINA_FALSE));
159 }
160 }
161
150 session_target_view_push(session, wdg); 162 session_target_view_push(session, wdg);
151 eo_do(o, evas_obj_size_set(local_w, local_h)); 163 eo_do(o, evas_obj_size_set(local_w, local_h));
152 io = elm_win_inlined_image_object_get(o); 164 io = elm_win_inlined_image_object_get(o);
@@ -183,7 +195,7 @@ _widget_del(Gui_Session *session, const Gui_Widget *wdg, void *data EINA_UNUSED)
183static Eina_Bool 195static Eina_Bool
184_widget_eo_do(Gui_Session *session, const Gui_Widget *wdg, void *prop, void *data EINA_UNUSED) 196_widget_eo_do(Gui_Session *session, const Gui_Widget *wdg, void *prop, void *data EINA_UNUSED)
185{ 197{
186 Eina_Bool ret; 198 Eina_Bool ret = EINA_TRUE;
187 if (IS_WIN(wdg) && (!strcmp(SIZE_SET, prop_name_get((Gui_Widget_Property* ) prop)))) 199 if (IS_WIN(wdg) && (!strcmp(SIZE_SET, prop_name_get((Gui_Widget_Property* ) prop))))
188 { 200 {
189 /* If target exists, don't resize win, because it's defined by target's size. */ 201 /* If target exists, don't resize win, because it's defined by target's size. */
@@ -209,10 +221,58 @@ _target_back_button_clicked(void *data, Eo *obj EINA_UNUSED, const Eo_Event_Desc
209 Gui_Session *session = data; 221 Gui_Session *session = data;
210 Gui_Widget *wdg; 222 Gui_Widget *wdg;
211 wdg = (Gui_Widget *) session_target_view_pop(session); 223 wdg = (Gui_Widget *) session_target_view_pop(session);
212 if (wdg) 224
213 { 225 if (!wdg)
214 manager_widget_delete(session, wdg, MODE_SIMULATOR, NULL); 226 return EO_CALLBACK_CONTINUE;
215 } 227
228 /* Delete upper window. */
229 manager_widget_delete(session, wdg, MODE_SIMULATOR, NULL);
230
231 /* Probably rotation was changed on child window. So when we go back,
232 * need to resize currently upper window. */
233 Evas_Coord w, h;
234 session_target_local_geometry_get(session, &w, &h);
235
236 Eo *o, *io;
237 wdg = (Gui_Widget *) session_target_view_top(session);
238 o = session_eo_get(session, wdg);
239 io = elm_win_inlined_image_object_get(o);
240 eo_do(o, evas_obj_size_set(w, h));
241 /* Show previous window. */
242 eo_do(o, evas_obj_visibility_set(EINA_TRUE));
243 eo_do(io, evas_obj_size_set(w, h));
244
245 return EO_CALLBACK_CONTINUE;
246}
247
248/* Rotate callback*/
249static Eina_Bool
250_target_rotate_button_clicked(void *data, Eo *obj, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
251{
252 Gui_Session *session = data;
253 Eo *menu_box;
254 eo_do(obj, eo_base_data_get("menu_box", (void **) &menu_box));
255
256 /* Flip width and height */
257 Evas_Coord w, h;
258 session_target_local_geometry_get(session, &w, &h);
259 session_target_local_geometry_set(session, h, w);
260
261 /* Flip window's dimensions. */
262 Eo *win = (Eo *) session_target_win_get(session);
263 eo_do(win, evas_obj_size_set(h, w + 50));
264
265 /* Change position of the box*/
266 eo_do(menu_box, evas_obj_position_set(0, w));
267 eo_do(menu_box, evas_obj_size_set(h, 50));
268
269 Gui_Widget *wdg;
270 Eo *o, *io;
271 wdg = (Gui_Widget *) session_target_view_top(session);
272 o = session_eo_get(session, wdg);
273 eo_do(o, evas_obj_size_set(h, w));
274 io = elm_win_inlined_image_object_get(o);
275 eo_do(io, evas_obj_size_set(h, w));
216 return EO_CALLBACK_CONTINUE; 276 return EO_CALLBACK_CONTINUE;
217} 277}
218 278
@@ -257,6 +317,14 @@ simulator_ctx_call(Gui_Context *ctx, const char *target_name)
257 eo_do(back, evas_obj_visibility_set(EINA_TRUE)); 317 eo_do(back, evas_obj_visibility_set(EINA_TRUE));
258 eo_do(menu_box, elm_obj_box_pack_end(back)); 318 eo_do(menu_box, elm_obj_box_pack_end(back));
259 319
320 Eo *rotate = eo_add(ELM_OBJ_BUTTON_CLASS, menu_box);
321 eo_unref(rotate);
322 eo_do(rotate, elm_wdg_part_text_set(NULL, "Rotate"));
323 eo_do(rotate, evas_obj_visibility_set(EINA_TRUE));
324 eo_do(menu_box, elm_obj_box_pack_end(rotate));
325 /* Hack arpund box, because I need to set position for box, when rotating. */
326 eo_do(rotate, eo_base_data_set("menu_box", menu_box, NULL));
327
260 /* We know current display's DPI and target's dpi. So we can calculate 328 /* We know current display's DPI and target's dpi. So we can calculate
261 * target's size in pixels in current DPI to match metric size of target. */ 329 * target's size in pixels in current DPI to match metric size of target. */
262 int target_dpix, target_dpiy, target_w, target_h; 330 int target_dpix, target_dpiy, target_w, target_h;
@@ -277,6 +345,7 @@ simulator_ctx_call(Gui_Context *ctx, const char *target_name)
277 eo_do(tw, evas_obj_size_set(w, h + 50)); 345 eo_do(tw, evas_obj_size_set(w, h + 50));
278 346
279 eo_do(back, eo_event_callback_add(&_CLICKED_EVENT, _target_back_button_clicked, exec_data.session)); 347 eo_do(back, eo_event_callback_add(&_CLICKED_EVENT, _target_back_button_clicked, exec_data.session));
348 eo_do(rotate, eo_event_callback_add(&_CLICKED_EVENT, _target_rotate_button_clicked, exec_data.session));
280 eo_do(tw, evas_obj_visibility_set(EINA_TRUE)); 349 eo_do(tw, evas_obj_visibility_set(EINA_TRUE));
281 } 350 }
282 session_target_win_set(exec_data.session, td, tw); 351 session_target_win_set(exec_data.session, td, tw);