Hello

I revised some naming conventions by seoz's comment.
And also attaching new test case for elm_genlist_item_fields_update.

Thank you

-----Original Message-----
From: Hyoyoung Chang [mailto:hyoyoung.ch...@samsung.com] 
Sent: Thursday, October 27, 2011 2:06 PM
To: 'Enlightenment developer list'
Subject: [E-devel] [patch] elm_genlist - add elm_genlist_item_fields_update
function

Dear developers

I made a patch to add elm_genlist_item_fields_update function.
It can be used to updating genlist's item part without realize/unrealize
itself.

Prototype is
elm_genlist_item_fields_update
(Elm_Genlist_Item *it, const char *part, Elm_Genlist_Item_Field_Flags itf)

Part supports globbing. Passing "*" to part means updating all parts.
Item field can be one of icon, content and state.
I think it's useful to speed up if an app updates frequently.

Thanks


Index: elementary/src/lib/elm_genlist.c
===================================================================
--- elementary/src/lib/elm_genlist.c    (由щ퉬�쟾 64419)
+++ elementary/src/lib/elm_genlist.c    (�옉�뾽 �궗蹂�)
@@ -1,5 +1,5 @@
 #include <assert.h>
-
+#include <fnmatch.h>
 #include <Elementary.h>
 #include <Elementary_Cursor.h>
 #include "elm_priv.h"
