cedric pushed a commit to branch master.

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

commit a5183ee424d65cf37343ea46f7982c74f60d6fbc
Author: Cedric BAIL <[email protected]>
Date:   Mon Jan 5 10:53:57 2015 +0100

    edje: Edje_Edit - add API for renaming of image.
    
    Reviewers: Hermet, raster, seoz, cedric
    
    @feature
    
    Subscribers: reutskiy.v.v
    
    Projects: #efl
    
    Differential Revision: https://phab.enlightenment.org/D1830
    
    Signed-off-by: Cedric BAIL <[email protected]>
---
 src/lib/edje/Edje_Edit.h | 13 +++++++++++++
 src/lib/edje/edje_edit.c | 24 ++++++++++++++++++++++++
 2 files changed, 37 insertions(+)

diff --git a/src/lib/edje/Edje_Edit.h b/src/lib/edje/Edje_Edit.h
index aba67ee..ebc3dc8 100644
--- a/src/lib/edje/Edje_Edit.h
+++ b/src/lib/edje/Edje_Edit.h
@@ -4666,6 +4666,19 @@ EAPI Eina_Bool edje_edit_image_del(Evas_Object *obj, 
const char *name);
  */
 EAPI Eina_Bool edje_edit_image_replace(Evas_Object *obj, const char *name, 
const char *new_name);
 
+/** Rename image
+ *
+ * @param obj Object being edited.
+ * @param name The name of the image to be renamed.
+ * @param new_name The new_name of the image.
+ *
+ * @return @c EINA_TRUE in case of success, @c EINA_FALSE otherwise.(including 
the
+ * case when one of the names is not valid)
+ *
+ * @since 1.12
+ */
+EAPI Eina_Bool edje_edit_image_rename(Evas_Object *obj, const char *name, 
const char *new_name);
+
 /** Get list of (Edje_Part_Image_Use *) - group-part-state triplets where given
  * image is used
  *
diff --git a/src/lib/edje/edje_edit.c b/src/lib/edje/edje_edit.c
index bb35f38..f7d8e86 100644
--- a/src/lib/edje/edje_edit.c
+++ b/src/lib/edje/edje_edit.c
@@ -7320,6 +7320,30 @@ edje_edit_image_replace(Evas_Object *obj, const char 
*name, const char *new_name
    return EINA_TRUE;
 }
 
+EAPI Eina_Bool
+edje_edit_image_rename(Evas_Object *obj, const char *name, const char 
*new_name)
+{
+   Edje_Image_Directory_Entry *de = NULL;
+   unsigned int i;
+   GET_ED_OR_RETURN(EINA_FALSE);
+
+   // Check if image with 'new_name' already exists
+   if (edje_edit_image_id_get(obj, new_name) >= 0) 
+      return EINA_FALSE;
+
+   for (i = 0; i < ed->file->image_dir->entries_count; ++i)
+     {
+        de = ed->file->image_dir->entries + i;
+        if ((de->entry) && (!strcmp(name, de->entry)))
+          break;
+     }
+   if (i == ed->file->image_dir->entries_count) return EINA_FALSE;
+
+   _edje_if_string_replace(ed, &de->entry, new_name);
+
+   return EINA_TRUE;
+}
+
 EAPI Eina_List*
 edje_edit_image_usage_list_get(Evas_Object *obj, const char *name, Eina_Bool 
first_only)
 {

-- 


Reply via email to