From 421e3de6043388b9d1d2df360bac10b3a3c1b621 Mon Sep 17 00:00:00 2001 From: Gustavo Lima Chaves Date: Tue, 6 Mar 2012 20:25:29 +0000 Subject: [PATCH] [Elm] More future-proofness on elm layout: returning values on methods. There were others with boolean returns already, let's planify that. SVN revision: 68848 --- src/lib/elm_deprecated.h | 6 ++-- src/lib/elm_layout.c | 78 +++++++++++++++++++++++++++++------------------- src/lib/elm_layout.h | 24 ++++++++++----- 3 files changed, 68 insertions(+), 40 deletions(-) diff --git a/src/lib/elm_deprecated.h b/src/lib/elm_deprecated.h index 41eb55a..f80607d 100644 --- a/src/lib/elm_deprecated.h +++ b/src/lib/elm_deprecated.h @@ -1823,6 +1823,7 @@ EINA_DEPRECATED EAPI const char *elm_label_label_get(const Evas_Object *obj); * @param obj The layout object * @param swallow The swallow part name in the edje file * @param content The child that will be added in this layout object + * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise * * Once the content object is set, a previously set one will be deleted. * If you want to keep that old content object, use the @@ -1841,7 +1842,7 @@ EINA_DEPRECATED EAPI const char *elm_label_label_get(const Evas_Object *obj); * * @ingroup Layout */ -EINA_DEPRECATED EAPI void elm_layout_content_set(Evas_Object *obj, const char *swallow, Evas_Object *content); +EINA_DEPRECATED EAPI Eina_Bool elm_layout_content_set(Evas_Object *obj, const char *swallow, Evas_Object *content); /** * Get the child object in the given content part. @@ -1878,11 +1879,12 @@ EINA_DEPRECATED EAPI Evas_Object *elm_layout_content_unset(Evas_Object *obj, con * @param obj The layout object * @param part The TEXT part where to set the text * @param text The text to set + * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise * * @ingroup Layout * @deprecated use elm_object_part_text_set() instead. */ -EINA_DEPRECATED EAPI void elm_layout_text_set(Evas_Object *obj, const char *part, const char *text); +EINA_DEPRECATED EAPI Eina_Bool elm_layout_text_set(Evas_Object *obj, const char *part, const char *text); /** * Get the text set in the given part diff --git a/src/lib/elm_layout.c b/src/lib/elm_layout.c index 215704d..753ea36 100644 --- a/src/lib/elm_layout.c +++ b/src/lib/elm_layout.c @@ -513,10 +513,11 @@ elm_layout_theme_set(Evas_Object *obj, const char *clas, const char *group, cons return ret; } -EAPI void +EAPI Eina_Bool elm_layout_content_set(Evas_Object *obj, const char *swallow, Evas_Object *content) { _content_set_hook(obj, swallow, content); + return EINA_TRUE; } @@ -532,10 +533,11 @@ elm_layout_content_unset(Evas_Object *obj, const char *swallow) return _content_unset_hook(obj, swallow); } -EAPI void +EAPI Eina_Bool elm_layout_text_set(Evas_Object *obj, const char *part, const char *text) { _elm_layout_label_set(obj, part, text); + return EINA_TRUE; } EAPI const char * @@ -544,13 +546,13 @@ elm_layout_text_get(const Evas_Object *obj, const char *part) return _elm_layout_label_get(obj, part); } -EAPI void +EAPI Eina_Bool elm_layout_box_append(Evas_Object *obj, const char *part, Evas_Object *child) { - ELM_CHECK_WIDTYPE(obj, widtype); + ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE; Widget_Data *wd = elm_widget_data_get(obj); Subinfo *si; - if (!wd) return; + if (!wd) return EINA_FALSE; if (!edje_object_part_box_append(wd->lay, part, child)) WRN("child %p could not be appended to box part '%s'", child, part); @@ -564,15 +566,17 @@ elm_layout_box_append(Evas_Object *obj, const char *part, Evas_Object *child) si->obj = child; wd->subs = eina_list_append(wd->subs, si); _request_sizing_eval(wd); + + return EINA_TRUE; } -EAPI void +EAPI Eina_Bool elm_layout_box_prepend(Evas_Object *obj, const char *part, Evas_Object *child) { - ELM_CHECK_WIDTYPE(obj, widtype); + ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE; Widget_Data *wd = elm_widget_data_get(obj); Subinfo *si; - if (!wd) return; + if (!wd) return EINA_FALSE; if (!edje_object_part_box_prepend(wd->lay, part, child)) WRN("child %p could not be prepended to box part '%s'", child, part); @@ -586,6 +590,8 @@ elm_layout_box_prepend(Evas_Object *obj, const char *part, Evas_Object *child) si->obj = child; wd->subs = eina_list_prepend(wd->subs, si); _request_sizing_eval(wd); + + return EINA_TRUE; } static void @@ -595,13 +601,13 @@ _box_reference_del(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, si->p.box.reference = NULL; } -EAPI void +EAPI Eina_Bool elm_layout_box_insert_before(Evas_Object *obj, const char *part, Evas_Object *child, const Evas_Object *reference) { - ELM_CHECK_WIDTYPE(obj, widtype); + ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE; Widget_Data *wd = elm_widget_data_get(obj); Subinfo *si; - if (!wd) return; + if (!wd) return EINA_FALSE; if (!edje_object_part_box_insert_before(wd->lay, part, child, reference)) WRN("child %p could not be inserted before %p inf box part '%s'", @@ -621,15 +627,17 @@ elm_layout_box_insert_before(Evas_Object *obj, const char *part, Evas_Object *ch wd->subs = eina_list_append(wd->subs, si); _request_sizing_eval(wd); + + return EINA_TRUE; } -EAPI void +EAPI Eina_Bool elm_layout_box_insert_at(Evas_Object *obj, const char *part, Evas_Object *child, unsigned int pos) { - ELM_CHECK_WIDTYPE(obj, widtype); + ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE; Widget_Data *wd = elm_widget_data_get(obj); Subinfo *si; - if (!wd) return; + if (!wd) return EINA_FALSE; if (!edje_object_part_box_insert_at(wd->lay, part, child, pos)) WRN("child %p could not be inserted at %u to box part '%s'", @@ -646,6 +654,8 @@ elm_layout_box_insert_at(Evas_Object *obj, const char *part, Evas_Object *child, si->p.box.pos = pos; wd->subs = eina_list_append(wd->subs, si); _request_sizing_eval(wd); + + return EINA_TRUE; } static Evas_Object * @@ -711,16 +721,16 @@ elm_layout_box_remove(Evas_Object *obj, const char *part, Evas_Object *child) return NULL; } -EAPI void +EAPI Eina_Bool elm_layout_box_remove_all(Evas_Object *obj, const char *part, Eina_Bool clear) { - ELM_CHECK_WIDTYPE(obj, widtype); + ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE; Widget_Data *wd = elm_widget_data_get(obj); Subinfo *si; Eina_List *lst; - if (!wd) return; - EINA_SAFETY_ON_NULL_RETURN(part); + if (!wd) return EINA_FALSE; + EINA_SAFETY_ON_NULL_RETURN_VAL(part, EINA_FALSE); lst = eina_list_clone(wd->subs); EINA_LIST_FREE(lst, si) @@ -734,15 +744,17 @@ elm_layout_box_remove_all(Evas_Object *obj, const char *part, Eina_Bool clear) } /* eventually something may not be added with layout, del them as well */ edje_object_part_box_remove_all(wd->lay, part, clear); + + return EINA_TRUE; } -EAPI void +EAPI Eina_Bool elm_layout_table_pack(Evas_Object *obj, const char *part, Evas_Object *child, unsigned short col, unsigned short row, unsigned short colspan, unsigned short rowspan) { - ELM_CHECK_WIDTYPE(obj, widtype); + ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE; Widget_Data *wd = elm_widget_data_get(obj); Subinfo *si; - if (!wd) return; + if (!wd) return EINA_FALSE; if (!edje_object_part_table_pack (wd->lay, part, child, col, row, colspan, rowspan)) @@ -763,6 +775,8 @@ elm_layout_table_pack(Evas_Object *obj, const char *part, Evas_Object *child, un si->p.table.rowspan = rowspan; wd->subs = eina_list_append(wd->subs, si); _request_sizing_eval(wd); + + return EINA_TRUE; } EAPI Evas_Object * @@ -786,16 +800,16 @@ elm_layout_table_unpack(Evas_Object *obj, const char *part, Evas_Object *child) return NULL; } -EAPI void +EAPI Eina_Bool elm_layout_table_clear(Evas_Object *obj, const char *part, Eina_Bool clear) { - ELM_CHECK_WIDTYPE(obj, widtype); + ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE; Widget_Data *wd = elm_widget_data_get(obj); Subinfo *si; Eina_List *lst; - if (!wd) return; - EINA_SAFETY_ON_NULL_RETURN(part); + if (!wd) return EINA_FALSE; + EINA_SAFETY_ON_NULL_RETURN_VAL(part, EINA_FALSE); lst = eina_list_clone(wd->subs); EINA_LIST_FREE(lst, si) @@ -809,6 +823,8 @@ elm_layout_table_clear(Evas_Object *obj, const char *part, Eina_Bool clear) } /* eventually something may not be added with layout, del them as well */ edje_object_part_table_clear(wd->lay, part, clear); + + return EINA_TRUE; } EAPI Evas_Object * @@ -895,13 +911,13 @@ elm_layout_part_cursor_get(const Evas_Object *obj, const char *part_name) return elm_object_cursor_get(pc->obj); } -EAPI void +EAPI Eina_Bool elm_layout_part_cursor_unset(Evas_Object *obj, const char *part_name) { - ELM_CHECK_WIDTYPE(obj, widtype); - EINA_SAFETY_ON_NULL_RETURN(part_name); + ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE; + EINA_SAFETY_ON_NULL_RETURN_VAL(part_name, EINA_FALSE); Widget_Data *wd = elm_widget_data_get(obj); - EINA_SAFETY_ON_NULL_RETURN(wd); + EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EINA_FALSE); Eina_List *l; Part_Cursor *pc; @@ -912,9 +928,11 @@ elm_layout_part_cursor_unset(Evas_Object *obj, const char *part_name) if (pc->obj) elm_object_cursor_unset(pc->obj); _part_cursor_free(pc); wd->parts_cursors = eina_list_remove_list(wd->parts_cursors, l); - return; + return EINA_TRUE; } } + + return EINA_FALSE; } EAPI Eina_Bool diff --git a/src/lib/elm_layout.h b/src/lib/elm_layout.h index df0c4a5..1f87fd4 100644 --- a/src/lib/elm_layout.h +++ b/src/lib/elm_layout.h @@ -197,6 +197,7 @@ EAPI Eina_Bool elm_layout_theme_set(Evas_Object *obj, const c * @param obj the layout object * @param part the box part to which the object will be appended. * @param child the child object to append to box. + * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise * * Once the object is appended, it will become child of the layout. Its * lifetime will be bound to the layout, whenever the layout dies the child @@ -210,7 +211,7 @@ EAPI Eina_Bool elm_layout_theme_set(Evas_Object *obj, const c * * @ingroup Layout */ -EAPI void elm_layout_box_append(Evas_Object *obj, const char *part, Evas_Object *child); +EAPI Eina_Bool elm_layout_box_append(Evas_Object *obj, const char *part, Evas_Object *child); /** * Prepend child to layout box part. @@ -218,6 +219,7 @@ EAPI void elm_layout_box_append(Evas_Object *obj, const * @param obj the layout object * @param part the box part to prepend. * @param child the child object to prepend to box. + * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise * * Once the object is prepended, it will become child of the layout. Its * lifetime will be bound to the layout, whenever the layout dies the child @@ -231,7 +233,7 @@ EAPI void elm_layout_box_append(Evas_Object *obj, const * * @ingroup Layout */ -EAPI void elm_layout_box_prepend(Evas_Object *obj, const char *part, Evas_Object *child); +EAPI Eina_Bool elm_layout_box_prepend(Evas_Object *obj, const char *part, Evas_Object *child); /** * Insert child to layout box part before a reference object. @@ -240,6 +242,7 @@ EAPI void elm_layout_box_prepend(Evas_Object *obj, const * @param part the box part to insert. * @param child the child object to insert into box. * @param reference another reference object to insert before in box. + * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise * * Once the object is inserted, it will become child of the layout. Its * lifetime will be bound to the layout, whenever the layout dies the child @@ -253,7 +256,7 @@ EAPI void elm_layout_box_prepend(Evas_Object *obj, const * * @ingroup Layout */ -EAPI void elm_layout_box_insert_before(Evas_Object *obj, const char *part, Evas_Object *child, const Evas_Object *reference); +EAPI Eina_Bool elm_layout_box_insert_before(Evas_Object *obj, const char *part, Evas_Object *child, const Evas_Object *reference); /** * Insert child to layout box part at a given position. @@ -262,6 +265,7 @@ EAPI void elm_layout_box_insert_before(Evas_Object *obj, * @param part the box part to insert. * @param child the child object to insert into box. * @param pos the numeric position >=0 to insert the child. + * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise * * Once the object is inserted, it will become child of the layout. Its * lifetime will be bound to the layout, whenever the layout dies the child @@ -275,7 +279,7 @@ EAPI void elm_layout_box_insert_before(Evas_Object *obj, * * @ingroup Layout */ -EAPI void elm_layout_box_insert_at(Evas_Object *obj, const char *part, Evas_Object *child, unsigned int pos); +EAPI Eina_Bool elm_layout_box_insert_at(Evas_Object *obj, const char *part, Evas_Object *child, unsigned int pos); /** * Remove a child of the given part box. @@ -304,6 +308,7 @@ EAPI Evas_Object *elm_layout_box_remove(Evas_Object *obj, const * @param clear If EINA_TRUE, then all objects will be deleted as * well, otherwise they will just be removed and will be * dangling on the canvas. + * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise * * The objects will be removed from the box part and their lifetime will * not be handled by the layout anymore. This is equivalent to @@ -314,7 +319,7 @@ EAPI Evas_Object *elm_layout_box_remove(Evas_Object *obj, const * * @ingroup Layout */ -EAPI void elm_layout_box_remove_all(Evas_Object *obj, const char *part, Eina_Bool clear); +EAPI Eina_Bool elm_layout_box_remove_all(Evas_Object *obj, const char *part, Eina_Bool clear); /** * Insert child to layout table part. @@ -327,6 +332,7 @@ EAPI void elm_layout_box_remove_all(Evas_Object *obj, co * @param colspan how many columns should be used to store this object. (>= * 1) * @param rowspan how many rows should be used to store this object. (>= 1) + * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise * * Once the object is inserted, it will become child of the table. Its * lifetime will be bound to the layout, and whenever the layout dies the @@ -349,7 +355,7 @@ EAPI void elm_layout_box_remove_all(Evas_Object *obj, co * * @ingroup Layout */ -EAPI void elm_layout_table_pack(Evas_Object *obj, const char *part, Evas_Object *child_obj, unsigned short col, unsigned short row, unsigned short colspan, unsigned short rowspan); +EAPI Eina_Bool elm_layout_table_pack(Evas_Object *obj, const char *part, Evas_Object *child_obj, unsigned short col, unsigned short row, unsigned short colspan, unsigned short rowspan); /** * Unpack (remove) a child of the given part table. @@ -378,6 +384,7 @@ EAPI Evas_Object *elm_layout_table_unpack(Evas_Object *obj, cons * @param clear If EINA_TRUE, then all objects will be deleted as * well, otherwise they will just be removed and will be * dangling on the canvas. + * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise * * The objects will be removed from the table part and their lifetime will * not be handled by the layout anymore. This is equivalent to @@ -388,7 +395,7 @@ EAPI Evas_Object *elm_layout_table_unpack(Evas_Object *obj, cons * * @ingroup Layout */ -EAPI void elm_layout_table_clear(Evas_Object *obj, const char *part, Eina_Bool clear); +EAPI Eina_Bool elm_layout_table_clear(Evas_Object *obj, const char *part, Eina_Bool clear); /** * Get the edje layout @@ -504,10 +511,11 @@ EAPI const char *elm_layout_part_cursor_get(const Evas_Object * * @param obj The layout object. * @param part_name a part from loaded edje group, that had a cursor set * with elm_layout_part_cursor_set(). + * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise * * @ingroup Layout */ -EAPI void elm_layout_part_cursor_unset(Evas_Object *obj, const char *part_name); +EAPI Eina_Bool elm_layout_part_cursor_unset(Evas_Object *obj, const char *part_name); /** * Sets a specific cursor style for an edje part. -- 2.7.4