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.c151
1 files changed, 80 insertions, 71 deletions
diff --git a/libraries/edje/src/lib/edje_load.c b/libraries/edje/src/lib/edje_load.c
index 644bb7c..8fe5842 100644
--- a/libraries/edje/src/lib/edje_load.c
+++ b/libraries/edje/src/lib/edje_load.c
@@ -262,6 +262,10 @@ _edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *g
262{ 262{
263 Edje *ed; 263 Edje *ed;
264 Evas *tev; 264 Evas *tev;
265 Edje_Real_Part *rp;
266 Eina_List *textblocks = NULL;
267 Eina_List *sources = NULL;
268 Eina_List *externals = NULL;
265 Eina_List *old_swallows; 269 Eina_List *old_swallows;
266 unsigned int n; 270 unsigned int n;
267 Eina_List *parts = NULL; 271 Eina_List *parts = NULL;
@@ -323,7 +327,6 @@ _edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *g
323 else 327 else
324 { 328 {
325 unsigned int i; 329 unsigned int i;
326 int errors = 0;
327 330
328 /* colorclass stuff */ 331 /* colorclass stuff */
329 for (i = 0; i < ed->collection->parts_count; ++i) 332 for (i = 0; i < ed->collection->parts_count; ++i)
@@ -333,8 +336,6 @@ _edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *g
333 336
334 ep = ed->collection->parts[i]; 337 ep = ed->collection->parts[i];
335 338
336 if (errors)
337 break;
338 /* Register any color classes in this parts descriptions. */ 339 /* Register any color classes in this parts descriptions. */
339 if ((ep->default_desc) && (ep->default_desc->color_class)) 340 if ((ep->default_desc) && (ep->default_desc->color_class))
340 _edje_color_class_member_add(ed, ep->default_desc->color_class); 341 _edje_color_class_member_add(ed, ep->default_desc->color_class);
@@ -353,12 +354,12 @@ _edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *g
353 for (n = 0; n < ed->collection->parts_count; n++) 354 for (n = 0; n < ed->collection->parts_count; n++)
354 { 355 {
355 Edje_Part *ep; 356 Edje_Part *ep;
356 Edje_Real_Part *rp;
357 357
358 ep = ed->collection->parts[n]; 358 ep = ed->collection->parts[n];
359 rp = eina_mempool_malloc(_edje_real_part_mp, sizeof(Edje_Real_Part)); 359 rp = eina_mempool_malloc(_edje_real_part_mp, sizeof(Edje_Real_Part));
360 if (!rp) 360 if (!rp)
361 { 361 {
362 /* FIXME: destroy all allocated ressource, need to have a common exit point */
362 ed->load_error = EDJE_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED; 363 ed->load_error = EDJE_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED;
363 evas_event_thaw(tev); 364 evas_event_thaw(tev);
364 evas_event_thaw_eval(tev); 365 evas_event_thaw_eval(tev);
@@ -373,7 +374,7 @@ _edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *g
373 if (!rp->drag) 374 if (!rp->drag)
374 { 375 {
375 ed->load_error = EDJE_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED; 376 ed->load_error = EDJE_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED;
376 free(rp); 377 eina_mempool_free(_edje_real_part_mp, rp);
377 evas_event_thaw(tev); 378 evas_event_thaw(tev);
378 evas_event_thaw_eval(tev); 379 evas_event_thaw_eval(tev);
379 return 0; 380 return 0;
@@ -407,9 +408,12 @@ _edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *g
407 rp->object = evas_object_text_add(ed->base.evas); 408 rp->object = evas_object_text_add(ed->base.evas);
408 evas_object_text_font_source_set(rp->object, ed->path); 409 evas_object_text_font_source_set(rp->object, ed->path);
409 break; 410 break;
410 case EDJE_PART_TYPE_SWALLOW:
411 case EDJE_PART_TYPE_GROUP: 411 case EDJE_PART_TYPE_GROUP:
412 sources = eina_list_append(sources, rp);
413 case EDJE_PART_TYPE_SWALLOW:
412 case EDJE_PART_TYPE_EXTERNAL: 414 case EDJE_PART_TYPE_EXTERNAL:
415 if (ep->type == EDJE_PART_TYPE_EXTERNAL)
416 externals = eina_list_append(externals, rp);
413 rp->object = evas_object_rectangle_add(ed->base.evas); 417 rp->object = evas_object_rectangle_add(ed->base.evas);
414 evas_object_color_set(rp->object, 0, 0, 0, 0); 418 evas_object_color_set(rp->object, 0, 0, 0, 0);
415 evas_object_pass_events_set(rp->object, 1); 419 evas_object_pass_events_set(rp->object, 1);
@@ -417,13 +421,16 @@ _edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *g
417 _edje_callbacks_focus_add(rp->object, ed, rp); 421 _edje_callbacks_focus_add(rp->object, ed, rp);
418 break; 422 break;
419 case EDJE_PART_TYPE_TEXTBLOCK: 423 case EDJE_PART_TYPE_TEXTBLOCK:
424 textblocks = eina_list_append(textblocks, rp);
420 rp->object = evas_object_textblock_add(ed->base.evas); 425 rp->object = evas_object_textblock_add(ed->base.evas);
421 break; 426 break;
422 case EDJE_PART_TYPE_BOX: 427 case EDJE_PART_TYPE_BOX:
428 sources = eina_list_append(sources, rp);
423 rp->object = evas_object_box_add(ed->base.evas); 429 rp->object = evas_object_box_add(ed->base.evas);
424 rp->anim = _edje_box_layout_anim_new(rp->object); 430 rp->anim = _edje_box_layout_anim_new(rp->object);
425 break; 431 break;
426 case EDJE_PART_TYPE_TABLE: 432 case EDJE_PART_TYPE_TABLE:
433 sources = eina_list_append(sources, rp);
427 rp->object = evas_object_table_add(ed->base.evas); 434 rp->object = evas_object_table_add(ed->base.evas);
428 break; 435 break;
429 case EDJE_PART_TYPE_GRADIENT: 436 case EDJE_PART_TYPE_GRADIENT:
@@ -463,7 +470,6 @@ _edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *g
463 } 470 }
464 if (n > 0) 471 if (n > 0)
465 { 472 {
466 Edje_Real_Part *rp;
467 Eina_List *l; 473 Eina_List *l;
468 474
469 ed->table_parts = malloc(sizeof(Edje_Real_Part *) * n); 475 ed->table_parts = malloc(sizeof(Edje_Real_Part *) * n);
@@ -519,7 +525,7 @@ _edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *g
519 } 525 }
520 526
521 rp->swallow_params.min.w = 0; 527 rp->swallow_params.min.w = 0;
522 rp->swallow_params.min.w = 0; 528 rp->swallow_params.min.h = 0;
523 rp->swallow_params.max.w = -1; 529 rp->swallow_params.max.w = -1;
524 rp->swallow_params.max.h = -1; 530 rp->swallow_params.max.h = -1;
525 531
@@ -587,8 +593,6 @@ _edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *g
587 _edje_var_init(ed); 593 _edje_var_init(ed);
588 for (i = 0; i < ed->table_parts_size; i++) 594 for (i = 0; i < ed->table_parts_size; i++)
589 { 595 {
590 Edje_Real_Part *rp;
591
592 rp = ed->table_parts[i]; 596 rp = ed->table_parts[i];
593 evas_object_show(rp->object); 597 evas_object_show(rp->object);
594 if (_edje_block_break(ed)) break; 598 if (_edje_block_break(ed)) break;
@@ -599,6 +603,7 @@ _edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *g
599 _edje_dragable_pos_set(ed, rp, rp->drag->val.x, rp->drag->val.y); 603 _edje_dragable_pos_set(ed, rp, rp->drag->val.x, rp->drag->val.y);
600 } 604 }
601 } 605 }
606 ed->recalc_call = 1;
602 ed->dirty = 1; 607 ed->dirty = 1;
603#ifdef EDJE_CALC_CACHE 608#ifdef EDJE_CALC_CACHE
604 ed->all_part_change = 1; 609 ed->all_part_change = 1;
@@ -606,11 +611,28 @@ _edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *g
606 if ((evas_object_clipees_get(ed->base.clipper)) && 611 if ((evas_object_clipees_get(ed->base.clipper)) &&
607 (evas_object_visible_get(obj))) 612 (evas_object_visible_get(obj)))
608 evas_object_show(ed->base.clipper); 613 evas_object_show(ed->base.clipper);
609 614
610 /* instantiate 'internal swallows' */ 615 /* instantiate 'internal swallows' */
611 for (i = 0; i < ed->table_parts_size; i++) 616 EINA_LIST_FREE(externals, rp)
617 {
618 Edje_Part_Description_External *external;
619 Evas_Object *child_obj;
620
621 external = (Edje_Part_Description_External *) rp->part->default_desc;
622 child_obj = _edje_external_type_add(rp->part->source,
623 evas_object_evas_get(ed->obj), ed->obj,
624 external->external_params, rp->part->name);
625 if (child_obj)
626 {
627 _edje_real_part_swallow(rp, child_obj, EINA_TRUE);
628 rp->param1.external_params = _edje_external_params_parse(child_obj,
629 external->external_params);
630 _edje_external_recalc_apply(ed, rp, NULL, rp->chosen_description);
631 }
632 }
633
634 EINA_LIST_FREE(sources, rp)
612 { 635 {
613 Edje_Real_Part *rp;
614 /* XXX: curr_item and pack_it don't require to be NULL since 636 /* 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, 637 * 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 638 * XXX: and they're always set in this case, but GCC fails to
@@ -620,8 +642,6 @@ _edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *g
620 unsigned int item_count = 0; 642 unsigned int item_count = 0;
621 Edje_Pack_Element *pack_it = NULL; 643 Edje_Pack_Element *pack_it = NULL;
622 const char *source = NULL; 644 const char *source = NULL;
623
624 rp = ed->table_parts[i];
625 645
626 switch (rp->part->type) 646 switch (rp->part->type)
627 { 647 {
@@ -643,25 +663,9 @@ _edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *g
643 } 663 }
644 } 664 }
645 break; 665 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: 666 default:
667 /* This list should only be filled by group, box or table, nothing else. */
668 abort();
665 continue; 669 continue;
666 } 670 }
667 671
@@ -682,6 +686,11 @@ _edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *g
682 { 686 {
683 if (data == group_path_entry) 687 if (data == group_path_entry)
684 { 688 {
689 ERR("recursive loop group '%s' already included inside part '%s' of group '%s' from file '%s'",
690 group_path_entry, rp->part->name, group, file);
691 textblocks = eina_list_free(textblocks);
692 externals = eina_list_free(externals);
693 sources = eina_list_free(sources);
685 _edje_thaw(ed); 694 _edje_thaw(ed);
686 _edje_unblock(ed); 695 _edje_unblock(ed);
687 _edje_unref(ed); 696 _edje_unref(ed);
@@ -698,7 +707,7 @@ _edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *g
698 return 0; 707 return 0;
699 } 708 }
700 } 709 }
701 710
702 child_obj = edje_object_add(ed->base.evas); 711 child_obj = edje_object_add(ed->base.evas);
703 group_path = eina_list_append(group_path, group_path_entry); 712 group_path = eina_list_append(group_path, group_path_entry);
704 if (rp->part->type == EDJE_PART_TYPE_GROUP) 713 if (rp->part->type == EDJE_PART_TYPE_GROUP)
@@ -708,11 +717,16 @@ _edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *g
708 717
709 if (!_edje_object_file_set_internal(child_obj, file, source, rp->part->name, group_path)) 718 if (!_edje_object_file_set_internal(child_obj, file, source, rp->part->name, group_path))
710 { 719 {
720 ERR("impossible to set part '%s' of group '%s' from file '%s' to '%s'",
721 rp->part->name, group_path_entry, file, source);
722 textblocks = eina_list_free(textblocks);
723 externals = eina_list_free(externals);
724 sources = eina_list_free(sources);
711 _edje_thaw(ed); 725 _edje_thaw(ed);
712 _edje_unblock(ed); 726 _edje_unblock(ed);
713 _edje_unref(ed); 727 _edje_unref(ed);
714 _edje_file_del(ed); 728 _edje_file_del(ed);
715 729
716 if (group_path_started) 730 if (group_path_started)
717 { 731 {
718 while (group_path) 732 while (group_path)
@@ -794,56 +808,51 @@ _edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *g
794 { 808 {
795 const char *name; 809 const char *name;
796 Evas_Object *swallow; 810 Evas_Object *swallow;
797 811
798 name = eina_list_data_get(old_swallows); 812 name = eina_list_data_get(old_swallows);
799 old_swallows = eina_list_remove_list(old_swallows, old_swallows); 813 old_swallows = eina_list_remove_list(old_swallows, old_swallows);
800 814
801 swallow = eina_list_data_get(old_swallows); 815 swallow = eina_list_data_get(old_swallows);
802 old_swallows = eina_list_remove_list(old_swallows, old_swallows); 816 old_swallows = eina_list_remove_list(old_swallows, old_swallows);
803 817
804 edje_object_part_swallow(obj, name, swallow); 818 edje_object_part_swallow(obj, name, swallow);
805 eina_stringshare_del(name); 819 eina_stringshare_del(name);
806 } 820 }
807 } 821 }
808 822
809 _edje_recalc(ed); 823 _edje_recalc(ed);
810 _edje_thaw(ed); 824 _edje_thaw(ed);
811 _edje_unblock(ed); 825 _edje_unblock(ed);
812 _edje_unref(ed); 826 _edje_unref(ed);
813 ed->load_error = EDJE_LOAD_ERROR_NONE; 827 ed->load_error = EDJE_LOAD_ERROR_NONE;
814 _edje_emit(ed, "load", NULL); 828 _edje_emit(ed, "load", NULL);
815 /* instantiate 'internal swallows' */ 829
816 for (i = 0; i < ed->table_parts_size; i++) 830 /* instantiate 'internal textblock style' */
817 { 831 EINA_LIST_FREE(textblocks, rp)
818 Edje_Real_Part *rp; 832 if (rp->part->default_desc)
819 833 {
820 rp = ed->table_parts[i]; 834 Edje_Part_Description_Text *text;
821 if ((rp->part->type == EDJE_PART_TYPE_TEXTBLOCK) && 835 Edje_Style *stl = NULL;
822 (rp->part->default_desc)) 836 const char *style;
823 { 837
824 Edje_Part_Description_Text *text; 838 text = (Edje_Part_Description_Text *) rp->part->default_desc;
825 Edje_Style *stl = NULL; 839 style = edje_string_get(&text->text.style);
826 const char *style; 840 if (style)
827 841 {
828 text = (Edje_Part_Description_Text *) rp->part->default_desc; 842 Eina_List *l;
829 style = edje_string_get(&text->text.style); 843
830 if (style) 844 EINA_LIST_FOREACH(ed->file->styles, l, stl)
831 { 845 {
832 Eina_List *l; 846 if ((stl->name) && (!strcmp(stl->name, style))) break;
833 847 stl = NULL;
834 EINA_LIST_FOREACH(ed->file->styles, l, stl) 848 }
835 { 849 }
836 if ((stl->name) && (!strcmp(stl->name, style))) break; 850 if (stl)
837 stl = NULL; 851 {
838 } 852 if (evas_object_textblock_style_get(rp->object) != stl->style)
839 } 853 evas_object_textblock_style_set(rp->object, stl->style);
840 if (stl) 854 }
841 { 855 }
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 } 856 }
848 _edje_entry_init(ed); 857 _edje_entry_init(ed);
849 evas_event_thaw(tev); 858 evas_event_thaw(tev);