1
#include "edje_private.h"
3
static const Edje_File *_current_edje_file = NULL;
8
return _current_edje_file;
12
_edje_file_set(const Edje_File *edf)
14
_current_edje_file = edf;
18
_edje_font_string_free(void *data)
20
Edje_Font_Directory_Entry *fe = data;
22
eina_stringshare_del(fe->path);
27
_edje_collection_string_free(void *data)
29
Edje_Part_Collection_Directory_Entry *ce = data;
31
eina_stringshare_del(ce->entry);
37
edf = (Edje_File *)_edje_file_get();
40
CRI("This program as probably called edje_shutdown() with "
41
"active Edje objects still around. "
42
"This can cause problems as both Evas and Edje retain "
43
"references to the objects. "
44
"You should shut down all canvases and objects "
45
"before calling edje_shutdown(). "
46
"The following errors are the edje object files and "
47
"parts that are still hanging around, with their reference "
51
ERR("file: '%s', references: %i, part: '%s', references: %i",
52
edf->path, edf->references,
53
ce->ref->part, ce->ref->references);
55
_edje_collection_free(edf, ce->ref, ce);
62
_edje_file_convert_external(Edje_File *edf, Old_Edje_File *oedf)
64
Edje_External_Directory_Entry *ede;
68
edf->external_dir = calloc(1, sizeof (Edje_External_Directory));
69
if (!edf->external_dir) return EINA_FALSE;
70
if (!oedf->external_dir) return EINA_TRUE;
72
max = eina_list_count(oedf->external_dir->entries);
73
edf->external_dir->entries = calloc(1, sizeof (Edje_External_Directory_Entry) * max);
74
edf->external_dir->entries_count = max;
76
if (!edf->external_dir->entries && max)
79
EINA_LIST_FREE(oedf->external_dir->entries, ede)
81
edf->external_dir->entries[i++].entry = ede->entry;
85
free(oedf->external_dir);
86
oedf->external_dir = NULL;
92
_edje_file_convert_images(Edje_File *edf, Old_Edje_File *oedf)
94
Edje_Image_Directory_Entry *de;
95
Edje_Image_Directory_Set *ds;
99
edf->image_dir = calloc(1, sizeof (Edje_Image_Directory));
100
if (!edf->image_dir) return EINA_FALSE;
101
if (!oedf->image_dir) return EINA_TRUE;
104
EINA_LIST_FOREACH(oedf->image_dir->entries, l, de)
108
edf->image_dir->entries = calloc(1, sizeof (Edje_Image_Directory_Entry) * (max + 1));
109
edf->image_dir->entries_count = max + 1;
111
if (!edf->image_dir->entries && edf->image_dir->entries_count)
114
EINA_LIST_FREE(oedf->image_dir->entries, de)
116
memcpy(edf->image_dir->entries + de->id,
118
sizeof (Edje_Image_Directory_Entry));
123
EINA_LIST_FOREACH(oedf->image_dir->sets, l, ds)
127
edf->image_dir->sets = calloc(1, sizeof (Edje_Image_Directory_Set) * (max + 1));
128
edf->image_dir->sets_count = max + 1;
130
if (!edf->image_dir->sets && edf->image_dir->sets_count)
132
free(edf->image_dir->entries);
133
edf->image_dir->entries = NULL;
137
EINA_LIST_FREE(oedf->image_dir->sets, ds)
139
memcpy(edf->image_dir->sets + ds->id,
141
sizeof (Edje_Image_Directory_Set));
149
_edje_file_convert(Eet_File *file, Old_Edje_File *oedf)
151
Edje_Part_Collection_Directory_Entry *ce;
152
Edje_Font_Directory_Entry *fnt;
157
edf = calloc(1, sizeof (Edje_File));
158
if (!edf) return NULL;
160
edf->free_strings = eet_dictionary_get(file) ? 0 : 1;
162
if (edf->free_strings)
164
edf->fonts = eina_hash_string_small_new(_edje_font_string_free);
165
edf->collection = eina_hash_string_small_new(_edje_collection_string_free);
166
edf->data = eina_hash_string_small_new((Eina_Free_Cb)eina_stringshare_del);
170
edf->fonts = eina_hash_string_small_new(free);
171
edf->collection = eina_hash_string_small_new(free);
172
edf->data = eina_hash_string_small_new(NULL);
175
if (!edf->fonts || !edf->collection || !edf->data)
178
EINA_LIST_FREE(oedf->data, ed)
180
eina_hash_direct_add(edf->data, ed->key, ed->value);
184
EINA_LIST_FOREACH(oedf->collection_dir->entries, l, ce)
186
eina_hash_direct_add(edf->collection, ce->entry, ce);
189
EINA_LIST_FOREACH(oedf->font_dir->entries, l, fnt)
194
length = strlen(fnt->entry) + 7;
195
tmp = alloca(length);
197
snprintf(tmp, length, "fonts/%s", fnt->entry);
198
fnt->path = eina_stringshare_add(tmp);
199
if (edf->free_strings)
200
eina_stringshare_del(fnt->entry);
201
fnt->entry = fnt->path + 6;
203
eina_hash_direct_add(edf->fonts, fnt->entry, fnt);
206
if (!_edje_file_convert_images(edf, oedf))
209
if (!_edje_file_convert_external(edf, oedf))
213
edf->styles = oedf->styles;
214
edf->color_classes = oedf->color_classes;
215
edf->text_classes = oedf->text_classes;
216
edf->size_classes = oedf->size_classes;
217
edf->version = oedf->version;
218
edf->feature_ver = oedf->feature_ver;
219
edf->efl_version.major = oedf->efl_version.major;
220
edf->efl_version.minor = oedf->efl_version.minor;
221
edf->compiler = oedf->compiler;
223
edf->dangling = EINA_FALSE;
224
edf->warning = EINA_FALSE;
228
edf->collection_cache = NULL;
229
edf->collection_patterns = NULL;
234
eina_hash_free(edf->fonts);
235
eina_hash_free(edf->collection);
236
eina_hash_free(edf->data);
237
free(edf->image_dir);
238
free(edf->external_dir);
244
_edje_collection_program_add(Edje_Program ***array,
250
tmp = realloc(*array, sizeof (Edje_Program *) * (*count + 1));
253
tmp[(*count)++] = add;
257
Edje_Part_Collection *
258
_edje_collection_convert(Edje_File *file, Old_Edje_Part_Collection *oedc)
260
Edje_Part_Collection_Directory_Entry *ce;
261
Edje_Part_Collection *edc;
268
ce = eina_hash_find(file->collection, oedc->part);
271
EINA_LIST_FOREACH(oedc->parts, l, part)
279
case EDJE_PART_TYPE_##Tp: \
280
count = &Ce->count.Tp; \
299
*count += eina_list_count(part->other_desc) + 1;
301
ce->count.part = eina_list_count(oedc->parts);
303
#define CONVERT_EMN(Tp, Sz, Ce) \
304
Ce->mp.Tp = eina_mempool_add("one_big", #Tp, NULL, sizeof (Sz), Ce->count.Tp);
306
CONVERT_EMN(RECTANGLE, Edje_Part_Description_Common, ce);
307
CONVERT_EMN(TEXT, Edje_Part_Description_Text, ce);
308
CONVERT_EMN(IMAGE, Edje_Part_Description_Image, ce);
309
CONVERT_EMN(SWALLOW, Edje_Part_Description_Common, ce);
310
CONVERT_EMN(TEXTBLOCK, Edje_Part_Description_Text, ce);
311
CONVERT_EMN(GROUP, Edje_Part_Description_Common, ce);
312
CONVERT_EMN(BOX, Edje_Part_Description_Box, ce);
313
CONVERT_EMN(TABLE, Edje_Part_Description_Table, ce);
314
CONVERT_EMN(EXTERNAL, Edje_Part_Description_External, ce);
315
CONVERT_EMN(part, Edje_Part, ce);
316
CONVERT_EMN(VECTOR, Edje_Part_Description_Vector, ce);
319
edc = calloc(1, sizeof (Edje_Part_Collection));
320
if (!edc) return NULL;
323
EINA_LIST_FREE(oedc->programs, pg)
325
if (!pg->signal && !pg->source)
326
_edje_collection_program_add(&edc->programs.nocmp,
327
&edc->programs.nocmp_count,
329
else if (pg->signal && !strpbrk(pg->signal, "*?[\\")
330
&& pg->source && !strpbrk(pg->source, "*?[\\"))
331
_edje_collection_program_add(&edc->programs.strcmp,
332
&edc->programs.strcmp_count,
334
else if (pg->signal && edje_program_is_strncmp(pg->signal)
335
&& pg->source && edje_program_is_strncmp(pg->source))
336
_edje_collection_program_add(&edc->programs.strncmp,
337
&edc->programs.strncmp_count,
339
else if (pg->signal && edje_program_is_strrncmp(pg->signal)
340
&& pg->source && edje_program_is_strrncmp(pg->source))
341
_edje_collection_program_add(&edc->programs.strrncmp,
342
&edc->programs.strrncmp_count,
345
_edje_collection_program_add(&edc->programs.fnmatch,
346
&edc->programs.fnmatch_count,
350
edc->data = eina_hash_string_small_new(NULL);
351
EINA_LIST_FREE(oedc->data, di)
353
eina_hash_direct_add(edc->data, di->key, di->value);
357
edc->parts_count = eina_list_count(oedc->parts);
358
edc->parts = calloc(edc->parts_count, sizeof (Edje_Part *));
361
EINA_LIST_FREE(oedc->parts, part)
363
Old_Edje_Part_Description *oepd;
364
Edje_Pack_Element *elm;
365
Edje_Part *replacement;
368
replacement = eina_mempool_malloc(ce->mp.part, sizeof (Edje_Part));
370
replacement->name = part->name;
371
replacement->default_desc = _edje_description_convert(part->type, ce, part->default_desc);
373
replacement->other_count = eina_list_count(part->other_desc);
374
replacement->other_desc = calloc(replacement->other_count, sizeof (Edje_Part_Description_Common *));
377
EINA_LIST_FREE(part->other_desc, oepd)
378
replacement->other_desc[i++] = _edje_description_convert(part->type, ce, oepd);
380
replacement->source = part->source;
381
replacement->source2 = part->source2;
382
replacement->source3 = part->source3;
383
replacement->source4 = part->source4;
384
replacement->source5 = part->source5;
385
replacement->source6 = part->source6;
386
replacement->id = part->id;
387
replacement->clip_to_id = part->clip_to_id;
388
replacement->dragable = part->dragable;
389
replacement->items_count = eina_list_count(part->items);
390
replacement->items = calloc(replacement->items_count, sizeof (Edje_Pack_Element *));
393
EINA_LIST_FREE(part->items, elm)
394
replacement->items[i++] = elm;
396
replacement->type = part->type;
397
replacement->effect = part->effect;
398
replacement->mouse_events = part->mouse_events;
399
replacement->repeat_events = part->repeat_events;
400
replacement->ignore_flags = part->ignore_flags;
401
replacement->mask_flags = part->mask_flags;
402
replacement->scale = part->scale;
403
replacement->precise_is_inside = part->precise_is_inside;
404
replacement->use_alternate_font_metrics = part->use_alternate_font_metrics;
405
replacement->pointer_mode = part->pointer_mode;
406
replacement->entry_mode = part->entry_mode;
407
replacement->select_mode = part->select_mode;
408
replacement->multiline = part->multiline;
409
replacement->api = part->api;
410
replacement->required = part->required;
412
edc->parts[k++] = replacement;
418
edc->alias = oedc->alias;
419
edc->prop.min = oedc->prop.min;
420
edc->prop.max = oedc->prop.max;
421
edc->script = oedc->script;
422
edc->part = oedc->part;
423
edc->lua_script_only = oedc->lua_script_only;
424
edc->checked = oedc->checked;
431
Edje_Part_Description_Common *
432
_edje_description_convert(int type,
433
Edje_Part_Collection_Directory_Entry *ce,
434
Old_Edje_Part_Description *oed)
436
Edje_Part_Description_Common *result = NULL;
440
case EDJE_PART_TYPE_RECTANGLE:
441
result = eina_mempool_malloc(ce->mp.RECTANGLE,
442
sizeof (Edje_Part_Description_Common));
445
case EDJE_PART_TYPE_SWALLOW:
446
result = eina_mempool_malloc(ce->mp.SWALLOW,
447
sizeof (Edje_Part_Description_Common));
450
case EDJE_PART_TYPE_GROUP:
451
result = eina_mempool_malloc(ce->mp.GROUP,
452
sizeof (Edje_Part_Description_Common));
455
case EDJE_PART_TYPE_IMAGE:
457
Edje_Part_Description_Image *img;
458
Edje_Part_Image_Id *id;
461
img = eina_mempool_malloc(ce->mp.IMAGE, sizeof (Edje_Part_Description_Image));
463
img->image.tweens_count = eina_list_count(oed->image.tween_list);
464
img->image.tweens = calloc(img->image.tweens_count,
465
sizeof (Edje_Part_Image_Id *));
466
if (img->image.tweens_count > 0 && !img->image.tweens)
468
eina_mempool_free(ce->mp.IMAGE, img);
472
EINA_LIST_FREE(oed->image.tween_list, id)
473
img->image.tweens[i++] = id;
475
img->image.id = oed->image.id;
476
img->image.scale_hint = oed->image.scale_hint;
477
img->image.set = oed->image.set;
479
img->image.border = oed->image.border;
480
img->image.fill = oed->image.fill;
482
result = &img->common;
486
#define CONVERT_ALLOC_POOL(Short, Type, Name) \
487
case EDJE_PART_TYPE_##Short: \
489
Edje_Part_Description_##Type * Name; \
491
Name = eina_mempool_malloc(ce->mp.Short, sizeof (Edje_Part_Description_##Type)); \
492
Name->Name = oed->Name; \
493
result = &Name->common; \
497
CONVERT_ALLOC_POOL(TEXT, Text, text);
498
CONVERT_ALLOC_POOL(TEXTBLOCK, Text, text);
499
CONVERT_ALLOC_POOL(BOX, Box, box);
500
CONVERT_ALLOC_POOL(TABLE, Table, table);
501
CONVERT_ALLOC_POOL(EXTERNAL, External, external_params);
502
CONVERT_ALLOC_POOL(VECTOR, Vector, vector);
505
*result = oed->common;