Group-level data edc blocks manipulation API for Edje_Edit.

SVN revision: 45903
This commit is contained in:
Gustavo Lima Chaves 2010-02-05 16:39:06 +00:00
parent b08434f220
commit f61a15fba9
2 changed files with 258 additions and 46 deletions

View File

@ -248,9 +248,11 @@ edje_edit_data_list_get(
Evas_Object *obj ///< The edje object
);
/**Create a new data object in the given edje
* If another data with the same name exists nothing is created and FALSE is returned.
/** Create a new *global* data object in the given edje file. If
* another data entry with the same name exists, nothing is created and
* FALSE is returned.
*/
EAPI Eina_Bool ///@return TRUE on success
edje_edit_data_add(
Evas_Object *obj, ///< The edje object
@ -288,6 +290,54 @@ edje_edit_data_name_set(
const char *newname ///< The new name to set
);
/** Create a new data object in the given edje file *belonging to the
* current group*. If another data entry with the same name exists,
* nothing is created and FALSE is returned.
*/
/** Retrieves a list with the item names inside the data block **/
EAPI Eina_List * ///@return An Eina_List* of string (char *) containing all the data names.
edje_edit_group_data_list_get(
Evas_Object *obj ///< The edje object
);
EAPI Eina_Bool ///@return EINA_TRUE on success
edje_edit_group_data_add(
Evas_Object *obj, ///< The edje object
const char *itemname, ///< The name for the new data
const char *value ///< The value for the new data
);
/** Delete the given data object from edje */
EAPI Eina_Bool ///@return EINA_TRUE on success
edje_edit_group_data_del(
Evas_Object *obj, ///< The edje object
const char *itemname ///< The name of the data to remove
);
/** Get the data associated with the given itemname **/
EAPI const char * ///@return The data value
edje_edit_group_data_value_get(
Evas_Object * obj, ///< The edje object
char *itemname ///< The name of the data item
);
/** Set the data associated with the given itemname **/
EAPI Eina_Bool ///@return EINA_TRUE on success
edje_edit_group_data_value_set(
Evas_Object * obj, ///< The edje object
const char *itemname, ///< The name of the data item
const char *value ///< The new value to set
);
/** Change the name of the given data object */
EAPI Eina_Bool ///@return EINA_TRUE on success
edje_edit_group_data_name_set(
Evas_Object *obj, ///< The edje object
const char *itemname, ///< The name of the data item
const char *newname ///< The new name to set
);
//@}
/******************************************************************************/
/*********************** COLOR CLASSES API ********************************/

View File

@ -951,6 +951,25 @@ edje_edit_group_max_h_set(Evas_Object *obj, int h)
/* DATA API */
/***************/
EAPI Eina_List *
edje_edit_group_data_list_get(Evas_Object * obj)
{
Eina_List *datas;
Eina_List *l;
Edje_Data *d;
GET_ED_OR_RETURN(NULL);
if (!ed->file || !ed->collection)
return NULL;
datas = NULL;
EINA_LIST_FOREACH(ed->collection->data, l, d)
datas = eina_list_append(datas, eina_stringshare_add(d->key));
return datas;
}
EAPI Eina_List *
edje_edit_data_list_get(Evas_Object * obj)
{
@ -970,6 +989,36 @@ edje_edit_data_list_get(Evas_Object * obj)
return datas;
}
EAPI Eina_Bool
edje_edit_group_data_add(Evas_Object *obj, const char *key, const char *value)
{
Edje_Data *new;
Edje_Data *d;
Eina_List *l;
int len;
GET_ED_OR_RETURN(EINA_FALSE);
if (!key || !ed->file || !ed->collection)
return EINA_FALSE;
len = strlen(key);
EINA_LIST_FOREACH(ed->collection->data, l, d)
if ((d->key) && (!strncmp(d->key, key, len)))
return EINA_FALSE;
new = _alloc(sizeof(Edje_Data));
if (!new) return EINA_FALSE;
new->key = (char*)eina_stringshare_add(key);
if (value) new->value = (char*)eina_stringshare_add(value);
else new->value = NULL;
ed->collection->data = eina_list_append(ed->collection->data, new);
return EINA_TRUE;
}
EAPI Eina_Bool
edje_edit_data_add(Evas_Object *obj, const char *itemname, const char *value)
{
@ -998,6 +1047,34 @@ edje_edit_data_add(Evas_Object *obj, const char *itemname, const char *value)
return 1;
}
EAPI Eina_Bool
edje_edit_group_data_del(Evas_Object *obj, const char *key)
{
Eina_List *l;
Edje_Data *d;
int len;
GET_ED_OR_RETURN(EINA_FALSE);
if (!key || !ed->file || !ed->collection)
return EINA_FALSE;
len = strlen(key);
EINA_LIST_FOREACH(ed->collection->data, l, d)
{
if (strncmp(d->key, key, len) == 0)
{
_edje_if_string_free(ed, d->key);
_edje_if_string_free(ed, d->value);
ed->collection->data = eina_list_remove(ed->collection->data, d);
free(d);
return EINA_TRUE;
}
}
return EINA_FALSE;
}
EAPI Eina_Bool
edje_edit_data_del(Evas_Object *obj, const char *itemname)
{
@ -1023,6 +1100,26 @@ edje_edit_data_del(Evas_Object *obj, const char *itemname)
return 0;
}
EAPI const char *
edje_edit_group_data_value_get(Evas_Object * obj, char *key)
{
Eina_List *l;
Edje_Data *d;
int len;
GET_ED_OR_RETURN(NULL);
if (!key || !ed->file || !ed->collection)
return NULL;
len = strlen(key);
EINA_LIST_FOREACH(ed->collection->data, l, d)
if (strncmp(d->key, key, len) == 0)
return eina_stringshare_add(d->value);
return NULL;
}
EAPI const char *
edje_edit_data_value_get(Evas_Object * obj, char *itemname)
{
@ -1041,6 +1138,30 @@ edje_edit_data_value_get(Evas_Object * obj, char *itemname)
return NULL;
}
EAPI Eina_Bool
edje_edit_group_data_value_set(Evas_Object *obj, const char *key, const char *value)
{
Eina_List *l;
Edje_Data *d;
int len;
GET_ED_OR_RETURN(EINA_FALSE);
if (!key || !value || !ed->file || !ed->collection)
return EINA_FALSE;
len = strlen(key);
EINA_LIST_FOREACH(ed->collection->data, l, d)
if (strncmp(d->key, key, len) == 0)
{
_edje_if_string_free(ed, d->value);
d->value = (char*)eina_stringshare_add(value);
return EINA_TRUE;
}
return EINA_FALSE;
}
EAPI Eina_Bool
edje_edit_data_value_set(Evas_Object *obj, const char *itemname, const char *value)
{
@ -1063,6 +1184,32 @@ edje_edit_data_value_set(Evas_Object *obj, const char *itemname, const char *val
return 0;
}
EAPI Eina_Bool
edje_edit_group_data_name_set(Evas_Object *obj, const char *key, const char *new_key)
{
Eina_List *l;
Edje_Data *d;
int len;
GET_ED_OR_RETURN(EINA_FALSE);
if (!key || !new_key || !ed->file || !ed->collection) {
return EINA_FALSE;
}
len = strlen(key);
EINA_LIST_FOREACH(ed->collection->data, l, d) {
if (strncmp(d->key, key, len) == 0)
{
_edje_if_string_free(ed, d->key);
d->key = (char*)eina_stringshare_add(new_key);
return EINA_TRUE;
}
}
return EINA_FALSE;
}
EAPI Eina_Bool
edje_edit_data_name_set(Evas_Object *obj, const char *itemname, const char *newname)
{
@ -5891,7 +6038,22 @@ _edje_generate_source_of_group(Edje *ed, const char *group, FILE *f)
h = edje_edit_group_max_h_get(obj);
if ((w > -1) || (h > -1))
fprintf(f, I2"max: %d %d;\n", w, h);
//TODO Support data
/* Data */
if ((ll = edje_edit_group_data_list_get(obj)))
{
fprintf(f, I2"data {\n");
EINA_LIST_FOREACH(ll, l, data)
{
fprintf(f, I3"item: \"%s\" \"%s\";\n", data,
edje_edit_group_data_value_get(obj, data));
}
fprintf(f, I2"}\n\n");
edje_edit_string_list_free(ll);
}
//TODO Support script
/* Parts */
@ -6228,7 +6390,7 @@ _edje_edit_internal_save(Evas_Object *obj, int current_only)
if (strcmp(ef->compiler, "edje_edit"))
{
_edje_if_string_free(ed, ef->compiler);
ef->compiler = eina_stringshare_add("edje_edit");
ef->compiler = (char *)eina_stringshare_add("edje_edit");
}
if (!_edje_edit_edje_file_save(eetf, ef))