From ccfc1b7eea7f951a18ab8748926bd37328471a1a Mon Sep 17 00:00:00 2001 From: tiago Date: Mon, 26 Apr 2010 18:19:43 +0000 Subject: [PATCH] Edje_edit image_del git-svn-id: http://svn.enlightenment.org/svn/e/trunk/edje@48337 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- src/lib/Edje_Edit.h | 11 ++++++++ src/lib/edje_edit.c | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+) diff --git a/src/lib/Edje_Edit.h b/src/lib/Edje_Edit.h index 852c735..63d67f6 100644 --- a/src/lib/Edje_Edit.h +++ b/src/lib/Edje_Edit.h @@ -2251,6 +2251,17 @@ EAPI Eina_List * edje_edit_images_list_get(Evas_Object *obj); */ EAPI Eina_Bool edje_edit_image_add(Evas_Object *obj, const char *path); +/** Delete an image from the image collection + * + * It actually write directly to the file so you don't have to save. + * + * @param obj Object being edited. + * @param name The name of the image file to include in the edje. + * + * @return EINA_TRUE if succesful, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_image_del(Evas_Object *obj, const char *name); + /** Add an image entry to the image collection * * This function adds the given image entry to the edje image collection. The diff --git a/src/lib/edje_edit.c b/src/lib/edje_edit.c index d1876db..a317391 100644 --- a/src/lib/edje_edit.c +++ b/src/lib/edje_edit.c @@ -4384,6 +4384,82 @@ edje_edit_image_add(Evas_Object *obj, const char* path) } EAPI Eina_Bool +edje_edit_image_del(Evas_Object *obj, const char* name) +{ + Eina_List *l; + Edje_Image_Directory_Entry *de; + + GET_ED_OR_RETURN(EINA_FALSE); + + if (!name) return EINA_FALSE; + if (!ed->file) return EINA_FALSE; + if (!ed->path) return EINA_FALSE; + + /* Create Image_Directory if not exist */ + if (!ed->file->image_dir) + return EINA_TRUE; + + EINA_LIST_FOREACH(ed->file->image_dir->entries, l, de) + { + if (!strcmp(name, de->entry)) + { + ed->file->image_dir->entries = eina_list_remove_list( + ed->file->image_dir->entries, l); + break; + } + de = NULL; + } + + if (!de) + { + WRN("Unable to find image entry part \"%s\"", name); + return EINA_TRUE; + } + + { + char entry[PATH_MAX]; + Eet_File *eetf; + + /* open the eet file */ + eetf = eet_open(ed->path, EET_FILE_MODE_READ_WRITE); + if (!eetf) + { + ERR("Unable to open \"%s\" for writing output", ed->path); + ed->file->image_dir->entries = + eina_list_append(ed->file->image_dir->entries, de); + return EINA_FALSE; + } + + snprintf(entry, sizeof(entry), "images/%i", de->id); + + if (eet_delete(eetf, entry) <= 0) + { + ERR("Unable to delete \"%s\" font entry", entry); + eet_close(eetf); + ed->file->image_dir->entries = + eina_list_append(ed->file->image_dir->entries, de); + return EINA_FALSE; + } + + /* write the edje_file */ + if (!_edje_edit_update_edje_file(ed, eetf)) + { + eet_close(eetf); + ed->file->image_dir->entries = + eina_list_append(ed->file->image_dir->entries, de); + return EINA_FALSE; + } + + eet_close(eetf); + } + + free(de->entry); + free(de); + + return EINA_TRUE; +} + +EAPI Eina_Bool edje_edit_image_data_add(Evas_Object *obj, const char *name, int id) { Eina_List *l; -- 2.7.4