Created new function edje_edit_image_data_add().
authorantognolli <antognolli@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Mon, 13 Jul 2009 19:17:35 +0000 (19:17 +0000)
committerantognolli <antognolli@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Mon, 13 Jul 2009 19:17:35 +0000 (19:17 +0000)
Now it's possible to add an image that is already inside the eet (with a
default key name) to the edje image collection.

git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/edje@41320 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/Edje_Edit.h
src/lib/edje_edit.c

index adc17a0..a8525f1 100644 (file)
@@ -1575,6 +1575,21 @@ edje_edit_image_add(
    const char* path        ///< The name of the image file to include in the edje
 );
 
+/**Add an image entry to the image collection
+ *
+ * This function adds the given image entry to the edje image collection. The
+ * image needs to be inside the eet already, with key name "images/id". After
+ * you have to create a new image_part that use this image, referring to it as
+ * "name". Note that all the parts in the edje share the same image collection,
+ * thus you can/must use the same image for different part.
+ */
+EAPI unsigned char        /// @return TRUE on success or FALSE on failure
+edje_edit_image_data_add(
+   Evas_Object *obj,      ///< The edje object
+   const char *name,      ///< The image entry name
+   int id                 ///< The image id
+);
+
 /**Get normal image name for a given part state. Remember to free the returned string using edje_edit_string_free().*/
 EAPI const char *          ///@return The name of the image used by state
 edje_edit_state_image_get(
index b8afb17..48cb607 100644 (file)
@@ -3443,6 +3443,53 @@ edje_edit_image_add(Evas_Object *obj, const char* path)
    return 1;
 }
 
+EAPI unsigned char
+edje_edit_image_data_add(Evas_Object *obj, const char *name, int id)
+{
+   Eina_List *l;
+   Edje_Image_Directory_Entry *de;
+   Edje_Image_Directory_Entry *i, *t;
+   int free_id = 0;
+
+   GET_ED_OR_RETURN(0);
+
+   if (!name) return 0;
+   if (!ed->file) return 0;
+   if (!ed->path) return 0;
+
+   /* Create Image_Directory if not exist */
+   if (!ed->file->image_dir)
+     ed->file->image_dir = mem_alloc(sizeof(Edje_Image_Directory));
+
+   /* Loop trough image directory to find if image exist */
+   t = NULL;
+   EINA_LIST_FOREACH(ed->file->image_dir->entries, l, i)
+     {
+       if (!i) return 0;
+       if (i->id == id) t = i;
+     }
+
+   /* Create Image Entry */
+   if (!t)
+     de = mem_alloc(sizeof(Edje_Image_Directory_Entry));
+   else
+     {
+       de = t;
+       free(de->entry);
+     }
+   de->entry = mem_strdup(name);
+   de->id = id;
+   de->source_type = 1;
+   de->source_param = 1;
+
+   /* Add image to Image Directory */
+   if (!t)
+     ed->file->image_dir->entries =
+       eina_list_append(ed->file->image_dir->entries, de);
+
+   return 1;
+}
+
 EAPI int
 edje_edit_image_id_get(Evas_Object *obj, const char *image_name)
 {