Hello,
I have a patch for genlist.

1. elm_genlist_item_item_class_update() API
It is required to change an item's item class on run-time.
Applications want to change a certain item's style and callbacks
dynamically.
This looks ok because changing one item's style does not affect performance,
And this API uses elm_genlist_item_update internally.
API name follows elementary naming conventions.
I've also added test code to elementary_test, Genlist 7.

2. constant to macro.
I replaced 2 constants for max_item_per_block and longpress_timeout to
macros.
This could be used in other places of the code.

3. duplicated assignment.
In elm_genlist_item_append, it->before = 0 is written in if and else.
I put this statement out of if().

4. fix doxygen typo
I fixed elm_genlist_compress_mode_set doxygen.

Thanks.
Daniel Juyung Seo.

Index: TMP/st/elementary/src/bin/test_genlist.c
===================================================================
--- TMP/st/elementary/src/bin/test_genlist.c    (revision 54616)
+++ TMP/st/elementary/src/bin/test_genlist.c    (working copy)
@@ -1195,7 +1195,16 @@ struct genlist7_data
   Evas_Object *win, *pager;
 };
 
+static Elm_Genlist_Item_Class itc7;
 static void
+gl_sel7(void *data, Evas_Object *obj, void *event_info)
+{
+   if (!event_info) return;
+   elm_genlist_item_item_class_update(event_info, &itc7);
+   printf("sel item data [%p] on genlist obj [%p], item pointer [%p], new item 
style [%s] \n", data, obj, event_info, itc7.item_style);
+}
+
+static void
 test_genlist7_back_cb(void *data, Evas_Object *obj __UNUSED__, void 
*event_info __UNUSED__)
 {
     struct genlist7_data *info = data;
@@ -1277,20 +1286,26 @@ test_genlist7(void *data __UNUSED__, Evas_Object *
    itc2.func.state_get = gl2_state_get;
    itc2.func.del       = gl2_del;
 
+   itc7.item_style     = "double_label";
+   itc7.func.label_get = gl5_label_get;
+   itc7.func.icon_get  = gl5_icon_get;
+   itc7.func.state_get = gl5_state_get;
+   itc7.func.del       = gl5_del;
+
    tit[0].mode = 0;
    tit[0].item = elm_genlist_item_append(gl, &itc2,
                                         &(tit[0])/* item data */, NULL/* 
parent */,
-                                         ELM_GENLIST_ITEM_NONE, gl_sel/* func 
*/,
+                                         ELM_GENLIST_ITEM_NONE, gl_sel7/* func 
*/,
                                         NULL/* func data */);
    tit[1].mode = 1;
    tit[1].item = elm_genlist_item_append(gl, &itc2,
                                         &(tit[1])/* item data */, NULL/* 
parent */,
-                                         ELM_GENLIST_ITEM_NONE, gl_sel/* func 
*/,
+                                         ELM_GENLIST_ITEM_NONE, gl_sel7/* func 
*/,
                                         NULL/* func data */);
    tit[2].mode = 2;
    tit[2].item = elm_genlist_item_append(gl, &itc2,
                                         &(tit[2])/* item data */, NULL/* 
parent */,
-                                         ELM_GENLIST_ITEM_NONE, gl_sel/* func 
*/,
+                                         ELM_GENLIST_ITEM_NONE, gl_sel7/* func 
*/,
                                         NULL/* func data */);
 
    evas_object_resize(win, 320, 320);
Index: TMP/st/elementary/src/lib/Elementary.h.in
===================================================================
--- TMP/st/elementary/src/lib/Elementary.h.in   (revision 54616)
+++ TMP/st/elementary/src/lib/Elementary.h.in   (working copy)
@@ -1665,6 +1665,7 @@ extern "C" {
    EAPI void              elm_genlist_item_icons_orphan(Elm_Genlist_Item *it);
    EAPI const Evas_Object *elm_genlist_item_object_get(const Elm_Genlist_Item 
*it);
    EAPI void              elm_genlist_item_update(Elm_Genlist_Item *item);
+   EAPI void              elm_genlist_item_item_class_update(Elm_Genlist_Item 
*it, Elm_Genlist_Item_Class *itc);
    EAPI void              elm_genlist_item_tooltip_text_set(Elm_Genlist_Item 
*item, const char *text);
    EAPI void              
elm_genlist_item_tooltip_content_cb_set(Elm_Genlist_Item *item, 
Elm_Tooltip_Item_Content_Cb func, const void *data, Evas_Smart_Cb del_cb);
    EAPI void              elm_genlist_item_tooltip_unset(Elm_Genlist_Item 
*item);
Index: TMP/st/elementary/src/lib/elm_genlist.c
===================================================================
--- TMP/st/elementary/src/lib/elm_genlist.c     (revision 54616)
+++ TMP/st/elementary/src/lib/elm_genlist.c     (working copy)
@@ -3,6 +3,8 @@
 #include "elm_priv.h"
 
 #define SWIPE_MOVES 12
+#define MAX_ITEMS_PER_BLOCK 32
+#define LONGPRESS_TIMEOUT 1.0
 
 /**
  * @defgroup Genlist Genlist
@@ -2123,9 +2125,9 @@ elm_genlist_add(Evas_Object *parent)
 
    wd->obj = obj;
    wd->mode = ELM_LIST_SCROLL;
-   wd->max_items_per_block = 32;
+   wd->max_items_per_block = MAX_ITEMS_PER_BLOCK;
    wd->item_cache_max = wd->max_items_per_block * 2;
-   wd->longpress_timeout = 1.0;
+   wd->longpress_timeout = LONGPRESS_TIMEOUT;
 
    evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
    evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
@@ -2423,7 +2425,6 @@ elm_genlist_item_append(Evas_Object *obj, const El
      {
         wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
         it->rel = NULL;
-        it->before = 0;
      }
    else
      {
@@ -2437,8 +2438,8 @@ elm_genlist_item_append(Evas_Object *obj, const El
                                        EINA_INLIST_GET(it2));
         it->rel = it2;
         it->rel->relcount++;
-        it->before = 0;
      }
+   it->before = 0;
    _item_queue(wd, it);
    return it;
 }
@@ -3555,6 +3556,25 @@ elm_genlist_item_update(Elm_Genlist_Item *it)
    it->wd->update_job = ecore_job_add(_update_job, it->wd);
 }
 
+/**
+ * Update the item class of an item
+ *
+ * @param it The item
+ * @parem itc The item class for the item
+ *
+ * @ingroup Genlist
+ */
+EAPI void
+elm_genlist_item_item_class_update(Elm_Genlist_Item *it, 
Elm_Genlist_Item_Class *itc)
+{
+   ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
+   if (!it->block) return;
+   if (!itc) return;
+   if (it->delete_me) return;
+   it->itc = itc;
+   elm_genlist_item_update(it);
+}
+
 static Evas_Object *
 _elm_genlist_item_label_create(void *data, Evas_Object *obj, void *item 
__UNUSED__)
 {
@@ -3960,8 +3980,8 @@ elm_genlist_no_select_mode_get(const Evas_Object *
  * Set compress mode
  *
  * This will enable the compress mode where items are "compressed" horizontally
- * to fit the genlist scrollable viewport width. this is special for gnelist.
- * do not rely on elm_genlist_horizontal_mode_set() being set to
+ * to fit the genlist scrollable viewport width. This is special for genlist.
+ * Do not rely on elm_genlist_horizontal_mode_set() being set to
  * ELM_LIST_COMPRESS to work as genlist needs to handle it specially.
  *
  * @param obj The genlist object
------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today
http://p.sf.net/sfu/msIE9-sfdev2dev
_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to