diff options
author | David Walter Seikel | 2012-01-23 23:30:42 +1000 |
---|---|---|
committer | David Walter Seikel | 2012-01-23 23:30:42 +1000 |
commit | 825a3d837a33f226c879cd02ad15c3fba57e8b2c (patch) | |
tree | 75f57bd9c4253508d338dc79ba8e57a7abc42255 /libraries/edje/src/lib/edje_edit.c | |
parent | Add ability to disable the test harness, or the Lua compile test. (diff) | |
download | SledjHamr-825a3d837a33f226c879cd02ad15c3fba57e8b2c.zip SledjHamr-825a3d837a33f226c879cd02ad15c3fba57e8b2c.tar.gz SledjHamr-825a3d837a33f226c879cd02ad15c3fba57e8b2c.tar.bz2 SledjHamr-825a3d837a33f226c879cd02ad15c3fba57e8b2c.tar.xz |
Update the EFL to what I'm actually using, coz I'm using some stuff not yet released.
Diffstat (limited to '')
-rw-r--r-- | libraries/edje/src/lib/edje_edit.c | 131 |
1 files changed, 60 insertions, 71 deletions
diff --git a/libraries/edje/src/lib/edje_edit.c b/libraries/edje/src/lib/edje_edit.c index 901a1b1..eec5e04 100644 --- a/libraries/edje/src/lib/edje_edit.c +++ b/libraries/edje/src/lib/edje_edit.c | |||
@@ -20,14 +20,18 @@ EAPI Eina_Error EDJE_EDIT_ERROR_GROUP_CURRENTLY_USED = 0 ; | |||
20 | EAPI Eina_Error EDJE_EDIT_ERROR_GROUP_REFERENCED = 0; | 20 | EAPI Eina_Error EDJE_EDIT_ERROR_GROUP_REFERENCED = 0; |
21 | EAPI Eina_Error EDJE_EDIT_ERROR_GROUP_DOES_NOT_EXIST = 0; | 21 | EAPI Eina_Error EDJE_EDIT_ERROR_GROUP_DOES_NOT_EXIST = 0; |
22 | 22 | ||
23 | /* Get ed(Edje*) from obj(Evas_Object*) */ | 23 | /* Get eed(Edje_Edit*) from obj(Evas_Object*) */ |
24 | #define GET_ED_OR_RETURN(RET) \ | 24 | #define GET_EED_OR_RETURN(RET) \ |
25 | Edje *ed; \ | ||
26 | Edje_Edit *eed; \ | 25 | Edje_Edit *eed; \ |
27 | if (!evas_object_smart_type_check_ptr(obj, _edje_edit_type)) \ | 26 | if (!evas_object_smart_type_check_ptr(obj, _edje_edit_type)) \ |
28 | return RET; \ | 27 | return RET; \ |
29 | eed = evas_object_smart_data_get(obj); \ | 28 | eed = evas_object_smart_data_get(obj); \ |
30 | if (!eed) return RET; \ | 29 | if (!eed) return RET; |
30 | |||
31 | /* Get ed(Edje*) from obj(Evas_Object*) */ | ||
32 | #define GET_ED_OR_RETURN(RET) \ | ||
33 | Edje *ed; \ | ||
34 | GET_EED_OR_RETURN(RET); \ | ||
31 | ed = (Edje *)eed; | 35 | ed = (Edje *)eed; |
32 | 36 | ||
33 | /* Get rp(Edje_Real_Part*) from obj(Evas_Object*) and part(char*) */ | 37 | /* Get rp(Edje_Real_Part*) from obj(Evas_Object*) and part(char*) */ |
@@ -388,72 +392,59 @@ _edje_real_part_free(Edje_Real_Part *rp) | |||
388 | static Eina_Bool | 392 | static Eina_Bool |
389 | _edje_import_font_file(Edje *ed, const char *path, const char *entry) | 393 | _edje_import_font_file(Edje *ed, const char *path, const char *entry) |
390 | { | 394 | { |
395 | Eina_File *f; | ||
396 | Eet_File *eetf = NULL; | ||
391 | void *fdata = NULL; | 397 | void *fdata = NULL; |
392 | long fsize = 0; | 398 | long fsize = 0; |
393 | 399 | ||
394 | /* Read font data from file */ | 400 | /* Read font data from file */ |
395 | { | 401 | f = eina_file_open(path, 0); |
396 | FILE *f = fopen(path, "rb"); | 402 | if (!f) |
397 | if (!f) | 403 | { |
398 | { | 404 | ERR("Unable to open font file \"%s\"", path); |
399 | ERR("Unable to open font file \"%s\"", path); | 405 | return EINA_FALSE; |
400 | return EINA_FALSE; | 406 | } |
401 | } | ||
402 | 407 | ||
403 | fseek(f, 0, SEEK_END); | 408 | fsize = eina_file_size_get(f); |
404 | fsize = ftell(f); | 409 | fdata = eina_file_map_all(f, EINA_FILE_SEQUENTIAL); |
405 | rewind(f); | 410 | if (!fdata) |
406 | fdata = malloc(fsize); | 411 | { |
407 | if (!fdata) | 412 | ERR("Unable to map font file \"%s\"", path); |
408 | { | 413 | goto on_error; |
409 | ERR("Unable to alloc font file \"%s\"", path); | 414 | } |
410 | fclose(f); | ||
411 | return EINA_FALSE; | ||
412 | } | ||
413 | if (fread(fdata, fsize, 1, f) != 1) | ||
414 | { | ||
415 | free(fdata); | ||
416 | fclose(f); | ||
417 | ERR("Unable to read all of font file \"%s\"", path); | ||
418 | return EINA_FALSE; | ||
419 | } | ||
420 | fclose(f); | ||
421 | } | ||
422 | 415 | ||
423 | /* Write font to edje file */ | 416 | /* Write font to edje file */ |
424 | { | 417 | eetf = eet_open(ed->path, EET_FILE_MODE_READ_WRITE); |
425 | /* open the eet file */ | 418 | if (!eetf) |
426 | Eet_File *eetf = eet_open(ed->path, EET_FILE_MODE_READ_WRITE); | 419 | { |
427 | if (!eetf) | 420 | ERR("Unable to open \"%s\" for writing output", ed->path); |
428 | { | 421 | goto on_error; |
429 | ERR("Unable to open \"%s\" for writing output", ed->path); | 422 | } |
430 | free(fdata); | ||
431 | return EINA_FALSE; | ||
432 | } | ||
433 | 423 | ||
434 | if (eet_write(eetf, entry, fdata, fsize, 1) <= 0) | 424 | if (eet_write(eetf, entry, fdata, fsize, 1) <= 0) |
435 | { | 425 | { |
436 | ERR("Unable to write font part \"%s\" as \"%s\" part entry", | 426 | ERR("Unable to write font part \"%s\" as \"%s\" part entry", |
437 | path, entry); | 427 | path, entry); |
438 | eet_close(eetf); | 428 | goto on_error; |
439 | free(fdata); | 429 | } |
440 | return EINA_FALSE; | ||
441 | } | ||
442 | 430 | ||
443 | free(fdata); | 431 | /* write the edje_file */ |
432 | if (!_edje_edit_edje_file_save(eetf, ed->file)) | ||
433 | goto on_error; | ||
444 | 434 | ||
445 | /* write the edje_file */ | 435 | eet_close(eetf); |
446 | if (!_edje_edit_edje_file_save(eetf, ed->file)) | ||
447 | { | ||
448 | eet_delete(eetf, entry); | ||
449 | eet_close(eetf); | ||
450 | return EINA_FALSE; | ||
451 | } | ||
452 | 436 | ||
453 | eet_close(eetf); | 437 | eina_file_map_free(f, fdata); |
454 | } | 438 | eina_file_close(f); |
455 | 439 | ||
456 | return EINA_TRUE; | 440 | return EINA_TRUE; |
441 | |||
442 | on_error: | ||
443 | if (eetf) eet_close(eetf); | ||
444 | eina_file_map_free(f, fdata); | ||
445 | eina_file_close(f); | ||
446 | |||
447 | return EINA_FALSE; | ||
457 | } | 448 | } |
458 | 449 | ||
459 | 450 | ||
@@ -4791,7 +4782,7 @@ edje_edit_image_id_get(Evas_Object *obj, const char *image_name) | |||
4791 | { | 4782 | { |
4792 | eina_error_set(0); | 4783 | eina_error_set(0); |
4793 | 4784 | ||
4794 | GET_ED_OR_RETURN(-1); | 4785 | GET_EED_OR_RETURN(-1); |
4795 | 4786 | ||
4796 | return _edje_image_id_find(eed, image_name); | 4787 | return _edje_image_id_find(eed, image_name); |
4797 | } | 4788 | } |
@@ -5174,7 +5165,6 @@ EAPI Eina_Bool | |||
5174 | edje_edit_program_add(Evas_Object *obj, const char *name) | 5165 | edje_edit_program_add(Evas_Object *obj, const char *name) |
5175 | { | 5166 | { |
5176 | Edje_Program *epr; | 5167 | Edje_Program *epr; |
5177 | Edje_Part_Collection *pc; | ||
5178 | 5168 | ||
5179 | eina_error_set(0); | 5169 | eina_error_set(0); |
5180 | 5170 | ||
@@ -5191,7 +5181,7 @@ edje_edit_program_add(Evas_Object *obj, const char *name) | |||
5191 | if (!epr) return EINA_FALSE; | 5181 | if (!epr) return EINA_FALSE; |
5192 | 5182 | ||
5193 | //Add program to group | 5183 | //Add program to group |
5194 | pc = ed->collection; | 5184 | // pc = ed->collection; |
5195 | 5185 | ||
5196 | /* By default, source and signal are empty, so they fill in nocmp category */ | 5186 | /* By default, source and signal are empty, so they fill in nocmp category */ |
5197 | ed->collection->programs.nocmp = realloc(ed->collection->programs.nocmp, | 5187 | ed->collection->programs.nocmp = realloc(ed->collection->programs.nocmp, |
@@ -5237,7 +5227,6 @@ edje_edit_program_del(Evas_Object *obj, const char *prog) | |||
5237 | Eina_List *l, *l_next; | 5227 | Eina_List *l, *l_next; |
5238 | Edje_Program_Target *prt; | 5228 | Edje_Program_Target *prt; |
5239 | Edje_Program_After *pa; | 5229 | Edje_Program_After *pa; |
5240 | Edje_Part_Collection *pc; | ||
5241 | Edje_Program *p; | 5230 | Edje_Program *p; |
5242 | Program_Script *ps, *old_ps; | 5231 | Program_Script *ps, *old_ps; |
5243 | int id, i; | 5232 | int id, i; |
@@ -5248,7 +5237,7 @@ edje_edit_program_del(Evas_Object *obj, const char *prog) | |||
5248 | GET_ED_OR_RETURN(EINA_FALSE); | 5237 | GET_ED_OR_RETURN(EINA_FALSE); |
5249 | GET_EPR_OR_RETURN(EINA_FALSE); | 5238 | GET_EPR_OR_RETURN(EINA_FALSE); |
5250 | 5239 | ||
5251 | pc = ed->collection; | 5240 | //pc = ed->collection; |
5252 | 5241 | ||
5253 | //Remove program from programs list | 5242 | //Remove program from programs list |
5254 | id = epr->id; | 5243 | id = epr->id; |
@@ -5737,7 +5726,7 @@ edje_edit_program_action_set(Evas_Object *obj, const char *prog, Edje_Action_Typ | |||
5737 | 5726 | ||
5738 | eina_error_set(0); | 5727 | eina_error_set(0); |
5739 | 5728 | ||
5740 | GET_ED_OR_RETURN(EINA_FALSE); | 5729 | GET_EED_OR_RETURN(EINA_FALSE); |
5741 | GET_EPR_OR_RETURN(EINA_FALSE); | 5730 | GET_EPR_OR_RETURN(EINA_FALSE); |
5742 | 5731 | ||
5743 | //printf("SET ACTION for program: %s [%d]\n", prog, action); | 5732 | //printf("SET ACTION for program: %s [%d]\n", prog, action); |
@@ -6081,7 +6070,7 @@ edje_edit_script_set(Evas_Object *obj, const char *code) | |||
6081 | { | 6070 | { |
6082 | eina_error_set(0); | 6071 | eina_error_set(0); |
6083 | 6072 | ||
6084 | GET_ED_OR_RETURN(); | 6073 | GET_EED_OR_RETURN(); |
6085 | 6074 | ||
6086 | free(eed->embryo_source); | 6075 | free(eed->embryo_source); |
6087 | free(eed->embryo_processed); | 6076 | free(eed->embryo_processed); |
@@ -6104,7 +6093,7 @@ edje_edit_script_program_get(Evas_Object *obj, const char *prog) | |||
6104 | 6093 | ||
6105 | eina_error_set(0); | 6094 | eina_error_set(0); |
6106 | 6095 | ||
6107 | GET_ED_OR_RETURN(NULL); | 6096 | GET_EED_OR_RETURN(NULL); |
6108 | GET_EPR_OR_RETURN(NULL); | 6097 | GET_EPR_OR_RETURN(NULL); |
6109 | 6098 | ||
6110 | if (epr->action != EDJE_ACTION_TYPE_SCRIPT) | 6099 | if (epr->action != EDJE_ACTION_TYPE_SCRIPT) |
@@ -6124,7 +6113,7 @@ edje_edit_script_program_set(Evas_Object *obj, const char *prog, const char *cod | |||
6124 | 6113 | ||
6125 | eina_error_set(0); | 6114 | eina_error_set(0); |
6126 | 6115 | ||
6127 | GET_ED_OR_RETURN(); | 6116 | GET_EED_OR_RETURN(); |
6128 | GET_EPR_OR_RETURN(); | 6117 | GET_EPR_OR_RETURN(); |
6129 | 6118 | ||
6130 | if (epr->action != EDJE_ACTION_TYPE_SCRIPT) | 6119 | if (epr->action != EDJE_ACTION_TYPE_SCRIPT) |
@@ -6550,7 +6539,7 @@ almost_out: | |||
6550 | EAPI Eina_Bool | 6539 | EAPI Eina_Bool |
6551 | edje_edit_script_compile(Evas_Object *obj) | 6540 | edje_edit_script_compile(Evas_Object *obj) |
6552 | { | 6541 | { |
6553 | GET_ED_OR_RETURN(EINA_FALSE); | 6542 | GET_EED_OR_RETURN(EINA_FALSE); |
6554 | 6543 | ||
6555 | if (!eed->script_need_recompile) | 6544 | if (!eed->script_need_recompile) |
6556 | return EINA_TRUE; | 6545 | return EINA_TRUE; |
@@ -6561,7 +6550,7 @@ edje_edit_script_compile(Evas_Object *obj) | |||
6561 | EAPI const Eina_List * | 6550 | EAPI const Eina_List * |
6562 | edje_edit_script_error_list_get(Evas_Object *obj) | 6551 | edje_edit_script_error_list_get(Evas_Object *obj) |
6563 | { | 6552 | { |
6564 | GET_ED_OR_RETURN(NULL); | 6553 | GET_EED_OR_RETURN(NULL); |
6565 | return eed->errors; | 6554 | return eed->errors; |
6566 | } | 6555 | } |
6567 | 6556 | ||
@@ -6643,7 +6632,7 @@ _edje_generate_source_of_program(Evas_Object *obj, const char *program, Eina_Str | |||
6643 | const char *api_name, *api_description; | 6632 | const char *api_name, *api_description; |
6644 | Edje_Program *epr; | 6633 | Edje_Program *epr; |
6645 | 6634 | ||
6646 | GET_ED_OR_RETURN(EINA_FALSE); | 6635 | GET_EED_OR_RETURN(EINA_FALSE); |
6647 | 6636 | ||
6648 | epr = _edje_program_get_byname(obj, program); | 6637 | epr = _edje_program_get_byname(obj, program); |
6649 | 6638 | ||
@@ -6816,7 +6805,7 @@ _edje_generate_source_of_state(Evas_Object *obj, const char *part, const char *s | |||
6816 | if (pd->aspect.min || pd->aspect.max) | 6805 | if (pd->aspect.min || pd->aspect.max) |
6817 | BUF_APPENDF(I5"aspect: %g %g;\n", TO_DOUBLE(pd->aspect.min), TO_DOUBLE(pd->aspect.max)); | 6806 | BUF_APPENDF(I5"aspect: %g %g;\n", TO_DOUBLE(pd->aspect.min), TO_DOUBLE(pd->aspect.max)); |
6818 | if (pd->aspect.prefer) | 6807 | if (pd->aspect.prefer) |
6819 | BUF_APPENDF(I5"aspect_preference: %s;\n", prefers[pd->aspect.prefer]); | 6808 | BUF_APPENDF(I5"aspect_preference: %s;\n", prefers[(int) pd->aspect.prefer]); |
6820 | 6809 | ||
6821 | if (pd->color_class) | 6810 | if (pd->color_class) |
6822 | BUF_APPENDF(I5"color_class: \"%s\";\n", pd->color_class); | 6811 | BUF_APPENDF(I5"color_class: \"%s\";\n", pd->color_class); |
@@ -7786,7 +7775,7 @@ edje_edit_print_internal_status(Evas_Object *obj) | |||
7786 | */ | 7775 | */ |
7787 | eina_error_set(0); | 7776 | eina_error_set(0); |
7788 | 7777 | ||
7789 | GET_ED_OR_RETURN(); | 7778 | GET_EED_OR_RETURN(); |
7790 | 7779 | ||
7791 | _edje_generate_source(obj); | 7780 | _edje_generate_source(obj); |
7792 | /* | 7781 | /* |