From 8537a736119f663a20b04ca4203ac64b79f8642d Mon Sep 17 00:00:00 2001 From: sachiel Date: Fri, 13 Aug 2010 20:07:12 +0000 Subject: [PATCH] Use right key to find stuff in the eet file. By Fidencio Store filename for the fonts when adding eith Edje_Edit. By Fidencio Use the hash in edje_file to dump fonts with edje_decc, avoiding the need for the fontmap, which should probably be taken out entirely later. git-svn-id: http://svn.enlightenment.org/svn/e/trunk/edje@51095 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- src/bin/edje_decc.c | 13 ++++++++----- src/lib/edje_edit.c | 17 ++++++++++++++++- src/lib/edje_lua.c | 2 +- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/src/bin/edje_decc.c b/src/bin/edje_decc.c index 072461c..427c440 100644 --- a/src/bin/edje_decc.c +++ b/src/bin/edje_decc.c @@ -216,7 +216,7 @@ output(void) ERR("Cannot create image object for save."); exit(-1); } - snprintf(buf, sizeof(buf), "images/%i", ei->id); + snprintf(buf, sizeof(buf), "edje/images/%i", ei->id); evas_object_image_file_set(im, file_in, buf); snprintf(out, sizeof(out), "%s/%s", outdir, ei->entry); printf("Output Image: %s\n", out); @@ -279,17 +279,19 @@ output(void) if (sf->file) fputs(sf->file, f); fclose(f); } - if (fontlist) + if (edje_file->fonts) { - Font *fn; + Edje_Font_Directory_Entry *fn; + Eina_Iterator *it; - EINA_LIST_FOREACH(fontlist->list, l, fn) + it = eina_hash_iterator_data_new(edje_file->fonts); + EINA_ITERATOR_FOREACH(it, fn) { void *font; int fontsize; char out[4096]; - snprintf(out, sizeof(out), "fonts/%s", fn->name); + snprintf(out, sizeof(out), "edje/fonts/%s", fn->entry); font = eet_read(ef, out, &fontsize); if (font) { @@ -321,6 +323,7 @@ output(void) free(font); } } + eina_iterator_free(it); } { char out[4096]; diff --git a/src/lib/edje_edit.c b/src/lib/edje_edit.c index a26bcbf..898dc8b 100644 --- a/src/lib/edje_edit.c +++ b/src/lib/edje_edit.c @@ -3946,6 +3946,7 @@ EAPI Eina_Bool edje_edit_font_add(Evas_Object *obj, const char* path, const char* alias) { char entry[PATH_MAX]; + char *new_path; struct stat st; Edje_Font_Directory_Entry *fnt; @@ -3959,13 +3960,26 @@ edje_edit_font_add(Evas_Object *obj, const char* path, const char* alias) if (!ed->path) return EINA_FALSE; /* Alias */ - if (!alias) + if (alias) + { + if ((new_path = strrchr(path, '/'))) new_path ++; + else new_path = (char *)path; + } + else { if ((alias = strrchr(path, '/'))) alias ++; else alias = (char *)path; + new_path = (char *)alias; } snprintf(entry, sizeof(entry), "edje/fonts/%s", alias); + /* Initializing a new font hash, if no exist */ + if (!ed->file->fonts) + { + ed->file->fonts = eina_hash_string_small_new(NULL); + if (!ed->file->fonts) return EINA_FALSE; + } + /* Check if exists */ fnt = eina_hash_find(ed->file->fonts, alias); if (fnt) @@ -3978,6 +3992,7 @@ edje_edit_font_add(Evas_Object *obj, const char* path, const char* alias) ERR("Unable to alloc font entry part \"%s\"", alias); return EINA_FALSE; } + fnt->file = eina_stringshare_add(new_path); fnt->entry = eina_stringshare_add(alias); eina_hash_direct_add(ed->file->fonts, fnt->entry, fnt); diff --git a/src/lib/edje_lua.c b/src/lib/edje_lua.c index d96e365..b01d0ad 100644 --- a/src/lib/edje_lua.c +++ b/src/lib/edje_lua.c @@ -2163,7 +2163,7 @@ _edje_lua_image_set_file(lua_State *L) Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mImage); int id = edje_edit_image_id_get(obj->ed->obj, luaL_checkstring(L, 2)); char buf[256]; - sprintf(buf, "images/%i", id); + sprintf(buf, "edje/images/%i", id); evas_object_image_file_set(obj->eo, obj->ed->path, buf); return 0; } -- 2.7.4