cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=7c1a78cfd2be3f44a5bbfe4f197f2f519f5e983d

commit 7c1a78cfd2be3f44a5bbfe4f197f2f519f5e983d
Author: Kateryna Fesyna <[email protected]>
Date:   Mon Jun 23 11:26:25 2014 +0200

    edje: Edje_Edit - add edje_edit_sound_tone_add() function that allows user 
to add new tone to collection
    
    Summary:
    New function provides the ability to add new tones to currently loaded 
collection.
    It takes the name that will define new tone in collection and its frequency 
as parameters.
    
    @feature
    
    Reviewers: cedric, Hermet, seoz, raster
    
    CC: reutskiy.v.v, cedric
    
    Differential Revision: https://phab.enlightenment.org/D1023
    
    Signed-off-by: Cedric BAIL <[email protected]>
---
 src/lib/edje/Edje_Edit.h | 21 ++++++++++++++++++++-
 src/lib/edje/edje_edit.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 65 insertions(+), 1 deletion(-)

diff --git a/src/lib/edje/Edje_Edit.h b/src/lib/edje/Edje_Edit.h
index 30bb3f1..5330618 100644
--- a/src/lib/edje/Edje_Edit.h
+++ b/src/lib/edje/Edje_Edit.h
@@ -4398,9 +4398,26 @@ edje_edit_sound_sample_add(Evas_Object *obj, const char* 
name, const char* snd_s
  * @param name The name of the sound to be deleted from the edje.
  *
  * @return EINA_TRUE if successful, EINA_FALSE otherwise.
+ * @see edje_edit_sound_sample_add()
  */
 EAPI Eina_Bool edje_edit_sound_sample_del(Evas_Object *obj, const char *name);
 
+/** Add new tone to the collection
+ *
+ * This function adds new tone with given frequency to the edje collection.
+ * The added sound sample could be used by PLAY_TONE action in any program
+ * of any group that is in the current collection.
+ *
+ * @param obj Object being edited.
+ * @param name The name that will identify tone.
+ * @param frequency Frequency of added tone. This value should be in range of 
20 to 20000 inclusive.
+ *
+ * @return @c EINA_TRUE if successful, @c EINA_FALSE otherwise.
+ * @see edje_edit_sound_tone_del()
+ * @since 1.11
+ */
+EAPI Eina_Bool edje_edit_sound_tone_add(Evas_Object *obj, const char* name, 
int frequency);
+
 /** Delete tone from the collection
  *
  * Deletes tone from collection by its name. After successfull deletion
@@ -4410,7 +4427,9 @@ EAPI Eina_Bool edje_edit_sound_sample_del(Evas_Object 
*obj, const char *name);
  * @param obj Object being edited.
  * @param name The name of the tone to be deleted from the edje.
  *
- * @return EINA_TRUE if successful, EINA_FALSE otherwise.
+ * @return @c EINA_TRUE if successful, @c EINA_FALSE otherwise.
+ * @see edje_edit_sound_tone_add()
+ * @since 1.11
  */
 EAPI Eina_Bool edje_edit_sound_tone_del(Evas_Object *obj, const char* name);
 
diff --git a/src/lib/edje/edje_edit.c b/src/lib/edje/edje_edit.c
index 8764480..244bb66 100644
--- a/src/lib/edje/edje_edit.c
+++ b/src/lib/edje/edje_edit.c
@@ -1207,6 +1207,51 @@ edje_edit_sound_sample_del(Evas_Object *obj, const char* 
name)
 }
 
 EAPI Eina_Bool
+edje_edit_sound_tone_add(Evas_Object *obj, const char* name, int frequency)
+{
+   if (!name) return EINA_FALSE;
+   if ((frequency < 20) || (frequency > 20000))
+     return EINA_FALSE;
+
+   GET_ED_OR_RETURN(EINA_FALSE);
+
+   Edje_Sound_Tone *sound_tone = NULL;
+   Edje_Sound_Tone *sound_tones_array = NULL;
+   unsigned int i = 0;
+   int id = 0;
+
+   _initialize_sound_dir(ed);
+
+   for (i = 0; i < ed->file->sound_dir->tones_count; ++i)
+     {
+        sound_tone = ed->file->sound_dir->tones + i;
+        if (!strcmp(name, sound_tone->name))
+          {
+             WRN("Can not add new tone because"
+                 "tone named \"%s\" already exists.", name);
+             return EINA_FALSE;
+          }
+     }
+   ed->file->sound_dir->tones_count++;
+
+   sound_tones_array = realloc(ed->file->sound_dir->tones,
+                               sizeof(Edje_Sound_Tone) *
+                               ed->file->sound_dir->tones_count);
+   if (sound_tones_array)
+     ed->file->sound_dir->tones = sound_tones_array;
+   else return EINA_FALSE;
+
+   sound_tone = ed->file->sound_dir->tones +
+                ed->file->sound_dir->tones_count - 1;
+   sound_tone->name = (char*)eina_stringshare_add(name);
+   sound_tone->value = frequency;
+   sound_tone->id = id;
+
+   return EINA_TRUE;
+}
+
+
+EAPI Eina_Bool
 edje_edit_sound_tone_del(Evas_Object *obj, const char* name)
 {
    GET_ED_OR_RETURN(EINA_FALSE);

-- 


Reply via email to