summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVorobiov Vitalii <vi.vorobiov@samsung.com>2013-12-14 18:40:26 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2013-12-14 18:40:26 +0900
commit0640b7f34109d53b5da9a9f23ec3e6c9c475d47a (patch)
tree4741decb27ccabaa0435a2e6eebcb11fe967781a /src
parent3a47fe5fa8d6ee20b36375a79879f1b0c652c8fa (diff)
edje: adding Alias API into edje_edit module
Summary: This commit will add some API for working with aliases. There are four functions will be added: 1. edje_edit_group_aliases_get - this function will return the list of aliases of certain group. 2. edje_edit_group_is_alias - this function will check if the given group name is actually an alias. 3. edje_edit_group_aliased_get - return the main real group that is being aliased. 4. edje_edit_group_alias_add - add new alias name. Also the function "edje_edit_group_del" was modified because of wrong behaviour. Now if the given group is alias, it will successfully delete it, but if the given group is main group, it will also delete all it's aliases. This commit also modify EDJ file by adding new field for detecting if the group is alias or not. Reviewers: cedric, seoz, raster Reviewed By: raster CC: reutskiy.v.v, cedric Differential Revision: https://phab.enlightenment.org/D376
Diffstat (limited to 'src')
-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 9be1eb6d08..6fd2c425db 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)
2993 alias = mem_alloc(SZ(Edje_Part_Collection_Directory_Entry)); 2993 alias = mem_alloc(SZ(Edje_Part_Collection_Directory_Entry));
2994 alias->id = current_de->id; 2994 alias->id = current_de->id;
2995 alias->entry = parse_str(0); 2995 alias->entry = parse_str(0);
2996 alias->group_alias = EINA_TRUE;
2996 2997
2997 EINA_LIST_FOREACH(aliases, l, tmp) 2998 EINA_LIST_FOREACH(aliases, l, tmp)
2998 if (strcmp(alias->entry, tmp->entry) == 0) 2999 if (strcmp(alias->entry, tmp->entry) == 0)
diff --git a/src/lib/edje/Edje_Edit.h b/src/lib/edje/Edje_Edit.h
index 542a05d896..099dce7c3c 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);
181 * Functions to deal with groups property (see @ref edcref). 181 * Functions to deal with groups property (see @ref edcref).
182 */ //@{ 182 */ //@{
183 183
184/** Create a new empty group in the given edje.
185 *
186 * If a group with the same name exist none is created.
187 *
188 * @param obj Object being edited.
189 * @param name Name of the new group.
190 *
191 * @return EINA_TRUE if successfully added the group, EINA_FALSE if an error
192 * occurred or if a group with the same name exists.
193 */
194
195/** 184/**
196 * @brief Add an edje (empty) group to an edje object's group set. 185 * @brief Add an edje (empty) group to an edje object's group set.
197 * 186 *
@@ -211,18 +200,6 @@ EAPI void edje_edit_print_internal_status(Evas_Object *obj);
211 */ 200 */
212EAPI Eina_Bool edje_edit_group_add(Evas_Object *obj, const char *name); 201EAPI Eina_Bool edje_edit_group_add(Evas_Object *obj, const char *name);
213 202
214/** Delete the specified group from the given edje.
215 *
216 * You can only delete a currently unused group.
217 * All the parts and the programs inside the group will be deleted as well,
218 * but not image or font embedded in the edje.
219 *
220 * @param obj Object being edited.
221 * @param group_name Name of group to delete.
222 *
223 * @return EINA_TRUE if successful, EINA_FALSE otherwise.
224 */
225
226/** 203/**
227 * @brief Delete the specified group from the edje file. 204 * @brief Delete the specified group from the edje file.
228 * 205 *
@@ -236,6 +213,9 @@ EAPI Eina_Bool edje_edit_group_add(Evas_Object *obj, const char *name);
236 * the file. 213 * the file.
237 * This function may fail if the group to be deleted is currently in use. 214 * This function may fail if the group to be deleted is currently in use.
238 * 215 *
216 * @attention be carefull, if you deleting group, it will delete all it's aliases also,
217 * if you deleting alias, then it will delete alias only.
218 *
239 */ 219 */
240EAPI Eina_Bool edje_edit_group_del(Evas_Object *obj, const char *group_name); 220EAPI Eina_Bool edje_edit_group_del(Evas_Object *obj, const char *group_name);
241 221
@@ -327,6 +307,61 @@ EAPI int edje_edit_group_max_h_get(Evas_Object *obj);
327 */ 307 */
328EAPI Eina_Bool edje_edit_group_max_h_set(Evas_Object *obj, int h); 308EAPI Eina_Bool edje_edit_group_max_h_set(Evas_Object *obj, int h);
329 309
310//@}
311/******************************************************************************/
312/************************** ALIAS API **************************************/
313/******************************************************************************/
314/** @name Alias API
315 * Functions to deal with aliases that just another names of the group in the edje (see @ref edcref).
316 */ //@{
317
318/**
319 * Retrieves a list of aliases for this group.
320 * If given group name is an alias name then this function will return NULL.
321 *
322 * @attention After you done using returned list, please use edje_edit_string_list_free to free this list.
323 *
324 * @param obj Object being edited.
325 * @param group_name Group name or alias.
326 *
327 * @return List of strings, each being a name of alias of given group or alias name.
328 */
329EAPI Eina_List * edje_edit_group_aliases_get(Evas_Object *obj, const char *group_name);
330
331/**
332 * Check if this group is an alias name.
333 *
334 * @param obj Object being edited.
335 * @param alias_name Group name that is alias.
336 *
337 * @return EINA_TRUE if alias, EINA_FALSE otherwise.
338 */
339EAPI Eina_Bool edje_edit_group_alias_is(Evas_Object *obj, const char *alias_name);
340
341/**
342 * Return the main group name that is aliased by given alias name.
343 *
344 * @attention After you done using this string, please use edje_edit_string_free to free this string.
345 *
346 * @param obj Object being edited.
347 * @param alias_name Group name that is alias.
348 *
349 * @return name of the main group that is being aliased.
350 */
351EAPI const char * edje_edit_group_aliased_get(Evas_Object *obj, const char *alias_name);
352
353/**
354 * Add new alias to the given group.
355 *
356 * @attention when aliasing a group, be sure that the given group_name is no an alias.
357 *
358 * @param obj Object being edited.
359 * @param group_name Group name that is being aliased.
360 * @param alias_name Group name that is alias.
361 *
362 * @return EINA_TRUE if success, EINA_FALSE otherwise.
363 */
364EAPI Eina_Bool edje_edit_group_alias_add(Evas_Object *obj, const char *group_name, const char *alias_name);
330 365
331//@} 366//@}
332/******************************************************************************/ 367/******************************************************************************/
diff --git a/src/lib/edje/edje_data.c b/src/lib/edje/edje_data.c
index 672e1823d6..2e515ad4b6 100644
--- a/src/lib/edje/edje_data.c
+++ b/src/lib/edje/edje_data.c
@@ -371,6 +371,7 @@ _edje_edd_init(void)
371 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection_directory_entry, Edje_Part_Collection_Directory_Entry, "count.EXTERNAL", count.EXTERNAL, EET_T_INT); 371 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection_directory_entry, Edje_Part_Collection_Directory_Entry, "count.EXTERNAL", count.EXTERNAL, EET_T_INT);
372 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection_directory_entry, Edje_Part_Collection_Directory_Entry, "count.SPACER", count.SPACER, EET_T_INT); 372 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection_directory_entry, Edje_Part_Collection_Directory_Entry, "count.SPACER", count.SPACER, EET_T_INT);
373 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection_directory_entry, Edje_Part_Collection_Directory_Entry, "count.part", count.part, EET_T_INT); 373 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection_directory_entry, Edje_Part_Collection_Directory_Entry, "count.part", count.part, EET_T_INT);
374 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection_directory_entry, Edje_Part_Collection_Directory_Entry, "group_alias", group_alias, EET_T_UCHAR);
374 375
375 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Style_Tag); 376 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Style_Tag);
376 _edje_edd_edje_style_tag = 377 _edje_edd_edje_style_tag =
diff --git a/src/lib/edje/edje_edit.c b/src/lib/edje/edje_edit.c
index 97fe9c6e43..4386023c9f 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)
1008EAPI Eina_Bool 1008EAPI Eina_Bool
1009edje_edit_group_del(Evas_Object *obj, const char *group_name) 1009edje_edit_group_del(Evas_Object *obj, const char *group_name)
1010{ 1010{
1011 Edje_Part_Collection_Directory_Entry *e; 1011 Edje_Part_Collection_Directory_Entry *e, *e_del;
1012 Edje_Part_Collection *die = NULL; 1012 Edje_Part_Collection *die = NULL;
1013 Edje_Part_Collection *g; 1013 Edje_Part_Collection *g;
1014 Eina_List *l; 1014 Eina_List *l;
@@ -1018,9 +1018,6 @@ edje_edit_group_del(Evas_Object *obj, const char *group_name)
1018 1018
1019 GET_ED_OR_RETURN(EINA_FALSE); 1019 GET_ED_OR_RETURN(EINA_FALSE);
1020 1020
1021 /* if (eina_hash_find(ed->file->collection_hash, group_name)) */
1022 /* return EINA_FALSE; */
1023
1024 if (strcmp(ed->group, group_name) == 0) return EINA_FALSE; 1021 if (strcmp(ed->group, group_name) == 0) return EINA_FALSE;
1025 e = eina_hash_find(ed->file->collection, group_name); 1022 e = eina_hash_find(ed->file->collection, group_name);
1026 if (!e) return EINA_FALSE; 1023 if (!e) return EINA_FALSE;
@@ -1030,13 +1027,15 @@ edje_edit_group_del(Evas_Object *obj, const char *group_name)
1030 _edje_edit_group_references_update(obj, group_name, NULL); 1027 _edje_edit_group_references_update(obj, group_name, NULL);
1031 1028
1032 EINA_LIST_FOREACH(ed->file->collection_cache, l, g) 1029 EINA_LIST_FOREACH(ed->file->collection_cache, l, g)
1033 if (g->id == e->id) 1030 {
1034 { 1031 if (strcmp(g->part, e->entry) == 0)
1035 ed->file->collection_cache = 1032 {
1036 eina_list_remove_list(ed->file->collection_cache, l); 1033 ed->file->collection_cache =
1037 die = g; 1034 eina_list_remove_list(ed->file->collection_cache, l);
1038 break; 1035 die = g;
1039 } 1036 break;
1037 }
1038 }
1040 1039
1041 /* Remove collection/id from eet file */ 1040 /* Remove collection/id from eet file */
1042 eetf = eet_open(ed->file->path, EET_FILE_MODE_READ_WRITE); 1041 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)
1066 } 1065 }
1067 eet_close(eetf); 1066 eet_close(eetf);
1068 1067
1069 /* Free Group */ 1068 l = NULL; g = NULL;
1069 /* Free Group and all it's Aliases */
1070 if (!e->group_alias)
1071 {
1072 EINA_LIST_FOREACH(ed->file->collection_cache, l, g)
1073 {
1074 if (e->id == g->id)
1075 {
1076 ed->file->collection_cache =
1077 eina_list_remove_list(ed->file->collection_cache, l);
1078 e_del = eina_hash_find(ed->file->collection, g->part);
1079 _edje_collection_free(ed->file, g, e_del);
1080 eina_hash_del(ed->file->collection, g->part, e_del);
1081 }
1082 }
1083 }
1070 if (die) _edje_collection_free(ed->file, die, e); 1084 if (die) _edje_collection_free(ed->file, die, e);
1071 eina_hash_del(ed->file->collection, group_name, e); 1085 eina_hash_del(ed->file->collection, group_name, e);
1072 1086
@@ -1143,6 +1157,128 @@ FUNC_GROUP_ACCESSOR(min, h);
1143FUNC_GROUP_ACCESSOR(max, w); 1157FUNC_GROUP_ACCESSOR(max, w);
1144FUNC_GROUP_ACCESSOR(max, h); 1158FUNC_GROUP_ACCESSOR(max, h);
1145 1159
1160/****************/
1161/* ALIAS API */
1162/****************/
1163
1164EAPI Eina_List *
1165edje_edit_group_aliases_get(Evas_Object *obj, const char *group_name)
1166{
1167 Eina_Iterator *i;
1168 Edje_Part_Collection_Directory_Entry *e;
1169 Edje_Part_Collection_Directory_Entry *d;
1170 Eina_List *alias_list = NULL;
1171
1172 GET_ED_OR_RETURN(NULL);
1173 if (!ed->file || !ed->file->collection)
1174 return NULL;
1175
1176 e = eina_hash_find(ed->file->collection, group_name);
1177 if (!e) return NULL;
1178
1179 i = eina_hash_iterator_data_new(ed->file->collection);
1180 EINA_ITERATOR_FOREACH(i, d)
1181 {
1182 if ((e->id == d->id) && (d->group_alias))
1183 alias_list = eina_list_append(alias_list, eina_stringshare_add(d->entry));
1184 }
1185 eina_iterator_free(i);
1186
1187 return alias_list;
1188}
1189
1190EAPI Eina_Bool
1191edje_edit_group_alias_is(Evas_Object *obj, const char *alias_name)
1192{
1193 Edje_Part_Collection_Directory_Entry *e;
1194
1195 GET_ED_OR_RETURN(EINA_FALSE);
1196 if (!ed->file || !ed->file->collection)
1197 return EINA_FALSE;
1198
1199 e = eina_hash_find(ed->file->collection, alias_name);
1200 if (!e) return EINA_FALSE;
1201
1202 return e->group_alias;
1203}
1204
1205EAPI const char *
1206edje_edit_group_aliased_get(Evas_Object *obj, const char *alias_name)
1207{
1208 Eina_Iterator *i;
1209 Edje_Part_Collection_Directory_Entry *e;
1210 Edje_Part_Collection_Directory_Entry *d;
1211 const char *group_name = NULL;
1212
1213 GET_ED_OR_RETURN(NULL);
1214 if (!ed->file || !ed->file->collection)
1215 return NULL;
1216
1217 e = eina_hash_find(ed->file->collection, alias_name);
1218 if (!e) return NULL;
1219 if (!e->group_alias) return eina_stringshare_add(alias_name);
1220
1221 i = eina_hash_iterator_data_new(ed->file->collection);
1222 EINA_ITERATOR_FOREACH(i, d)
1223 {
1224 if ((e->id == d->id) && (!d->group_alias))
1225 {
1226 group_name = d->entry;
1227 break;
1228 }
1229 }
1230 eina_iterator_free(i);
1231
1232 return eina_stringshare_add(group_name);
1233}
1234
1235EAPI Eina_Bool
1236edje_edit_group_alias_add(Evas_Object *obj, const char *group_name, const char *alias_name)
1237{
1238 Edje_Part_Collection_Directory_Entry *e;
1239 Edje_Part_Collection_Directory_Entry *de;
1240
1241 GET_ED_OR_RETURN(EINA_FALSE);
1242
1243 if (!ed->file || !ed->file->collection)
1244 return EINA_FALSE;
1245
1246 /* check if a group with the same alias already exists */
1247 if (eina_hash_find(ed->file->collection, alias_name))
1248 return EINA_FALSE;
1249 /* check if a group that is being aliased is really exists */
1250 e = eina_hash_find(ed->file->collection, group_name);
1251 if (!e) return EINA_FALSE;
1252 /* check that a group that is being aliased is not an alias */
1253 if (e->group_alias) return EINA_FALSE;
1254
1255 /* Create structs */
1256 de = _alloc(sizeof(Edje_Part_Collection_Directory_Entry));
1257 if (!de) return EINA_FALSE;
1258
1259 /* Init Edje_Part_Collection_Directory_Entry */
1260 de->id = e->id;
1261 de->entry = eina_stringshare_add(alias_name);
1262 de->group_alias = EINA_TRUE;
1263
1264 memcpy(&de->count, &e->count, sizeof (de->count));
1265 eina_hash_direct_add(ed->file->collection, de->entry, de);
1266
1267 EDIT_EMN(RECTANGLE, Edje_Part_Description_Common, de);
1268 EDIT_EMN(TEXT, Edje_Part_Description_Text, de);
1269 EDIT_EMN(IMAGE, Edje_Part_Description_Image, de);
1270 EDIT_EMN(SWALLOW, Edje_Part_Description_Common, de);
1271 EDIT_EMN(TEXTBLOCK, Edje_Part_Description_Text, de);
1272 EDIT_EMN(GROUP, Edje_Part_Description_Common, de);
1273 EDIT_EMN(BOX, Edje_Part_Description_Box, de);
1274 EDIT_EMN(TABLE, Edje_Part_Description_Table, de);
1275 EDIT_EMN(EXTERNAL, Edje_Part_Description_External, de);
1276 EDIT_EMN(SPACER, Edje_Part_Description_Common, de);
1277 EDIT_EMN(part, Edje_Part, de);
1278
1279 return EINA_TRUE;
1280}
1281
1146/***************/ 1282/***************/
1147/* DATA API */ 1283/* DATA API */
1148/***************/ 1284/***************/
diff --git a/src/lib/edje/edje_private.h b/src/lib/edje/edje_private.h
index ec2a2d608b..3340f623b7 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
734 } mp_rtl; /* For Right To Left interface */ 734 } mp_rtl; /* For Right To Left interface */
735 735
736 Edje_Part_Collection *ref; 736 Edje_Part_Collection *ref;
737 Eina_Bool group_alias;
737}; 738};
738 739
739/*----------*/ 740/*----------*/