rimmed pushed a commit to branch master. http://git.enlightenment.org/tools/eflete.git/commit/?id=bb666ed43a82036670213b424fa36fb4cac009c7
commit bb666ed43a82036670213b424fa36fb4cac009c7 Author: Vitalii Vorobiov <[email protected]> Date: Tue Sep 6 17:12:02 2016 +0300 editor: edje_edit API for sound samples and tones --- src/bin/common/signals.h | 24 +++++++-- src/bin/editor/banned_edje_edit_api.h | 6 +++ src/bin/editor/editor.h | 12 +++++ src/bin/editor/editor_top_level.c | 65 +++++++++++++++++++++++ src/bin/project_manager/project_manager.c | 12 +++-- src/bin/resource_manager/resource_manager_react.c | 46 ++++++++++++---- src/bin/ui/sound_manager.c | 19 ++----- 7 files changed, 150 insertions(+), 34 deletions(-) diff --git a/src/bin/common/signals.h b/src/bin/common/signals.h index 392e8b5..99f943b 100644 --- a/src/bin/common/signals.h +++ b/src/bin/common/signals.h @@ -291,7 +291,7 @@ typedef struct { /** * emited when sound is added. - * eventinfo - NULL + * eventinfo - sound's name * * @ingroup Window */ @@ -299,7 +299,7 @@ typedef struct { /** * emited when sound is deleted. - * eventinfo - NULL + * eventinfo - sound's name * * @ingroup Window */ @@ -307,7 +307,23 @@ typedef struct { /** * emited when tone is added. - * eventinfo - NULL + * eventinfo - tone's name + * + * @ingroup Window + */ +#define SIGNAL_EDITOR_TONE_ADDED "SIGNAL_EDITOR_TONE_ADDED" + +/** + * emited when sound is deleted. + * eventinfo - tone's name + * + * @ingroup Window + */ +#define SIGNAL_EDITOR_TONE_DELETED "SIGNAL_EDITOR_TONE_DELETED" + +/** + * emited when tone is added. + * eventinfo - image's name * * @ingroup Window */ @@ -315,7 +331,7 @@ typedef struct { /** * emited when sound is deleted. - * eventinfo - NULL + * eventinfo - image's name * * @ingroup Window */ diff --git a/src/bin/editor/banned_edje_edit_api.h b/src/bin/editor/banned_edje_edit_api.h index e3d3c8c..4124dce 100644 --- a/src/bin/editor/banned_edje_edit_api.h +++ b/src/bin/editor/banned_edje_edit_api.h @@ -65,6 +65,12 @@ //#pragma GCC poison edje_edit_color_class_name_set #pragma GCC poison edje_edit_color_class_description_set +/* Sound and Tone API */ +#pragma GCC poison edje_edit_sound_sample_add +#pragma GCC poison edje_edit_sound_sample_del +#pragma GCC poison edje_edit_sound_tone_add +#pragma GCC poison edje_edit_sound_tone_del + /* Text styles API */ //#pragma GCC poison edje_edit_style_add //#pragma GCC poison edje_edit_style_del diff --git a/src/bin/editor/editor.h b/src/bin/editor/editor.h index 9020b79..7ddbfe3 100644 --- a/src/bin/editor/editor.h +++ b/src/bin/editor/editor.h @@ -254,6 +254,18 @@ editor_color_class_colors_set(Evas_Object *obj, const char *name, int r2, int g2, int b2, int a2, int r3, int g3, int b3, int a3) EINA_WARN_UNUSED_RESULT; +Eina_Bool +editor_sound_sample_add(Evas_Object *obj, const char *name, const char *source, Eina_Bool notify) EINA_WARN_UNUSED_RESULT; + +Eina_Bool +editor_sound_sample_del(Evas_Object *obj, const char *name, Eina_Bool notify) EINA_WARN_UNUSED_RESULT; + +Eina_Bool +editor_sound_tone_add(Evas_Object *obj, const char *name, int frq, Eina_Bool notify) EINA_WARN_UNUSED_RESULT; + +Eina_Bool +editor_sound_tone_del(Evas_Object *obj, const char *name, Eina_Bool notify) EINA_WARN_UNUSED_RESULT; + /* General */ Eina_Bool editor_save(Evas_Object *edit_object) EINA_WARN_UNUSED_RESULT; diff --git a/src/bin/editor/editor_top_level.c b/src/bin/editor/editor_top_level.c index 1956dc5..215fdd4 100644 --- a/src/bin/editor/editor_top_level.c +++ b/src/bin/editor/editor_top_level.c @@ -131,3 +131,68 @@ editor_color_class_colors_set(Evas_Object *obj, const char *name, evas_object_smart_callback_call(ap.win, SIGNAL_EDITOR_RESOURCE_ATTRIBUTE_CHANGED, &attribute); return true; } + +Eina_Bool +editor_sound_sample_add(Evas_Object *obj, const char *name, const char *source, Eina_Bool notify) +{ + assert(obj != NULL); + assert(name != NULL); + + if (!edje_edit_sound_sample_add(obj, name, source)) + return false; + + if (!editor_save(obj)) + return false; /* i hope it will never happen */ + _editor_project_changed(); + if (notify) + evas_object_smart_callback_call(ap.win, SIGNAL_EDITOR_SOUND_ADDED, (void *)name); + return true; +} + +Eina_Bool +editor_sound_sample_del(Evas_Object *obj, const char *name, Eina_Bool notify) +{ + assert(obj != NULL); + assert(name != NULL); + + CRIT_ON_FAIL(edje_edit_sound_sample_del(obj, name)); + + if (!editor_save(obj)) + return false; /* i hope it will never happen */ + _editor_project_changed(); + if (notify) + evas_object_smart_callback_call(ap.win, SIGNAL_EDITOR_SOUND_DELETED, (void *)name); + return true; +} + +Eina_Bool +editor_sound_tone_add(Evas_Object *obj, const char *name, int frq, Eina_Bool notify) +{ + assert(obj != NULL); + assert(name != NULL); + + CRIT_ON_FAIL(edje_edit_sound_tone_add(obj, name, frq)); + + if (!editor_save(obj)) + return false; /* i hope it will never happen */ + _editor_project_changed(); + if (notify) + evas_object_smart_callback_call(ap.win, SIGNAL_EDITOR_TONE_ADDED, (void *)name); + return true; +} + +Eina_Bool +editor_sound_tone_del(Evas_Object *obj, const char *name, Eina_Bool notify) +{ + assert(obj != NULL); + assert(name != NULL); + + CRIT_ON_FAIL(edje_edit_sound_tone_del(obj, name)); + + if (!editor_save(obj)) + return false; /* i hope it will never happen */ + _editor_project_changed(); + if (notify) + evas_object_smart_callback_call(ap.win, SIGNAL_EDITOR_TONE_DELETED, (void *)name); + return true; +} diff --git a/src/bin/project_manager/project_manager.c b/src/bin/project_manager/project_manager.c index 43b5bbb..9dabbfd 100644 --- a/src/bin/project_manager/project_manager.c +++ b/src/bin/project_manager/project_manager.c @@ -409,11 +409,13 @@ _project_dummy_sample_add(Project *project) edje_object_file_set(edje_edit_obj, project->saved_edj, EFLETE_INTERNAL_GROUP_NAME); snprintf(buf, sizeof(buf), "%s"EFLETE_DUMMY_SAMPLE_NAME, ap.path.sound_path); - edje_edit_sound_sample_add(edje_edit_obj, EFLETE_DUMMY_SAMPLE_NAME, buf); + if (editor_sound_sample_add(edje_edit_obj, EFLETE_DUMMY_SAMPLE_NAME, buf, false)) + { + you_shall_not_pass_editor_signals(NULL); + CRIT_ON_FAIL(editor_save(edje_edit_obj)); + you_shall_pass_editor_signals(NULL); + } - you_shall_not_pass_editor_signals(NULL); - CRIT_ON_FAIL(editor_save(edje_edit_obj)); - you_shall_pass_editor_signals(NULL); evas_object_del(edje_edit_obj); ecore_evas_free(project->ecore_evas); @@ -1198,7 +1200,7 @@ pm_project_group_import(Project *project, const char *edj, const char *group) eina_binbuf_free(sound_bin); THREAD_CONTEXT_SWITCH_BEGIN; - CRIT_ON_FAIL(edje_edit_sound_sample_add(project->global_object, data, res_file)); + CRIT_ON_FAIL(editor_sound_sample_add(project->global_object, data, res_file, false)); THREAD_CONTEXT_SWITCH_END; res = (External_Resource *)resource_add(data, RESOURCE_TYPE_SOUND); res->source = eina_stringshare_add(res_file); diff --git a/src/bin/resource_manager/resource_manager_react.c b/src/bin/resource_manager/resource_manager_react.c index a459505..ea90489 100644 --- a/src/bin/resource_manager/resource_manager_react.c +++ b/src/bin/resource_manager/resource_manager_react.c @@ -212,8 +212,8 @@ _colorclass_added(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *ei) { - const char *image_name = (const char *)ei; - printf("Colorclass added [%s] \n", image_name); + const char *name = (const char *)ei; + printf("Colorclass added [%s] \n", name); } static void @@ -221,22 +221,44 @@ _colorclass_deleted(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *ei) { - const char *image_name = (const char *)ei; - printf("Colorclass deleted [%s] \n", image_name); + const char *name = (const char *)ei; + printf("Colorclass deleted [%s] \n", name); } static void _sound_added(void *data __UNUSED__, Evas_Object *obj __UNUSED__, - void *ei __UNUSED__) + void *ei) { + const char *name = (const char *)ei; + printf("Sound added [%s] \n", name); } static void _sound_deleted(void *data __UNUSED__, Evas_Object *obj __UNUSED__, - void *ei __UNUSED__) + void *ei) +{ + const char *name = (const char *)ei; + printf("Sound deleted [%s] \n", name); +} + +static void +_tone_added(void *data __UNUSED__, + Evas_Object *obj __UNUSED__, + void *ei) +{ + const char *name = (const char *)ei; + printf("Tone added [%s] \n", name); +} + +static void +_tone_deleted(void *data __UNUSED__, + Evas_Object *obj __UNUSED__, + void *ei) { + const char *name = (const char *)ei; + printf("Tone deleted [%s] \n", name); } static void @@ -244,8 +266,8 @@ _image_added(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *ei) { - const char *image_name = (const char *)ei; - printf("We got new image [%s] \n", image_name); + const char *name = (const char *)ei; + printf("We got new image [%s] \n", name); } static void @@ -253,8 +275,8 @@ image_deleted(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *ei) { - const char *image_name = (const char *)ei; - printf("And old image was deleted [%s] \n", image_name); + const char *name = (const char *)ei; + printf("And old image was deleted [%s] \n", name); } static void @@ -585,6 +607,8 @@ _resource_callbacks_register(Project *project) evas_object_smart_callback_add(ap.win, SIGNAL_EDITOR_COLORCLASS_DELETED, _colorclass_deleted, project); evas_object_smart_callback_add(ap.win, SIGNAL_EDITOR_SOUND_ADDED, _sound_added, project); evas_object_smart_callback_add(ap.win, SIGNAL_EDITOR_SOUND_DELETED, _sound_deleted, project); + evas_object_smart_callback_add(ap.win, SIGNAL_EDITOR_TONE_ADDED, _tone_added, project); + evas_object_smart_callback_add(ap.win, SIGNAL_EDITOR_TONE_DELETED, _tone_deleted, project); evas_object_smart_callback_add(ap.win, SIGNAL_EDITOR_IMAGE_ADDED, _image_added, project); evas_object_smart_callback_add(ap.win, SIGNAL_EDITOR_IMAGE_DELETED, image_deleted, project); evas_object_smart_callback_add(ap.win, SIGNAL_EDITOR_STYLE_ADDED, _style_added, project); @@ -621,6 +645,8 @@ _resource_callbacks_unregister(Project *project) evas_object_smart_callback_del_full(ap.win, SIGNAL_EDITOR_COLORCLASS_DELETED, _colorclass_deleted, project); evas_object_smart_callback_del_full(ap.win, SIGNAL_EDITOR_SOUND_ADDED, _sound_added, project); evas_object_smart_callback_del_full(ap.win, SIGNAL_EDITOR_SOUND_DELETED, _sound_deleted, project); + evas_object_smart_callback_del_full(ap.win, SIGNAL_EDITOR_TONE_ADDED, _tone_added, project); + evas_object_smart_callback_del_full(ap.win, SIGNAL_EDITOR_TONE_DELETED, _tone_deleted, project); evas_object_smart_callback_del_full(ap.win, SIGNAL_EDITOR_IMAGE_ADDED, _image_added, project); evas_object_smart_callback_del_full(ap.win, SIGNAL_EDITOR_IMAGE_DELETED, image_deleted, project); evas_object_smart_callback_del_full(ap.win, SIGNAL_EDITOR_STYLE_ADDED, _style_added, project); diff --git a/src/bin/ui/sound_manager.c b/src/bin/ui/sound_manager.c index c290afc..3843c78 100644 --- a/src/bin/ui/sound_manager.c +++ b/src/bin/ui/sound_manager.c @@ -266,7 +266,7 @@ _add_sample_done(void *data __UNUSED__, return true; } - edje_edit_sound_sample_add(ap.project->global_object, res->name, res->path); + CRIT_ON_FAIL(editor_sound_sample_add(ap.project->global_object, res->name, res->source, true)); snd = (Sound_Data *)mem_malloc(sizeof(Sound_Data)); snd->name = eina_stringshare_ref(res->name); @@ -274,10 +274,6 @@ _add_sample_done(void *data __UNUSED__, 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); - - CRIT_ON_FAIL(editor_save(ap.project->global_object)); - TODO("Remove this line once edje_edit_sound_sample_add would be added into Editor Module and saving would work properly") - ap.project->changed = true; evas_object_smart_callback_call(ap.win, SIGNAL_EDITOR_ATTRIBUTE_CHANGED, &attribute); return true; @@ -294,7 +290,7 @@ _tone_add(void) tone_name = eina_stringshare_add(elm_entry_entry_get(mng.tone_entry)); frq = atoi(elm_entry_entry_get(mng.frq_entry)); - edje_edit_sound_tone_add(ap.project->global_object, tone_name, frq); + CRIT_ON_FAIL(editor_sound_tone_add(ap.project->global_object, tone_name, frq, true)); tone = (Tone_Resource *)resource_add(tone_name, RESOURCE_TYPE_TONE); tone->freq = frq; @@ -307,9 +303,6 @@ _tone_add(void) snd->resource = (Resource *)tone; elm_gengrid_item_append(mng.gengrid, gic, snd, _grid_sel_cb, NULL); - CRIT_ON_FAIL(editor_save(ap.project->global_object)); - TODO("Remove this line once edje_edit_image_add would be added into Editor Module and saving would work properly") - ap.project->changed = true; evas_object_smart_callback_call(ap.win, SIGNAL_EDITOR_ATTRIBUTE_CHANGED, &attribute); } @@ -460,7 +453,7 @@ _sound_del_cb(void *data __UNUSED__, request.resource_type = RESOURCE_TYPE_SOUND; 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); + CRIT_ON_FAIL(editor_sound_sample_del(ap.project->global_object, snd->name, true)); ecore_file_unlink(res->path); resource_remove(&ap.project->sounds, (Resource *)res); elm_object_item_del(grid_it); @@ -471,17 +464,13 @@ _sound_del_cb(void *data __UNUSED__, request.resource_type = RESOURCE_TYPE_TONE; res = (External_Resource *)resource_get(ap.project->tones, &request); if (res->used_in) ERR("Unable to delete tone '%s'", res->name); - edje_edit_sound_tone_del(ap.project->global_object, snd->name); + CRIT_ON_FAIL(editor_sound_tone_del(ap.project->global_object, snd->name, true)); resource_remove(&ap.project->tones, (Resource *)res); elm_object_item_del(grid_it); break; } } - CRIT_ON_FAIL(editor_save(ap.project->global_object)); - TODO("Remove this line once edje_edit_sound_..._del would be added into Editor Modulei and saving would work properly") - ap.project->changed = true; - elm_object_disabled_set(mng.btn_del, true); evas_object_smart_callback_call(ap.win, SIGNAL_SOUND_UNSELECTED, NULL); evas_object_smart_callback_call(ap.win, SIGNAL_EDITOR_ATTRIBUTE_CHANGED, &attribute); --
