1
#include "edje_private.h"
3
typedef struct _Edje_Table_Items Edje_Table_Items;
4
struct _Edje_Table_Items
10
unsigned short colspan;
11
unsigned short rowspan;
14
typedef struct _Edje_Drag_Items Edje_Drag_Items;
15
struct _Edje_Drag_Items
29
void _edje_file_add(Edje *ed, const Eina_File *f);
31
/* START - Nested part support */
32
#define _edje_smart_nested_type "Evas_Smart_Nested"
33
typedef struct _Edje_Nested_Support Edje_Nested_Support;
34
struct _Edje_Nested_Support /* We builed nested-parts list using this struct */
36
Evas_Object *o; /* Smart object containing nested children */
37
unsigned char nested_children_count; /* Number of nested children */
41
_edje_smart_nested_smart_class_new(void)
43
static Evas_Smart_Class _sc = EVAS_SMART_CLASS_INIT_NAME_VERSION("EdjeNested");
44
static const Evas_Smart_Class *class = NULL;
45
static Evas_Smart *smart;
51
smart = evas_smart_class_new(class);
56
edje_smart_nested_add(Evas *evas)
58
return evas_object_smart_add(evas, _edje_smart_nested_smart_class_new());
61
/* END - Nested part support */
63
#ifdef EDJE_PROGRAM_CACHE
64
static Eina_Bool _edje_collection_free_prog_cache_matches_free_cb(const Eina_Hash *hash, const void *key, void *data, void *fdata);
66
static void _edje_object_pack_item_hints_set(Evas_Object *obj, Edje_Pack_Element *it);
67
static void _cb_signal_repeat(void *data, Evas_Object *obj, const char *signal, const char *source);
69
static Eina_Hash *_edje_object_collect(Edje *ed);
71
static int _sort_defined_boxes(const void *a, const void *b);
73
/************************** API Routines **************************/
76
_efl_canvas_layout_efl_file_file_get(Eo *obj EINA_UNUSED, Edje *ed)
82
_efl_canvas_layout_efl_file_group_get(Eo *obj EINA_UNUSED, Edje *ed)
88
_efl_canvas_layout_layout_load_error_get(const Eo *obj EINA_UNUSED, Edje *ed)
90
switch (ed->load_error)
92
case EDJE_LOAD_ERROR_NONE: return EFL_GFX_IMAGE_LOAD_ERROR_NONE;
93
case EDJE_LOAD_ERROR_GENERIC: return EFL_GFX_IMAGE_LOAD_ERROR_GENERIC;
94
case EDJE_LOAD_ERROR_DOES_NOT_EXIST: return EFL_GFX_IMAGE_LOAD_ERROR_DOES_NOT_EXIST;
95
case EDJE_LOAD_ERROR_PERMISSION_DENIED: return EFL_GFX_IMAGE_LOAD_ERROR_PERMISSION_DENIED;
96
case EDJE_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED: return EFL_GFX_IMAGE_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED;
97
case EDJE_LOAD_ERROR_CORRUPT_FILE: return EFL_GFX_IMAGE_LOAD_ERROR_CORRUPT_FILE;
98
case EDJE_LOAD_ERROR_UNKNOWN_FORMAT: return EFL_GFX_IMAGE_LOAD_ERROR_UNKNOWN_FORMAT;
99
case EDJE_LOAD_ERROR_INCOMPATIBLE_FILE: return EFL_GFX_IMAGE_LOAD_ERROR_INCOMPATIBLE_FILE;
100
case EDJE_LOAD_ERROR_UNKNOWN_COLLECTION: return EFL_GFX_IMAGE_LOAD_ERROR_UNKNOWN_COLLECTION;
101
case EDJE_LOAD_ERROR_RECURSIVE_REFERENCE: return EFL_GFX_IMAGE_LOAD_ERROR_RECURSIVE_REFERENCE;
104
return EFL_GFX_IMAGE_LOAD_ERROR_GENERIC;
108
edje_load_error_str(Edje_Load_Error error)
112
case EDJE_LOAD_ERROR_NONE:
115
case EDJE_LOAD_ERROR_GENERIC:
116
return "Generic Error";
118
case EDJE_LOAD_ERROR_DOES_NOT_EXIST:
119
return "File Does Not Exist";
121
case EDJE_LOAD_ERROR_PERMISSION_DENIED:
122
return "Permission Denied";
124
case EDJE_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED:
125
return "Resource Allocation Failed";
127
case EDJE_LOAD_ERROR_CORRUPT_FILE:
128
return "Corrupt File";
130
case EDJE_LOAD_ERROR_UNKNOWN_FORMAT:
131
return "Unknown Format";
133
case EDJE_LOAD_ERROR_INCOMPATIBLE_FILE:
134
return "Incompatible File";
136
case EDJE_LOAD_ERROR_UNKNOWN_COLLECTION:
137
return "Unknown Collection";
139
case EDJE_LOAD_ERROR_RECURSIVE_REFERENCE:
140
return "Recursive Reference";
143
return "Unknown Error";
148
edje_mmap_collection_list(Eina_File *f)
150
Eina_List *lst = NULL;
155
edf = _edje_cache_file_coll_open(f, NULL, &error_ret, NULL, NULL);
161
i = eina_hash_iterator_key_new(edf->collection);
163
EINA_ITERATOR_FOREACH(i, key)
164
lst = eina_list_append(lst, eina_stringshare_add(key));
166
eina_iterator_free(i);
168
_edje_cache_file_unref(edf);
175
edje_file_collection_list(const char *file)
178
Eina_List *lst = NULL;
181
if ((!file) || (!*file)) return NULL;
182
tmp = eina_vpath_resolve(file);
183
f = eina_file_open(tmp, EINA_FALSE);
186
lst = edje_mmap_collection_list(f);
188
eina_file_close(f); // close matching open OK
195
edje_file_collection_list_free(Eina_List *lst)
199
if (eina_list_data_get(lst)) eina_stringshare_del(eina_list_data_get(lst));
200
lst = eina_list_remove(lst, eina_list_data_get(lst));
205
edje_mmap_collection_list_free(Eina_List *lst)
207
edje_file_collection_list_free(lst);
211
edje_mmap_color_class_used_list(Eina_File *f)
213
Eina_List *lst = NULL, *l;
219
edf = _edje_cache_file_coll_open(f, NULL, &error_ret, NULL, NULL);
222
Edje_Color_Class_Info *cc_info;
224
cc_info = eet_data_read(edf->ef, _edje_edd_edje_color_class_info,
225
"edje/color_class_info");
228
EINA_LIST_FOREACH(cc_info->colors, l, s)
229
lst = eina_list_append(lst, eina_stringshare_add(s));
230
eina_list_free(cc_info->colors);
233
_edje_cache_file_unref(edf);
240
edje_file_color_class_used_list(const char *file)
243
Eina_List *lst = NULL;
246
if ((!file) || (!*file)) return NULL;
247
tmp = eina_vpath_resolve(file);
248
f = eina_file_open(tmp, EINA_FALSE);
251
lst = edje_mmap_collection_list(f);
253
eina_file_close(f); // close matching open OK
260
edje_file_color_class_used_free(Eina_List *lst)
267
edje_mmap_group_exists(Eina_File *f, const char *glob)
271
Eina_Bool succeed = EINA_FALSE;
272
Eina_Bool is_glob = EINA_FALSE;
278
edf = _edje_cache_file_coll_open(f, NULL, &error_ret, NULL, NULL);
279
if (!edf) return EINA_FALSE;
281
for (p = glob; *p; p++)
283
if ((*p == '*') || (*p == '?') || (*p == '['))
292
if (!edf->collection_patterns)
294
Edje_Part_Collection_Directory_Entry *ce;
298
i = eina_hash_iterator_data_new(edf->collection);
300
EINA_ITERATOR_FOREACH(i, ce)
301
l = eina_list_append(l, ce);
303
eina_iterator_free(i);
305
edf->collection_patterns = edje_match_collection_dir_init(l);
309
succeed = edje_match_collection_dir_exec(edf->collection_patterns, glob);
310
if (edf->collection_patterns)
312
edje_match_patterns_free(edf->collection_patterns);
313
edf->collection_patterns = NULL;
318
if (eina_hash_find(edf->collection, glob)) succeed = EINA_TRUE;
320
_edje_cache_file_unref(edf);
322
DBG("edje_file_group_exists: '%s', '%s': %i.", eina_file_filename_get(f), glob, succeed);
328
edje_mmap_3d_has(Eina_File *f EINA_UNUSED, const char *group EINA_UNUSED)
333
typedef struct _Edje_File_Iterator Edje_File_Iterator;
334
struct _Edje_File_Iterator
336
Eina_Iterator iterator;
342
_edje_file_iterator_next(Eina_Iterator *it, void **data)
344
Edje_File_Iterator *et = (void *)it;
345
Edje_File *edf = NULL;
347
if (!eina_iterator_next(et->it, (void **)&edf))
355
_edje_file_iterator_container(Eina_Iterator *it EINA_UNUSED)
361
_edje_file_iterator_free(Eina_Iterator *it)
363
Edje_File_Iterator *et = (void *)it;
365
EINA_MAGIC_SET(&et->iterator, 0);
366
eina_iterator_free(et->it);
371
edje_file_iterator_new(void)
373
Edje_File_Iterator *it;
375
it = calloc(1, sizeof (Edje_File_Iterator));
376
if (!it) return NULL;
378
EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
379
it->it = eina_hash_iterator_data_new(_edje_file_hash);
381
it->iterator.version = EINA_ITERATOR_VERSION;
382
it->iterator.next = _edje_file_iterator_next;
383
it->iterator.get_container = _edje_file_iterator_container;
384
it->iterator.free = _edje_file_iterator_free;
386
return &it->iterator;
390
edje_file_group_exists(const char *file, const char *glob)
393
Eina_Bool result = EINA_FALSE;
396
if ((!file) || (!*file) || (!glob))
399
tmp = eina_vpath_resolve(file);
400
f = eina_file_open(tmp, EINA_FALSE);
403
result = edje_mmap_group_exists(f, glob);
405
eina_file_close(f); // close matching open OK
413
edje_mmap_data_get(const Eina_File *f, const char *key)
419
if (!key) return NULL;
421
edf = _edje_cache_file_coll_open(f, NULL, &error_ret, NULL, NULL);
424
str = (char *)edje_string_get(eina_hash_find(edf->data, key));
426
if (str) str = strdup(str);
428
_edje_cache_file_unref(edf);
434
edje_file_data_get(const char *file, const char *key)
437
char *str = NULL, *tmp;
439
if (!key) return NULL;
441
tmp = eina_vpath_resolve(file);
442
f = eina_file_open(tmp, EINA_FALSE);
445
ERR("File [%s] can not be opened.", file);
448
str = edje_mmap_data_get(f, key);
449
eina_file_close(f); // close matching open OK
457
_edje_programs_patterns_clean(Edje_Part_Collection *edc)
459
_edje_signals_sources_patterns_clean(&edc->patterns.programs);
461
eina_rbtree_delete(edc->patterns.programs.exact_match,
462
EINA_RBTREE_FREE_CB(edje_match_signal_source_free),
464
edc->patterns.programs.exact_match = NULL;
466
free(edc->patterns.programs.u.programs.globing);
467
edc->patterns.programs.u.programs.globing = NULL;
471
_evas_object_viewport_del(void *data, Evas *_evas EINA_UNUSED, Evas_Object *eo EINA_UNUSED, void *event_info EINA_UNUSED)
473
Eo* viewport = (Eo*) data;
474
evas_object_del(viewport);
479
_edje_physics_world_update_cb(void *data, EPhysics_World *world EINA_UNUSED, void *event_info EINA_UNUSED)
482
if (EPH_LOAD()) _edje_recalc_do(edje);
487
_edje_part_allowed_seat_find(Edje_Real_Part *rp, const char *seat_name)
492
for (i = 0; i < rp->part->allowed_seats_count; i++)
494
name = rp->part->allowed_seats[i]->name;
495
if (!strcmp(seat_name, name))
502
/* It goes throught the list of registered seats and
503
* set event filters for each of these seats. */
505
_edje_part_seat_filter_apply(Edje *ed, Edje_Real_Part *rp)
511
EINA_LIST_FOREACH(ed->seats, l, seat)
513
found = _edje_part_allowed_seat_find(rp, seat->name);
514
efl_input_seat_event_filter_set(rp->object, seat->device, found);
518
/* It goes throught the list of all edje parts and
519
* set event filters for each of these parts. Should be called when
520
* a new seat is added.
523
_edje_seat_event_filter_apply(Edje *ed, Edje_Seat *seat)
529
for (i = 0; i < ed->table_parts_size; i++)
531
rp = ed->table_parts[i];
532
if (!rp->part->allowed_seats)
535
found = _edje_part_allowed_seat_find(rp, seat->name);
536
efl_input_seat_event_filter_set(rp->object, seat->device, found);
541
_edje_device_add(Edje *ed, Efl_Input_Device *dev)
543
Edje_Seat *s, *seat = NULL;
544
Eina_Stringshare *name;
548
if (ed->collection && ed->collection->use_custom_seat_names)
549
name = eina_stringshare_add(efl_name_get(dev));
553
name = eina_stringshare_printf("seat%i", ed->seats_count);
555
EINA_SAFETY_ON_NULL_RETURN(name);
557
EINA_LIST_FOREACH(ed->seats, l, s)
567
seat = calloc(1, sizeof(Edje_Seat));
568
EINA_SAFETY_ON_NULL_GOTO(seat, seat_err);
569
ed->seats = eina_list_append(ed->seats, seat);
570
seat->name = eina_stringshare_ref(name);
574
snprintf(sig, sizeof(sig), "seat,added,%s,%s", seat->name,
576
_edje_emit(ed, sig, "");
577
_edje_seat_event_filter_apply(ed, seat);
580
eina_stringshare_del(name);
584
_edje_device_added_cb(void *data, const Efl_Event *event)
586
Efl_Input_Device *dev = event->info;
589
if (efl_input_device_type_get(dev) != EFL_INPUT_DEVICE_TYPE_SEAT)
592
_edje_device_add(ed, dev);
596
_edje_device_removed_cb(void *data, const Efl_Event *event)
598
Efl_Input_Device *dev = event->info;
599
Edje_Seat *s, *seat = NULL;
604
if (efl_input_device_type_get(dev) != EFL_INPUT_DEVICE_TYPE_SEAT)
607
EINA_LIST_FOREACH(ed->seats, l, s)
609
if (s->device != dev)
615
/* It shouldn't happen. New seats are always registered. */
616
EINA_SAFETY_ON_NULL_RETURN(seat);
619
snprintf(sig, sizeof(sig), "seat,removed,%s", seat->name);
620
_edje_emit(ed, sig, "");
624
_edje_device_changed_cb(void *data, const Efl_Event *event)
626
Efl_Input_Device *dev = event->info;
627
Edje_Seat *s, *seat = NULL;
628
Eina_Stringshare *name;
633
if (efl_input_device_type_get(dev) != EFL_INPUT_DEVICE_TYPE_SEAT)
636
EINA_LIST_FOREACH(ed->seats, l, s)
638
if (s->device != dev)
644
/* not registered seat */
648
name = efl_name_get(dev);
652
/* no name changes */
653
if (eina_streq(seat->name, name))
656
/* check if device name was changed to match name used on EDC */
657
EINA_LIST_FOREACH(ed->seats, l, s)
659
if (eina_streq(s->name, name))
661
if (s->device == dev)
665
WRN("Two seats were detected with the same name: %s.\n"
666
"Fix it or focus will misbehave", name);
672
if (seat->focused_part)
673
s->focused_part = seat->focused_part;
675
ed->seats = eina_list_remove(ed->seats, seat);
676
eina_stringshare_del(seat->name);
679
_edje_seat_event_filter_apply(ed, s);
685
snprintf(sig, sizeof(sig), "seat,renamed,%s,%s", seat->name, name);
686
eina_stringshare_replace(&seat->name, name);
687
_edje_emit(ed, sig, "");
688
_edje_seat_event_filter_apply(ed, seat);
691
static void _edje_device_canvas_del(void *data, const Efl_Event *event);
693
EFL_CALLBACKS_ARRAY_DEFINE(edje_device_callbacks,
694
{ EFL_CANVAS_SCENE_EVENT_DEVICE_ADDED, _edje_device_added_cb },
695
{ EFL_CANVAS_SCENE_EVENT_DEVICE_REMOVED, _edje_device_removed_cb },
696
{ EFL_EVENT_DEL, _edje_device_canvas_del });
698
EFL_CALLBACKS_ARRAY_DEFINE(edje_device_custom_callbacks,
699
{ EFL_CANVAS_SCENE_EVENT_DEVICE_CHANGED, _edje_device_changed_cb },
700
{ EFL_CANVAS_SCENE_EVENT_DEVICE_ADDED, _edje_device_added_cb },
701
{ EFL_CANVAS_SCENE_EVENT_DEVICE_REMOVED, _edje_device_removed_cb },
702
{ EFL_EVENT_DEL, _edje_device_canvas_del });
705
_edje_device_canvas_del(void *data, const Efl_Event *event)
709
if (ed->collection && ed->collection->use_custom_seat_names)
710
efl_event_callback_array_del(event->object, edje_device_custom_callbacks(), ed);
712
efl_event_callback_array_del(event->object, edje_device_callbacks(), ed);
716
_edje_devices_add(Edje *ed, Evas *tev)
718
const Eina_List *devices, *l;
719
Efl_Input_Device *dev;
721
ed->need_seat = EINA_TRUE;
723
devices = evas_device_list(tev, NULL);
724
EINA_LIST_FOREACH(devices, l, dev)
726
if (efl_input_device_type_get(dev) == EFL_INPUT_DEVICE_TYPE_SEAT)
727
_edje_device_add(ed, dev);
730
if (ed->collection && ed->collection->use_custom_seat_names)
731
efl_event_callback_array_add(tev, edje_device_custom_callbacks(), ed);
733
efl_event_callback_array_add(tev, edje_device_callbacks(), ed);
737
_edje_process_colorclass(Edje *ed)
741
for (i = 0; i < ed->collection->parts_count; ++i)
746
ep = ed->collection->parts[i];
748
/* Register any color classes in this parts descriptions. */
749
if ((ep->default_desc) && (ep->default_desc->color_class))
750
efl_observable_observer_add(_edje_color_class_member, ep->default_desc->color_class, ed->obj);
752
for (k = 0; k < ep->other.desc_count; k++)
754
Edje_Part_Description_Common *desc;
756
desc = ep->other.desc[k];
758
if (desc->color_class)
759
efl_observable_observer_add(_edje_color_class_member, desc->color_class, ed->obj);
765
_edje_process_sizeclass(Edje *ed)
769
for (i = 0; i < ed->collection->parts_count; ++i)
774
ep = ed->collection->parts[i];
776
/* Register any size classes in this parts descriptions. */
777
if ((ep->default_desc) && (ep->default_desc->size_class))
778
efl_observable_observer_add(_edje_size_class_member, ep->default_desc->size_class, ed->obj);
780
for (k = 0; k < ep->other.desc_count; k++)
782
Edje_Part_Description_Common *desc;
784
desc = ep->other.desc[k];
786
if (desc->size_class)
787
efl_observable_observer_add(_edje_size_class_member, desc->size_class, ed->obj);
794
_edje_process_physics(Edje *ed)
798
EPH_CALL(ephysics_init)();
799
ed->world = EPH_CALL(ephysics_world_new)();
800
EPH_CALL(ephysics_world_event_callback_add)
801
(ed->world, EPHYSICS_CALLBACK_WORLD_UPDATE,
802
_edje_physics_world_update_cb, ed);
803
EPH_CALL(ephysics_world_rate_set)
804
(ed->world, ed->collection->physics.world.rate);
805
EPH_CALL(ephysics_world_gravity_set)
806
(ed->world, ed->collection->physics.world.gravity.x,
807
ed->collection->physics.world.gravity.y,
808
ed->collection->physics.world.gravity.z);
814
_edje_object_file_set_internal(Evas_Object *obj, const Eina_File *file, const char *group, const char *parent, Eina_List *group_path, Eina_Array *nested)
819
Eina_List *textblocks = NULL;
820
Eina_List *sources = NULL;
821
Eina_List *externals = NULL;
822
Eina_Hash *collect = NULL;
825
int group_path_started = 0;
826
Evas_Object *nested_smart = NULL;
829
Eina_Hash *part_match = NULL;
831
/* Get data pointer of top-of-stack */
832
int idx = eina_array_count(nested) - 1;
833
Edje_Nested_Support *st_nested = (idx >= 0) ? eina_array_data_get(nested, idx) : NULL;
835
ed = _edje_fetch(obj);
836
if (!ed) return EFL_GFX_IMAGE_LOAD_ERROR_GENERIC;
837
if (!group) group = "";
838
if ((ed->file) && (ed->file->f == file) &&
839
(ed->group) && (!strcmp(group, ed->group)))
843
had_file = !!ed->file;
845
tev = evas_object_evas_get(obj);
846
evas_event_freeze(tev);
848
collect = _edje_object_collect(ed);
850
part_match = eina_hash_string_superfast_new(NULL);
852
if (_edje_lua_script_only(ed)) _edje_lua_script_only_shutdown(ed);
855
/* clear physics world / shutdown ephysics */
856
if ((ed->collection) && (ed->collection->physics_enabled) && (ed->world))
860
EPH_CALL(ephysics_world_del)(ed->world);
861
EPH_CALL(ephysics_shutdown)();
868
eina_stringshare_replace(&ed->path, file ? eina_file_filename_get(file) : NULL);
869
eina_stringshare_replace(&ed->group, group);
871
ed->parent = eina_stringshare_add(parent);
873
ed->load_error = EDJE_LOAD_ERROR_NONE;
874
_edje_file_add(ed, file);
875
ed->block_break = EINA_FALSE;
878
ed->has_entries = EINA_FALSE;
882
if (ed->collection->parts_count > 0xffff)
884
ed->load_error = EDJE_LOAD_ERROR_CORRUPT_FILE;
886
return EFL_GFX_IMAGE_LOAD_ERROR_CORRUPT_FILE;
888
eina_array_step_set(&parts, sizeof (Eina_Array), 8);
890
if (ed->collection->prop.orientation != EDJE_ORIENTATION_AUTO)
891
ed->is_rtl = (ed->collection->prop.orientation ==
892
EDJE_ORIENTATION_RTL);
894
ed->groups = eina_list_append(ed->groups, ed);
896
if (ed->collection->lua_script_only)
898
ed->load_error = EDJE_LOAD_ERROR_NONE;
899
_edje_lua_script_only_init(ed);
905
if (ed->collection->physics_enabled)
908
_edje_process_physics(ed);
910
ERR("Edje compiled without support to physics.");
914
/* handle multiseat stuff */
915
if (ed->collection->need_seat || ed->need_seat)
916
_edje_devices_add(ed, tev);
918
/* colorclass stuff */
919
_edje_process_colorclass(ed);
921
/* sizeclass stuff */
922
_edje_process_sizeclass(ed);
924
/* build real parts */
925
for (n = 0; n < ed->collection->parts_count; n++)
928
Eina_Bool memerr = EINA_FALSE;
930
ep = ed->collection->parts[n];
932
eina_hash_add(part_match, ep->name, (void*)1);
934
if (ep->nested_children_count) /* Add object to nested parts list */
936
st_nested = malloc(sizeof(*st_nested));
937
nested_smart = st_nested->o = edje_smart_nested_add(tev);
939
/* We add 1 to children_count because the parent
940
object is added to smart obj children as well */
941
st_nested->nested_children_count =
942
ep->nested_children_count + 1;
944
evas_object_show(st_nested->o);
946
eina_array_push(nested, st_nested);
949
rp = eina_mempool_malloc(_edje_real_part_mp, sizeof(Edje_Real_Part));
952
/* FIXME: destroy all allocated ressource, need to have a common exit point */
953
ed->load_error = EDJE_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED;
957
memset(rp, 0, sizeof (Edje_Real_Part));
959
if ((ep->dragable.x != 0) || (ep->dragable.y != 0))
961
rp->drag = calloc(1, sizeof (Edje_Real_Part_Drag));
964
ed->load_error = EDJE_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED;
968
rp->drag->step.x = FROM_INT(ep->dragable.step_x);
969
rp->drag->step.y = FROM_INT(ep->dragable.step_y);
971
// allow part type specific data - this keeps real_part smaller
974
case EDJE_PART_TYPE_TEXT:
975
case EDJE_PART_TYPE_TEXTBLOCK:
976
rp->type = EDJE_RP_TYPE_TEXT;
977
rp->typedata.text = calloc(1, sizeof(Edje_Real_Part_Text));
978
if (!rp->typedata.text) memerr = EINA_TRUE;
981
case EDJE_PART_TYPE_GROUP:
982
case EDJE_PART_TYPE_SWALLOW:
983
case EDJE_PART_TYPE_EXTERNAL:
984
rp->type = EDJE_RP_TYPE_SWALLOW;
985
rp->typedata.swallow = calloc(1, sizeof(Edje_Real_Part_Swallow));
986
if (!rp->typedata.swallow) memerr = EINA_TRUE;
989
case EDJE_PART_TYPE_BOX:
990
case EDJE_PART_TYPE_TABLE:
991
rp->type = EDJE_RP_TYPE_CONTAINER;
992
rp->typedata.container = calloc(1, sizeof(Edje_Real_Part_Container));
993
if (!rp->typedata.container) memerr = EINA_TRUE;
996
case EDJE_PART_TYPE_VECTOR:
997
rp->type = EDJE_RP_TYPE_VECTOR;
998
rp->typedata.vector = calloc(1, sizeof(Edje_Real_Part_Vector));
999
if (!rp->typedata.vector)
1002
rp->typedata.vector->current_id = -1;
1011
if (rp->drag) free(rp->drag);
1012
ed->load_error = EDJE_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED;
1013
eina_mempool_free(_edje_real_part_mp, rp);
1014
evas_event_thaw(tev);
1015
evas_event_thaw_eval(tev);
1016
return EFL_GFX_IMAGE_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED;
1021
eina_array_push(&parts, rp);
1022
rp->param1.description =
1023
_edje_part_description_find(ed, rp, "default", 0.0, EINA_TRUE);
1024
rp->chosen_description = rp->param1.description;
1025
if (!rp->param1.description)
1026
ERR("no default part description for '%s'!",
1031
case EDJE_PART_TYPE_RECTANGLE:
1032
rp->object = evas_object_rectangle_add(ed->base.evas);
1035
case EDJE_PART_TYPE_VECTOR:
1036
rp->object = evas_object_vg_add(ed->base.evas);
1039
case EDJE_PART_TYPE_PROXY:
1040
case EDJE_PART_TYPE_IMAGE:
1041
rp->object = evas_object_image_add(ed->base.evas);
1044
case EDJE_PART_TYPE_SNAPSHOT:
1045
rp->object = evas_object_image_filled_add(ed->base.evas);
1046
evas_object_image_snapshot_set(rp->object, EINA_TRUE);
1049
case EDJE_PART_TYPE_TEXT:
1050
_edje_text_part_on_add(ed, rp);
1051
rp->object = evas_object_text_add(ed->base.evas);
1052
evas_object_text_font_source_set(rp->object, ed->path);
1055
case EDJE_PART_TYPE_GROUP:
1056
sources = eina_list_append(sources, rp);
1059
// fallthrough intentional
1060
case EDJE_PART_TYPE_SWALLOW:
1062
case EDJE_PART_TYPE_EXTERNAL:
1063
if (ep->type == EDJE_PART_TYPE_EXTERNAL)
1064
externals = eina_list_append(externals, rp);
1065
rp->object = evas_object_rectangle_add(ed->base.evas);
1066
evas_object_color_set(rp->object, 0, 0, 0, 0);
1067
evas_object_pass_events_set(rp->object, 1);
1068
evas_object_pointer_mode_set(rp->object, EVAS_OBJECT_POINTER_MODE_NOGRAB);
1069
_edje_callbacks_focus_add(rp->object, ed, rp);
1072
case EDJE_PART_TYPE_TEXTBLOCK:
1073
_edje_textblock_styles_add(ed, rp);
1074
textblocks = eina_list_append(textblocks, rp);
1075
rp->object = evas_object_textblock_add(ed->base.evas);
1078
case EDJE_PART_TYPE_BOX:
1079
sources = eina_list_append(sources, rp);
1080
rp->object = evas_object_box_add(ed->base.evas);
1081
rp->typedata.container->anim = _edje_box_layout_anim_new(rp->object);
1084
case EDJE_PART_TYPE_TABLE:
1085
sources = eina_list_append(sources, rp);
1086
rp->object = evas_object_table_add(ed->base.evas);
1089
case EDJE_PART_TYPE_GRADIENT:
1090
ERR("YOU ARE USING GRADIENT IN PART %s FROM GROUP %s INSIDE FILE %s !! THEY ARE NOW REMOVED !",
1091
ep->name, group, eina_file_filename_get(file));
1094
case EDJE_PART_TYPE_SPACER:
1099
ERR("wrong part type %i!", ep->type);
1105
if (nested_smart) /* Update this pointer to father object only
1106
this will make smart object size == father sz */
1108
rp->nested_smart = nested_smart;
1109
nested_smart = NULL;
1112
if (ep->allowed_seats)
1113
_edje_part_seat_filter_apply(ed, rp);
1116
efl_canvas_object_no_render_set(rp->object, 1);
1118
if (st_nested && st_nested->nested_children_count) /* Add this to list of children */
1120
evas_object_smart_member_add(rp->object,
1123
st_nested->nested_children_count--;
1125
/* No more nested children for this obj */
1126
while (st_nested && (st_nested->nested_children_count == 0))
1128
/* Loop to add smart counter as child */
1129
Evas_Object *p_obj = st_nested->o;
1131
st_nested = eina_array_pop(nested);
1134
/* Check for parent in stack */
1135
idx = eina_array_count(nested) - 1;
1136
st_nested = (idx >= 0) ? eina_array_data_get(nested, idx) : NULL;
1140
st_nested->nested_children_count--;
1141
evas_object_smart_member_add(p_obj, st_nested->o);
1145
evas_object_smart_member_add(p_obj, ed->obj);
1150
evas_object_smart_member_add(rp->object, ed->obj);
1152
// evas_object_layer_set(rp->object, evas_object_layer_get(ed->obj));
1153
rp->mouse_events = ep->mouse_events;
1154
rp->repeat_events = ep->repeat_events;
1156
if (ep->type != EDJE_PART_TYPE_SWALLOW && ep->type != EDJE_PART_TYPE_GROUP && ep->type != EDJE_PART_TYPE_EXTERNAL)
1158
if (rp->mouse_events)
1160
_edje_callbacks_add(rp->object, ed, rp);
1161
if (rp->repeat_events)
1162
evas_object_repeat_events_set(rp->object, rp->repeat_events);
1164
if (ep->pointer_mode != EVAS_OBJECT_POINTER_MODE_AUTOGRAB)
1165
evas_object_pointer_mode_set(rp->object, ep->pointer_mode);
1169
evas_object_pass_events_set(rp->object, 1);
1170
evas_object_pointer_mode_set(rp->object, EVAS_OBJECT_POINTER_MODE_NOGRAB);
1172
efl_canvas_object_anti_alias_set(rp->object, ep->anti_alias);
1173
efl_canvas_object_precise_is_inside_set(rp->object, ep->precise_is_inside);
1175
if (rp->part->clip_to_id < 0)
1176
evas_object_clip_set(rp->object, ed->base.clipper);
1181
ed->table_parts = malloc(sizeof(Edje_Real_Part *) * n);
1182
ed->table_parts_size = n;
1183
/* FIXME: check malloc return */
1184
n = eina_array_count(&parts) - 1;
1185
while ((rp = eina_array_pop(&parts)))
1187
ed->table_parts[n] = rp;
1190
for (i = 0; i < ed->table_parts_size; i++)
1192
Edje_Real_Part *clip_to = NULL;
1194
rp = ed->table_parts[i];
1195
if (rp->param1.description) /* FIXME: prevent rel to gone radient part to go wrong. You may
1196
be able to remove this when all theme are correctly rewritten. */
1198
if (rp->param1.description->rel1.id_x >= 0)
1199
rp->param1.description->rel1.id_x %= ed->table_parts_size;
1200
if (rp->param1.description->rel1.id_y >= 0)
1201
rp->param1.description->rel1.id_y %= ed->table_parts_size;
1202
if (rp->param1.description->rel2.id_x >= 0)
1203
rp->param1.description->rel2.id_x %= ed->table_parts_size;
1204
if (rp->param1.description->rel2.id_y >= 0)
1205
rp->param1.description->rel2.id_y %= ed->table_parts_size;
1208
if (rp->param1.description && (rp->param1.description->clip_to_id >= 0))
1210
clip_to = ed->table_parts[rp->param1.description->clip_to_id % ed->table_parts_size];
1211
ed->has_state_clip = EINA_TRUE;
1213
else if (rp->part->clip_to_id >= 0)
1214
clip_to = ed->table_parts[rp->part->clip_to_id % ed->table_parts_size];
1215
if (clip_to && clip_to->object && rp->object)
1217
evas_object_pass_events_set(clip_to->object, 1);
1218
evas_object_pointer_mode_set(clip_to->object, EVAS_OBJECT_POINTER_MODE_NOGRAB);
1219
evas_object_clip_set(rp->object, clip_to->object);
1224
if (rp->part->dragable.confine_id >= 0)
1225
rp->drag->confine_to = ed->table_parts[rp->part->dragable.confine_id % ed->table_parts_size];
1226
if (rp->part->dragable.threshold_id >= 0)
1227
rp->drag->threshold = ed->table_parts[rp->part->dragable.threshold_id % ed->table_parts_size];
1230
if ((rp->type == EDJE_RP_TYPE_SWALLOW) &&
1231
(rp->typedata.swallow))
1233
rp->typedata.swallow->swallow_params.min.w = 0;
1234
rp->typedata.swallow->swallow_params.min.h = 0;
1235
rp->typedata.swallow->swallow_params.max.w = -1;
1236
rp->typedata.swallow->swallow_params.max.h = -1;
1239
if (rp->part->type == EDJE_PART_TYPE_TEXT
1240
|| rp->part->type == EDJE_PART_TYPE_TEXTBLOCK)
1242
Edje_Part_Description_Text *text;
1244
text = (Edje_Part_Description_Text *)rp->param1.description;
1247
if (ed->file->feature_ver < 1)
1249
text->text.id_source = -1;
1250
text->text.id_text_source = -1;
1253
if ((rp->type == EDJE_RP_TYPE_TEXT) &&
1254
(rp->typedata.text))
1256
if (text->text.id_source >= 0)
1258
rp->typedata.text->source =
1259
ed->table_parts[text->text.id_source % ed->table_parts_size];
1262
if (text->text.id_text_source >= 0)
1264
rp->typedata.text->text_source =
1265
ed->table_parts[text->text.id_text_source % ed->table_parts_size];
1270
if ((rp->part->type == EDJE_PART_TYPE_TEXTBLOCK) &&
1271
rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
1273
_edje_entry_real_part_init(ed, rp);
1274
if (!ed->has_entries)
1275
ed->has_entries = EINA_TRUE;
1283
_edje_util_freeze(ed);
1285
for (i = 0; i < ed->table_parts_size; i++)
1287
rp = ed->table_parts[i];
1288
/* SPACER parts do not have objects */
1289
if (rp->object) evas_object_show(rp->object);
1290
if (_edje_block_break(ed)) break;
1293
if (rp->part->dragable.x < 0) rp->drag->val.x = FROM_DOUBLE(1.0);
1294
if (rp->part->dragable.y < 0) rp->drag->val.x = FROM_DOUBLE(1.0);
1295
_edje_dragable_pos_set(ed, rp, rp->drag->val.x, rp->drag->val.y);
1298
ed->recalc_call = EINA_TRUE;
1299
ed->dirty = EINA_TRUE;
1300
#ifdef EDJE_CALC_CACHE
1301
ed->all_part_change = EINA_TRUE;
1303
if ((evas_object_clipees_has(ed->base.clipper)) &&
1304
(evas_object_visible_get(obj)))
1305
evas_object_show(ed->base.clipper);
1307
/* instantiate 'internal swallows' */
1308
EINA_LIST_FREE(externals, rp)
1310
Edje_Part_Description_External *external;
1311
Evas_Object *child_obj;
1313
external = (Edje_Part_Description_External *)rp->part->default_desc;
1314
child_obj = _edje_external_type_add(rp->part->source,
1315
evas_object_evas_get(ed->obj), ed->obj,
1316
external->external_params, rp->part->name);
1319
_edje_real_part_swallow(ed, rp, child_obj, EINA_TRUE);
1320
rp->param1.external_params = _edje_external_params_parse(child_obj,
1321
external->external_params);
1322
_edje_external_recalc_apply(ed, rp, NULL, rp->chosen_description);
1326
EINA_LIST_FREE(sources, rp)
1328
/* XXX: curr_item and pack_it don't require to be NULL since
1329
* XXX: they are just used when source != NULL and type == BOX,
1330
* XXX: and they're always set in this case, but GCC fails to
1331
* XXX: notice that, so let's shut it up
1333
Edje_Pack_Element **curr_item = NULL;
1334
unsigned int item_count = 0;
1335
Edje_Pack_Element *pack_it = NULL;
1336
const char *source = NULL;
1338
switch (rp->part->type)
1340
case EDJE_PART_TYPE_GROUP:
1341
source = rp->part->source;
1344
case EDJE_PART_TYPE_BOX:
1345
case EDJE_PART_TYPE_TABLE:
1346
if (rp->part->items)
1348
curr_item = rp->part->items;
1349
item_count = rp->part->items_count;
1352
pack_it = *curr_item;
1353
source = pack_it->source;
1361
/* This list should only be filled by group, box or table, nothing else. */
1368
Evas_Object *child_obj;
1369
Edje_Pack_Element pack_it_copy;
1370
const char *group_path_entry = eina_stringshare_add(source);
1375
group_path = eina_list_append(NULL, eina_stringshare_add(group));
1376
group_path_started = 1;
1378
/* make sure that this group isn't already in the tree of parents */
1379
EINA_LIST_FOREACH(group_path, l, data)
1381
if (data == group_path_entry)
1383
ERR("recursive loop group '%s' already included inside part '%s' of group '%s' from file '%s'",
1384
group_path_entry, rp->part->name, group, eina_file_filename_get(file));
1385
ed->load_error = EDJE_LOAD_ERROR_RECURSIVE_REFERENCE;
1386
eina_stringshare_del(group_path_entry);
1393
pack_it_copy = *pack_it;
1397
memset(&pack_it_copy, 0, sizeof (pack_it_copy));
1402
Eina_Error load_error;
1403
child_obj = edje_object_add(ed->base.evas);
1404
edje_object_mirrored_set(child_obj, edje_object_mirrored_get(ed->obj));
1406
group_path = eina_list_append(group_path, group_path_entry);
1407
if (rp->part->type == EDJE_PART_TYPE_GROUP)
1409
_edje_real_part_swallow(ed, rp, child_obj, EINA_FALSE);
1412
load_error = _edje_object_file_set_internal(child_obj, file, source, rp->part->name, group_path, nested);
1415
ERR("impossible to set part '%s' of group '%s' from file '%s' to '%s'",
1416
rp->part->name, group_path_entry, eina_file_filename_get(file), source);
1417
ed->load_error = edje_object_load_error_get(child_obj);
1418
evas_object_del(child_obj);
1419
eina_stringshare_del(group_path_entry);
1423
group_path = eina_list_remove(group_path, group_path_entry);
1425
edje_object_propagate_callback_add(child_obj,
1428
if (rp->part->type == EDJE_PART_TYPE_GROUP)
1430
Edje *edg = _edje_fetch(child_obj);
1431
ed->groups = eina_list_append(ed->groups, edg);
1432
evas_object_data_set(child_obj, "\377 edje.part_obj", rp);
1433
_edje_real_part_swallow(ed, rp, child_obj, EINA_FALSE);
1434
_edje_subobj_register(ed, child_obj);
1439
if ((rp->type == EDJE_RP_TYPE_CONTAINER) &&
1440
(rp->typedata.container))
1442
Eina_Strbuf *buf = NULL;
1443
const char *name = pack_it_copy.name;
1445
pack_it->parent = rp;
1447
_edje_object_pack_item_hints_set(child_obj, &pack_it_copy);
1449
if (pack_it->spread.h > 1 && pack_it->spread.w >= 1)
1451
buf = eina_strbuf_new();
1453
eina_strbuf_append_printf(buf, "%s{%i,%i}", name, pack_it_copy.col, pack_it_copy.row);
1455
eina_strbuf_append_printf(buf, "%i,%i", pack_it_copy.col, pack_it_copy.row);
1456
name = eina_strbuf_string_get(buf);
1458
if (name) evas_object_name_set(child_obj, name);
1459
if (buf) eina_strbuf_free(buf);
1461
if (rp->part->type == EDJE_PART_TYPE_BOX)
1463
_edje_real_part_box_append(ed, rp, child_obj);
1464
evas_object_data_set(child_obj, "\377 edje.box_item", pack_it);
1466
else if (rp->part->type == EDJE_PART_TYPE_TABLE)
1468
_edje_real_part_table_pack(ed, rp, child_obj,
1469
pack_it_copy.col, pack_it_copy.row,
1470
pack_it_copy.colspan, pack_it_copy.rowspan);
1471
evas_object_data_set(child_obj, "\377 edje.table_item", pack_it);
1473
_edje_subobj_register(ed, child_obj);
1474
evas_object_show(child_obj);
1475
rp->typedata.container->items = eina_list_append(rp->typedata.container->items, child_obj);
1479
pack_it_copy.spread.w--;
1481
if (pack_it_copy.spread.w < 1 && pack_it)
1483
pack_it_copy.col = pack_it->col;
1485
pack_it_copy.spread.h--;
1486
pack_it_copy.spread.w = pack_it->spread.w;
1489
while (pack_it_copy.spread.h > 0);
1491
eina_stringshare_del(group_path_entry);
1493
if ((rp->type == EDJE_RP_TYPE_CONTAINER) &&
1494
(rp->typedata.container))
1498
pack_it = *curr_item;
1499
source = pack_it->source;
1513
if (group_path_started)
1517
EINA_LIST_FREE(group_path, str)
1518
eina_stringshare_del(str);
1521
/* reswallow any swallows that existed before setting the file */
1524
Edje_User_Defined *eud;
1525
Eina_List *boxes = NULL;
1529
it = eina_hash_iterator_data_new(collect);
1530
EINA_ITERATOR_FOREACH(it, l)
1532
EINA_LIST_FOREACH(l, ll, eud)
1534
Evas_Object *child = NULL;
1536
if (!eina_hash_find(part_match, eud->part))
1538
/* part no longer exists */
1541
case EDJE_USER_SWALLOW:
1542
child = eud->u.swallow.child;
1544
case EDJE_USER_BOX_PACK:
1545
child = eud->u.box.child;
1547
case EDJE_USER_TABLE_PACK:
1548
child = eud->u.table.child;
1550
case EDJE_USER_STRING:
1551
eina_stringshare_del(eud->u.string.text);
1552
/* string has extra ref in this case */
1554
eina_stringshare_del(eud->u.string.text);
1556
case EDJE_USER_DRAG_STEP:
1557
case EDJE_USER_DRAG_PAGE:
1558
case EDJE_USER_DRAG_VALUE:
1559
case EDJE_USER_DRAG_SIZE:
1561
case EDJE_USER_TEXT_STYLE:
1563
Edje_Part_Text_Prop *prop;
1564
EINA_LIST_FREE(eud->u.text_style.props, prop)
1568
case EDJE_USER_TEXT_EXPAND:
1574
WRN("Container part '%s' no longer exists, hiding previously-contained child object", eud->part);
1575
evas_object_hide(child);
1582
case EDJE_USER_SWALLOW:
1583
edje_object_part_swallow(obj, eud->part, eud->u.swallow.child);
1584
child = eud->u.swallow.child;
1587
case EDJE_USER_BOX_PACK:
1588
boxes = eina_list_append(boxes, eud);
1592
case EDJE_USER_TABLE_PACK:
1593
edje_object_part_table_pack(obj, eud->part, eud->u.table.child,
1594
eud->u.table.col, eud->u.table.row,
1595
eud->u.table.colspan, eud->u.table.rowspan);
1596
child = eud->u.table.child;
1599
case EDJE_USER_DRAG_STEP:
1600
edje_object_part_drag_step_set(obj, eud->part,
1601
eud->u.drag_position.x,
1602
eud->u.drag_position.y);
1605
case EDJE_USER_DRAG_PAGE:
1606
edje_object_part_drag_page_set(obj, eud->part,
1607
eud->u.drag_position.x,
1608
eud->u.drag_position.y);
1611
case EDJE_USER_DRAG_VALUE:
1612
edje_object_part_drag_value_set(obj, eud->part,
1613
eud->u.drag_position.x,
1614
eud->u.drag_position.y);
1617
case EDJE_USER_DRAG_SIZE:
1618
edje_object_part_drag_size_set(obj, eud->part,
1620
eud->u.drag_size.h);
1623
case EDJE_USER_STRING:
1624
switch (eud->u.string.type)
1626
case EDJE_TEXT_TYPE_NORMAL:
1627
efl_text_set(efl_part(obj, eud->part), eud->u.string.text);
1629
case EDJE_TEXT_TYPE_MARKUP:
1630
efl_text_markup_set(efl_part(obj, eud->part), eud->u.string.text);
1632
case EDJE_TEXT_TYPE_ESCAPED:
1633
edje_object_part_text_escaped_set(obj, eud->part, eud->u.string.text);
1635
case EDJE_TEXT_TYPE_UNESCAPED:
1636
edje_object_part_text_unescaped_set(obj, eud->part, eud->u.string.text);
1639
eina_stringshare_del(eud->u.string.text);
1640
/* string has extra ref in this case */
1642
eina_stringshare_del(eud->u.string.text);
1645
case EDJE_USER_TEXT_STYLE:
1647
Edje_Part_Text_Prop *prop;
1648
EINA_LIST_FREE(eud->u.text_style.props, prop)
1650
_canvas_layout_user_text_apply(eud, obj,
1656
case EDJE_USER_TEXT_EXPAND:
1658
efl_canvas_layout_part_text_expand_set(
1659
efl_part(obj, eud->part),
1660
eud->u.text_expand.expand);
1667
eina_iterator_free(it);
1669
boxes = eina_list_sort(boxes, -1, _sort_defined_boxes);
1670
EINA_LIST_FREE(boxes, eud)
1671
edje_object_part_box_append(obj, eud->part, eud->u.box.child);
1672
eina_hash_free(part_match);
1673
eina_hash_free(collect);
1676
snprintf(lang, sizeof(lang), "edje,language,%s", _edje_language);
1678
snprintf(lang, sizeof(lang), "edje,language,%s", "none");
1679
edje_object_signal_emit(obj, lang, "edje");
1681
if (edje_object_mirrored_get(obj))
1682
edje_object_signal_emit(obj, "edje,state,rtl", "edje");
1684
edje_object_signal_emit(obj, "edje,state,ltr", "edje");
1687
_edje_util_thaw(ed);
1690
ed->load_error = EDJE_LOAD_ERROR_NONE;
1691
_edje_emit(ed, "load", NULL);
1693
/* instantiate 'internal textblock style' */
1694
EINA_LIST_FREE(textblocks, rp)
1695
if (rp->part->default_desc)
1697
Edje_Part_Description_Text *text;
1698
Evas_Textblock_Style *style = NULL;
1700
text = (Edje_Part_Description_Text *)rp->part->default_desc;
1701
style = _edje_textblock_style_get(ed, edje_string_get(&text->text.style));
1703
if (evas_object_textblock_style_get(rp->object) != style)
1704
evas_object_textblock_style_set(rp->object, style);
1707
_edje_entry_init(ed);
1708
eina_array_flush(&parts);
1709
evas_event_thaw(tev);
1710
evas_event_thaw_eval(tev);
1713
evas_event_thaw(tev);
1714
evas_event_thaw_eval(tev);
1715
return EFL_GFX_IMAGE_LOAD_ERROR_GENERIC;
1718
eina_list_free(textblocks);
1719
eina_list_free(externals);
1720
eina_list_free(sources);
1721
eina_array_flush(&parts);
1722
_edje_util_thaw(ed);
1726
if (group_path_started)
1730
EINA_LIST_FREE(group_path, path)
1731
eina_stringshare_del(path);
1733
evas_event_thaw(tev);
1734
evas_event_thaw_eval(tev);
1735
return EFL_GFX_IMAGE_LOAD_ERROR_GENERIC;
1739
_edje_file_add(Edje *ed, const Eina_File *f)
1741
if (!_edje_edd_edje_file) return;
1744
ed->load_error = EDJE_LOAD_ERROR_DOES_NOT_EXIST;
1750
ed->file = _edje_cache_file_coll_open(f, ed->group, &(err),
1751
&(ed->collection), ed);
1752
ed->load_error = (unsigned short)err;
1755
if (!ed->collection)
1759
_edje_cache_file_unref(ed->file);
1766
_sort_defined_boxes(const void *a, const void *b)
1768
const Edje_User_Defined *euda = a;
1769
const Edje_User_Defined *eudb = b;
1771
if (euda->part - eudb->part != 0)
1772
return euda->part - eudb->part;
1773
return euda->u.box.index - eudb->u.box.index;
1777
_edje_object_collect(Edje *ed)
1779
Edje_User_Defined *eud;
1784
collect = ed->user_defined;
1785
ed->user_defined = NULL;
1787
it = eina_hash_iterator_data_new(collect);
1788
EINA_ITERATOR_FOREACH(it, l)
1790
EINA_LIST_FOREACH(l, ll, eud)
1794
case EDJE_USER_STRING:
1795
eud->u.string.text = eina_stringshare_ref(eud->u.string.text);
1798
case EDJE_USER_BOX_PACK:
1799
if (eud->u.box.index == -1)
1801
Edje_User_Defined *search;
1803
Eina_List *children;
1808
rp = _edje_real_part_recursive_get(&ed, eud->part);
1811
if (rp->part->type != EDJE_PART_TYPE_BOX) continue;
1813
children = evas_object_box_children_get(rp->object);
1814
EINA_LIST_FREE(children, child)
1815
if (!evas_object_data_get(child, "\377 edje.box_item"))
1817
EINA_LIST_FOREACH(l, ls, search)
1819
if (search->type == EDJE_USER_BOX_PACK &&
1820
search->u.box.child == child &&
1821
search->part == eud->part /* beauty of stringshare ! */)
1823
search->u.box.index = idx++;
1827
_edje_real_part_box_remove(eud->ed, rp, child);
1833
case EDJE_USER_TABLE_PACK:
1837
rp = _edje_real_part_recursive_get(&ed, eud->part);
1840
if (rp->part->type != EDJE_PART_TYPE_TABLE) continue;
1841
_edje_real_part_table_unpack(eud->ed, rp, eud->u.table.child);
1846
case EDJE_USER_SWALLOW:
1847
edje_object_part_unswallow(NULL, eud->u.swallow.child);
1850
case EDJE_USER_TEXT_STYLE:
1851
_canvas_layout_user_text_collect(ed, eud);
1854
case EDJE_USER_DRAG_STEP:
1855
case EDJE_USER_DRAG_PAGE:
1856
case EDJE_USER_DRAG_VALUE:
1857
case EDJE_USER_DRAG_SIZE:
1858
case EDJE_USER_TEXT_EXPAND:
1863
eina_iterator_free(it);
1869
_edje_file_callbacks_del(Edje *ed, Evas *e)
1873
if (!tev) tev = evas_object_evas_get(ed->obj);
1874
if (ed->collection && ed->collection->use_custom_seat_names)
1875
efl_event_callback_array_del(tev, edje_device_custom_callbacks(), ed);
1877
efl_event_callback_array_del(tev, edje_device_callbacks(), ed);
1881
_edje_file_del(Edje *ed)
1885
if (ed->obj && (!efl_invalidated_get(ed->obj)))
1886
tev = evas_object_evas_get(ed->obj);
1888
ed->groups = eina_list_free(ed->groups);
1892
_edje_file_callbacks_del(ed, tev);
1893
evas_event_freeze(tev);
1896
if (ed->freeze_calc)
1898
_edje_util_freeze_calc_list = eina_list_remove(_edje_util_freeze_calc_list, ed);
1899
ed->freeze_calc = EINA_FALSE;
1900
_edje_util_freeze_calc_count--;
1902
_edje_entry_shutdown(ed);
1903
_edje_message_del(ed);
1904
_edje_block_violate(ed);
1905
_edje_var_shutdown(ed);
1906
if (!((ed->file) && (ed->collection)))
1910
evas_event_thaw(tev);
1911
evas_event_thaw_eval(tev);
1916
eina_hash_free(ed->user_defined);
1917
ed->user_defined = NULL;
1919
if (ed->table_parts)
1922
for (i = 0; i < ed->table_parts_size; i++)
1926
Evas_Object *face_obj;
1929
rp = ed->table_parts[i];
1933
EINA_LIST_FREE(rp->body_faces, face_obj)
1934
evas_object_del(face_obj);
1937
if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
1938
_edje_entry_real_part_shutdown(ed, rp);
1943
_edje_collection_free_part_description_clean(rp->part->type,
1944
rp->custom->description,
1945
ed->file->free_strings);
1946
free(rp->custom->description);
1947
rp->custom->description = NULL;
1950
if ((rp->type == EDJE_RP_TYPE_CONTAINER) &&
1951
(rp->typedata.container))
1953
if (rp->typedata.container->items)
1955
/* evas_box/table handles deletion of objects */
1956
rp->typedata.container->items = eina_list_free(rp->typedata.container->items);
1958
if (rp->typedata.container->anim)
1960
_edje_box_layout_free_data(rp->typedata.container->anim);
1961
rp->typedata.container->anim = NULL;
1963
free(rp->typedata.container);
1964
rp->typedata.container = NULL;
1966
else if ((rp->type == EDJE_RP_TYPE_TEXT) &&
1967
(rp->typedata.text))
1969
eina_stringshare_del(rp->typedata.text->text);
1970
eina_stringshare_del(rp->typedata.text->font);
1971
eina_stringshare_del(rp->typedata.text->cache.in_str);
1972
eina_stringshare_del(rp->typedata.text->cache.out_str);
1973
free(rp->typedata.text);
1974
rp->typedata.text = NULL;
1976
else if ((rp->type == EDJE_RP_TYPE_SWALLOW) &&
1977
(rp->typedata.swallow))
1979
if (rp->typedata.swallow->swallowed_object)
1981
/* Objects swallowed by the app do not get deleted,
1982
but those internally swallowed (GROUP type) do. */
1983
switch (rp->part->type)
1985
case EDJE_PART_TYPE_EXTERNAL:
1986
_edje_external_parsed_params_free(rp->typedata.swallow->swallowed_object, rp->param1.external_params);
1988
_edje_external_parsed_params_free(rp->typedata.swallow->swallowed_object, rp->param2->external_params);
1991
// fallthrough intentional
1992
case EDJE_PART_TYPE_GROUP:
1993
evas_object_del(rp->typedata.swallow->swallowed_object);
1994
rp->typedata.swallow->swallowed_object = NULL;
1998
_edje_real_part_swallow_clear(ed, rp);
2000
free(rp->typedata.swallow);
2001
rp->typedata.swallow = NULL;
2003
else if ((rp->type == EDJE_RP_TYPE_VECTOR) &&
2004
(rp->typedata.vector))
2006
if (rp->typedata.vector->anim)
2008
efl_canvas_object_animation_stop(rp->object);
2009
efl_del(rp->typedata.vector->anim);
2011
if (rp->typedata.vector->lottie_virtual_file)
2012
eina_file_close(rp->typedata.vector->lottie_virtual_file);
2013
if (rp->typedata.vector->lottie_data)
2014
free(rp->typedata.vector->lottie_data);
2016
free(rp->typedata.vector);
2017
rp->typedata.vector = NULL;
2022
_edje_callbacks_focus_del(rp->object, ed);
2023
_edje_callbacks_del(rp->object, ed);
2024
evas_object_del(rp->object);
2028
/* Cleanup optional part. */
2031
free(rp->param1.set);
2032
rp->param1.set = NULL;
2036
free(rp->param2->set);
2037
rp->param2->set = NULL;
2038
#ifdef EDJE_CALC_CACHE
2039
_edje_calc_params_clear(&(rp->param2->p));
2042
eina_mempool_free(_edje_real_part_state_mp, rp->param2);
2046
free(rp->custom->set);
2047
rp->custom->set = NULL;
2048
#ifdef EDJE_CALC_CACHE
2049
_edje_calc_params_clear(&(rp->custom->p));
2052
eina_mempool_free(_edje_real_part_state_mp, rp->custom);
2056
#ifdef EDJE_CALC_CACHE
2057
_edje_calc_params_clear(rp->current);
2063
#ifdef EDJE_CALC_CACHE
2064
_edje_calc_params_clear(&(rp->param1.p));
2066
eina_mempool_free(_edje_real_part_mp, rp);
2067
ed->table_parts[i] = NULL;
2070
if ((ed->file) && (ed->collection))
2075
for (i = 0; i < ed->collection->parts_count; ++i)
2077
ep = ed->collection->parts[i];
2079
_edje_textblock_styles_del(ed, ep);
2080
_edje_text_part_on_del(ed, ep);
2081
_edje_color_class_on_del(ed, ep);
2083
_edje_object_textblock_styles_cache_cleanup(ed);
2085
_edje_cache_coll_unref(ed->file, ed->collection);
2086
ed->collection = NULL;
2090
_edje_cache_file_unref(ed->file);
2094
// Cleanup all animator
2097
Edje_Running_Program *runp;
2099
EINA_LIST_FREE(ed->actions, runp)
2102
efl_event_callback_del(ed->obj, EFL_CANVAS_OBJECT_EVENT_ANIMATOR_TICK, _edje_timer_cb, ed);
2103
ecore_animator_del(ed->animator);
2104
ed->animator = NULL;
2106
if (ed->pending_actions)
2108
Edje_Pending_Program *pp;
2110
EINA_LIST_FREE(ed->pending_actions, pp)
2112
ecore_timer_del(pp->timer);
2122
EINA_LIST_FREE(ed->seats, seat)
2124
eina_stringshare_del(seat->name);
2127
ed->seats_count = 0;
2130
if (ed->L) _edje_lua2_script_shutdown(ed);
2132
_edje_subobj_unregister(ed, ed->subobjs->data);
2133
if (ed->table_parts) free(ed->table_parts);
2134
ed->table_parts = NULL;
2135
ed->table_parts_size = 0;
2138
evas_event_thaw(tev);
2139
evas_event_thaw_eval(tev);
2144
_edje_file_free(Edje_File *edf)
2146
Edje_Color_Tree_Node *ectn;
2147
Edje_Color_Class *ecc;
2148
Edje_Text_Class *etc;
2149
Edje_Size_Class *esc;
2151
#define HASH_FREE(Hash) \
2152
if (Hash) eina_hash_free(Hash); \
2155
/* Clean cache before cleaning memory pool */
2156
if (edf->collection_cache) _edje_cache_coll_flush(edf);
2158
HASH_FREE(edf->fonts);
2159
HASH_FREE(edf->collection);
2160
HASH_FREE(edf->data);
2161
HASH_FREE(edf->image_id_hash);
2163
if (edf->requires_count)
2167
for (i = 0; i < edf->requires_count; i++)
2168
eina_stringshare_del(edf->requires[i]);
2169
free(edf->requires);
2176
if (edf->free_strings)
2178
for (i = 0; i < edf->image_dir->entries_count; ++i)
2179
eina_stringshare_del(edf->image_dir->entries[i].entry);
2181
for (i = 0; i < edf->image_dir->vectors_count; ++i)
2182
eina_stringshare_del(edf->image_dir->vectors[i].entry);
2185
/* Sets have been added after edje received eet dictionary support */
2186
for (i = 0; i < edf->image_dir->sets_count; ++i)
2188
Edje_Image_Directory_Set_Entry *se;
2190
EINA_LIST_FREE(edf->image_dir->sets[i].entries, se)
2194
free(edf->image_dir->entries);
2195
free(edf->image_dir->sets);
2196
free(edf->image_dir->vectors);
2197
free(edf->image_dir);
2203
if (edf->free_strings)
2205
for (i = 0; i < edf->sound_dir->samples_count; ++i)
2207
eina_stringshare_del(edf->sound_dir->samples[i].name);
2208
eina_stringshare_del(edf->sound_dir->samples[i].snd_src);
2211
for (i = 0; i < edf->sound_dir->tones_count; ++i)
2212
eina_stringshare_del(edf->sound_dir->tones[i].name);
2214
free(edf->sound_dir->samples);
2215
free(edf->sound_dir->tones);
2216
free(edf->sound_dir);
2219
if (edf->vibration_dir)
2223
if (edf->free_strings)
2225
for (i = 0; i < edf->vibration_dir->samples_count; ++i)
2227
eina_stringshare_del(edf->vibration_dir->samples[i].name);
2228
eina_stringshare_del(edf->vibration_dir->samples[i].src);
2231
free(edf->vibration_dir->samples);
2232
free(edf->vibration_dir);
2235
if (edf->filter_dir)
2239
if (edf->free_strings)
2241
for (i = 0; i < edf->filter_dir->filters_count; ++i)
2243
eina_stringshare_del(edf->filter_dir->filters[i].name);
2244
eina_stringshare_del(edf->filter_dir->filters[i].script);
2247
free(edf->filter_dir->filters);
2248
free(edf->filter_dir);
2254
if (edf->free_strings)
2256
for (i = 0; i < edf->mo_dir->mo_entries_count; ++i)
2258
eina_stringshare_del(edf->mo_dir->mo_entries[i].locale);
2259
eina_stringshare_del(edf->mo_dir->mo_entries[i].mo_src);
2262
free(edf->mo_dir->mo_entries);
2266
if (edf->external_dir)
2268
if (edf->external_dir->entries) free(edf->external_dir->entries);
2269
free(edf->external_dir);
2272
eina_hash_free(edf->color_tree_hash);
2273
EINA_LIST_FREE(edf->color_tree, ectn)
2275
if (edf->free_strings && ectn->name) eina_stringshare_del(ectn->name);
2276
eina_list_free(ectn->color_classes);
2280
eina_hash_free(edf->color_hash);
2281
EINA_LIST_FREE(edf->color_classes, ecc)
2283
if (edf->free_strings && ecc->name) eina_stringshare_del(ecc->name);
2284
if (edf->free_strings) eina_stringshare_del(ecc->desc);
2288
eina_hash_free(edf->text_hash);
2289
EINA_LIST_FREE(edf->text_classes, etc)
2291
if (edf->free_strings)
2293
if (etc->name) eina_stringshare_del(etc->name);
2294
if (etc->font) eina_stringshare_del(etc->font);
2299
eina_hash_free(edf->size_hash);
2300
EINA_LIST_FREE(edf->size_classes, esc)
2302
if (edf->free_strings && esc->name) eina_stringshare_del(esc->name);
2306
if (edf->collection_patterns) edje_match_patterns_free(edf->collection_patterns);
2307
if (edf->path) eina_stringshare_del(edf->path);
2308
if (edf->free_strings && edf->compiler) eina_stringshare_del(edf->compiler);
2309
if (edf->free_strings) eina_stringshare_del(edf->id);
2310
eina_hash_free(edf->style_hash);
2311
_edje_file_textblock_style_cleanup(edf);
2312
if (edf->ef) eet_close(edf->ef);
2313
if (edf->f) eina_file_close(edf->f); // close matching open (in _edje_file_open) OK
2318
_edje_program_free(Edje_Program *pr, Eina_Bool free_strings)
2320
Edje_Program_Target *prt;
2321
Edje_Program_After *pa;
2325
if (pr->name) eina_stringshare_del(pr->name);
2326
if (pr->signal) eina_stringshare_del(pr->signal);
2327
if (pr->source) eina_stringshare_del(pr->source);
2328
if (pr->filter.part) eina_stringshare_del(pr->filter.part);
2329
if (pr->filter.state) eina_stringshare_del(pr->filter.state);
2330
if (pr->state) eina_stringshare_del(pr->state);
2331
if (pr->state2) eina_stringshare_del(pr->state2);
2332
if (pr->sample_name) eina_stringshare_del(pr->sample_name);
2333
if (pr->tone_name) eina_stringshare_del(pr->tone_name);
2334
if (pr->seat) eina_stringshare_del(pr->seat);
2336
EINA_LIST_FREE(pr->targets, prt)
2338
EINA_LIST_FREE(pr->after, pa)
2344
_edje_collection_free(Edje_File *edf, Edje_Part_Collection *ec, Edje_Part_Collection_Directory_Entry *ce)
2348
_edje_embryo_script_shutdown(ec);
2350
#define EDJE_LOAD_PROGRAM_FREE(Array, Ec, It, FreeStrings) \
2351
for (It = 0; It < Ec->programs.Array##_count; ++It) \
2352
_edje_program_free(Ec->programs.Array[It], FreeStrings); \
2353
free(Ec->programs.Array);
2355
EDJE_LOAD_PROGRAM_FREE(fnmatch, ec, i, edf->free_strings);
2356
EDJE_LOAD_PROGRAM_FREE(strcmp, ec, i, edf->free_strings);
2357
EDJE_LOAD_PROGRAM_FREE(strncmp, ec, i, edf->free_strings);
2358
EDJE_LOAD_PROGRAM_FREE(strrncmp, ec, i, edf->free_strings);
2359
EDJE_LOAD_PROGRAM_FREE(nocmp, ec, i, edf->free_strings);
2361
for (i = 0; i < ec->parts_count; ++i)
2368
if (edf->free_strings && ep->name) eina_stringshare_del(ep->name);
2369
if (ep->default_desc)
2371
_edje_collection_free_part_description_clean(ep->type, ep->default_desc, edf->free_strings);
2372
ep->default_desc = NULL;
2374
for (j = 0; j < ep->other.desc_count; ++j)
2375
_edje_collection_free_part_description_clean(ep->type, ep->other.desc[j], edf->free_strings);
2377
free(ep->other.desc);
2378
/* Alloc for RTL objects in edje_calc.c:_edje_part_description_find() */
2379
if (ep->other.desc_rtl)
2380
free(ep->other.desc_rtl);
2382
for (j = 0; j < ep->items_count; ++j)
2386
for (j = 0; j < ep->allowed_seats_count; ++j)
2388
if (edf->free_strings)
2389
eina_stringshare_del(ep->allowed_seats[j]->name);
2390
free(ep->allowed_seats[j]);
2392
free(ep->allowed_seats);
2393
// technically need this - but we ASSUME we use "one_big" so everything gets
2394
// freed in one go lower down when we del the mempool... but what if pool goes
2396
eina_mempool_free(ce->mp->mp.part, ep);
2406
it = eina_hash_iterator_data_new(ec->data);
2407
EINA_ITERATOR_FOREACH(it, es)
2409
eina_iterator_free(it);
2411
eina_hash_free(ec->data);
2413
#ifdef EDJE_PROGRAM_CACHE
2414
if (ec->prog_cache.no_matches) eina_hash_free(ec->prog_cache.no_matches);
2415
if (ec->prog_cache.matches)
2417
eina_hash_foreach(ec->prog_cache.matches,
2418
_edje_collection_free_prog_cache_matches_free_cb,
2420
eina_hash_free(ec->prog_cache.matches);
2423
_edje_programs_patterns_clean(ec);
2424
if (ec->patterns.table_programs) free(ec->patterns.table_programs);
2425
ec->patterns.table_programs = NULL;
2426
ec->patterns.table_programs_size = 0;
2428
if (ec->script) embryo_program_free(ec->script);
2429
_edje_lua2_script_unload(ec);
2431
if (ec->limits.parts) free(ec->limits.parts);
2433
eina_hash_free(ec->alias);
2434
eina_hash_free(ec->aliased);
2436
/* Destroy all part and description. */
2437
edje_cache_emp_free(ce);
2442
_edje_collection_free_part_description_clean(int type, Edje_Part_Description_Common *desc, Eina_Bool free_strings)
2446
if (free_strings && desc->color_class) eina_stringshare_del(desc->color_class);
2447
//clean the map colors
2448
if (desc->map.colors)
2450
for (i = 0; i < desc->map.colors_count; i++)
2451
free(desc->map.colors[i]);
2452
free(desc->map.colors);
2457
case EDJE_PART_TYPE_IMAGE:
2459
Edje_Part_Description_Image *img;
2461
img = (Edje_Part_Description_Image *)desc;
2463
for (i = 0; i < img->image.tweens_count; ++i)
2464
free(img->image.tweens[i]);
2465
free(img->image.tweens);
2469
case EDJE_PART_TYPE_EXTERNAL:
2471
Edje_Part_Description_External *external;
2473
external = (Edje_Part_Description_External *)desc;
2475
if (external->external_params)
2476
_edje_external_params_free(external->external_params, free_strings);
2480
case EDJE_PART_TYPE_TEXT:
2481
case EDJE_PART_TYPE_TEXTBLOCK:
2484
Edje_Part_Description_Text *text;
2486
text = (Edje_Part_Description_Text *)desc;
2488
eina_stringshare_del(text->text.text.str);
2489
eina_stringshare_del(text->text.domain);
2490
eina_stringshare_del(text->text.text_class);
2491
eina_stringshare_del(text->text.style.str);
2492
eina_stringshare_del(text->text.font.str);
2499
_edje_collection_free_part_description_free(int type,
2500
Edje_Part_Description_Common *desc,
2501
Edje_Part_Collection_Directory_Entry *ce,
2502
Eina_Bool free_strings)
2504
#define FREE_POOL(Type, Ce, Desc) \
2505
case EDJE_PART_TYPE_##Type: eina_mempool_free(ce->mp->mp.Type, Desc); \
2509
_edje_collection_free_part_description_clean(type, desc, free_strings);
2513
FREE_POOL(RECTANGLE, ce, desc);
2514
FREE_POOL(TEXT, ce, desc);
2515
FREE_POOL(IMAGE, ce, desc);
2516
FREE_POOL(PROXY, ce, desc);
2517
FREE_POOL(SWALLOW, ce, desc);
2518
FREE_POOL(TEXTBLOCK, ce, desc);
2519
FREE_POOL(GROUP, ce, desc);
2520
FREE_POOL(BOX, ce, desc);
2521
FREE_POOL(TABLE, ce, desc);
2522
FREE_POOL(EXTERNAL, ce, desc);
2523
FREE_POOL(SNAPSHOT, ce, desc);
2524
FREE_POOL(SPACER, ce, desc);
2528
#ifdef EDJE_PROGRAM_CACHE
2530
_edje_collection_free_prog_cache_matches_free_cb(const Eina_Hash *hash EINA_UNUSED, const void *key EINA_UNUSED, void *data, void *fdata EINA_UNUSED)
2532
eina_list_free((Eina_List *)data);
2542
_edje_object_pack_item_hints_set(Evas_Object *obj, Edje_Pack_Element *it)
2544
Evas_Coord w = 0, h = 0, minw, minh;
2545
Evas_Aspect_Control mode = EVAS_ASPECT_CONTROL_NONE;
2550
if ((minw <= 0) && (minh <= 0))
2552
edje_object_size_min_get(obj, &w, &h);
2553
if ((w <= 0) && (h <= 0))
2554
edje_object_size_min_calc(obj, &w, &h);
2561
if (((minw <= 0) && (minh <= 0)) && ((w > 0) || (h > 0)))
2562
evas_object_size_hint_min_set(obj, w, h);
2564
evas_object_size_hint_min_set(obj, minw, minh);
2566
evas_object_size_hint_request_set(obj, it->prefer.w, it->prefer.h);
2567
evas_object_size_hint_max_set(obj, it->max.w, it->max.h);
2568
evas_object_size_hint_padding_set(obj, it->padding.l, it->padding.r, it->padding.t, it->padding.b);
2569
evas_object_size_hint_align_set(obj, TO_DOUBLE(it->align.x), TO_DOUBLE(it->align.y));
2570
evas_object_size_hint_weight_set(obj, TO_DOUBLE(it->weight.x), TO_DOUBLE(it->weight.y));
2572
switch (it->aspect.mode)
2574
case EDJE_ASPECT_CONTROL_NONE: mode = EVAS_ASPECT_CONTROL_NONE; break;
2576
case EDJE_ASPECT_CONTROL_NEITHER: mode = EVAS_ASPECT_CONTROL_NEITHER; break;
2578
case EDJE_ASPECT_CONTROL_HORIZONTAL: mode = EVAS_ASPECT_CONTROL_HORIZONTAL; break;
2580
case EDJE_ASPECT_CONTROL_VERTICAL: mode = EVAS_ASPECT_CONTROL_VERTICAL; break;
2582
case EDJE_ASPECT_CONTROL_BOTH: mode = EVAS_ASPECT_CONTROL_BOTH; break;
2584
evas_object_size_hint_aspect_set(obj, mode, it->aspect.w, it->aspect.h);
2586
evas_object_resize(obj, w, h);
2590
_edje_find_alias(Eina_Hash *aliased, char *src, int *length)
2595
*length = strlen(src);
2596
if (*length == 0) return NULL;
2598
alias = eina_hash_find(aliased, src);
2599
if (alias) return alias;
2601
search = strrchr(src, EDJE_PART_PATH_SEPARATOR);
2602
if (search == NULL) return NULL;
2605
alias = _edje_find_alias(aliased, src, length);
2606
*search = EDJE_PART_PATH_SEPARATOR;
2612
_cb_signal_repeat(void *data, Evas_Object *obj, const char *sig, const char *source)
2614
Edje_Pack_Element *pack_it;
2615
Evas_Object *parent;
2618
char new_src[4096]; /* XXX is this max reasonable? */
2619
size_t length_parent = 0;
2620
size_t length_index = 0;
2621
size_t length_source;
2623
const char *alias = NULL;
2624
const char *name = NULL;
2625
Edje_Message_Signal emsg;
2628
ed = _edje_fetch(obj);
2631
pack_it = evas_object_data_get(obj, "\377 edje.box_item");
2632
if (!pack_it) pack_it = evas_object_data_get(obj, "\377 edje.table_item");
2633
name = evas_object_name_get(obj);
2637
if (!name) name = pack_it->name;
2640
Eina_Iterator *it = NULL;
2643
if (pack_it->parent->part->type == EDJE_PART_TYPE_BOX)
2645
it = evas_object_box_iterator_new(pack_it->parent->object);
2647
else if (pack_it->parent->part->type == EDJE_PART_TYPE_TABLE)
2649
it = evas_object_table_iterator_new(pack_it->parent->object);
2652
EINA_ITERATOR_FOREACH(it, o)
2654
if (o == obj) break;
2657
eina_iterator_free(it);
2663
length_index = strlen(name) + 2;
2667
/* Replace snprint("%s%c%s") == memcpy + *new_src + memcat */
2669
length_parent = strlen(ed->parent);
2670
length_source = strlen(source);
2671
if (length_source + length_parent + 2 + length_index > sizeof(new_src))
2675
memcpy(new_src, ed->parent, length_parent);
2676
if (ed->parent && length_index)
2678
new_src[length_parent++] = EDJE_PART_PATH_SEPARATOR_INDEXL;
2679
if ((pack_it->parent->part->type == EDJE_PART_TYPE_BOX) ||
2680
(!name && (pack_it->parent->part->type == EDJE_PART_TYPE_TABLE)))
2681
length_parent += eina_convert_itoa(i, new_src + length_parent);
2684
memcpy(new_src + length_parent, name, length_index - 2);
2685
length_parent += length_index - 2;
2687
new_src[length_parent++] = EDJE_PART_PATH_SEPARATOR_INDEXR;
2690
new_src[length_parent] = EDJE_PART_PATH_SEPARATOR;
2691
memcpy(new_src + length_parent + 1, source, length_source + 1);
2693
/* Handle alias renaming */
2694
ed_parent = _edje_fetch(parent);
2695
if (ed_parent && ed_parent->collection && ed_parent->collection->aliased)
2699
alias = _edje_find_alias(ed_parent->collection->aliased, new_src, &length);
2705
/* Add back the end of the source */
2706
origin = strlen(new_src);
2707
length++; /* Remove the trailing ':' from the count */
2708
if (origin > length)
2711
size_t alias_length;
2713
alias_length = strlen(alias);
2714
tmp = alloca(alias_length + origin - length + 2);
2715
memcpy(tmp, alias, alias_length);
2716
tmp[alias_length] = EDJE_PART_PATH_SEPARATOR;
2717
memcpy(tmp + alias_length + 1, new_src + length, origin - length + 1);
2725
emsg.src = alias ? alias : new_src;
2728
_edje_util_message_send(ed_parent, EDJE_QUEUE_SCRIPT,
2729
EDJE_MESSAGE_SIGNAL, 0, &emsg);