rimmed pushed a commit to branch master.

http://git.enlightenment.org/tools/eflete.git/commit/?id=632ac08f01e078457e344d39a6d05cbafba804e3

commit 632ac08f01e078457e344d39a6d05cbafba804e3
Author: Vyacheslav Reutskiy <v.reuts...@samsung.com>
Date:   Tue Feb 2 10:25:33 2016 +0200

    sound editor: use the Sound_Data for communicate sound editor and property
    
    Change-Id: I14bf6d02589f40b9181d4a8cf7f9c637d1a34258
---
 src/bin/ui/editors/sound_editor.c | 246 ++++++++++++--------------------
 src/bin/ui/editors/sound_editor.h |   1 +
 src/bin/ui/property_sound.c       | 289 ++++++++++----------------------------
 3 files changed, 172 insertions(+), 364 deletions(-)

diff --git a/src/bin/ui/editors/sound_editor.c 
b/src/bin/ui/editors/sound_editor.c
index 701c9f9..ae02fdd 100644
--- a/src/bin/ui/editors/sound_editor.c
+++ b/src/bin/ui/editors/sound_editor.c
@@ -54,7 +54,7 @@ struct _Sound_Editor
    Elm_Validator_Regexp *tone_validator, *frq_validator;
    Evas_Object *gengrid;
    Evas_Object *markup;
-   Elm_Object_Item *tone;
+   Elm_Object_Item *tone_header;
    Search_Data sound_search_data;
    Evas_Object *check;
    const char  *snd_src;
@@ -67,39 +67,28 @@ _grid_label_get(void *data,
                 Evas_Object *obj __UNUSED__,
                 const char  *part)
 {
-   const Item *it = data;
-   if (!part)
-     return NULL;
+   Sound_Data *snd = (Sound_Data *)data;
 
-   if (!strcmp(part, "elm.label.type"))
-     return strdup(it->format);
-   else
-     return strdup(it->sound_name);
-}
-
-static char *
-_grid_group_label_get(void *data,
-                      Evas_Object *obj __UNUSED__,
-                      const char  *part)
-{
-   const Item *it = data;
-   if (!part)
-     return NULL;
+   if (!part) goto exit;
 
    if (!strcmp(part, "elm.text"))
-     return strdup(it->sound_name);
+     return strdup(snd->name);
+
+   if (!strcmp(part, "elm.text.type"))
+     return strdup(snd->type_label);
 
+exit:
    return NULL;
 }
 
 static void
-_grid_del(void *data,
-          Evas_Object *obj __UNUSED__)
+_grid_del(void *data, Evas_Object *obj __UNUSED__)
 {
-   Item *it = data;
-   eina_stringshare_del(it->sound_name);
-   eina_stringshare_del(it->format);
-   free(it);
+   Sound_Data *snd = (Sound_Data *)data;
+
+   eina_stringshare_del(snd->name);
+   eina_stringshare_del(snd->type_label);
+   free(snd);
 }
 
 static Eina_Stringshare *
@@ -123,92 +112,68 @@ _sound_format_get(Eina_Stringshare *snd_src)
 }
 
 static void
