rimmed pushed a commit to branch master. http://git.enlightenment.org/tools/eflete.git/commit/?id=5202da641f8911b580b932a580e33bf367249ea7
commit 5202da641f8911b580b932a580e33bf367249ea7 Author: Mykyta Biliavskyi <[email protected]> Date: Thu Aug 11 19:30:49 2016 +0300 Resource export: additional case for sound resource. Newly added sound sample uses absolute path as a source. This make wrong path on export resource stage. Sound sample is stored into deeper eirectories. For example: Sound 1.wav was added into project form /tmp/snds/ directory. On exporting resources into /home/user/export sound above will be exported at /home/user/export/sounds/tmp/snds/1.wav instead /home/user/export/soungs/1.wav. Now sound file name parced directly from it source. --- src/bin/project_manager/project_manager.c | 32 ++++++++++++++++--- .../project_manager_export_resources.c | 36 ++++++++++++---------- src/bin/project_manager/resource_manager.h | 1 + src/bin/ui/image_manager.c | 13 ++++---- src/bin/ui/popup.c | 2 +- src/bin/ui/sound_manager.c | 16 +++++----- src/bin/ui/sound_player/sound_player.c | 6 ++-- 7 files changed, 68 insertions(+), 38 deletions(-) diff --git a/src/bin/project_manager/project_manager.c b/src/bin/project_manager/project_manager.c index cc5363a..0eab64b 100644 --- a/src/bin/project_manager/project_manager.c +++ b/src/bin/project_manager/project_manager.c @@ -669,13 +669,22 @@ _external_resources_export(Eina_List *resources, const char *dst) buf = eina_strbuf_new(); EINA_LIST_FOREACH(resources, l, res) { - eina_strbuf_append_printf(buf, "%s/%s", dst, res->name); + if (res->resource_type == RESOURCE_TYPE_SOUND) + { + eina_strbuf_append_printf(buf, "%s/%s", dst, ecore_file_file_get(res->source)); + } + else if (res->path == NULL) + eina_strbuf_append_printf(buf, "%s/%s", dst, res->name); + else + { + eina_strbuf_append_printf(buf, "%s/%s", dst, res->source); + } path = ecore_file_dir_get(eina_strbuf_string_get(buf)); if (!ecore_file_is_dir(path)) { ecore_file_mkpath(path); } - ecore_file_cp(res->source, eina_strbuf_string_get(buf)); + ecore_file_cp(res->path, eina_strbuf_string_get(buf)); eina_strbuf_reset(buf); free(path); path = NULL; @@ -689,20 +698,33 @@ _external_resource_export(Eina_List *resources, Eina_Stringshare *name, const ch Eina_Strbuf *buf; Eina_List *l; External_Resource *res; - char *path; + char *path = NULL; buf = eina_strbuf_new(); EINA_LIST_FOREACH(resources, l, res) { if (name == res->name) { - eina_strbuf_append_printf(buf, "%s/%s", dst, res->name); + if (res->resource_type == RESOURCE_TYPE_SOUND) + { + eina_strbuf_append_printf(buf, "%s/%s", dst, ecore_file_file_get(res->source)); + } + else if (res->path == NULL) + { + eina_strbuf_append_printf(buf, "%s/%s", dst, res->name); + } + else + { + eina_strbuf_append_printf(buf, "%s/%s", dst, res->source); + } + path = ecore_file_dir_get(eina_strbuf_string_get(buf)); + if (!ecore_file_is_dir(path)) { ecore_file_mkpath(path); } - ecore_file_cp(res->source, eina_strbuf_string_get(buf)); + ecore_file_cp(res->path, eina_strbuf_string_get(buf)); eina_strbuf_reset(buf); free(path); break; diff --git a/src/bin/project_manager/project_manager_export_resources.c b/src/bin/project_manager/project_manager_export_resources.c index 4bfa58e..8ef3509 100644 --- a/src/bin/project_manager/project_manager_export_resources.c +++ b/src/bin/project_manager/project_manager_export_resources.c @@ -153,15 +153,17 @@ _image_resources_feedback_job(void *data, Ecore_Thread *th) res = (External_Resource *) resource_add(image_name, RESOURCE_TYPE_IMAGE); comp_type = edje_edit_image_compression_type_get(project->global_object, res->name); + + res->source = eina_stringshare_add(image_name); if (comp_type == EDJE_EDIT_IMAGE_COMP_USER) - res->source = eina_stringshare_add(image_name); + res->path = eina_stringshare_add(res->source); else - res->source = eina_stringshare_printf("%s/%s", resource_folder, image_name); + res->path = eina_stringshare_printf("%s/%s", resource_folder, res->source); resource_insert(&project->images, (Resource *)res); - if (!ecore_file_exists(res->source)) + if (!ecore_file_exists(res->path)) { - file_dir = ecore_file_dir_get(res->source); + file_dir = ecore_file_dir_get(res->path); ecore_file_mkpath(file_dir); free(file_dir); id = edje_edit_image_id_get(project->global_object, image_name); @@ -176,7 +178,7 @@ _image_resources_feedback_job(void *data, Ecore_Thread *th) source_file = eina_stringshare_printf("edje/images/%i", id); ids->id = source_file; ids->im = NULL; - ids->source = res->source; + ids->source = res->path; eina_lock_release(&ids->mutex); ecore_main_loop_thread_safe_call_sync(_image_save_routine, ids); eina_lock_take(&ids->mutex); @@ -247,20 +249,21 @@ _sound_resources_feedback_job(void *data, Ecore_Thread *th) ecore_thread_feedback(th, message); res = (External_Resource*)resource_add(sound_name, RESOURCE_TYPE_SOUND); - res->source = eina_stringshare_printf("%s/%s", resource_folder, sound_file); + res->source = eina_stringshare_add(ecore_file_file_get(sound_file)); + res->path = eina_stringshare_printf("%s/%s", resource_folder, res->source); resource_insert(&project->sounds, (Resource *)res); - if (!ecore_file_exists(res->source)) + if (!ecore_file_exists(res->path)) { - file_dir = ecore_file_dir_get(res->source); + file_dir = ecore_file_dir_get(res->path); ecore_file_mkpath(file_dir); free(file_dir); sound_bin = edje_edit_sound_samplebuffer_get(project->global_object, sound_name); - if (!(f = fopen(res->source, "wb"))) + if (!(f = fopen(res->path, "wb"))) { - message = eina_stringshare_printf(_("Could not open file: %s"), res->source); + message = eina_stringshare_printf(_("Could not open file: %s"), res->path); ecore_thread_feedback(th, message); - ERR("Could not open file: %s", res->source); + ERR("Could not open file: %s", res->path); sleep(2); continue; } @@ -342,20 +345,21 @@ _font_resources_feedback_job(void *data, Ecore_Thread *th) ecore_thread_feedback(th, message); res = (External_Resource *)resource_add(font_file, RESOURCE_TYPE_FONT); - res->source = eina_stringshare_printf("%s/%s", resource_folder, font_file); + res->source = eina_stringshare_add(font_file); + res->path = eina_stringshare_printf("%s/%s", resource_folder, res->source); resource_insert(&project->fonts, (Resource *)res); - if (!ecore_file_exists(res->source)) + if (!ecore_file_exists(res->path)) { edje_edit_string_free(font_file); font_file = eina_stringshare_printf("edje/fonts/%s", font_name); font = eet_read(ef, font_file, &size); if (!font) continue; - if (!(f = fopen(res->source, "wb"))) + if (!(f = fopen(res->path, "wb"))) { - message = eina_stringshare_printf(_("Could not open file: %s"), res->source); + message = eina_stringshare_printf(_("Could not open file: %s"), res->path); ecore_thread_feedback(th, message); - ERR("Could not open file: %s", res->source); + ERR("Could not open file: %s", res->path); sleep(2); continue; } diff --git a/src/bin/project_manager/resource_manager.h b/src/bin/project_manager/resource_manager.h index df574a4..38cb4e4 100644 --- a/src/bin/project_manager/resource_manager.h +++ b/src/bin/project_manager/resource_manager.h @@ -70,6 +70,7 @@ struct _External_Resource RESOURCE_COMMON; Eina_Stringshare *source; + Eina_Stringshare *path; }; struct _Tone_Resource diff --git a/src/bin/ui/image_manager.c b/src/bin/ui/image_manager.c index f9baccc..2020fb2 100644 --- a/src/bin/ui/image_manager.c +++ b/src/bin/ui/image_manager.c @@ -252,7 +252,7 @@ _image_manager_gengrid_item_data_create(Evas_Object *edje_edit_obj, it->image_name); it->quality = edje_edit_image_compression_rate_get(edje_edit_obj, it->image_name); - it->source = eina_stringshare_add(res->source); + it->source = eina_stringshare_add(res->path); img = _image_manager_image_create(ap.project->global_object, it); elm_image_object_size_get(img, &it->width, &it->height); @@ -291,11 +291,12 @@ _on_image_done(void *data __UNUSED__, file_name = ecore_file_file_get(selected); res = (External_Resource *)resource_add(file_name, RESOURCE_TYPE_IMAGE); - res->source = eina_stringshare_printf("%s/images/%s", ap.project->develop_path, file_name); + res->path = eina_stringshare_printf("%s/images/%s", ap.project->develop_path, file_name); + res->source = eina_stringshare_add(file_name); - if (!ecore_file_exists(res->source)) + if (!ecore_file_exists(res->path)) { - ecore_file_cp(selected, res->source); + ecore_file_cp(selected, res->path); resource_insert(&ap.project->images, (Resource *)res); } @@ -320,7 +321,7 @@ _on_image_done(void *data __UNUSED__, it->quality = edje_edit_image_compression_rate_get(ap.project->global_object, it->image_name); - it->source = eina_stringshare_add(res->source); + it->source = eina_stringshare_add(res->path); img = _image_manager_image_create(ap.project->global_object, it); elm_image_object_size_get(img, &it->width, &it->height); evas_object_del(img); @@ -379,7 +380,7 @@ _image_del_cb(void *data __UNUSED__, if (!res->used_in) { - ecore_file_unlink(res->source); + ecore_file_unlink(res->path); elm_object_item_del(grid_item); edje_edit_image_del(ap.project->global_object, it->image_name); resource_remove(&ap.project->images, (Resource *)res); diff --git a/src/bin/ui/popup.c b/src/bin/ui/popup.c index 1f0bab4..6721b9c 100644 --- a/src/bin/ui/popup.c +++ b/src/bin/ui/popup.c @@ -676,7 +676,7 @@ _image_gengrid_init(Helper_Data *helper_data) it = (Item *)mem_malloc(sizeof(Item)); it->image_name = eina_stringshare_add(res->name); - it->source = eina_stringshare_add(res->source); + it->source = eina_stringshare_add(res->path); elm_gengrid_item_append(helper_data->gengrid, gic, it, NULL, NULL); } elm_gengrid_item_bring_in(elm_gengrid_first_item_get(helper_data->gengrid), diff --git a/src/bin/ui/sound_manager.c b/src/bin/ui/sound_manager.c index ae0fb3b..508ef57 100644 --- a/src/bin/ui/sound_manager.c +++ b/src/bin/ui/sound_manager.c @@ -247,26 +247,28 @@ _add_sample_done(void *data __UNUSED__, } res = (External_Resource *)resource_add(file_name, RESOURCE_TYPE_SOUND); - res->source = eina_stringshare_printf("%s/sounds/%s", ap.project->develop_path, file_name); + res->path = eina_stringshare_printf("%s/sounds/%s", ap.project->develop_path, sound_name); + res->source = eina_stringshare_add(sound_name); + res->name = eina_stringshare_add(sound_name); - if (!ecore_file_exists(res->source)) + if (!ecore_file_exists(res->path)) { - ecore_file_cp(selected, res->source); + ecore_file_cp(selected, res->path); resource_insert(&ap.project->sounds, (Resource *)res); } else { - ERR(_("File '%s' exist"), res->name); + ERR(_("File '%s' exist"), res->path); resource_free((Resource *)res); return true; } - edje_edit_sound_sample_add(ap.project->global_object, res->name, res->source); + edje_edit_sound_sample_add(ap.project->global_object, res->name, res->path); snd = (Sound_Data *)mem_malloc(sizeof(Sound_Data)); snd->name = eina_stringshare_ref(res->name); - snd->type_label = _sound_format_get(res->source); + snd->type_label = _sound_format_get(res->path); snd->type = SOUND_TYPE_SAMPLE; snd->resource = (Resource *)res; elm_gengrid_item_insert_before(mng.gengrid, gic, snd, mng.tone_header, _grid_sel_cb, NULL); @@ -446,7 +448,7 @@ _sound_del_cb(void *data __UNUSED__, res = (External_Resource *)resource_get(ap.project->sounds, &request); if (res->used_in) ERR("Unable to delete sample '%s'", res->name); edje_edit_sound_sample_del(ap.project->global_object, snd->name); - ecore_file_unlink(res->source); + ecore_file_unlink(res->path); resource_remove(&ap.project->sounds, (Resource *)res); elm_object_item_del(grid_it); break; diff --git a/src/bin/ui/sound_player/sound_player.c b/src/bin/ui/sound_player/sound_player.c index 4e72a4a..4760bd4 100644 --- a/src/bin/ui/sound_player/sound_player.c +++ b/src/bin/ui/sound_player/sound_player.c @@ -216,8 +216,8 @@ _sample_play() { sample = (External_Resource *)snd->resource; _create_io_stream(); - ecore_audio_obj_name_set(in, sample->source); - ret = ecore_audio_obj_source_set(in, sample->source); + ecore_audio_obj_name_set(in, sample->path); + ret = ecore_audio_obj_source_set(in, sample->path); if (!ret) { ERR("Can not set source obj for added sample"); @@ -226,7 +226,7 @@ _sample_play() len = ecore_audio_obj_in_length_get(in); elm_slider_min_max_set(rewin, 0, len); elm_slider_value_set(rewin, 0.0); - length = ecore_file_size(sample->source); + length = ecore_file_size(sample->path); } ret = ecore_audio_obj_out_input_attach(out, in); --
