From d147af24e3671180ff5f58ade1d9fca19dab49e0 Mon Sep 17 00:00:00 2001 From: Rafael Antognolli Date: Mon, 13 Jul 2009 19:17:35 +0000 Subject: [PATCH] Created new function edje_edit_image_data_add(). Now it's possible to add an image that is already inside the eet (with a default key name) to the edje image collection. SVN revision: 41320 --- legacy/edje/src/lib/Edje_Edit.h | 15 +++++++++++ legacy/edje/src/lib/edje_edit.c | 47 +++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) diff --git a/legacy/edje/src/lib/Edje_Edit.h b/legacy/edje/src/lib/Edje_Edit.h index adc17a02d0..a8525f1b97 100644 --- a/legacy/edje/src/lib/Edje_Edit.h +++ b/legacy/edje/src/lib/Edje_Edit.h @@ -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( diff --git a/legacy/edje/src/lib/edje_edit.c b/legacy/edje/src/lib/edje_edit.c index b8afb17d75..48cb607b32 100644 --- a/legacy/edje/src/lib/edje_edit.c +++ b/legacy/edje/src/lib/edje_edit.c @@ -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) {