summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/bin/edje/edje_cc_handlers.c1
-rw-r--r--src/lib/edje/Edje_Edit.h81
-rw-r--r--src/lib/edje/edje_data.c1
-rw-r--r--src/lib/edje/edje_edit.c160
-rw-r--r--src/lib/edje/edje_private.h1
5 files changed, 209 insertions, 35 deletions
diff --git a/src/bin/edje/edje_cc_handlers.c b/src/bin/edje/edje_cc_handlers.c
index 9be1eb6d0..6fd2c425d 100644
--- a/src/bin/edje/edje_cc_handlers.c
+++ b/src/bin/edje/edje_cc_handlers.c
@@ -2993,6 +2993,7 @@ st_collections_group_alias(void)
alias = mem_alloc(SZ(Edje_Part_Collection_Directory_Entry));
alias->id = current_de->id;
alias->entry = parse_str(0);
+ alias->group_alias = EINA_TRUE;
EINA_LIST_FOREACH(aliases, l, tmp)
if (strcmp(alias->entry, tmp->entry) == 0)
diff --git a/src/lib/edje/Edje_Edit.h b/src/lib/edje/Edje_Edit.h
index 542a05d89..099dce7c3 100644
--- a/src/lib/edje/Edje_Edit.h
+++ b/src/lib/edje/Edje_Edit.h
@@ -181,17 +181,6 @@ EAPI void edje_edit_print_internal_status(Evas_Object *obj);
* Functions to deal with groups property (see @ref edcref).
*/ //@{
-/** Create a new empty group in the given edje.
- *
- * If a group with the same name exist none is created.
- *
- * @param obj Object being edited.
- * @param name Name of the new group.
- *
- * @return EINA_TRUE if successfully added the group, EINA_FALSE if an error
- * occurred or if a group with the same name exists.
- */
-
/**
* @brief Add an edje (empty) group to an edje object's group set.
*
@@ -211,18 +200,6 @@ EAPI void edje_edit_print_internal_status(Evas_Object *obj);
*/
EAPI Eina_Bool edje_edit_group_add(Evas_Object *obj, const char *name);
-/** Delete the specified group from the given edje.
- *
- * You can only delete a currently unused group.
- * All the parts and the programs inside the group will be deleted as well,
- * but not image or font embedded in the edje.
- *
- * @param obj Object being edited.
- * @param group_name Name of group to delete.
- *
- * @return EINA_TRUE if successful, EINA_FALSE otherwise.
- */
-
/**
* @brief Delete the specified group from the edje file.
*
@@ -236,6 +213,9 @@ EAPI Eina_Bool edje_edit_group_add(Evas_Object *obj, const char *name);
* the file.
* This function may fail if the group to be deleted is currently in use.
*
+ * @attention be carefull, if you deleting group, it will delete all it's aliases also,
+ * if you deleting alias, then it will delete alias only.
+ *
*/
EAPI Eina_Bool edje_edit_group_del(Evas_Object *obj, const char *group_name);
@@ -327,6 +307,61 @@ EAPI int edje_edit_group_max_h_get(Evas_Object *obj);
*/
EAPI Eina_Bool edje_edit_group_max_h_set(Evas_Object *obj, int h);
+//@}
+/******************************************************************************/
+/************************** ALIAS API **************************************/
+/******************************************************************************/
+/** @name Alias API
+ * Functions to deal with aliases that just another names of the group in the edje (see @ref edcref).
+ */ //@{
+
+/**
+ * Retrieves a list of aliases for this group.
+ * If given group name is an alias name then this function will return NULL.
+ *
+ * @attention After you done using returned list, please use edje_edit_string_list_free to free this list.
+ *
+ * @param obj Object being edited.
+ * @param group_name Group name or alias.
+ *
+ * @return List of strings, each being a name of alias of given group or alias name.
+ */
+EAPI Eina_List * edje_edit_group_aliases_get(Evas_Object *obj, const char *group_name);
+
+/**
+ * Check if this group is an alias name.
+ *
+ * @param obj Object being edited.
+ * @param alias_name Group name that is alias.
+ *
+ * @return EINA_TRUE if alias, EINA_FALSE otherwise.
+ */
+EAPI Eina_Bool edje_edit_group_alias_is(Evas_Object *obj, const char *alias_name);
+
+/**
+ * Return the main group name that is aliased by given alias name.
+ *
+ * @attention After you done using this string, please use edje_edit_string_free to free this string.
+ *
+ * @param obj Object being edited.
+ * @param alias_name Group name that is alias.
+ *
+ * @return name of the main group that is being aliased.
+ */
+EAPI const char * edje_edit_group_aliased_get(Evas_Object *obj, const char *alias_name);
+
+/**
+ * Add new alias to the given group.
+ *
+ * @attention when aliasing a group, be sure that the given group_name is no an alias.
+ *
+ * @param obj Object being edited.
+ * @param group_name Group name that is being aliased.
+ * @param alias_name Group name that is alias.
+ *
+ * @return EINA_TRUE if success, EINA_FALSE otherwise.
+ */
+EAPI Eina_Bool edje_edit_group_alias_add(Evas_Object *obj, const char *group_name, const char *alias_name);
//@}
/******************************************************************************/
diff --git a/src/lib/edje/edje_data.c b/src/lib/edje/edje_data.c
index 672e1823d..2e515ad4b 100644
--- a/src/lib/edje/edje_data.c
+++ b/src/lib/edje/edje_data.c
@@ -371,6 +371,7 @@ _edje_edd_init(void)
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection_directory_entry, Edje_Part_Collection_Directory_Entry, "count.EXTERNAL", count.EXTERNAL, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection_directory_entry, Edje_Part_Collection_Directory_Entry, "count.SPACER", count.SPACER, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection_directory_entry, Edje_Part_Collection_Directory_Entry, "count.part", count.part, EET_T_INT);
+ EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection_directory_entry, Edje_Part_Collection_Directory_Entry, "group_alias", group_alias, EET_T_UCHAR);
EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Style_Tag);
_edje_edd_edje_style_tag =
diff --git a/src/lib/edje/edje_edit.c b/src/lib/edje/edje_edit.c
index 97fe9c6e4..4386023c9 100644
--- a/src/lib/edje/edje_edit.c
+++ b/src/lib/edje/edje_edit.c
@@ -1008,7 +1008,7 @@ edje_edit_group_add(Evas_Object *obj, const char *name)
EAPI Eina_Bool
edje_edit_group_del(Evas_Object *obj, const char *group_name)
{
- Edje_Part_Collection_Directory_Entry *e;
+ Edje_Part_Collection_Directory_Entry *e, *e_del;
Edje_Part_Collection *die = NULL;
Edje_Part_Collection *g;
Eina_List *l;
@@ -1018,9 +1018,6 @@ edje_edit_group_del(Evas_Object *obj, const char *group_name)
GET_ED_OR_RETURN(EINA_FALSE);
- /* if (eina_hash_find(ed->file->collection_hash, group_name)) */
- /* return EINA_FALSE; */
-
if (strcmp(ed->group, group_name) == 0) return EINA_FALSE;
e = eina_hash_find(ed->file->collection, group_name);
if (!e) return EINA_FALSE;
@@ -1030,13 +1027,15 @@ edje_edit_group_del(Evas_Object *obj, const char *group_name)
_edje_edit_group_references_update(obj, group_name, NULL);
EINA_LIST_FOREACH(ed->file->collection_cache, l, g)
- if (g->id == e->id)
- {
- ed->file->collection_cache =
- eina_list_remove_list(ed->file->collection_cache, l);
- die = g;
- break;
- }
+ {
+ if (strcmp(g->part, e->entry) == 0)
+ {
+ ed->file->collection_cache =
+ eina_list_remove_list(ed->file->collection_cache, l);
+ die = g;
+ break;
+ }
+ }
/* Remove collection/id from eet file */
eetf = eet_open(ed->file->path, EET_FILE_MODE_READ_WRITE);
@@ -1066,7 +1065,22 @@ edje_edit_group_del(Evas_Object *obj, const char *group_name)
}
eet_close(eetf);
- /* Free Group */
+ l = NULL; g = NULL;
+ /* Free Group and all it's Aliases */
+ if (!e->group_alias)
+ {
+ EINA_LIST_FOREACH(ed->file->collection_cache, l, g)
+ {
+ if (e->id == g->id)
+ {
+ ed->file->collection_cache =
+ eina_list_remove_list(ed->file->collection_cache, l);
+ e_del = eina_hash_find(ed->file->collection, g->part);
+ _edje_collection_free(ed->file, g, e_del);
+ eina_hash_del(ed->file->collection, g->part, e_del);
+ }
+ }
+ }
if (die) _edje_collection_free(ed->file, die, e);
eina_hash_del(ed->file->collection, group_name, e);
@@ -1143,6 +1157,128 @@ FUNC_GROUP_ACCESSOR(min, h);
FUNC_GROUP_ACCESSOR(max, w);
FUNC_GROUP_ACCESSOR(max, h);
+/****************/
+/* ALIAS API */
+/****************/
+
+EAPI Eina_List *
+edje_edit_group_aliases_get(Evas_Object *obj, const char *group_name)
+{
+ Eina_Iterator *i;
+ Edje_Part_Collection_Directory_Entry *e;
+ Edje_Part_Collection_Directory_Entry *d;
+ Eina_List *alias_list = NULL;
+
+ GET_ED_OR_RETURN(NULL);
+ if (!ed->file || !ed->file->collection)
+ return NULL;
+
+ e = eina_hash_find(ed->file->collection, group_name);
+ if (!e) return NULL;
+
+ i = eina_hash_iterator_data_new(ed->file->collection);
+ EINA_ITERATOR_FOREACH(i, d)
+ {
+ if ((e->id == d->id) && (d->group_alias))
+ alias_list = eina_list_append(alias_list, eina_stringshare_add(d->entry));
+ }
+ eina_iterator_free(i);
+
+ return alias_list;
+}
+
+EAPI Eina_Bool
+edje_edit_group_alias_is(Evas_Object *obj, const char *alias_name)
+{
+ Edje_Part_Collection_Directory_Entry *e;
+
+ GET_ED_OR_RETURN(EINA_FALSE);
+ if (!ed->file || !ed->file->collection)
+ return EINA_FALSE;
+
+ e = eina_hash_find(ed->file->collection, alias_name);
+ if (!e) return EINA_FALSE;
+
+ return e->group_alias;
+}
+
+EAPI const char *
+edje_edit_group_aliased_get(Evas_Object *obj, const char *alias_name)
+{
+ Eina_Iterator *i;
+ Edje_Part_Collection_Directory_Entry *e;
+ Edje_Part_Collection_Directory_Entry *d;
+ const char *group_name = NULL;
+
+ GET_ED_OR_RETURN(NULL);
+ if (!ed->file || !ed->file->collection)
+ return NULL;
+
+ e = eina_hash_find(ed->file->collection, alias_name);
+ if (!e) return NULL;
+ if (!e->group_alias) return eina_stringshare_add(alias_name);
+
+ i = eina_hash_iterator_data_new(ed->file->collection);
+ EINA_ITERATOR_FOREACH(i, d)
+ {
+ if ((e->id == d->id) && (!d->group_alias))
+ {
+ group_name = d->entry;
+ break;
+ }
+ }
+ eina_iterator_free(i);
+
+ return eina_stringshare_add(group_name);
+}
+
+EAPI Eina_Bool
+edje_edit_group_alias_add(Evas_Object *obj, const char *group_name, const char *alias_name)
+{
+ Edje_Part_Collection_Directory_Entry *e;
+ Edje_Part_Collection_Directory_Entry *de;
+
+ GET_ED_OR_RETURN(EINA_FALSE);
+
+ if (!ed->file || !ed->file->collection)
+ return EINA_FALSE;
+
+ /* check if a group with the same alias already exists */
+ if (eina_hash_find(ed->file->collection, alias_name))
+ return EINA_FALSE;
+ /* check if a group that is being aliased is really exists */
+ e = eina_hash_find(ed->file->collection, group_name);
+ if (!e) return EINA_FALSE;
+ /* check that a group that is being aliased is not an alias */
+ if (e->group_alias) return EINA_FALSE;
+
+ /* Create structs */
+ de = _alloc(sizeof(Edje_Part_Collection_Directory_Entry));
+ if (!de) return EINA_FALSE;
+
+ /* Init Edje_Part_Collection_Directory_Entry */
+ de->id = e->id;
+ de->entry = eina_stringshare_add(alias_name);
+ de->group_alias = EINA_TRUE;
+
+ memcpy(&de->count, &e->count, sizeof (de->count));
+ eina_hash_direct_add(ed->file->collection, de->entry, de);
+
+ EDIT_EMN(RECTANGLE, Edje_Part_Description_Common, de);
+ EDIT_EMN(TEXT, Edje_Part_Description_Text, de);
+ EDIT_EMN(IMAGE, Edje_Part_Description_Image, de);
+ EDIT_EMN(SWALLOW, Edje_Part_Description_Common, de);
+ EDIT_EMN(TEXTBLOCK, Edje_Part_Description_Text, de);
+ EDIT_EMN(GROUP, Edje_Part_Description_Common, de);
+ EDIT_EMN(BOX, Edje_Part_Description_Box, de);
+ EDIT_EMN(TABLE, Edje_Part_Description_Table, de);
+ EDIT_EMN(EXTERNAL, Edje_Part_Description_External, de);
+ EDIT_EMN(SPACER, Edje_Part_Description_Common, de);
+ EDIT_EMN(part, Edje_Part, de);
+
+ return EINA_TRUE;
+}
+
/***************/
/* DATA API */
/***************/
diff --git a/src/lib/edje/edje_private.h b/src/lib/edje/edje_private.h
index ec2a2d608..3340f623b 100644
--- a/src/lib/edje/edje_private.h
+++ b/src/lib/edje/edje_private.h
@@ -734,6 +734,7 @@ struct _Edje_Part_Collection_Directory_Entry
} mp_rtl; /* For Right To Left interface */
Edje_Part_Collection *ref;
+ Eina_Bool group_alias;
};
/*----------*/