summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@samsung.com>2014-03-21 14:28:29 -0400
committerMike Blumenkrantz <zmike@samsung.com>2014-03-21 15:12:38 -0400
commit153e3b45b476cc9514a0a8385af788ea6b0eaa61 (patch)
tree4f132af0b7db989975574a014f921f1c795c2ffd /src
parentcc6eed2f86fc24cc1b5bfe978ac1aec77784b827 (diff)
edje_cc now supports group.remove for removing parts from inherited groups
@feature
Diffstat (limited to 'src')
-rw-r--r--src/bin/edje/edje_cc_handlers.c115
1 files changed, 115 insertions, 0 deletions
diff --git a/src/bin/edje/edje_cc_handlers.c b/src/bin/edje/edje_cc_handlers.c
index 4f3a9b3..828b6f3 100644
--- a/src/bin/edje/edje_cc_handlers.c
+++ b/src/bin/edje/edje_cc_handlers.c
@@ -137,6 +137,7 @@ static Edje_Pack_Element *current_item = NULL;
137static Edje_Part_Description_Common *current_desc = NULL; 137static Edje_Part_Description_Common *current_desc = NULL;
138static Edje_Part_Description_Common *parent_desc = NULL; 138static Edje_Part_Description_Common *parent_desc = NULL;
139static Edje_Program *current_program = NULL; 139static Edje_Program *current_program = NULL;
140static Eina_Bool current_group_inherit = EINA_FALSE;
140 141
141struct _Edje_Cc_Handlers_Hierarchy_Info 142struct _Edje_Cc_Handlers_Hierarchy_Info
142{ /* Struct that keeps globals value to impl hierarchy */ 143{ /* Struct that keeps globals value to impl hierarchy */
@@ -189,6 +190,7 @@ static void ob_collections(void);
189static void ob_collections_group(void); 190static void ob_collections_group(void);
190static void st_collections_group_name(void); 191static void st_collections_group_name(void);
191static void st_collections_group_inherit(void); 192static void st_collections_group_inherit(void);
193static void st_collections_group_remove(void);
192static void st_collections_group_script_only(void); 194static void st_collections_group_script_only(void);
193static void st_collections_group_alias(void); 195static void st_collections_group_alias(void);
194static void st_collections_group_min(void); 196static void st_collections_group_min(void);
@@ -456,6 +458,7 @@ New_Statement_Handler statement_handlers[] =
456 {"collections.grpup.vibrations.sample.source", st_collections_group_vibration_sample_source}, /* dup */ 458 {"collections.grpup.vibrations.sample.source", st_collections_group_vibration_sample_source}, /* dup */
457 {"collections.group.name", st_collections_group_name}, 459 {"collections.group.name", st_collections_group_name},
458 {"collections.group.inherit", st_collections_group_inherit}, 460 {"collections.group.inherit", st_collections_group_inherit},
461 {"collections.group.remove", st_collections_group_remove},
459 {"collections.group.script_only", st_collections_group_script_only}, 462 {"collections.group.script_only", st_collections_group_script_only},
460 {"collections.group.lua_script_only", st_collections_group_script_only}, 463 {"collections.group.lua_script_only", st_collections_group_script_only},
461 {"collections.group.alias", st_collections_group_alias}, 464 {"collections.group.alias", st_collections_group_alias},
@@ -2709,6 +2712,7 @@ ob_collections_group(void)
2709 ERR("A collection without a name was detected, that's not allowed."); 2712 ERR("A collection without a name was detected, that's not allowed.");
2710 exit(-1); 2713 exit(-1);
2711 } 2714 }
2715 current_group_inherit = EINA_FALSE;
2712 2716
2713 current_de = mem_alloc(SZ(Edje_Part_Collection_Directory_Entry)); 2717 current_de = mem_alloc(SZ(Edje_Part_Collection_Directory_Entry));
2714 current_de->id = eina_list_count(edje_collections); 2718 current_de->id = eina_list_count(edje_collections);
@@ -3092,6 +3096,7 @@ st_collections_group_inherit(void)
3092 } 3096 }
3093 3097
3094 free(parent_name); 3098 free(parent_name);
3099 current_group_inherit = EINA_TRUE;
3095 #undef STRDUP 3100 #undef STRDUP
3096} 3101}
3097 3102
@@ -3643,6 +3648,116 @@ ob_collections_group_parts_part(void)
3643 prnt->nested_children_count++; 3648 prnt->nested_children_count++;
3644} 3649}
3645 3650
3651static void *
3652_part_desc_free(Edje_Part_Description_Common *ed)
3653{
3654 if (!ed) return NULL;
3655 free((void*)ed->state.name);
3656 free(ed);
3657 return NULL;
3658}
3659
3660static void *
3661_part_free(Edje_Part *ep)
3662{
3663 Edje_Part_Parser *epp = (Edje_Part_Parser*)ep;
3664 unsigned int j;
3665
3666 free((void*)ep->name);
3667 free((void*)ep->source);
3668 free((void*)ep->source2);
3669 free((void*)ep->source3);
3670 free((void*)ep->source4);
3671 free((void*)ep->source5);
3672 free((void*)ep->source6);
3673
3674 free((void*)epp->reorder.insert_before);
3675 free((void*)epp->reorder.insert_after);
3676
3677 for (j = 0 ; j < ep->items_count ; j++)
3678 free(ep->items[j]);
3679 free(ep->items);
3680
3681 free((void*)ep->api.name);
3682 free((void*)ep->api.description);
3683
3684 _part_desc_free(ep->default_desc);
3685 for (j = 0 ; j < ep->other.desc_count ; j++)
3686 _part_desc_free(ep->other.desc[j]);
3687 free(ep->other.desc);
3688 free(ep);
3689 return NULL;
3690}
3691
3692/**
3693 @page edcref
3694 @property
3695 remove
3696 @parameters
3697 [part name] [part name] [part name] ...
3698 @effect
3699 Removes the listed parts from an inherited group. Removing nonexistent
3700 parts is not allowed.
3701 @endproperty
3702 @since 1.10
3703*/
3704static void
3705st_collections_group_remove(void)
3706{
3707 unsigned int n, argc, orig_count;
3708 Edje_Part_Collection *pc;
3709
3710 check_min_arg_count(1);
3711
3712 if (!current_group_inherit)
3713 {
3714 ERR("Cannot remove parts from non-inherited group '%s'", current_de->entry);
3715 exit(-1);
3716 }
3717
3718 pc = eina_list_last_data_get(edje_collections);
3719 orig_count = pc->parts_count;
3720
3721 for (n = 0, argc = get_arg_count(); n < argc; n++)
3722 {
3723 char *name;
3724 unsigned int j, cur_count = pc->parts_count;
3725
3726 name = parse_str(n);
3727
3728 for (j = 0; j < pc->parts_count; j++)
3729 {
3730 unsigned int i;
3731
3732 if (strcmp(pc->parts[j]->name, name)) continue;
3733
3734 pc->parts[j] = _part_free(pc->parts[j]);
3735 for (i = j; i < pc->parts_count - 1; i++)
3736 {
3737 if (!pc->parts[i + 1]) break;
3738 pc->parts[i] = pc->parts[i + 1];
3739 }
3740 pc->parts_count--;
3741 break;
3742 }
3743 if (cur_count == pc->parts_count)
3744 {
3745 ERR("Attempted removal of nonexistent part '%s' in group '%s'.",
3746 name, current_de->entry);
3747 exit(-1);
3748 }
3749 free(name);
3750 }
3751 if (orig_count == pc->parts_count) return;
3752 if (pc->parts_count)
3753 pc->parts = realloc(pc->parts, pc->parts_count * sizeof(Edje_Part *));
3754 else
3755 {
3756 free(pc->parts);
3757 pc->parts = NULL;
3758 }
3759}
3760
3646/** 3761/**
3647 @page edcref 3762 @page edcref
3648 @property 3763 @property