From: Vyacheslav Reutskiy Date: Fri, 3 Jun 2016 09:26:57 +0000 (+0300) Subject: edje_edit: add API for set/get part item X-Git-Tag: accepted/tizen/common/20160804.174451~40 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=36d0eea5ff3fcbc4bb7434255cc154737d27c9c6;p=platform%2Fupstream%2Fefl.git edje_edit: add API for set/get part item Change-Id: Ib09ffb4b7f565d4736dfe889effb0cb7bf83d294 --- diff --git a/src/lib/edje/Edje_Edit.h b/src/lib/edje/Edje_Edit.h index 5f5cb86..0422e83 100644 --- a/src/lib/edje/Edje_Edit.h +++ b/src/lib/edje/Edje_Edit.h @@ -2507,6 +2507,31 @@ EAPI Eina_Bool edje_edit_part_item_del(Evas_Object *obj, const char *part, const EAPI Eina_Bool edje_edit_part_item_index_del(Evas_Object *obj, const char *part, unsigned int index); +/** Set name for item from table or box items. + * + * @param obj Object being edited. + * @param part Part to change item's source. This part should have BOX or TABLE type. + * @param index Index of item + * @param name New item name. + * + * @return @c EINA_TRUE in case of success, @c EINA_FALSE otherwise. + * @since 1.18 + */ +EAPI Eina_Bool +edje_edit_part_item_index_name_set(Evas_Object *obj, const char *part, unsigned int index, const char *name); + +/** Get name for item from table or box items. + * + * @param obj Object being edited. + * @param part Part to return item's source. This part should have BOX or TABLE type. + * @param index Index of item. + * + * @return name of the given item. + * @since 1.18 + */ +EAPI const char * +edje_edit_part_item_index_name_get(Evas_Object *obj, const char *part, unsigned int index); + /** Set source for item from table or box items. * * @param obj Object being edited. diff --git a/src/lib/edje/edje_edit.c b/src/lib/edje/edje_edit.c index 2e8ce7c..687a7e5 100644 --- a/src/lib/edje/edje_edit.c +++ b/src/lib/edje/edje_edit.c @@ -5228,6 +5228,59 @@ edje_edit_part_item_index_del(Evas_Object *obj, const char *part, unsigned int i return EINA_TRUE; } +EAPI Eina_Bool +edje_edit_part_item_index_name_set(Evas_Object *obj, const char *part, unsigned int index, const char *name) +{ + Edje_Part *ep; + unsigned int i; + + GET_RP_OR_RETURN(EINA_FALSE); + + /* There is only Box and Table is allowed. */ + if ((rp->part->type != EDJE_PART_TYPE_BOX) && + (rp->part->type != EDJE_PART_TYPE_TABLE)) + return EINA_FALSE; + if (rp->part->items_count < index) + return EINA_FALSE; + + ep = rp->part; + + if (!ed->file) return EINA_FALSE; + + /* check if a part with given name is exists. */ + for (i = 0; i < ep->items_count; ++i) + { + if (ep->items[i]->name && (!strcmp(ep->items[i]->name, name))) + return EINA_FALSE; + } + + eina_stringshare_del(ep->items[index]->name); + ep->items[index]->name = eina_stringshare_add(name); + + return EINA_TRUE; +} + +EAPI const char * +edje_edit_part_item_index_name_get(Evas_Object *obj, const char *part, unsigned int index) +{ + Edje_Part *ep; + + GET_RP_OR_RETURN(NULL); + + /* There is only Box and Table is allowed. */ + if ((rp->part->type != EDJE_PART_TYPE_BOX) && + (rp->part->type != EDJE_PART_TYPE_TABLE)) + return NULL; + if (rp->part->items_count < index) + return EINA_FALSE; + + ep = rp->part; + + if (!ed->file) return NULL; + + return eina_stringshare_add(ep->items[index]->name); +} + /* deprecated */ EAPI Eina_Bool edje_edit_part_item_source_set(Evas_Object *obj, const char *part, const char *item_name, const char *source_group)