cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=246df0818442c11d03c192e0df4bb0a40acf00d8

commit 246df0818442c11d03c192e0df4bb0a40acf00d8
Author: Vorobiov Vitalii <[email protected]>
Date:   Fri Jun 13 18:02:27 2014 +0200

    edje: Edje_Edit - add edje_edit_part_item_source functions.
    
    Summary:
    Changing item's sources and getting current source of the item.
    Add getter and setter for functions with source value in item.
    Main functions:
    - edje_edit_part_item_source_get
    - edje_edit_part_item_source_set
    
    @feature
    
    Reviewers: cedric, Hermet, seoz, raster
    
    CC: reutskiy.v.v, cedric
    
    Differential Revision: https://phab.enlightenment.org/D1027
    
    Signed-off-by: Cedric BAIL <[email protected]>
---
 src/lib/edje/Edje_Edit.h | 23 +++++++++++++++-
 src/lib/edje/edje_edit.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 92 insertions(+), 1 deletion(-)

diff --git a/src/lib/edje/Edje_Edit.h b/src/lib/edje/Edje_Edit.h
index 77240aa..ae004a9 100644
--- a/src/lib/edje/Edje_Edit.h
+++ b/src/lib/edje/Edje_Edit.h
@@ -1557,7 +1557,7 @@ EAPI Eina_Bool 
edje_edit_part_drag_threshold_set(Evas_Object *obj, const char *p
  * @param obj Object being edited.
  * @param part Part to add a new item. This part should have BOX or TABLE type.
  * @param item_name Name of new item that is not exist in BOX or TABLE yet.
- * @param source_group Source (means group name) of the
+ * @param source_group Source (means group name) of the new item
  *
  * @return EINA_TRUE if successful, EINA_FALSE otherwise.
  */
@@ -1571,6 +1571,27 @@ EAPI Eina_Bool edje_edit_part_item_append(Evas_Object 
*obj, const char *part, co
  */
 EAPI Eina_List * edje_edit_part_items_list_get(Evas_Object *obj, const char 
*part);
 
+/** Set source 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 item_name Name of item.
+ * @param source_group New gorup name.
+ *
+ * @return EINA_TRUE if successful, EINA_FALSE otherwise.
+ */
+EAPI Eina_Bool edje_edit_part_item_source_set(Evas_Object *obj, const char 
*part, const char *item_name, const char *source_group);
+
+/** Get source 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 item_name Name of item.
+ *
+ * @return source of the given item.
+ */
+EAPI const char * edje_edit_part_item_source_get(Evas_Object *obj, const char 
*part, const char *item_name);
+
 //@}
 
/******************************************************************************/
 /**************************   STATES API   
************************************/
diff --git a/src/lib/edje/edje_edit.c b/src/lib/edje/edje_edit.c
index c2d1d05..d171600 100644
--- a/src/lib/edje/edje_edit.c
+++ b/src/lib/edje/edje_edit.c
@@ -3793,6 +3793,76 @@ edje_edit_part_items_list_get(Evas_Object *obj, const 
char *part)
    return items_list;
 }
 
+EAPI Eina_Bool
+edje_edit_part_item_source_set(Evas_Object *obj, const char *part, const char 
*item_name, const char *source_group)
+{
+   Edje_Part *ep;
+   unsigned int i;
+   Edje_Pack_Element *item;
+
+   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;
+
+   ep = rp->part;
+
+   if (!ed->file) return EINA_FALSE;
+
+   /* check if a source group is exists. */
+   if (!eina_hash_find(ed->file->collection, source_group))
+     return EINA_FALSE;
+
+   /* check if item is exists and get it. */
+   for (i = 0; i < ep->items_count; ++i)
+     {
+        if (ep->items[i]->name && (!strcmp(ep->items[i]->name, item_name)))
+          {
+             item = ep->items[i];
+             break;
+          }
+     }
+   if (!item) return EINA_FALSE;
+
+   item->source = eina_stringshare_add(source_group);
+
+   return EINA_TRUE;
+}
+
+EAPI const char *
+edje_edit_part_item_source_get(Evas_Object *obj, const char *part, const char 
*item_name)
+{
+   Edje_Part *ep;
+   unsigned int i;
+   Edje_Pack_Element *item;
+
+   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;
+
+   ep = rp->part;
+
+   if (!ed->file) return NULL;
+
+   /* check if item is exists and get it. */
+   for (i = 0; i < ep->items_count; ++i)
+     {
+        if (ep->items[i]->name && (!strcmp(ep->items[i]->name, item_name)))
+          {
+             item = ep->items[i];
+             break;
+          }
+     }
+   if (!item) return NULL;
+
+   return eina_stringshare_add(item->source);
+}
+
 /*********************/
 /*  PART STATES API  */
 /*********************/

-- 


Reply via email to