aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/edje/src/lib/edje_load.c
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/edje/src/lib/edje_load.c')
-rw-r--r--libraries/edje/src/lib/edje_load.c1525
1 files changed, 1525 insertions, 0 deletions
diff --git a/libraries/edje/src/lib/edje_load.c b/libraries/edje/src/lib/edje_load.c
new file mode 100644
index 0000000..644bb7c
--- /dev/null
+++ b/libraries/edje/src/lib/edje_load.c
@@ -0,0 +1,1525 @@
1#include "edje_private.h"
2
3#ifdef EDJE_PROGRAM_CACHE
4static Eina_Bool _edje_collection_free_prog_cache_matches_free_cb(const Eina_Hash *hash, const void *key, void *data, void *fdata);
5#endif
6static void _edje_object_pack_item_hints_set(Evas_Object *obj, Edje_Pack_Element *it);
7static void _cb_signal_repeat(void *data, Evas_Object *obj, const char *signal, const char *source);
8
9static Eina_List *_edje_swallows_collect(Edje *ed);
10
11/************************** API Routines **************************/
12
13EAPI Eina_Bool
14edje_object_file_set(Evas_Object *obj, const char *file, const char *group)
15{
16 Eina_Bool ret;
17 Edje *ed;
18
19 ed = _edje_fetch(obj);
20 if (!ed)
21 return EINA_FALSE;
22 ret = ed->api->file_set(obj, file, group);
23 _edje_object_orientation_inform(obj);
24 return ret;
25}
26
27EAPI void
28edje_object_file_get(const Evas_Object *obj, const char **file, const char **group)
29{
30 Edje *ed;
31
32 ed = _edje_fetch(obj);
33 if (!ed)
34 {
35 if (file) *file = NULL;
36 if (group) *group = NULL;
37 return;
38 }
39 if (file) *file = ed->path;
40 if (group) *group = ed->group;
41}
42
43EAPI Edje_Load_Error
44edje_object_load_error_get(const Evas_Object *obj)
45{
46 Edje *ed;
47
48 ed = _edje_fetch(obj);
49 if (!ed) return EDJE_LOAD_ERROR_NONE;
50 return ed->load_error;
51}
52
53EAPI const char *
54edje_load_error_str(Edje_Load_Error error)
55{
56 switch (error)
57 {
58 case EDJE_LOAD_ERROR_NONE:
59 return "No Error";
60 case EDJE_LOAD_ERROR_GENERIC:
61 return "Generic Error";
62 case EDJE_LOAD_ERROR_DOES_NOT_EXIST:
63 return "File Does Not Exist";
64 case EDJE_LOAD_ERROR_PERMISSION_DENIED:
65 return "Permission Denied";
66 case EDJE_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED:
67 return "Resource Allocation Failed";
68 case EDJE_LOAD_ERROR_CORRUPT_FILE:
69 return "Corrupt File";
70 case EDJE_LOAD_ERROR_UNKNOWN_FORMAT:
71 return "Unknown Format";
72 case EDJE_LOAD_ERROR_INCOMPATIBLE_FILE:
73 return "Incompatible File";
74 case EDJE_LOAD_ERROR_UNKNOWN_COLLECTION:
75 return "Unknown Collection";
76 case EDJE_LOAD_ERROR_RECURSIVE_REFERENCE:
77 return "Recursive Reference";
78 default:
79 return "Unknown Error";
80 }
81}
82
83
84EAPI Eina_List *
85edje_file_collection_list(const char *file)
86{
87 Eina_List *lst = NULL;
88 Edje_File *edf;
89 int error_ret = 0;
90
91 if ((!file) || (!*file)) return NULL;
92 edf = _edje_cache_file_coll_open(file, NULL, &error_ret, NULL);
93 if (edf)
94 {
95 Eina_Iterator *i;
96 const char *key;
97
98 i = eina_hash_iterator_key_new(edf->collection);
99
100 EINA_ITERATOR_FOREACH(i, key)
101 lst = eina_list_append(lst, eina_stringshare_add(key));
102
103 eina_iterator_free(i);
104
105 _edje_cache_file_unref(edf);
106 }
107 return lst;
108}
109
110EAPI void
111edje_file_collection_list_free(Eina_List *lst)
112{
113 while (lst)
114 {
115 if (eina_list_data_get(lst)) eina_stringshare_del(eina_list_data_get(lst));
116 lst = eina_list_remove(lst, eina_list_data_get(lst));
117 }
118}
119
120EAPI Eina_Bool
121edje_file_group_exists(const char *file, const char *glob)
122{
123 Edje_File *edf;
124 int error_ret = 0;
125 Eina_Bool succeed = EINA_FALSE;
126 Eina_Bool is_glob = EINA_FALSE;
127 const char *p;
128
129 if ((!file) || (!*file))
130 return EINA_FALSE;
131
132 edf = _edje_cache_file_coll_open(file, NULL, &error_ret, NULL);
133 if (!edf)
134 return EINA_FALSE;
135
136 for (p = glob; *p; p++)
137 {
138 if ((*p == '*') || (*p == '?') || (*p == '['))
139 {
140 is_glob = EINA_TRUE;
141 break;
142 }
143 }
144
145 if (is_glob)
146 {
147 if (!edf->collection_patterns)
148 {
149 Edje_Part_Collection_Directory_Entry *ce;
150 Eina_Iterator *i;
151 Eina_List *l = NULL;
152
153 i = eina_hash_iterator_data_new(edf->collection);
154
155 EINA_ITERATOR_FOREACH(i, ce)
156 l = eina_list_append(l, ce);
157
158 eina_iterator_free(i);
159
160 edf->collection_patterns = edje_match_collection_dir_init(l);
161 eina_list_free(l);
162 }
163
164 succeed = edje_match_collection_dir_exec(edf->collection_patterns, glob);
165 if (edf->collection_patterns)
166 {
167 edje_match_patterns_free(edf->collection_patterns);
168 edf->collection_patterns = NULL;
169 }
170 }
171 else
172 {
173 if (eina_hash_find(edf->collection, glob)) succeed = EINA_TRUE;
174 }
175 _edje_cache_file_unref(edf);
176
177 INF("edje_file_group_exists: '%s', '%s': %i\n", file, glob, succeed);
178
179 return succeed;
180}
181
182
183EAPI char *
184edje_file_data_get(const char *file, const char *key)
185{
186 Edje_File *edf;
187 char *str = NULL;
188 int error_ret = 0;
189
190 if (key)
191 {
192 edf = _edje_cache_file_coll_open(file, NULL, &error_ret, NULL);
193 if (edf)
194 {
195 str = (char*) edje_string_get(eina_hash_find(edf->data, key));
196
197 if (str) str = strdup(str);
198
199 _edje_cache_file_unref(edf);
200 }
201 }
202 return str;
203}
204
205void
206_edje_programs_patterns_clean(Edje *ed)
207{
208 _edje_signals_sources_patterns_clean(&ed->patterns.programs);
209
210 eina_rbtree_delete(ed->patterns.programs.exact_match,
211 EINA_RBTREE_FREE_CB(edje_match_signal_source_free),
212 NULL);
213 ed->patterns.programs.exact_match = NULL;
214
215 free(ed->patterns.programs.u.programs.globing);
216 ed->patterns.programs.u.programs.globing = NULL;
217}
218
219void
220_edje_programs_patterns_init(Edje *ed)
221{
222 Edje_Signals_Sources_Patterns *ssp = &ed->patterns.programs;
223 Edje_Program **all;
224 unsigned int i, j;
225
226 if (ssp->signals_patterns)
227 return;
228
229 edje_match_program_hash_build(ed->collection->programs.strcmp,
230 ed->collection->programs.strcmp_count,
231 &ssp->exact_match);
232
233 j = ed->collection->programs.strncmp_count
234 + ed->collection->programs.strrncmp_count
235 + ed->collection->programs.fnmatch_count
236 + ed->collection->programs.nocmp_count;
237 if (j == 0) return ;
238
239 all = malloc(sizeof (Edje_Program *) * j);
240 if (!all) return ;
241 j = 0;
242
243 /* FIXME: Build specialized data type for each case */
244#define EDJE_LOAD_PROGRAMS_ADD(Array, Ed, It, Git, All) \
245 for (It = 0; It < Ed->collection->programs.Array##_count; ++It, ++Git) \
246 All[Git] = Ed->collection->programs.Array[It];
247
248 EDJE_LOAD_PROGRAMS_ADD(fnmatch, ed, i, j, all);
249 EDJE_LOAD_PROGRAMS_ADD(strncmp, ed, i, j, all);
250 EDJE_LOAD_PROGRAMS_ADD(strrncmp, ed, i, j, all);
251 /* FIXME: Do a special pass for that one */
252 EDJE_LOAD_PROGRAMS_ADD(nocmp, ed, i, j, all);
253
254 ssp->u.programs.globing = all;
255 ssp->u.programs.count = j;
256 ssp->signals_patterns = edje_match_programs_signal_init(all, j);
257 ssp->sources_patterns = edje_match_programs_source_init(all, j);
258}
259
260int
261_edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *group, const char *parent, Eina_List *group_path)
262{
263 Edje *ed;
264 Evas *tev;
265 Eina_List *old_swallows;
266 unsigned int n;
267 Eina_List *parts = NULL;
268 int group_path_started = 0;
269
270 ed = _edje_fetch(obj);
271 if (!ed) return 0;
272 if (!file) file = "";
273 if (!group) group = "";
274 if (((ed->path) && (!strcmp(file, ed->path))) &&
275 (ed->group) && (!strcmp(group, ed->group)))
276 return 1;
277
278 tev = evas_object_evas_get(obj);
279 evas_event_freeze(tev);
280 old_swallows = _edje_swallows_collect(ed);
281
282 if (_edje_script_only(ed)) _edje_script_only_shutdown(ed);
283 if (_edje_lua_script_only(ed)) _edje_lua_script_only_shutdown(ed);
284 _edje_file_del(ed);
285
286 eina_stringshare_replace(&ed->path, file);
287 eina_stringshare_replace(&ed->group, group);
288
289 ed->parent = eina_stringshare_add(parent);
290
291 ed->load_error = EDJE_LOAD_ERROR_NONE;
292 _edje_file_add(ed);
293
294 if (ed->file && ed->file->external_dir)
295 {
296 unsigned int i;
297
298 for (i = 0; i < ed->file->external_dir->entries_count; ++i)
299 edje_module_load(ed->file->external_dir->entries[i].entry);
300 }
301
302 _edje_textblock_styles_add(ed);
303 _edje_textblock_style_all_update(ed);
304
305 ed->has_entries = EINA_FALSE;
306
307 if (ed->collection)
308 {
309 if (ed->collection->prop.orientation != EDJE_ORIENTATION_AUTO)
310 ed->is_rtl = (ed->collection->prop.orientation ==
311 EDJE_ORIENTATION_RTL);
312
313 if (ed->collection->script_only)
314 {
315 ed->load_error = EDJE_LOAD_ERROR_NONE;
316 _edje_script_only_init(ed);
317 }
318 else if (ed->collection->lua_script_only)
319 {
320 ed->load_error = EDJE_LOAD_ERROR_NONE;
321 _edje_lua_script_only_init(ed);
322 }
323 else
324 {
325 unsigned int i;
326 int errors = 0;
327
328 /* colorclass stuff */
329 for (i = 0; i < ed->collection->parts_count; ++i)
330 {
331 Edje_Part *ep;
332 unsigned int k;
333
334 ep = ed->collection->parts[i];
335
336 if (errors)
337 break;
338 /* Register any color classes in this parts descriptions. */
339 if ((ep->default_desc) && (ep->default_desc->color_class))
340 _edje_color_class_member_add(ed, ep->default_desc->color_class);
341
342 for (k = 0; k < ep->other.desc_count; k++)
343 {
344 Edje_Part_Description_Common *desc;
345
346 desc = ep->other.desc[k];
347
348 if (desc->color_class)
349 _edje_color_class_member_add(ed, desc->color_class);
350 }
351 }
352 /* build real parts */
353 for (n = 0; n < ed->collection->parts_count; n++)
354 {
355 Edje_Part *ep;
356 Edje_Real_Part *rp;
357
358 ep = ed->collection->parts[n];
359 rp = eina_mempool_malloc(_edje_real_part_mp, sizeof(Edje_Real_Part));
360 if (!rp)
361 {
362 ed->load_error = EDJE_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED;
363 evas_event_thaw(tev);
364 evas_event_thaw_eval(tev);
365 return 0;
366 }
367
368 memset(rp, 0, sizeof (Edje_Real_Part));
369
370 if ((ep->dragable.x != 0) || (ep->dragable.y != 0))
371 {
372 rp->drag = calloc(1, sizeof (Edje_Real_Part_Drag));
373 if (!rp->drag)
374 {
375 ed->load_error = EDJE_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED;
376 free(rp);
377 evas_event_thaw(tev);
378 evas_event_thaw_eval(tev);
379 return 0;
380 }
381
382 rp->drag->step.x = FROM_INT(ep->dragable.step_x);
383 rp->drag->step.y = FROM_INT(ep->dragable.step_y);
384 }
385
386 rp->edje = ed;
387 _edje_ref(rp->edje);
388 rp->part = ep;
389 parts = eina_list_append(parts, rp);
390 rp->param1.description =
391 _edje_part_description_find(ed, rp, "default", 0.0);
392 rp->chosen_description = rp->param1.description;
393 if (!rp->param1.description)
394 ERR("no default part description!");
395
396 switch (ep->type)
397 {
398 case EDJE_PART_TYPE_RECTANGLE:
399 rp->object = evas_object_rectangle_add(ed->base.evas);
400 break;
401 case EDJE_PART_TYPE_PROXY:
402 case EDJE_PART_TYPE_IMAGE:
403 rp->object = evas_object_image_add(ed->base.evas);
404 break;
405 case EDJE_PART_TYPE_TEXT:
406 _edje_text_part_on_add(ed, rp);
407 rp->object = evas_object_text_add(ed->base.evas);
408 evas_object_text_font_source_set(rp->object, ed->path);
409 break;
410 case EDJE_PART_TYPE_SWALLOW:
411 case EDJE_PART_TYPE_GROUP:
412 case EDJE_PART_TYPE_EXTERNAL:
413 rp->object = evas_object_rectangle_add(ed->base.evas);
414 evas_object_color_set(rp->object, 0, 0, 0, 0);
415 evas_object_pass_events_set(rp->object, 1);
416 evas_object_pointer_mode_set(rp->object, EVAS_OBJECT_POINTER_MODE_NOGRAB);
417 _edje_callbacks_focus_add(rp->object, ed, rp);
418 break;
419 case EDJE_PART_TYPE_TEXTBLOCK:
420 rp->object = evas_object_textblock_add(ed->base.evas);
421 break;
422 case EDJE_PART_TYPE_BOX:
423 rp->object = evas_object_box_add(ed->base.evas);
424 rp->anim = _edje_box_layout_anim_new(rp->object);
425 break;
426 case EDJE_PART_TYPE_TABLE:
427 rp->object = evas_object_table_add(ed->base.evas);
428 break;
429 case EDJE_PART_TYPE_GRADIENT:
430 ERR("SPANK ! SPANK ! SPANK ! YOU ARE USING GRADIENT IN PART %s FROM GROUP %s INSIDE FILE %s !! THEY ARE NOW REMOVED !",
431 ep->name, group, file);
432 default:
433 ERR("wrong part type %i!", ep->type);
434 break;
435 }
436
437 if (rp->object)
438 {
439 evas_object_smart_member_add(rp->object, ed->obj);
440// evas_object_layer_set(rp->object, evas_object_layer_get(ed->obj));
441 if (ep->type != EDJE_PART_TYPE_SWALLOW && ep->type != EDJE_PART_TYPE_GROUP && ep->type != EDJE_PART_TYPE_EXTERNAL)
442 {
443 if (ep->mouse_events)
444 {
445 _edje_callbacks_add(rp->object, ed, rp);
446 if (ep->repeat_events)
447 evas_object_repeat_events_set(rp->object, 1);
448
449 if (ep->pointer_mode != EVAS_OBJECT_POINTER_MODE_AUTOGRAB)
450 evas_object_pointer_mode_set(rp->object, ep->pointer_mode);
451 }
452 else
453 {
454 evas_object_pass_events_set(rp->object, 1);
455 evas_object_pointer_mode_set(rp->object, EVAS_OBJECT_POINTER_MODE_NOGRAB);
456 }
457 if (ep->precise_is_inside)
458 evas_object_precise_is_inside_set(rp->object, 1);
459 }
460 if (rp->part->clip_to_id < 0)
461 evas_object_clip_set(rp->object, ed->base.clipper);
462 }
463 }
464 if (n > 0)
465 {
466 Edje_Real_Part *rp;
467 Eina_List *l;
468
469 ed->table_parts = malloc(sizeof(Edje_Real_Part *) * n);
470 ed->table_parts_size = n;
471 /* FIXME: check malloc return */
472 n = 0;
473 EINA_LIST_FOREACH(parts, l, rp)
474 {
475 ed->table_parts[n] = rp;
476 n++;
477 }
478 eina_list_free(parts);
479 for (i = 0; i < ed->table_parts_size; i++)
480 {
481 rp = ed->table_parts[i];
482 if (rp->param1.description) /* FIXME: prevent rel to gone radient part to go wrong. You may
483 be able to remove this when all theme are correctly rewritten. */
484 {
485 if (rp->param1.description->rel1.id_x >= 0)
486 rp->param1.rel1_to_x = ed->table_parts[rp->param1.description->rel1.id_x % ed->table_parts_size];
487 if (rp->param1.description->rel1.id_y >= 0)
488 rp->param1.rel1_to_y = ed->table_parts[rp->param1.description->rel1.id_y % ed->table_parts_size];
489 if (rp->param1.description->rel2.id_x >= 0)
490 rp->param1.rel2_to_x = ed->table_parts[rp->param1.description->rel2.id_x % ed->table_parts_size];
491 if (rp->param1.description->rel2.id_y >= 0)
492 rp->param1.rel2_to_y = ed->table_parts[rp->param1.description->rel2.id_y % ed->table_parts_size];
493 }
494 if (rp->part->clip_to_id >= 0)
495 {
496 rp->clip_to = ed->table_parts[rp->part->clip_to_id % ed->table_parts_size];
497 if (rp->clip_to)
498 {
499 evas_object_pass_events_set(rp->clip_to->object, 1);
500 evas_object_pointer_mode_set(rp->clip_to->object, EVAS_OBJECT_POINTER_MODE_NOGRAB);
501 evas_object_clip_set(rp->object, rp->clip_to->object);
502 }
503 }
504 if (rp->drag)
505 {
506 if (rp->part->dragable.confine_id >= 0)
507 rp->drag->confine_to = ed->table_parts[rp->part->dragable.confine_id % ed->table_parts_size];
508 }
509
510 /* replay events for dragable */
511 if (rp->part->dragable.event_id >= 0)
512 {
513 rp->events_to =
514 ed->table_parts[rp->part->dragable.event_id % ed->table_parts_size];
515 /* events_to may be used only with dragable */
516 if (!rp->events_to->part->dragable.x &&
517 !rp->events_to->part->dragable.y)
518 rp->events_to = NULL;
519 }
520
521 rp->swallow_params.min.w = 0;
522 rp->swallow_params.min.w = 0;
523 rp->swallow_params.max.w = -1;
524 rp->swallow_params.max.h = -1;
525
526 if (rp->part->type == EDJE_PART_TYPE_TEXT
527 || rp->part->type == EDJE_PART_TYPE_TEXTBLOCK)
528 {
529 Edje_Part_Description_Text *text;
530
531 text = (Edje_Part_Description_Text *) rp->param1.description;
532
533 if (ed->file->feature_ver < 1)
534 {
535 text->text.id_source = -1;
536 text->text.id_text_source = -1;
537 }
538
539 if (text->text.id_source >= 0)
540 rp->text.source = ed->table_parts[text->text.id_source % ed->table_parts_size];
541 if (text->text.id_text_source >= 0)
542 rp->text.text_source = ed->table_parts[text->text.id_text_source % ed->table_parts_size];
543 if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
544 {
545 _edje_entry_real_part_init(rp);
546 if (!ed->has_entries)
547 ed->has_entries = EINA_TRUE;
548 }
549 }
550 }
551 }
552
553 _edje_programs_patterns_init(ed);
554
555 n = ed->collection->programs.fnmatch_count +
556 ed->collection->programs.strcmp_count +
557 ed->collection->programs.strncmp_count +
558 ed->collection->programs.strrncmp_count +
559 ed->collection->programs.nocmp_count;
560 if (n > 0)
561 {
562 Edje_Program *pr;
563
564 ed->table_programs = malloc(sizeof(Edje_Program *) * n);
565 if (ed->table_programs)
566 {
567 ed->table_programs_size = n;
568
569#define EDJE_LOAD_BUILD_TABLE(Array, Ed, It, Tmp) \
570 for (It = 0; It < Ed->collection->programs.Array##_count; ++It) \
571 { \
572 Tmp = Ed->collection->programs.Array[It]; \
573 Ed->table_programs[Tmp->id] = Tmp; \
574 }
575
576 EDJE_LOAD_BUILD_TABLE(fnmatch, ed, i, pr);
577 EDJE_LOAD_BUILD_TABLE(strcmp, ed, i, pr);
578 EDJE_LOAD_BUILD_TABLE(strncmp, ed, i, pr);
579 EDJE_LOAD_BUILD_TABLE(strrncmp, ed, i, pr);
580 EDJE_LOAD_BUILD_TABLE(nocmp, ed, i, pr);
581 }
582 }
583 _edje_ref(ed);
584 _edje_block(ed);
585 _edje_freeze(ed);
586// if (ed->collection->script) _edje_embryo_script_init(ed);
587 _edje_var_init(ed);
588 for (i = 0; i < ed->table_parts_size; i++)
589 {
590 Edje_Real_Part *rp;
591
592 rp = ed->table_parts[i];
593 evas_object_show(rp->object);
594 if (_edje_block_break(ed)) break;
595 if (rp->drag)
596 {
597 if (rp->part->dragable.x < 0) rp->drag->val.x = FROM_DOUBLE(1.0);
598 if (rp->part->dragable.y < 0) rp->drag->val.x = FROM_DOUBLE(1.0);
599 _edje_dragable_pos_set(ed, rp, rp->drag->val.x, rp->drag->val.y);
600 }
601 }
602 ed->dirty = 1;
603#ifdef EDJE_CALC_CACHE
604 ed->all_part_change = 1;
605#endif
606 if ((evas_object_clipees_get(ed->base.clipper)) &&
607 (evas_object_visible_get(obj)))
608 evas_object_show(ed->base.clipper);
609
610 /* instantiate 'internal swallows' */
611 for (i = 0; i < ed->table_parts_size; i++)
612 {
613 Edje_Real_Part *rp;
614 /* XXX: curr_item and pack_it don't require to be NULL since
615 * XXX: they are just used when source != NULL and type == BOX,
616 * XXX: and they're always set in this case, but GCC fails to
617 * XXX: notice that, so let's shut it up
618 */
619 Edje_Pack_Element **curr_item = NULL;
620 unsigned int item_count = 0;
621 Edje_Pack_Element *pack_it = NULL;
622 const char *source = NULL;
623
624 rp = ed->table_parts[i];
625
626 switch (rp->part->type)
627 {
628 case EDJE_PART_TYPE_GROUP:
629 source = rp->part->source;
630 break;
631 case EDJE_PART_TYPE_BOX:
632 case EDJE_PART_TYPE_TABLE:
633 if (rp->part->items)
634 {
635 curr_item = rp->part->items;
636 item_count = rp->part->items_count;
637 if (item_count > 0)
638 {
639 pack_it = *curr_item;
640 source = pack_it->source;
641 item_count--;
642 curr_item++;
643 }
644 }
645 break;
646 case EDJE_PART_TYPE_EXTERNAL:
647 {
648 Edje_Part_Description_External *external;
649 Evas_Object *child_obj;
650
651 external = (Edje_Part_Description_External *) rp->part->default_desc;
652 child_obj = _edje_external_type_add(rp->part->source,
653 evas_object_evas_get(ed->obj), ed->obj,
654 external->external_params, rp->part->name);
655 if (child_obj)
656 {
657 _edje_real_part_swallow(rp, child_obj, EINA_TRUE);
658 rp->param1.external_params = _edje_external_params_parse(child_obj,
659 external->external_params);
660 _edje_external_recalc_apply(ed, rp, NULL, rp->chosen_description);
661 }
662 }
663 continue;
664 default:
665 continue;
666 }
667
668 while (source)
669 {
670 Eina_List *l;
671 Evas_Object *child_obj;
672 const char *group_path_entry = eina_stringshare_add(source);
673 const char *data;
674
675 if (!group_path)
676 {
677 group_path = eina_list_append(NULL, eina_stringshare_add(group));
678 group_path_started = 1;
679 }
680 /* make sure that this group isn't already in the tree of parents */
681 EINA_LIST_FOREACH(group_path, l, data)
682 {
683 if (data == group_path_entry)
684 {
685 _edje_thaw(ed);
686 _edje_unblock(ed);
687 _edje_unref(ed);
688 _edje_file_del(ed);
689 eina_stringshare_del(group_path_entry);
690 if (group_path_started)
691 {
692 eina_stringshare_del(eina_list_data_get(group_path));
693 eina_list_free(group_path);
694 }
695 ed->load_error = EDJE_LOAD_ERROR_RECURSIVE_REFERENCE;
696 evas_event_thaw(tev);
697 evas_event_thaw_eval(tev);
698 return 0;
699 }
700 }
701
702 child_obj = edje_object_add(ed->base.evas);
703 group_path = eina_list_append(group_path, group_path_entry);
704 if (rp->part->type == EDJE_PART_TYPE_GROUP)
705 {
706 _edje_real_part_swallow(rp, child_obj, EINA_FALSE);
707 }
708
709 if (!_edje_object_file_set_internal(child_obj, file, source, rp->part->name, group_path))
710 {
711 _edje_thaw(ed);
712 _edje_unblock(ed);
713 _edje_unref(ed);
714 _edje_file_del(ed);
715
716 if (group_path_started)
717 {
718 while (group_path)
719 {
720 eina_stringshare_del(eina_list_data_get(group_path));
721 group_path = eina_list_remove_list(group_path, group_path);
722 }
723 }
724 ed->load_error = edje_object_load_error_get(child_obj);
725 evas_object_del(child_obj);
726 evas_event_thaw(tev);
727 evas_event_thaw_eval(tev);
728 return 0;
729 }
730
731 group_path = eina_list_remove(group_path, group_path_entry);
732 eina_stringshare_del(group_path_entry);
733
734 edje_object_propagate_callback_add(child_obj,
735 _cb_signal_repeat,
736 obj);
737 if (rp->part->type == EDJE_PART_TYPE_GROUP)
738 {
739 _edje_real_part_swallow(rp, child_obj, EINA_TRUE);
740 _edje_subobj_register(ed, child_obj);
741 source = NULL;
742 }
743 else
744 {
745 pack_it->parent = rp;
746
747 _edje_object_pack_item_hints_set(child_obj, pack_it);
748 if (pack_it->name)
749 evas_object_name_set(child_obj, pack_it->name);
750
751 if (rp->part->type == EDJE_PART_TYPE_BOX)
752 {
753 _edje_real_part_box_append(rp, child_obj);
754 evas_object_data_set(child_obj, "\377 edje.box_item", pack_it);
755 }
756 else if (rp->part->type == EDJE_PART_TYPE_TABLE)
757 {
758 _edje_real_part_table_pack(rp, child_obj, pack_it->col, pack_it->row, pack_it->colspan, pack_it->rowspan);
759 evas_object_data_set(child_obj, "\377 edje.table_item", pack_it);
760 }
761 _edje_subobj_register(ed, child_obj);
762 evas_object_show(child_obj);
763 rp->items = eina_list_append(rp->items, child_obj);
764
765 if (item_count > 0)
766 {
767 pack_it = *curr_item;
768 source = pack_it->source;
769 curr_item++;
770 item_count--;
771 }
772 else
773 {
774 source = NULL;
775 curr_item = NULL;
776 pack_it = NULL;
777 }
778 }
779 }
780 }
781
782 if (group_path_started)
783 {
784 const char *str;
785
786 EINA_LIST_FREE(group_path, str)
787 eina_stringshare_del(str);
788 }
789
790 /* reswallow any swallows that existed before setting the file */
791 if (old_swallows)
792 {
793 while (old_swallows)
794 {
795 const char *name;
796 Evas_Object *swallow;
797
798 name = eina_list_data_get(old_swallows);
799 old_swallows = eina_list_remove_list(old_swallows, old_swallows);
800
801 swallow = eina_list_data_get(old_swallows);
802 old_swallows = eina_list_remove_list(old_swallows, old_swallows);
803
804 edje_object_part_swallow(obj, name, swallow);
805 eina_stringshare_del(name);
806 }
807 }
808
809 _edje_recalc(ed);
810 _edje_thaw(ed);
811 _edje_unblock(ed);
812 _edje_unref(ed);
813 ed->load_error = EDJE_LOAD_ERROR_NONE;
814 _edje_emit(ed, "load", NULL);
815 /* instantiate 'internal swallows' */
816 for (i = 0; i < ed->table_parts_size; i++)
817 {
818 Edje_Real_Part *rp;
819
820 rp = ed->table_parts[i];
821 if ((rp->part->type == EDJE_PART_TYPE_TEXTBLOCK) &&
822 (rp->part->default_desc))
823 {
824 Edje_Part_Description_Text *text;
825 Edje_Style *stl = NULL;
826 const char *style;
827
828 text = (Edje_Part_Description_Text *) rp->part->default_desc;
829 style = edje_string_get(&text->text.style);
830 if (style)
831 {
832 Eina_List *l;
833
834 EINA_LIST_FOREACH(ed->file->styles, l, stl)
835 {
836 if ((stl->name) && (!strcmp(stl->name, style))) break;
837 stl = NULL;
838 }
839 }
840 if (stl)
841 {
842 if (evas_object_textblock_style_get(rp->object) != stl->style)
843 evas_object_textblock_style_set(rp->object, stl->style);
844 }
845 }
846 }
847 }
848 _edje_entry_init(ed);
849 evas_event_thaw(tev);
850 evas_event_thaw_eval(tev);
851 return 1;
852 }
853 else
854 {
855 evas_event_thaw(tev);
856 evas_event_thaw_eval(tev);
857 return 0;
858 }
859 ed->load_error = EDJE_LOAD_ERROR_NONE;
860 _edje_entry_init(ed);
861 evas_event_thaw(tev);
862 evas_event_thaw_eval(tev);
863 return 1;
864}
865
866void
867_edje_file_add(Edje *ed)
868{
869 if (!_edje_edd_edje_file) return;
870 ed->file = _edje_cache_file_coll_open(ed->path, ed->group,
871 &(ed->load_error),
872 &(ed->collection));
873
874 if (!ed->collection)
875 {
876 if (ed->file)
877 {
878 _edje_cache_file_unref(ed->file);
879 ed->file = NULL;
880 }
881 }
882}
883
884static Eina_List *
885_edje_swallows_collect(Edje *ed)
886{
887 Eina_List *swallows = NULL;
888 unsigned int i;
889
890 if (!ed->file || !ed->table_parts) return NULL;
891 for (i = 0; i < ed->table_parts_size; i++)
892 {
893 Edje_Real_Part *rp;
894
895 rp = ed->table_parts[i];
896 if (rp->part->type != EDJE_PART_TYPE_SWALLOW || !rp->swallowed_object) continue;
897 swallows = eina_list_append(swallows, eina_stringshare_add(rp->part->name));
898 swallows = eina_list_append(swallows, rp->swallowed_object);
899 }
900 return swallows;
901}
902
903void
904_edje_file_del(Edje *ed)
905{
906 Evas *tev = evas_object_evas_get(ed->obj);
907
908 evas_event_freeze(tev);
909 if (ed->freeze_calc)
910 {
911 _edje_freeze_calc_list = eina_list_remove(_edje_freeze_calc_list, ed);
912 ed->freeze_calc = 0;
913 _edje_freeze_calc_count--;
914 }
915 _edje_entry_shutdown(ed);
916 _edje_message_del(ed);
917 _edje_block_violate(ed);
918 _edje_var_shutdown(ed);
919 _edje_programs_patterns_clean(ed);
920// if (ed->collection)
921// {
922// if (ed->collection->script) _edje_embryo_script_shutdown(ed);
923// }
924
925 if (!((ed->file) && (ed->collection)))
926 {
927 evas_event_thaw(tev);
928 evas_event_thaw_eval(tev);
929 return;
930 }
931 if (ed->table_parts)
932 {
933 unsigned int i;
934 for (i = 0; i < ed->table_parts_size; i++)
935 {
936 Edje_Real_Part *rp;
937
938 rp = ed->table_parts[i];
939 if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
940 _edje_entry_real_part_shutdown(rp);
941 if (rp->object)
942 {
943 _edje_callbacks_del(rp->object, ed);
944 _edje_callbacks_focus_del(rp->object, ed);
945 evas_object_del(rp->object);
946 }
947 if (rp->swallowed_object)
948 {
949 _edje_real_part_swallow_clear(rp);
950 /* Objects swallowed by the app do not get deleted,
951 but those internally swallowed (GROUP type) do. */
952 switch (rp->part->type)
953 {
954 case EDJE_PART_TYPE_EXTERNAL:
955 _edje_external_parsed_params_free(rp->swallowed_object, rp->param1.external_params);
956 if (rp->param2)
957 _edje_external_parsed_params_free(rp->swallowed_object, rp->param2->external_params);
958 case EDJE_PART_TYPE_GROUP:
959 evas_object_del(rp->swallowed_object);
960 default:
961 break;
962 }
963 rp->swallowed_object = NULL;
964 }
965 if (rp->items)
966 {
967 /* evas_box/table handles deletion of objects */
968 rp->items = eina_list_free(rp->items);
969 }
970 if (rp->anim)
971 {
972 _edje_box_layout_free_data(rp->anim);
973 rp->anim = NULL;
974 }
975 if (rp->text.text) eina_stringshare_del(rp->text.text);
976 if (rp->text.font) eina_stringshare_del(rp->text.font);
977 if (rp->text.cache.in_str) eina_stringshare_del(rp->text.cache.in_str);
978 if (rp->text.cache.out_str) eina_stringshare_del(rp->text.cache.out_str);
979
980 if (rp->custom)
981 {
982 // xxx: lua2
983 _edje_collection_free_part_description_clean(rp->part->type,
984 rp->custom->description,
985 ed->file->free_strings);
986 free(rp->custom->description);
987 rp->custom->description = NULL;
988 }
989
990 /* Cleanup optional part. */
991 free(rp->drag);
992 free(rp->param1.set);
993
994 if (rp->param2)
995 free(rp->param2->set);
996 eina_mempool_free(_edje_real_part_state_mp, rp->param2);
997
998 if (rp->custom)
999 free(rp->custom->set);
1000 eina_mempool_free(_edje_real_part_state_mp, rp->custom);
1001
1002 _edje_unref(rp->edje);
1003 eina_mempool_free(_edje_real_part_mp, rp);
1004 }
1005 }
1006 if ((ed->file) && (ed->collection))
1007 {
1008 Edje_Part *ep;
1009 unsigned int i;
1010
1011 _edje_textblock_styles_del(ed);
1012 for (i = 0; i < ed->collection->parts_count; ++i)
1013 {
1014 ep = ed->collection->parts[i];
1015
1016 _edje_text_part_on_del(ed, ep);
1017 _edje_color_class_on_del(ed, ep);
1018 }
1019
1020 _edje_cache_coll_unref(ed->file, ed->collection);
1021 ed->collection = NULL;
1022 }
1023 if (ed->file)
1024 {
1025 _edje_cache_file_unref(ed->file);
1026 ed->file = NULL;
1027 }
1028 if (ed->actions)
1029 {
1030 Edje_Running_Program *runp;
1031
1032 EINA_LIST_FREE(ed->actions, runp)
1033 {
1034 _edje_anim_count--;
1035 free(runp);
1036 }
1037 }
1038 _edje_animators = eina_list_remove(_edje_animators, ed);
1039 if (ed->pending_actions)
1040 {
1041 Edje_Pending_Program *pp;
1042
1043 EINA_LIST_FREE(ed->pending_actions, pp)
1044 {
1045 ecore_timer_del(pp->timer);
1046 free(pp);
1047 }
1048 }
1049 if (ed->L) _edje_lua2_script_shutdown(ed);
1050 while (ed->subobjs) evas_object_del(ed->subobjs->data);
1051 if (ed->table_parts) free(ed->table_parts);
1052 ed->table_parts = NULL;
1053 ed->table_parts_size = 0;
1054 if (ed->table_programs) free(ed->table_programs);
1055 ed->table_programs = NULL;
1056 ed->table_programs_size = 0;
1057 ed->focused_part = NULL;
1058 evas_event_thaw(tev);
1059 evas_event_thaw_eval(tev);
1060}
1061
1062void
1063_edje_file_free(Edje_File *edf)
1064{
1065 Edje_Color_Class *ecc;
1066
1067#define HASH_FREE(Hash) \
1068 if (Hash) eina_hash_free(Hash); \
1069 Hash = NULL;
1070
1071 /* Clean cache before cleaning memory pool */
1072 if (edf->collection_cache) _edje_cache_coll_flush(edf);
1073
1074 HASH_FREE(edf->fonts);
1075 HASH_FREE(edf->collection);
1076 HASH_FREE(edf->data);
1077
1078 if (edf->image_dir)
1079 {
1080 unsigned int i;
1081
1082 if (edf->free_strings)
1083 {
1084 for (i = 0; i < edf->image_dir->entries_count; ++i)
1085 eina_stringshare_del(edf->image_dir->entries[i].entry);
1086 }
1087
1088 /* Sets have been added after edje received eet dictionnary support */
1089 for (i = 0; i < edf->image_dir->sets_count; ++i)
1090 {
1091 Edje_Image_Directory_Set_Entry *se;
1092
1093 EINA_LIST_FREE(edf->image_dir->sets[i].entries, se)
1094 free(se);
1095
1096 }
1097
1098 free(edf->image_dir->entries);
1099 free(edf->image_dir->sets);
1100 free(edf->image_dir);
1101 }
1102 if (edf->sound_dir)
1103 {
1104 unsigned int i;
1105
1106 if (edf->free_strings)
1107 {
1108 for (i = 0; i < edf->sound_dir->samples_count; ++i)
1109 {
1110 eina_stringshare_del(edf->sound_dir->samples[i].name);
1111 eina_stringshare_del(edf->sound_dir->samples[i].snd_src);
1112 }
1113
1114 for (i = 0; i < edf->sound_dir->tones_count; ++i)
1115 eina_stringshare_del(edf->sound_dir->tones[i].name);
1116 }
1117 free(edf->sound_dir->samples);
1118 free(edf->sound_dir->tones);
1119 free(edf->sound_dir);
1120 }
1121
1122 if (edf->external_dir)
1123 {
1124 if (edf->external_dir->entries) free(edf->external_dir->entries);
1125 free(edf->external_dir);
1126 }
1127
1128 EINA_LIST_FREE(edf->color_classes, ecc)
1129 {
1130 if (edf->free_strings && ecc->name) eina_stringshare_del(ecc->name);
1131 free(ecc);
1132 }
1133
1134 if (edf->collection_patterns) edje_match_patterns_free(edf->collection_patterns);
1135 if (edf->path) eina_stringshare_del(edf->path);
1136 if (edf->free_strings && edf->compiler) eina_stringshare_del(edf->compiler);
1137 _edje_textblock_style_cleanup(edf);
1138 if (edf->ef) eet_close(edf->ef);
1139 free(edf);
1140}
1141
1142static void
1143_edje_program_free(Edje_Program *pr, Eina_Bool free_strings)
1144{
1145 Edje_Program_Target *prt;
1146 Edje_Program_After *pa;
1147
1148 if (free_strings)
1149 {
1150 if (pr->name) eina_stringshare_del(pr->name);
1151 if (pr->signal) eina_stringshare_del(pr->signal);
1152 if (pr->source) eina_stringshare_del(pr->source);
1153 if (pr->filter.part) eina_stringshare_del(pr->filter.part);
1154 if (pr->filter.state) eina_stringshare_del(pr->filter.state);
1155 if (pr->state) eina_stringshare_del(pr->state);
1156 if (pr->state2) eina_stringshare_del(pr->state2);
1157 if (pr->sample_name) eina_stringshare_del(pr->sample_name);
1158 if (pr->tone_name) eina_stringshare_del(pr->tone_name);
1159 }
1160 EINA_LIST_FREE(pr->targets, prt)
1161 free(prt);
1162 EINA_LIST_FREE(pr->after, pa)
1163 free(pa);
1164 free(pr);
1165}
1166
1167void
1168_edje_collection_free(Edje_File *edf, Edje_Part_Collection *ec, Edje_Part_Collection_Directory_Entry *ce)
1169{
1170 unsigned int i;
1171
1172 _edje_embryo_script_shutdown(ec);
1173
1174#define EDJE_LOAD_PROGRAM_FREE(Array, Ec, It, FreeStrings) \
1175 for (It = 0; It < Ec->programs.Array##_count; ++It) \
1176 _edje_program_free(Ec->programs.Array[It], FreeStrings); \
1177 free(Ec->programs.Array);
1178
1179 EDJE_LOAD_PROGRAM_FREE(fnmatch, ec, i, edf->free_strings);
1180 EDJE_LOAD_PROGRAM_FREE(strcmp, ec, i, edf->free_strings);
1181 EDJE_LOAD_PROGRAM_FREE(strncmp, ec, i, edf->free_strings);
1182 EDJE_LOAD_PROGRAM_FREE(strrncmp, ec, i, edf->free_strings);
1183 EDJE_LOAD_PROGRAM_FREE(nocmp, ec, i, edf->free_strings);
1184
1185 for (i = 0; i < ec->parts_count; ++i)
1186 {
1187 Edje_Part *ep;
1188 unsigned int j;
1189
1190 ep = ec->parts[i];
1191
1192 if (edf->free_strings && ep->name) eina_stringshare_del(ep->name);
1193 if (ep->default_desc)
1194 {
1195 _edje_collection_free_part_description_clean(ep->type, ep->default_desc, edf->free_strings);
1196 ep->default_desc = NULL;
1197 }
1198 for (j = 0; j < ep->other.desc_count; ++j)
1199 _edje_collection_free_part_description_clean(ep->type, ep->other.desc[j], edf->free_strings);
1200
1201 free(ep->other.desc);
1202 /* Alloc for RTL objects in edje_calc.c:_edje_part_description_find() */
1203 if(ep->other.desc_rtl)
1204 free(ep->other.desc_rtl);
1205
1206 free(ep->items);
1207// technically need this - but we ASSUME we use "one_big" so everything gets
1208// freed in one go lower down when we del the mempool... but what if pool goes
1209// "over"?
1210 eina_mempool_free(ce->mp.part, ep);
1211 }
1212 free(ec->parts);
1213 ec->parts = NULL;
1214
1215 if (ec->data)
1216 {
1217 Eina_Iterator *it;
1218 Edje_String *es;
1219
1220 it = eina_hash_iterator_data_new(ec->data);
1221 EINA_ITERATOR_FOREACH(it, es)
1222 free(es);
1223 eina_iterator_free(it);
1224
1225 eina_hash_free(ec->data);
1226 }
1227#ifdef EDJE_PROGRAM_CACHE
1228 if (ec->prog_cache.no_matches) eina_hash_free(ec->prog_cache.no_matches);
1229 if (ec->prog_cache.matches)
1230 {
1231 eina_hash_foreach(ec->prog_cache.matches,
1232 _edje_collection_free_prog_cache_matches_free_cb,
1233 NULL);
1234 eina_hash_free(ec->prog_cache.matches);
1235 }
1236#endif
1237 if (ec->script) embryo_program_free(ec->script);
1238 _edje_lua2_script_unload(ec);
1239
1240 /* Destroy all part and description. */
1241 eina_mempool_del(ce->mp.RECTANGLE);
1242 eina_mempool_del(ce->mp.TEXT);
1243 eina_mempool_del(ce->mp.IMAGE);
1244 eina_mempool_del(ce->mp.PROXY);
1245 eina_mempool_del(ce->mp.SWALLOW);
1246 eina_mempool_del(ce->mp.TEXTBLOCK);
1247 eina_mempool_del(ce->mp.GROUP);
1248 eina_mempool_del(ce->mp.BOX);
1249 eina_mempool_del(ce->mp.TABLE);
1250 eina_mempool_del(ce->mp.EXTERNAL);
1251 eina_mempool_del(ce->mp.part);
1252 memset(&ce->mp, 0, sizeof (ce->mp));
1253
1254 eina_mempool_del(ce->mp_rtl.RECTANGLE);
1255 eina_mempool_del(ce->mp_rtl.TEXT);
1256 eina_mempool_del(ce->mp_rtl.IMAGE);
1257 eina_mempool_del(ce->mp_rtl.PROXY);
1258 eina_mempool_del(ce->mp_rtl.SWALLOW);
1259 eina_mempool_del(ce->mp_rtl.TEXTBLOCK);
1260 eina_mempool_del(ce->mp_rtl.GROUP);
1261 eina_mempool_del(ce->mp_rtl.BOX);
1262 eina_mempool_del(ce->mp_rtl.TABLE);
1263 eina_mempool_del(ce->mp_rtl.EXTERNAL);
1264 memset(&ce->mp_rtl, 0, sizeof (ce->mp_rtl));
1265 free(ec);
1266 ce->ref = NULL;
1267}
1268
1269void
1270_edje_collection_free_part_description_clean(int type, Edje_Part_Description_Common *desc, Eina_Bool free_strings)
1271{
1272 if (free_strings && desc->color_class) eina_stringshare_del(desc->color_class);
1273
1274 switch (type)
1275 {
1276 case EDJE_PART_TYPE_IMAGE:
1277 {
1278 Edje_Part_Description_Image *img;
1279 unsigned int i;
1280
1281 img = (Edje_Part_Description_Image *) desc;
1282
1283 for (i = 0; i < img->image.tweens_count; ++i)
1284 free(img->image.tweens[i]);
1285 free(img->image.tweens);
1286 break;
1287 }
1288 case EDJE_PART_TYPE_EXTERNAL:
1289 {
1290 Edje_Part_Description_External *external;
1291
1292 external = (Edje_Part_Description_External *) desc;
1293
1294 if (external->external_params)
1295 _edje_external_params_free(external->external_params, free_strings);
1296 break;
1297 }
1298 case EDJE_PART_TYPE_TEXT:
1299 case EDJE_PART_TYPE_TEXTBLOCK:
1300 if (free_strings)
1301 {
1302 Edje_Part_Description_Text *text;
1303
1304 text = (Edje_Part_Description_Text *) desc;
1305
1306 if (text->text.text.str) eina_stringshare_del(text->text.text.str);
1307 if (text->text.text_class) eina_stringshare_del(text->text.text_class);
1308 if (text->text.style.str) eina_stringshare_del(text->text.style.str);
1309 if (text->text.font.str) eina_stringshare_del(text->text.font.str);
1310 }
1311 break;
1312 }
1313}
1314
1315void
1316_edje_collection_free_part_description_free(int type,
1317 Edje_Part_Description_Common *desc,
1318 Edje_Part_Collection_Directory_Entry *ce,
1319 Eina_Bool free_strings)
1320{
1321#define FREE_POOL(Type, Ce, Desc) \
1322 case EDJE_PART_TYPE_##Type: eina_mempool_free(Ce->mp.Type, Desc); \
1323 ce->count.Type--; \
1324 break;
1325
1326 _edje_collection_free_part_description_clean(type, desc, free_strings);
1327
1328 switch (type)
1329 {
1330 FREE_POOL(RECTANGLE, ce, desc);
1331 FREE_POOL(TEXT, ce, desc);
1332 FREE_POOL(IMAGE, ce, desc);
1333 FREE_POOL(PROXY, ce, desc);
1334 FREE_POOL(SWALLOW, ce, desc);
1335 FREE_POOL(TEXTBLOCK, ce, desc);
1336 FREE_POOL(GROUP, ce, desc);
1337 FREE_POOL(BOX, ce, desc);
1338 FREE_POOL(TABLE, ce, desc);
1339 FREE_POOL(EXTERNAL, ce, desc);
1340 }
1341}
1342
1343#ifdef EDJE_PROGRAM_CACHE
1344static Eina_Bool
1345_edje_collection_free_prog_cache_matches_free_cb(const Eina_Hash *hash, const void *key, void *data, void *fdata)
1346{
1347 eina_list_free((Eina_List *)data);
1348 return EINA_TRUE;
1349 key = NULL;
1350 hash = NULL;
1351 fdata = NULL;
1352}
1353#endif
1354
1355static void
1356_edje_object_pack_item_hints_set(Evas_Object *obj, Edje_Pack_Element *it)
1357{
1358 Evas_Coord w = 0, h = 0, minw, minh;
1359
1360 minw = it->min.w;
1361 minh = it->min.h;
1362
1363 if ((minw <= 0) && (minh <= 0))
1364 {
1365 edje_object_size_min_get(obj, &w, &h);
1366 if ((w <= 0) && (h <= 0))
1367 edje_object_size_min_calc(obj, &w, &h);
1368 }
1369 else
1370 {
1371 w = minw;
1372 h = minh;
1373 }
1374 if (((minw <= 0) && (minh <= 0)) && ((w > 0) || (h > 0)))
1375 evas_object_size_hint_min_set(obj, w, h);
1376 else
1377 evas_object_size_hint_min_set(obj, minw, minh);
1378
1379 evas_object_size_hint_request_set(obj, it->prefer.w, it->prefer.h);
1380 evas_object_size_hint_max_set(obj, it->max.w, it->max.h);
1381 evas_object_size_hint_padding_set(obj, it->padding.l, it->padding.r, it->padding.t, it->padding.b);
1382 evas_object_size_hint_align_set(obj, it->align.x, it->align.y);
1383 evas_object_size_hint_weight_set(obj, it->weight.x, it->weight.y);
1384 evas_object_size_hint_aspect_set(obj, it->aspect.mode, it->aspect.w, it->aspect.h);
1385
1386 evas_object_resize(obj, w, h);
1387}
1388
1389static const char *
1390_edje_find_alias(Eina_Hash *aliased, char *src, int *length)
1391{
1392 const char *alias;
1393 char *search;
1394
1395 *length = strlen(src);
1396 if (*length == 0) return NULL;
1397
1398 alias = eina_hash_find(aliased, src);
1399 if (alias) return alias;
1400
1401 search = strrchr(src, EDJE_PART_PATH_SEPARATOR);
1402 if (search == NULL) return NULL;
1403
1404 *search = '\0';
1405 alias = _edje_find_alias(aliased, src, length);
1406 *search = EDJE_PART_PATH_SEPARATOR;
1407
1408 return alias;
1409}
1410
1411static void
1412_cb_signal_repeat(void *data, Evas_Object *obj, const char *sig, const char *source)
1413{
1414 Edje_Pack_Element *pack_it;
1415 Evas_Object *parent;
1416 Edje *ed;
1417 Edje *ed_parent;
1418 char new_src[4096]; /* XXX is this max reasonable? */
1419 size_t length_parent = 0;
1420 size_t length_index = 0;
1421 size_t length_source;
1422 int i = 0;
1423 const char *alias = NULL;
1424 Edje_Message_Signal emsg;
1425
1426 parent = data;
1427 ed = _edje_fetch(obj);
1428 if (!ed) return;
1429
1430 pack_it = evas_object_data_get(obj, "\377 edje.box_item");
1431 if (!pack_it) pack_it = evas_object_data_get(obj, "\377 edje.table_item");
1432 if (pack_it)
1433 {
1434 if (!pack_it->name)
1435 {
1436 Eina_List *child = NULL;
1437 Evas_Object *o;
1438
1439 if (pack_it->parent->part->type == EDJE_PART_TYPE_BOX)
1440 {
1441 child = evas_object_box_children_get(pack_it->parent->object);
1442 }
1443 else if (pack_it->parent->part->type == EDJE_PART_TYPE_TABLE)
1444 {
1445 child = evas_object_table_children_get(pack_it->parent->object);
1446 }
1447
1448 EINA_LIST_FREE(child, o)
1449 {
1450 if (o == obj) break;
1451 i++;
1452 }
1453
1454 eina_list_free(child);
1455
1456 length_index = 12;
1457 }
1458 else
1459 {
1460 length_index = strlen(pack_it->name) + 2;
1461 }
1462 }
1463
1464 /* Replace snprint("%s%c%s") == memcpy + *new_src + memcat */
1465 if (ed->parent)
1466 length_parent = strlen(ed->parent);
1467 length_source = strlen(source);
1468 if (length_source + length_parent + 2 + length_index > sizeof(new_src))
1469 return;
1470
1471 if (ed->parent)
1472 memcpy(new_src, ed->parent, length_parent);
1473 if (ed->parent && length_index)
1474 {
1475 new_src[length_parent++] = EDJE_PART_PATH_SEPARATOR_INDEXL;
1476 if (length_index == 12)
1477 length_parent += eina_convert_itoa(i, new_src + length_parent);
1478 else
1479 {
1480 memcpy(new_src + length_parent, pack_it->name, length_index);
1481 length_parent += length_index - 2;
1482 }
1483 new_src[length_parent++] = EDJE_PART_PATH_SEPARATOR_INDEXR;
1484 }
1485
1486 new_src[length_parent] = EDJE_PART_PATH_SEPARATOR;
1487 memcpy(new_src + length_parent + 1, source, length_source + 1);
1488
1489 /* Handle alias renaming */
1490 ed_parent = _edje_fetch(parent);
1491 if (ed_parent && ed_parent->collection && ed_parent->collection->aliased)
1492 {
1493 int length;
1494
1495 alias = _edje_find_alias(ed_parent->collection->aliased, new_src, &length);
1496
1497 if (alias)
1498 {
1499 int origin;
1500
1501 /* Add back the end of the source */
1502 origin = strlen(new_src);
1503 length ++; /* Remove the trailing ':' from the count */
1504 if (origin > length)
1505 {
1506 char *tmp;
1507 size_t alias_length;
1508
1509 alias_length = strlen(alias);
1510 tmp = alloca(alias_length + origin - length + 2);
1511 memcpy(tmp, alias, alias_length);
1512 tmp[alias_length] = EDJE_PART_PATH_SEPARATOR;
1513 memcpy(tmp + alias_length + 1, new_src + length, origin - length + 1);
1514
1515 alias = tmp;
1516 }
1517 }
1518 }
1519
1520 emsg.sig = sig;
1521 emsg.src = alias ? alias : new_src;
1522 emsg.data = NULL;
1523 _edje_message_send(ed_parent, EDJE_QUEUE_SCRIPT,
1524 EDJE_MESSAGE_SIGNAL, 0, &emsg);
1525}