summaryrefslogtreecommitdiff
path: root/legacy
diff options
context:
space:
mode:
authorDavide Andreoli <dave@gurumeditation.it>2008-09-14 22:30:15 +0000
committerDavide Andreoli <dave@gurumeditation.it>2008-09-14 22:30:15 +0000
commitbae73a2b6079992df4b24a003229940e318f42af (patch)
tree7d15c54f80bc2ffdbfd040ebc4bc5bbf4fae4b37 /legacy
parent161ab7a9754c1675f3de87fcd77815f952882a91 (diff)
* Add top level data editing functions
* Also change edje_cache.c to don\'t free the data list when creating the data_cache SVN revision: 35987
Diffstat (limited to 'legacy')
-rw-r--r--legacy/edje/src/lib/Edje_Edit.h47
-rw-r--r--legacy/edje/src/lib/edje_cache.c4
-rw-r--r--legacy/edje/src/lib/edje_edit.c124
3 files changed, 172 insertions, 3 deletions
diff --git a/legacy/edje/src/lib/Edje_Edit.h b/legacy/edje/src/lib/Edje_Edit.h
index 3c72dbdc48..a45bd2617a 100644
--- a/legacy/edje/src/lib/Edje_Edit.h
+++ b/legacy/edje/src/lib/Edje_Edit.h
@@ -218,6 +218,53 @@ edje_edit_group_max_h_set(
218 218
219//@} 219//@}
220/******************************************************************************/ 220/******************************************************************************/
221/************************** DATA API **************************************/
222/******************************************************************************/
223/** @name Data API
224 * Functions to deal with data embedded in the edje (see @ref edcref).
225 */ //@{
226
227/** Retrieves a list with the item names inside the data block **/
228EAPI Evas_List * ///@return An Evas_List* of string (char *)containing all the data names.
229edje_edit_data_list_get(
230 Evas_Object *obj ///< The edje object
231);
232
233/**Create a new data object in the given edje
234 * If another data with the same name exists nothing is created and FALSE is returned.
235 */
236EAPI unsigned char ///@return TRUE on success
237edje_edit_data_add(
238 Evas_Object *obj, ///< The edje object
239 const char *itemname, ///< The name for the new data
240 const char *value ///< The value for the new data
241);
242
243/**Delete the given data object from edje */
244EAPI unsigned char ///@return TRUE on success
245edje_edit_data_del(
246 Evas_Object *obj, ///< The edje object
247 const char *itemname ///< The name of the data to remove
248);
249
250/** Get the data associated with the given itemname **/
251EAPI const char * ///@return The data value
252edje_edit_data_value_get(
253 Evas_Object * obj, ///< The edje object
254 char *itemname ///< The name of the data item
255);
256
257/** Set the data associated with the given itemname **/
258EAPI unsigned char ///@return TRUE on success
259edje_edit_data_value_set(
260 Evas_Object * obj, ///< The edje object
261 const char *itemname, ///< The name of the data item
262 const char *value ///< The new value to set
263);
264
265
266//@}
267/******************************************************************************/
221/************************** PARTS API *************************************/ 268/************************** PARTS API *************************************/
222/******************************************************************************/ 269/******************************************************************************/
223/** @name Parts API 270/** @name Parts API
diff --git a/legacy/edje/src/lib/edje_cache.c b/legacy/edje/src/lib/edje_cache.c
index 7853b50b8b..152e2ba729 100644
--- a/legacy/edje/src/lib/edje_cache.c
+++ b/legacy/edje/src/lib/edje_cache.c
@@ -133,13 +133,11 @@ _edje_file_open(const char *file, const char *coll, int *error_ret, Edje_Part_Co
133 133
134 _edje_textblock_style_parse_and_fix(edf); 134 _edje_textblock_style_parse_and_fix(edf);
135 135
136 for (l = edf->data; l; l = evas_list_remove(l, l->data)) 136 for (l = edf->data; l; l = l->next)
137 { 137 {
138 Edje_Data *di = l->data; 138 Edje_Data *di = l->data;
139 edf->data_cache = evas_hash_add(edf->data_cache, evas_stringshare_add(di->key), di->value); 139 edf->data_cache = evas_hash_add(edf->data_cache, evas_stringshare_add(di->key), di->value);
140 free(di);
141 } 140 }
142 edf->data = NULL;
143 141
144 if (coll) 142 if (coll)
145 { 143 {
diff --git a/legacy/edje/src/lib/edje_edit.c b/legacy/edje/src/lib/edje_edit.c
index 72504a1d0b..1f6957bbca 100644
--- a/legacy/edje/src/lib/edje_edit.c
+++ b/legacy/edje/src/lib/edje_edit.c
@@ -896,6 +896,130 @@ edje_edit_group_max_h_set(Evas_Object *obj, int h)
896} 896}
897 897
898/***************/ 898/***************/
899/* DATA API */
900/***************/
901
902EAPI Evas_List *
903edje_edit_data_list_get(Evas_Object * obj)
904{
905 Evas_List *datas, *l;
906
907 GET_ED_OR_RETURN(NULL);
908
909 if (!ed->file || !ed->file->data)
910 return NULL;
911
912 datas = NULL;
913 for (l = ed->file->data; l; l = l->next)
914 {
915 Edje_Data *d = l->data;
916 datas = evas_list_append(datas, evas_stringshare_add(d->key));
917 }
918
919 return datas;
920}
921
922EAPI unsigned char
923edje_edit_data_add(Evas_Object *obj, const char *itemname, const char *value)
924{
925 Evas_List *l;
926 Edje_Data *d;
927
928 GET_ED_OR_RETURN(0);
929
930 if (!itemname || !ed->file)
931 return 0;
932
933 for (l = ed->file->data; l; l = l->next)
934 {
935 Edje_Data *dd = l->data;
936 if (strcmp(dd->key, itemname) == 0)
937 return 0;
938 }
939
940 d = mem_alloc(sizeof(Edje_Data));
941 if (!d) return 0;
942
943 d->key = (char*)evas_stringshare_add(itemname);
944 if (value) d->value = (char*)evas_stringshare_add(value);
945 else d->value = NULL;
946
947 ed->file->data = evas_list_append(ed->file->data, d);
948
949 return 1;
950}
951
952EAPI unsigned char
953edje_edit_data_del(Evas_Object *obj, const char *itemname)
954{
955 Evas_List *l;
956
957 GET_ED_OR_RETURN(0);
958
959 if (!itemname || !ed->file || !ed->file->data)
960 return 0;
961
962 for (l = ed->file->data; l; l = l->next)
963 {
964 Edje_Data *d = l->data;
965 if (strcmp(d->key, itemname) == 0)
966 {
967 _edje_if_string_free(ed, d->key);
968 _edje_if_string_free(ed, d->value);
969 ed->file->data = evas_list_remove(ed->file->data, d);
970 free(d);
971 return 1;
972 }
973 }
974 return 0;
975}
976
977EAPI const char *
978edje_edit_data_value_get(Evas_Object * obj, char *itemname)
979{
980 Evas_List *l;
981
982 GET_ED_OR_RETURN(NULL);
983
984 if (!itemname || !ed->file || !ed->file->data)
985 return NULL;
986
987 for (l = ed->file->data; l; l = l->next)
988 {
989 Edje_Data *d = l->data;
990 if (strcmp(d->key, itemname) == 0)
991 return evas_stringshare_add(d->value);
992 }
993
994 return NULL;
995}
996
997EAPI unsigned char
998edje_edit_data_value_set( Evas_Object * obj, const char *itemname, const char *value)
999{
1000 Evas_List *l;
1001
1002 GET_ED_OR_RETURN(0);
1003
1004 if (!itemname || !value || !ed->file || !ed->file->data)
1005 return 0;
1006
1007 for (l = ed->file->data; l; l = l->next)
1008 {
1009 Edje_Data *d = l->data;
1010 if (strcmp(d->key, itemname) == 0)
1011 {
1012 _edje_if_string_free(ed, d->value);
1013 d->value = (char*)evas_stringshare_add(value);
1014 return 1;
1015 }
1016 }
1017
1018 return 0;
1019}
1020
1021
1022/***************/
899/* PARTS API */ 1023/* PARTS API */
900/***************/ 1024/***************/
901 1025