From 6af736860250f1f57c8fdd959495cc6be71b15ad Mon Sep 17 00:00:00 2001 From: "m.biliavskyi" Date: Wed, 30 Oct 2013 22:04:57 +0900 Subject: [PATCH] edje: make function which change style tag param's (name, value) and delete tag return Eina_Bool. This patch make the following function return Eina_Bool so the caller can detect errors. edje_edit_style_tag_value_set edje_edit_style_tag_name_set edje_edit_style_tag_del Reviewers: cedric, seoz Reviewed By: cedric CC: reutskiy.v.v, seoz Differential Revision: https://phab.enlightenment.org/D294 Signed-off-by: Cedric Bail --- src/lib/edje/Edje_Edit.h | 12 +++++++++--- src/lib/edje/edje_edit.c | 31 +++++++++++++++++-------------- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/src/lib/edje/Edje_Edit.h b/src/lib/edje/Edje_Edit.h index 0b1e5c48ac..47285c6920 100644 --- a/src/lib/edje/Edje_Edit.h +++ b/src/lib/edje/Edje_Edit.h @@ -602,8 +602,10 @@ EAPI const char * edje_edit_style_tag_value_get(Evas_Object *obj, const char *st * @param style Style containing the tag to change. * @param tag Name of the tag to set the value for. * @param new_value Value for the tag. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. */ -EAPI void edje_edit_style_tag_value_set(Evas_Object *obj, const char *style, const char *tag, const char *new_value); +EAPI Eina_Bool edje_edit_style_tag_value_set(Evas_Object *obj, const char *style, const char *tag, const char *new_value); /** Set the name of the given tag. * @@ -611,8 +613,10 @@ EAPI void edje_edit_style_tag_value_set(Evas_Object *obj, const char *style, con * @param style Style containing the tag to rename. * @param tag Tag to rename. * @param new_name New name for the tag. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. */ -EAPI void edje_edit_style_tag_name_set(Evas_Object *obj, const char *style, const char *tag, const char *new_name); +EAPI Eina_Bool edje_edit_style_tag_name_set(Evas_Object *obj, const char *style, const char *tag, const char *new_name); /** Add a new tag to the given text style. * @@ -631,8 +635,10 @@ EAPI Eina_Bool edje_edit_style_tag_add(Evas_Object *obj, const char *style, cons * @param obj Object being edited. * @param style Style from where to remove the tag. * @param tag Tag to delete. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. */ -EAPI void edje_edit_style_tag_del(Evas_Object *obj, const char *style, const char *tag); +EAPI Eina_Bool edje_edit_style_tag_del(Evas_Object *obj, const char *style, const char *tag); //@} diff --git a/src/lib/edje/edje_edit.c b/src/lib/edje/edje_edit.c index 22d3b6db0c..dabed3a0c2 100644 --- a/src/lib/edje/edje_edit.c +++ b/src/lib/edje/edje_edit.c @@ -1645,21 +1645,21 @@ edje_edit_style_tags_list_get(Evas_Object * obj, const char* style) return tags; } -EAPI void +EAPI Eina_Bool edje_edit_style_tag_name_set(Evas_Object * obj, const char* style, const char* tag, const char*new_name) { Edje_Style_Tag *t; - GET_ED_OR_RETURN(); - //printf("SET TAG NAME for '%s' FOR STYLE '%s'\n", tag, style); + GET_ED_OR_RETURN(EINA_FALSE); if (!ed->file || !ed->file->styles || !style || !tag) - return; + return EINA_FALSE; t = _edje_edit_style_tag_get(ed, style, tag); - if (!t) return; + if (!t) return EINA_FALSE; _edje_if_string_free(ed, t->key); t->key = eina_stringshare_add(new_name); + return EINA_TRUE; } EAPI const char* @@ -1680,21 +1680,21 @@ edje_edit_style_tag_value_get(Evas_Object * obj, const char* style, const char* return NULL; } -EAPI void +EAPI Eina_Bool edje_edit_style_tag_value_set(Evas_Object * obj, const char* style, const char* tag, const char*new_value) { Edje_Style_Tag *t; - GET_ED_OR_RETURN(); - //printf("SET TAG VALUE for '%s' FOR STYLE '%s'\n", tag, style); + GET_ED_OR_RETURN(EINA_FALSE); - if (!ed->file || !ed->file->styles || !style || !tag) - return; + if (!ed->file || !ed->file->styles || !style || !tag || !new_value) + return EINA_FALSE; t = _edje_edit_style_tag_get(ed, style, tag); - if (!t) return; + if (!t) return EINA_FALSE; _edje_if_string_free(ed, t->value); t->value = eina_stringshare_add(new_value); + return EINA_TRUE; } EAPI Eina_Bool @@ -1722,17 +1722,19 @@ edje_edit_style_tag_add(Evas_Object * obj, const char* style, const char* tag_na return EINA_TRUE; } -EAPI void +EAPI Eina_Bool edje_edit_style_tag_del(Evas_Object * obj, const char* style, const char* tag) { Edje_Style *s; Edje_Style_Tag *t; - GET_ED_OR_RETURN(); - //printf("DEL TAG '%s' IN STYLE '%s'\n", tag, style); + GET_ED_OR_RETURN(EINA_FALSE); + if (!ed->file || !ed->file->styles || !style || !tag ) + return EINA_FALSE; s = _edje_edit_style_get(ed, style); t = _edje_edit_style_tag_get(ed, style, tag); + if (!s || !t) return EINA_FALSE; s->tags = eina_list_remove(s->tags, t); _edje_if_string_free(ed, t->key); @@ -1741,6 +1743,7 @@ edje_edit_style_tag_del(Evas_Object * obj, const char* style, const char* tag) _edje_if_string_free(ed, t->text_class); free(t); t = NULL; + return EINA_TRUE; } /*******************/