edje: Edje_Edit - add API for renaming of image.
authorCedric BAIL <cedric@osg.samsung.com>
Mon, 5 Jan 2015 09:53:57 +0000 (10:53 +0100)
committerCedric BAIL <cedric@osg.samsung.com>
Mon, 5 Jan 2015 09:54:11 +0000 (10:54 +0100)
Reviewers: Hermet, raster, seoz, cedric

@feature

Subscribers: reutskiy.v.v

Projects: #efl

Differential Revision: https://phab.enlightenment.org/D1830

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
src/lib/edje/Edje_Edit.h
src/lib/edje/edje_edit.c

index aba67ee..ebc3dc8 100644 (file)
@@ -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
  *
index bb35f38..f7d8e86 100644 (file)
@@ -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)
 {