@@ -1663,7 +1663,8 @@
 static void
 _item_label_realize(Elm_Gen_Item *it,
                     Evas_Object *target,
-                    Eina_List **source)
+                    Eina_List **source,
+                    const char *parts)
 {
    if (it->itc->func.label_get)
      {
@@ -1673,6 +1674,9 @@
         *source = elm_widget_stringlist_get(edje_object_data_get(target, 
"labels"));
         EINA_LIST_FOREACH(*source, l, key)
           {
+             if (parts && fnmatch(parts, key, FNM_PERIOD))
+               continue;
+
              char *s = it->itc->func.label_get
                 ((void *)it->base.data, WIDGET(it), key);
 
@@ -1692,7 +1696,8 @@
 static Eina_List *
 _item_content_realize(Elm_Gen_Item *it,
                    Evas_Object *target,
-                   Eina_List **source)
+                   Eina_List **source,
+                   const char *parts)
 {
    Eina_List *res = NULL;
 
@@ -1705,6 +1710,9 @@
         *source = elm_widget_stringlist_get(edje_object_data_get(target, 
"contents"));
         EINA_LIST_FOREACH(*source, l, key)
           {
+             if (parts && fnmatch(parts, key, FNM_PERIOD))
+               continue;
+
              if (it->itc->func.content_get)
                ic = it->itc->func.content_get
                   ((void *)it->base.data, WIDGET(it), key);
@@ -1726,7 +1734,8 @@
 static void
 _item_state_realize(Elm_Gen_Item *it,
                     Evas_Object *target,
-                    Eina_List **source)
+                    Eina_List **source,
+                    const char *parts)
 {
    if (it->itc->func.state_get)
      {
@@ -1737,6 +1746,9 @@
         *source = elm_widget_stringlist_get(edje_object_data_get(target, 
"states"));
         EINA_LIST_FOREACH(*source, l, key)
           {
+             if (parts && fnmatch(parts, key, FNM_PERIOD))
+               continue;
+
              Eina_Bool on = it->itc->func.state_get
                 ((void *)it->base.data, WIDGET(it), key);
 
@@ -1895,9 +1907,9 @@
            will clean our mess */
         assert(eina_list_count(it->content_objs) == 0);
 
-        _item_label_realize(it, VIEW(it), &it->labels);
-        it->content_objs = _item_content_realize(it, VIEW(it), &it->contents);
-        _item_state_realize(it, VIEW(it), &it->states);
+        _item_label_realize(it, VIEW(it), &it->labels, NULL);
+        it->content_objs = _item_content_realize(it, VIEW(it), &it->contents, 
NULL);
+        _item_state_realize(it, VIEW(it), &it->states, NULL);
 
         if (!it->item->mincalcd)
           {
@@ -2870,11 +2882,11 @@
       will clean our mess */
    assert(eina_list_count(it->item->mode_content_objs) == 0);
 
-   _item_label_realize(it, it->item->mode_view, &it->item->mode_labels);
-   it->item->mode_content_objs = _item_content_realize(it,
-                                          it->item->mode_view,
-                                          &it->item->mode_contents);
-   _item_state_realize(it, it->item->mode_view, &it->item->mode_states);
+   _item_label_realize(it, it->item->mode_view, &it->item->mode_labels, NULL);
+   it->item->mode_content_objs =
+     _item_content_realize(it, it->item->mode_view,
+                           &it->item->mode_contents, NULL);
+   _item_state_realize(it, it->item->mode_view, &it->item->mode_states, NULL);
 
    edje_object_part_swallow(it->item->mode_view,
                             edje_object_data_get(it->item->mode_view, 
"mode_part"),
@@ -4181,6 +4193,23 @@
 }
 
 EAPI void
+elm_genlist_item_fields_update(Elm_Genlist_Item *it,
+                               const char *parts,
+                               Elm_Genlist_Item_Field_Flags itf)
+{
+   ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
+   if (!it->item->block) return;
+   if (it->delete_me) return;
+
+   if ((!itf) || (itf & ELM_GENLIST_ITEM_FIELD_LABEL))
+     _item_label_realize(it, it->base.view, &it->labels, parts);
+   if ((!itf) || (itf & ELM_GENLIST_ITEM_FIELD_CONTENT))
+     _item_content_realize(it, it->base.view, &it->contents, parts);
+   if ((!itf) || (itf & ELM_GENLIST_ITEM_FIELD_STATE))
+     _item_state_realize(it, it->base.view, &it->states, parts);
+}
+
+EAPI void
 elm_genlist_item_item_class_update(Elm_Gen_Item             *it,
                                    const Elm_Genlist_Item_Class *itc)
 {
Index: elementary/src/lib/Elementary.h.in
===================================================================
--- elementary/src/lib/Elementary.h.in  (由щ퉬�쟾 64419)
+++ elementary/src/lib/Elementary.h.in  (�옉�뾽 �궗蹂�)
@@ -18196,6 +18196,13 @@
         ELM_GENLIST_ITEM_SUBITEMS = (1 << 0), /**< may expand and have child 
items */
         ELM_GENLIST_ITEM_GROUP = (1 << 1) /**< index of a group of items */
      } Elm_Genlist_Item_Flags;
+   typedef enum _Elm_Genlist_Item_Field_Flags
+     {
+        ELM_GENLIST_ITEM_FIELD_ALL = 0,
+        ELM_GENLIST_ITEM_FIELD_LABEL = (1 << 0),
+        ELM_GENLIST_ITEM_FIELD_CONTENT = (1 << 1),
+        ELM_GENLIST_ITEM_FIELD_STATE = (1 << 2)
+     } Elm_Genlist_Item_Field_Flags;
    typedef struct _Elm_Genlist_Item_Class Elm_Genlist_Item_Class;  /**< 
Genlist item class definition structs */
    #define Elm_Genlist_Item_Class Elm_Gen_Item_Class
    typedef struct _Elm_Genlist_Item       Elm_Genlist_Item; /**< Item of 
Elm_Genlist. Sub-type of Elm_Widget_Item */
@@ -19230,6 +19237,27 @@
     */
    EAPI void               elm_genlist_item_update(Elm_Genlist_Item *item) 
EINA_ARG_NONNULL(1);
    /**
+    * Update the part of an item
+    *
+    * @param it The item
+    * @param parts The name of item's part
+    * @param itf The flags of item's part type
+    *
+    * This updates an item's part by calling item's fetching functions again
+    * to get the icons, labels and states. Use this when the original
+    * item data has changed and the changes are desired to be reflected.
+    * Second parts argument is used for globbing to match '*', '?', and '.'
+    * It can be used at updating multi fields.
+    *
+    * Use elm_genlist_realized_items_update() to update an item's all  
+    * property.
+    *
+    * @see elm_genlist_item_update()
+    *
+    * @ingroup Genlist
+    */
+   EAPI void               elm_genlist_item_fields_update(Elm_Genlist_Item 
*it, const char *parts, Elm_Genlist_Item_Field_Flags itf) EINA_ARG_NONNULL(1);
+   /**
     * Update the item class of an item
     *
     * @param it The item
Index: elementary/src/bin/test_genlist.c
===================================================================
--- elementary/src/bin/test_genlist.c   (由щ퉬�쟾 64419)
+++ elementary/src/bin/test_genlist.c   (�옉�뾽 �궗蹂�)
@@ -567,6 +567,22 @@
    elm_genlist_item_update(tit->item);
 }
 
+static void
+my_gl_labels_update(void *data, Evas_Object *obj __UNUSED__, void *event_info 
__UNUSED__)
+{
+   Testitem *tit = data;
+   tit->mode++;
+   elm_genlist_item_fields_update(tit->item, "*", 
ELM_GENLIST_ITEM_FIELD_LABEL);
+}
+
+static void
+my_gl_contents_update(void *data, Evas_Object *obj __UNUSED__, void 
*event_info __UNUSED__)
+{
+   Testitem *tit = data;
+   tit->mode++;
+   elm_genlist_item_fields_update(tit->item, "*", 
ELM_GENLIST_ITEM_FIELD_CONTENT);
+}
+
 void
 test_genlist3(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void 
*event_info __UNUSED__)
 {
@@ -629,16 +645,16 @@
    evas_object_show(bt);
 
    bt = elm_button_add(win);
-   elm_object_text_set(bt, "[2]");
-   evas_object_smart_callback_add(bt, "clicked", my_gl_update, &(tit[1]));
+   elm_object_text_set(bt, "labels");
+   evas_object_smart_callback_add(bt, "clicked", my_gl_labels_update, 
&(tit[1]));
    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
    elm_box_pack_end(bx2, bt);
    evas_object_show(bt);
 
    bt = elm_button_add(win);
-   elm_object_text_set(bt, "[3]");
-   evas_object_smart_callback_add(bt, "clicked", my_gl_update, &(tit[2]));
+   elm_object_text_set(bt, "contents");
+   evas_object_smart_callback_add(bt, "clicked", my_gl_contents_update, 
&(tit[2]));
    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
    elm_box_pack_end(bx2, bt);
------------------------------------------------------------------------------
The demand for IT networking professionals continues to grow, and the
demand for specialized networking skills is growing even more rapidly.
Take a complimentary Learning@Cisco Self-Assessment and learn 
about Cisco certifications, training, and career opportunities. 
http://p.sf.net/sfu/cisco-dev2dev
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to