Use right key to find stuff in the eet file. By Fidencio
authorsachiel <sachiel@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Fri, 13 Aug 2010 20:07:12 +0000 (20:07 +0000)
committersachiel <sachiel@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Fri, 13 Aug 2010 20:07:12 +0000 (20:07 +0000)
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: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/edje@51095 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/bin/edje_decc.c
src/lib/edje_edit.c
src/lib/edje_lua.c

index 072461c..427c440 100644 (file)
@@ -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];
index a26bcbf..898dc8b 100644 (file)
@@ -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);
index d96e365..b01d0ad 100644 (file)
@@ -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;
 }