-_grid_sel_sample(void *data,
-                 Evas_Object *obj __UNUSED__,
-                 void *event_info)
-{
-   Sound_Editor *edit = (Sound_Editor *)data;
-   Selected_Sound_Data *snd_data = mem_calloc(1, sizeof(Selected_Sound_Data));
-   External_Resource *res;
-   const Item *item;
-
-   assert(edit != NULL);
-
-   item = elm_object_item_data_get((Elm_Gengrid_Item *)event_info);
-   snd_data->markup = edit->markup;
-   snd_data->gengrid = edit->gengrid;
-   snd_data->sound_type = SOUND_TYPE_SAMPLE;
-   snd_data->compression_type = item->comp;
-   snd_data->quality = item->rate;
-
-   res = pm_resource_get(ap.project->sounds, item->sound_name);
-   if (!res->used_in) elm_object_disabled_set(edit->btn_del, false);
-
-   evas_object_smart_callback_call(ap.win, SIGNAL_SOUND_SELECT, snd_data);
-   free(snd_data);
-}
-
-static void
-_grid_sel_tone(void *data,
+_grid_selected(void *data,
                Evas_Object *obj __UNUSED__,
-               void *event_info __UNUSED__)
+               void *event_info)
 {
    Sound_Editor *edit = (Sound_Editor *)data;
-   Selected_Sound_Data *snd_data = mem_calloc(1, sizeof(Selected_Sound_Data));
-   External_Resource *res;
-   const Item *item;
+   External_Resource *res = NULL;
+   Sound_Data *snd;
 
    assert(edit != NULL);
 
-   item = elm_object_item_data_get((Elm_Gengrid_Item *)event_info);
-   snd_data->markup = edit->markup;
-   snd_data->gengrid = edit->gengrid;
-   snd_data->sound_type = SOUND_TYPE_TONE;
-   snd_data->tone = edit->tone;
-   snd_data->tone_frq = item->tone_frq;
-   elm_object_disabled_set(edit->btn_del, false);
+   snd = elm_object_item_data_get((Elm_Gengrid_Item *)event_info);
+   switch (snd->type)
+     {
+      case SOUND_TYPE_SAMPLE:
+         res = pm_resource_get(ap.project->sounds, snd->name);
+         break;
+      case SOUND_TYPE_TONE:
+         res = pm_resource_get(ap.project->tones, snd->name);
+         break;
+     }
+
+   assert(res != NULL);
 
-   res = pm_resource_get(ap.project->tones, item->sound_name);
    if (!res->used_in) elm_object_disabled_set(edit->btn_del, false);
-
-   evas_object_smart_callback_call(ap.win, SIGNAL_SOUND_SELECT, snd_data);
-   free(snd_data);
+   evas_object_smart_callback_call(ap.win, SIGNAL_SOUND_SELECT, snd);
 }
 
 static void
 _gengrid_content_fill(Sound_Editor *edit)
 {
    Eina_List *l;
-   Item *it;
-   External_Resource *res;
+   External_Resource *sample;
+   Tone_Resource *tone;
+   Sound_Data *snd;
 
    assert(edit != NULL);
    assert(ap.project != NULL);
 
-   it = (Item *)mem_calloc(1, sizeof(Item));
-   it->sound_name = eina_stringshare_add(_("<b>Sound Samples</b>"));
-   elm_gengrid_item_append(edit->gengrid, ggic, it, NULL, NULL);
-   EINA_LIST_FOREACH(ap.project->sounds, l, res)
+   snd = (Sound_Data *)mem_calloc(1, sizeof(Sound_Data));
+   snd->name = eina_stringshare_add(_("<b>Sound Samples</b>"));
+   elm_gengrid_item_append(edit->gengrid, ggic, snd, NULL, NULL);
+   EINA_LIST_FOREACH(ap.project->sounds, l, sample)
      {
-        it = (Item *)mem_calloc(1, sizeof(Item));
-        it->sound_name = eina_stringshare_add(res->name);
-        it->format = _sound_format_get(res->source);
-        it->comp = 
edje_edit_sound_compression_type_get(ap.project->global_object, it->sound_name);
-        it->rate = 
edje_edit_sound_compression_rate_get(ap.project->global_object, it->sound_name);
-        it->src = eina_stringshare_add(res->source);
-        elm_gengrid_item_append(edit->gengrid, gic, it, _grid_sel_sample, 
edit);
+        snd = (Sound_Data *)mem_calloc(1, sizeof(Sound_Data));
+        snd->name = eina_stringshare_ref(sample->name);
+        snd->type_label = _sound_format_get(sample->source);
+        snd->type = SOUND_TYPE_SAMPLE;
+        snd->resource = (Resource *)sample;
+        elm_gengrid_item_append(edit->gengrid, gic, snd, _grid_selected, edit);
      }
 
-   it = (Item *)mem_calloc(1, sizeof(Item));
-   it->sound_name = eina_stringshare_add(_("<b>Sound Tones</b>"));
-   edit->tone = elm_gengrid_item_append(edit->gengrid, ggic, it, NULL, NULL);
-   EINA_LIST_FOREACH(ap.project->tones, l, res)
+   snd = (Sound_Data *)mem_calloc(1, sizeof(Sound_Data));
+   snd->name = eina_stringshare_add(_("<b>Sound Tones</b>"));
+   edit->tone_header = elm_gengrid_item_append(edit->gengrid, ggic, snd, NULL, 
NULL);
+   EINA_LIST_FOREACH(ap.project->tones, l, tone)
      {
-        it = (Item *)mem_calloc(1, sizeof(Item));
-        it->sound_name = eina_stringshare_add(res->name);
-        it->tone_frq = 
edje_edit_sound_tone_frequency_get(ap.project->global_object, it->sound_name);
-        it->format = eina_stringshare_printf("%d", it->tone_frq);
-        elm_gengrid_item_append(edit->gengrid, gic, it, _grid_sel_tone, edit);
+        snd = (Sound_Data *)mem_calloc(1, sizeof(Sound_Data));
+        snd->name = eina_stringshare_ref(tone->name);
+        snd->type_label = eina_stringshare_printf("%d", tone->freq);
+        snd->type = SOUND_TYPE_TONE;
+        snd->resource = (Resource *)tone;
+        elm_gengrid_item_append(edit->gengrid, gic, snd, _grid_selected, edit);
      }
 }
 
@@ -249,7 +214,7 @@ _create_gengrid(Evas_Object *parent, Sound_Editor *editor)
 
    ggic = elm_gengrid_item_class_new();
    ggic->item_style = "group_index";
-   ggic->func.text_get = _grid_group_label_get;
+   ggic->func.text_get = _grid_label_get;
    ggic->func.content_get = NULL;
    ggic->func.del = _grid_del;
 
@@ -278,7 +243,7 @@ _add_sample_done(void *data,
                  Evas_Object *obj __UNUSED__,
                  void *event_info)
 {
-   Item *it;
+   Sound_Data *snd;
    Eina_Stringshare *sound_name;
    Eina_List *samples_list, *l;
    Eina_Bool exist = false;
@@ -332,12 +297,12 @@ _add_sample_done(void *data,
 
    edje_edit_sound_sample_add(ap.project->global_object, res->name, 
res->source);
 
-   it = (Item *)mem_calloc(1, sizeof(Item));
-   it->sound_name = eina_stringshare_add(sound_name);
-   it->format = _sound_format_get(selected);
-   it->comp = EDJE_EDIT_SOUND_COMP_RAW;
-   it->src = eina_stringshare_add(res->source);
-   elm_gengrid_item_insert_before(edit->gengrid, gic, it, edit->tone, 
_grid_sel_sample, edit);
+   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 = SOUND_TYPE_SAMPLE;
+   snd->resource = (Resource *)res;
+   elm_gengrid_item_insert_before(edit->gengrid, gic, snd, edit->tone_header, 
_grid_selected, edit);
 
    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")
@@ -380,9 +345,8 @@ _add_tone_done(void *data,
                Evas_Object *obj __UNUSED__,
                void *event_info __UNUSED__)
 {
-   Item *it;
+   Sound_Data *snd;
    Eina_Stringshare *tone_name;
-   const char *str_value;
    int frq;
    Eina_List *tones_list, *l;
    Eina_Bool exist = false;
@@ -408,21 +372,21 @@ _add_tone_done(void *data,
         return;
      }
 
-   str_value = elm_entry_entry_get(edit->frq_entry);
-   frq = atoi(str_value);
-
-   it = (Item *)mem_calloc(1, sizeof(Item));
-   it->sound_name = eina_stringshare_add(tone_name);
-   it->tone_frq = frq;
-   it->format = eina_stringshare_printf("%d", it->tone_frq);
-   elm_gengrid_item_append(edit->gengrid, gic, it, _grid_sel_tone, edit);
+   frq = atoi(elm_entry_entry_get(edit->frq_entry));
+   edje_edit_sound_tone_add(ap.project->global_object, tone_name, frq);
 
-   tone = mem_calloc(1, sizeof(External_Resource));
+   tone = (Tone_Resource *)mem_calloc(1, sizeof(Tone_Resource));
    tone->name = eina_stringshare_add(tone_name);
    tone->freq = frq;
-   ap.project->tones = eina_list_sorted_insert(ap.project->tones, 
(Eina_Compare_Cb) resource_cmp, tone);
+   ap.project->tones = eina_list_sorted_insert(ap.project->tones, 
(Eina_Compare_Cb)resource_cmp, tone);
+
+   snd = (Sound_Data *)mem_malloc(sizeof(Sound_Data));
+   snd->name = eina_stringshare_ref(tone->name);
+   snd->type_label = 
eina_stringshare_add(elm_entry_entry_get(edit->frq_entry));
+   snd->type = SOUND_TYPE_TONE;
+   snd->resource = (Resource *)tone;
+   elm_gengrid_item_append(edit->gengrid, gic, snd, _grid_selected, edit);
 
-   edje_edit_sound_tone_add(ap.project->global_object, tone_name, frq);
    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;
@@ -534,67 +498,43 @@ _on_delete_clicked_cb(void *data,
                       void *event_info __UNUSED__)
 {
    Elm_Object_Item *grid_it;
-   Item *item;
+   Sound_Data *snd;
    Eina_List *list, *l, *l_next;
    Sound_Editor *edit = (Sound_Editor *)data;
    External_Resource *res;
-   char buf[BUFF_MAX];
-   int symbs = 0, notdeleted = 0;
 
    assert(edit != NULL);
 
    list = (Eina_List *)elm_gengrid_selected_items_get(edit->gengrid);
-
-   snprintf(buf, BUFF_MAX, _("Unable to delete: "));
-   symbs = strlen(buf);
    EINA_LIST_FOREACH_SAFE(list, l, l_next, grid_it)
      {
-        item = elm_object_item_data_get(grid_it);
+        snd = elm_object_item_data_get(grid_it);
 
-        if (!item->tone_frq)
+        switch (snd->type)
           {
-             res = pm_resource_get(ap.project->sounds, item->sound_name);
-             if (!res->used_in)
-               {
-                  edje_edit_sound_sample_del(ap.project->global_object, 
item->sound_name);
-                  ap.project->sounds = pm_resource_del(ap.project->sounds, 
res);
-                  elm_object_item_del(grid_it);
-               }
-             else if ((res->used_in) && (notdeleted < 4))
-               {
-                  snprintf(buf + symbs, BUFF_MAX - symbs, _("<br>Sound 
\"%s\""), res->name);
-                  symbs += strlen(res->name);
-                  notdeleted++;
-               }
-          }
-        else
-          {
-             res = pm_resource_get(ap.project->tones, item->sound_name);
-             if (!res->used_in)
-               {
-                  edje_edit_sound_tone_del(ap.project->global_object, 
item->sound_name);
-                  ap.project->tones = pm_resource_del(ap.project->tones, res);
-                  elm_object_item_del(grid_it);
-               }
-             else if ((res->used_in) && (notdeleted < 4))
-               {
-                  snprintf(buf + symbs, BUFF_MAX - symbs, _("<br>Tone 
\"%s\""), res->name);
-                  symbs += strlen(res->name);
-                  notdeleted++;
-               }
+           case SOUND_TYPE_SAMPLE:
+              res = pm_resource_get(ap.project->sounds, snd->name);
+              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);
+              ap.project->sounds = pm_resource_del(ap.project->sounds, res);
+              elm_object_item_del(grid_it);
+              break;
+           case SOUND_TYPE_TONE:
+              res = pm_resource_get(ap.project->tones, snd->name);
+              if (res->used_in) ERR("Unable to delete tone '%s'", res->name);
+              edje_edit_sound_tone_del(ap.project->global_object, snd->name);
+              ap.project->tones = pm_resource_del(ap.project->tones, res);
+              elm_object_item_del(grid_it);
+              break;
           }
      }
 
-   if (notdeleted >= 4)
-     snprintf(buf + symbs, BUFF_MAX - symbs, "<br>...");
-
-   if (notdeleted != 0)
-     WARN("'%s' used in Programs", buf);
-
    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(edit->btn_del, true);
    evas_object_smart_callback_call(ap.win, SIGNAL_SOUND_UNSELECTED, NULL);
 }
 
diff --git a/src/bin/ui/editors/sound_editor.h 
b/src/bin/ui/editors/sound_editor.h
index a7c45e2..c67351b 100644
--- a/src/bin/ui/editors/sound_editor.h
+++ b/src/bin/ui/editors/sound_editor.h
@@ -28,6 +28,7 @@
  */
 
 #include "eflete.h"
+#include "project_manager.h"
 
 #ifdef HAVE_AUDIO
 TODO("Check pulse_audio on configure and add COREAUDIO support")
diff --git a/src/bin/ui/property_sound.c b/src/bin/ui/property_sound.c
index f89c6b1..c1f6676 100644
--- a/src/bin/ui/property_sound.c
+++ b/src/bin/ui/property_sound.c
@@ -47,9 +47,6 @@ evas_object_smart_callback_add(FRAME, "clicked", 
_on_frame_click, SCROLLER);
 
 struct _Sound_Prop_Data
 {
-   Evas_Object *markup;
-   Evas_Object *gengrid;
-
    Evas_Object *box;
    Evas_Object *sound_player;
    Evas_Object *preview_sound_player;
@@ -59,9 +56,7 @@ struct _Sound_Prop_Data
    Evas_Object *tone_box;
    Evas_Object *info_frame;
 
-   Elm_Object_Item *tone;
-   const char  *selected;
-   const char  *snd_src;
+   Sound_Data *snd;
 
 #ifdef HAVE_AUDIO
    struct {
@@ -83,7 +78,6 @@ struct _Sound_Prop_Data
       Eina_Bool playing : 1;
       Eina_Bool stopped : 1;
       Eina_Bool switched : 1;
-      Eina_Bool added : 1;
    } player_data;
 
    struct {
@@ -272,7 +266,6 @@ _rewind_cb(void *data)
 
    if (max == value)
      {
-        printf("3\n");
         elm_object_part_content_unset(edit->sound_player, 
"swallow.button.play");
         evas_object_hide(edit->player_data.pause);
         elm_object_part_content_set(edit->sound_player, "swallow.button.play", 
edit->player_data.play);
@@ -304,23 +297,11 @@ _create_io_stream(Sound_Prop_Data *edit)
 }
 
 static void
-_initialize_io_data(Sound_Prop_Data *edit)
-{
-   edit->io.offset = 0;
-
-   assert(edit != NULL);
-
-   _create_io_stream(edit);
-
-   eo_do(edit->io.in, ecore_audio_obj_name_set(edit->selected));
-   eo_do(edit->io.in, ecore_audio_obj_vio_set(&edit->io.vio, edit, NULL));
-}
-
-static void
-_tone_play(Sound_Prop_Data *edit, int tone_frq)
+_tone_play(Sound_Prop_Data *edit)
 {
    double value;
    Eina_Bool ret = false;
+   Tone_Resource *tone;
 
    assert(edit != NULL);
 
@@ -329,6 +310,7 @@ _tone_play(Sound_Prop_Data *edit, int tone_frq)
    elm_object_part_content_set(edit->sound_player, "swallow.button.play", 
edit->player_data.pause);
    evas_object_show(edit->player_data.pause);
 
+   tone = (Tone_Resource *)edit->snd->resource;
    if (edit->player_data.stopped)
      {
         eo_do(edit->io.in, ecore_audio_obj_paused_set(false));
@@ -340,8 +322,8 @@ _tone_play(Sound_Prop_Data *edit, int tone_frq)
    if (!edit->io.in)
      {
         edit->io.in = eo_add(ECORE_AUDIO_IN_TONE_CLASS, NULL);
-        eo_do(edit->io.in, ecore_audio_obj_name_set(edit->selected));
-        eo_do(edit->io.in, eo_key_data_set(ECORE_AUDIO_ATTR_TONE_FREQ, 
&tone_frq));
+        eo_do(edit->io.in, ecore_audio_obj_name_set(tone->name));
+        eo_do(edit->io.in, eo_key_data_set(ECORE_AUDIO_ATTR_TONE_FREQ, 
&tone->freq));
         eo_do(edit->io.in, 
ecore_audio_obj_in_length_set(TONE_PLAYING_DURATION));
         eo_do(edit->io.in, 
eo_event_callback_add(ECORE_AUDIO_IN_EVENT_IN_STOPPED,
                                                  _play_finished_cb, edit));
@@ -368,10 +350,11 @@ _tone_play(Sound_Prop_Data *edit, int tone_frq)
 }
 
 static void
-_add_sound_play(Sound_Prop_Data *edit)
+_sample_play(Sound_Prop_Data *edit)
 {
    double value;
    Eina_Bool ret = false;
+   External_Resource *sample;
 
    assert(edit != NULL);
 
@@ -390,9 +373,10 @@ _add_sound_play(Sound_Prop_Data *edit)
 
    if (!edit->io.in)
      {
+        sample = (External_Resource *)edit->snd->resource;
         _create_io_stream(edit);
-        eo_do(edit->io.in, ecore_audio_obj_name_set(edit->snd_src));
-        eo_do(edit->io.in, ret = ecore_audio_obj_source_set(edit->snd_src));
+        eo_do(edit->io.in, ecore_audio_obj_name_set(sample->source));
+        eo_do(edit->io.in, ret = ecore_audio_obj_source_set(sample->source));
         if (!ret)
           {
              ERR("Can not set source obj for added sample");
@@ -426,63 +410,12 @@ _add_sound_play(Sound_Prop_Data *edit)
 static void
 _play_sound(Sound_Prop_Data *edit)
 {
-   double value;
-   Eina_Bool ret = false;
-   Elm_Object_Item *g_item;
-   const Item *item;
-
    assert(edit != NULL);
 
-   g_item = elm_gengrid_selected_item_get(edit->gengrid);
-   if (!g_item)
-     return;
-
-   if (edit->player_data.added)
-     {
-        _add_sound_play(edit);
-        return;
-     }
-
-   item = elm_object_item_data_get(g_item);
-   if (item->tone_frq)
-     {
-        _tone_play(edit, item->tone_frq);
-        return;
-     }
-
-   elm_object_part_content_unset(edit->sound_player, "swallow.button.play");
-   evas_object_hide(edit->player_data.play);
-   elm_object_part_content_set(edit->sound_player, "swallow.button.play", 
edit->player_data.pause);
-   evas_object_show(edit->player_data.pause);
-
-   if (edit->player_data.stopped)
-     {
-        eo_do(edit->io.in, ecore_audio_obj_paused_set(false));
-        ecore_timer_thaw(edit->player_data.timer);
-        edit->player_data.stopped = false;
-        return;
-     }
-
-   if (!edit->io.in)
-     _initialize_io_data(edit);
-
-   eo_do(edit->io.out, ret = ecore_audio_obj_out_input_attach(edit->io.in));
-   if (!ret)
-     {
-        ERR("Couldn't attach input and output!");
-        elm_object_part_content_unset(edit->sound_player, 
"swallow.button.play");
-        evas_object_hide(edit->player_data.pause);
-        elm_object_part_content_set(edit->sound_player, "swallow.button.play", 
edit->player_data.play);
-        evas_object_show(edit->player_data.play);
-        return;
-     }
-   edit->player_data.playing = true;
-
-   value = elm_slider_value_get(edit->player_data.rewind);
-   if (value)
-     eo_do(edit->io.in, value = ecore_audio_obj_in_seek(value, SEEK_SET));
-
-   edit->player_data.timer = ecore_timer_add(UPDATE_FREQUENCY, _rewind_cb, 
edit);
+   if (SOUND_TYPE_SAMPLE == edit->snd->type)
+     _sample_play(edit);
+   else
+     _tone_play(edit);
 }
 
 static void
@@ -521,7 +454,6 @@ _interrupt_playing(Sound_Prop_Data *edit)
 
    edit->player_data.stopped = false;
    edit->player_data.playing = false;
-   edit->player_data.added = false;
 }
 
 static void
@@ -660,10 +592,11 @@ _sound_player_create(Evas_Object *parent, Sound_Prop_Data 
*edit)
 }
 
 static void
-_sample_info_update(Sound_Prop_Data *pd, Selected_Sound_Data *snd_data)
+_sample_info_update(Sound_Prop_Data *pd, const char *name, double duration,
+                    const char *type, double size, double quality,
+                    Edje_Edit_Sound_Comp compression_type)
 {
-   Evas_Object *item;
-   Eina_Stringshare *duration, *type;
+   Eina_Stringshare *dur_label, *type_label, *size_label;
 
    evas_object_show(pd->sample_box);
    evas_object_hide(pd->tone_box);
@@ -671,174 +604,108 @@ _sample_info_update(Sound_Prop_Data *pd, 
Selected_Sound_Data *snd_data)
    elm_object_content_unset(pd->info_frame);
    elm_object_content_set(pd->info_frame, pd->sample_box);
 
-   duration = eina_stringshare_printf("%.2f s", snd_data->duration);
-   type = eina_stringshare_printf(_("%s Format Sound (.%s)"), 
snd_data->format, snd_data->snd_src);
-
-   item = elm_object_part_content_get(pd->snd_data.file_name, 
"elm.swallow.content");
-   elm_object_text_set(item, snd_data->file_name);
-
-   item = elm_object_part_content_get(pd->snd_data.duration, 
"elm.swallow.content");
-   elm_object_text_set(item, duration);
-
-   item = elm_object_part_content_get(pd->snd_data.type, 
"elm.swallow.content");
-   elm_object_text_set(item, type);
+   dur_label = eina_stringshare_printf("%.2f s", duration);
+   type_label = eina_stringshare_printf(_("%s Format Sound"), type);
+   size_label = eina_stringshare_printf("%.2f KB", size / 1024.0);
 
-   Eina_Stringshare *size = eina_stringshare_printf("%.2f KB", 
snd_data->length / 1024.0);
-   item = elm_object_part_content_get(pd->snd_data.size, 
"elm.swallow.content");
-   elm_object_text_set(item, size);
+   elm_object_text_set(pd->snd_data.file_name, name);
+   elm_object_text_set(pd->snd_data.duration, dur_label);
+   elm_object_text_set(pd->snd_data.type, type_label);
+   elm_object_text_set(pd->snd_data.size, size_label);
+   ewe_combobox_select_item_set(pd->snd_data.compression_type, 
compression_type);
+   elm_spinner_value_set(pd->snd_data.compression_quality, quality);
 
-   ewe_combobox_select_item_set(pd->snd_data.compression_type, 
snd_data->compression_type);
-   elm_spinner_value_set(pd->snd_data.compression_quality , snd_data->quality);
-
-   eina_stringshare_del(duration);
-   eina_stringshare_del(type);
+   eina_stringshare_del(dur_label);
+   eina_stringshare_del(type_label);
+   eina_stringshare_del(size_label);
 }
 
 static void
-_tone_info_update(Sound_Prop_Data *pd, Selected_Sound_Data *snd_data)
+_tone_info_update(Sound_Prop_Data *pd, const char *name, double tone_frq)
 {
-   Evas_Object *item;
-
    evas_object_hide(pd->sample_box);
    evas_object_show(pd->tone_box);
 
    elm_object_content_unset(pd->info_frame);
    elm_object_content_set(pd->info_frame, pd->tone_box);
 
-   item = elm_object_part_content_get(pd->snd_data.tone_name, 
"elm.swallow.content");
-   elm_object_text_set(item, snd_data->file_name);
-
-   elm_spinner_value_set(pd->snd_data.tone_frq, snd_data->tone_frq);
+   elm_object_text_set(pd->snd_data.tone_name, name);
+   elm_spinner_value_set(pd->snd_data.tone_frq, tone_frq);
 }
 
-#ifdef HAVE_AUDIO
-
-static void
-_added_sample_src_info_setup(Sound_Prop_Data *edit,
-                             double *len)
-{
-   Eina_Bool ret;
-
-   assert(edit != NULL);
-
-   _create_io_stream(edit);
-   eo_do(edit->io.in, ecore_audio_obj_name_set(edit->snd_src));
-   eo_do(edit->io.in, ret = ecore_audio_obj_source_set(edit->snd_src));
-   if (!ret)
-     ERR("Can not set source obj for added sample");
-   eo_do(edit->io.in, *len = ecore_audio_obj_in_length_get());
-   elm_slider_min_max_set(edit->player_data.rewind, 0, *len);
-   elm_slider_value_set(edit->player_data.rewind, 0.0);
-   edit->io.length = ecore_file_size(edit->snd_src);
-}
-#endif
-
 static void
 _grid_sample_selected(void *data,
-                              Evas_Object *obj __UNUSED__,
-                              void *event_info)
+                      Evas_Object *obj __UNUSED__,
+                      void *event_info)
 {
    Sound_Prop_Data *edit = (Sound_Prop_Data *)data;
-   Selected_Sound_Data *snd_data = (Selected_Sound_Data *)event_info;
-
-   edit->markup = snd_data->markup;
-   edit->gengrid = snd_data->gengrid;
+   Sound_Data *snd = (Sound_Data *)event_info;
+   Eina_Bool ret;
+   External_Resource *sample;
 
    double len = 0.0;
-   const Item *item = NULL;
-   const Eina_List* sel_list = elm_gengrid_selected_items_get(edit->gengrid);
-   int count = eina_list_count(sel_list);
 #ifdef HAVE_AUDIO
    Eina_Bool auto_play = elm_check_state_get(edit->player_data.check);
 #endif
-
-   if (!edit->player_data.decoration)
-     {
-        elm_layout_signal_emit(edit->markup, "eflete,sound,clicked", "eflete");
-        edit->player_data.decoration = true;
-     }
+   edit->snd = snd;
 
 #ifdef HAVE_AUDIO
    _interrupt_playing(edit);
+
+   sample = (External_Resource *)snd->resource;
+   _create_io_stream(edit);
+   eo_do(edit->io.in, ecore_audio_obj_name_set(sample->source));
+   eo_do(edit->io.in, ret = ecore_audio_obj_source_set(sample->source));
+   if (!ret) ERR("Can not set source '%s' to obj sample", sample->source)
+   eo_do(edit->io.in, len = ecore_audio_obj_in_length_get());
+   elm_slider_min_max_set(edit->player_data.rewind, 0, len);
+   elm_slider_value_set(edit->player_data.rewind, 0.0);
+   edit->io.length = ecore_file_size(sample->source);
 #endif
 
-   if (count == 1)
-     {
-        item = elm_object_item_data_get(eina_list_data_get(sel_list));
-        edit->selected = eina_stringshare_add(item->sound_name);
+  _sample_info_update(edit, snd->name, len, snd->type_label,
+                      ecore_file_size(sample->source),
+                      
edje_edit_sound_compression_rate_get(ap.project->global_object, snd->name),
+                      
edje_edit_sound_compression_type_get(ap.project->global_object, snd->name));
 
-        edit->snd_src = item->src;
 #ifdef HAVE_AUDIO
-        _added_sample_src_info_setup(edit, &len);
-#endif
-        snd_data->file_name = item->sound_name;
-        snd_data->duration = len;
-        snd_data->format = item->format;
-        snd_data->compression_type = item->comp;
-        snd_data->quality = item->rate;
-
-        _sample_info_update(edit, snd_data);
-        edit->player_data.added = true;
-#ifdef HAVE_AUDIO
-        if ((edit->player_data.switched) || (auto_play))
-          {
-             edit->player_data.switched = false;
-             _add_sound_play(edit);
-          }
-#endif
+   if ((edit->player_data.switched) || (auto_play))
+     {
+        edit->player_data.switched = false;
+        _sample_play(edit);
      }
+#endif
 }
 
 static void
 _grid_tone_selected(void *data,
-               Evas_Object *obj __UNUSED__,
-               void *event_info)
+                    Evas_Object *obj __UNUSED__,
+                    void *event_info)
 {
    Sound_Prop_Data *edit = (Sound_Prop_Data *)data;
-   Selected_Sound_Data *snd_data = (Selected_Sound_Data *)event_info;
-   const Item *item;
+   Sound_Data *snd = (Sound_Data *)event_info;
+   Tone_Resource *tone;
 
    assert(edit != NULL);
 
-   edit->markup = snd_data->markup;
-   edit->gengrid = snd_data->gengrid;
-   edit->tone = snd_data->tone;
-
-   const Eina_List* sel_list = elm_gengrid_selected_items_get(edit->gengrid);
-   int count = eina_list_count(sel_list);
-
-   if (!edit->player_data.decoration)
-     {
-        elm_layout_signal_emit(edit->markup, "eflete,sound,clicked", "eflete");
-        edit->player_data.decoration = true;
-     }
-
+   edit->snd = snd;
 #ifdef HAVE_AUDIO
    _interrupt_playing(edit);
 #endif
 
-   if (count == 1)
-     {
-        item = elm_object_item_data_get(eina_list_data_get(sel_list));
-        edit->selected = eina_stringshare_add(item->sound_name);
+   tone = (Tone_Resource *)snd->resource;
 
-        elm_slider_min_max_set(edit->player_data.rewind, 0.0, 
TONE_PLAYING_DURATION);
-        elm_slider_value_set(edit->player_data.rewind, 0.0);
-
-        snd_data->file_name = item->sound_name;
+   elm_slider_min_max_set(edit->player_data.rewind, 0.0, 
TONE_PLAYING_DURATION);
+   elm_slider_value_set(edit->player_data.rewind, 0.0);
 
-        _tone_info_update(edit, snd_data);
+   _tone_info_update(edit, tone->name, tone->freq);
 #ifdef HAVE_AUDIO
-        if (edit->player_data.switched)
-          {
-             edit->player_data.switched = false;
-             _tone_play(edit, item->tone_frq);
-             return;
-          }
-        if (elm_check_state_get(edit->player_data.check))
-          _tone_play(edit, item->tone_frq);
-#endif
+   if ((edit->player_data.switched) || 
(elm_check_state_get(edit->player_data.check)))
+     {
+        edit->player_data.switched = false;
+        _tone_play(edit);
      }
+#endif
 }
 
 static void
@@ -910,21 +777,21 @@ _on_grid_clicked(void *data,
                  void *event_info)
 {
    Sound_Prop_Data *edit = (Sound_Prop_Data *)data;
-   Selected_Sound_Data *snd_data = (Selected_Sound_Data *)event_info;
+   Sound_Data *snd = (Sound_Data *)event_info;
 
    assert(edit != NULL);
-   assert(snd_data != NULL);
+   assert(snd != NULL);
 
-   switch (snd_data->sound_type)
+   switch (snd->type)
      {
       case SOUND_TYPE_SAMPLE:
         {
-           _grid_sample_selected(edit, NULL, snd_data);
+           _grid_sample_selected(edit, NULL, snd);
            break;
         }
       case SOUND_TYPE_TONE:
         {
-           _grid_tone_selected(edit, NULL, snd_data);
+           _grid_tone_selected(edit, NULL, snd);
            break;
         }
      }

-- 


Reply via email to