Welcome to 2 new elm_list APIs: elm_list_item_style_set/get
authorJosé Roberto de Souza <jose.souza@intel.com>
Fri, 9 Aug 2013 19:36:33 +0000 (16:36 -0300)
committerQuanxian Wang <quanxian.wang@intel.com>
Tue, 29 Oct 2013 10:05:49 +0000 (18:05 +0800)
src/lib/elm_list.c
src/lib/elm_list.h
src/lib/elm_widget_list.h

index 7ebab40..5ec044a 100644 (file)
@@ -77,6 +77,8 @@ _elm_list_item_free(Elm_List_Item *it)
    ELM_SAFE_FREE(it->long_timer, ecore_timer_del);
    ELM_SAFE_FREE(it->icon, evas_object_del);
    ELM_SAFE_FREE(it->end, evas_object_del);
+
+   eina_stringshare_del(it->style);
 }
 
 static Eina_Bool
@@ -663,9 +665,13 @@ _items_fix(Evas_Object *obj)
    i = 0;
    EINA_LIST_FOREACH(sd->items, l, it)
      {
+        const char *item_style;
+
         if (it->deleted)
           continue;
 
+        item_style = it->style ? it->style : style;
+
         it->even = i & 0x1;
         if ((it->even != it->is_even) || (!it->fixed) || (redo))
           {
@@ -674,24 +680,24 @@ _items_fix(Evas_Object *obj)
              if (it->is_separator)
                elm_widget_theme_object_set
                  (obj, VIEW(it), "separator", sd->h_mode ?
-                 "horizontal" : "vertical", style);
+                 "horizontal" : "vertical", item_style);
              else if (sd->mode == ELM_LIST_COMPRESS)
                {
                   if (it->even)
                     elm_widget_theme_object_set
-                      (obj, VIEW(it), "list", it_compress, style);
+                      (obj, VIEW(it), "list", it_compress, item_style);
                   else
                     elm_widget_theme_object_set
-                      (obj, VIEW(it), "list", it_compress_odd, style);
+                      (obj, VIEW(it), "list", it_compress_odd, item_style);
                }
              else
                {
                   if (it->even)
                     elm_widget_theme_object_set
-                      (obj, VIEW(it), "list", it_plain, style);
+                      (obj, VIEW(it), "list", it_plain, item_style);
                   else
                     elm_widget_theme_object_set
-                      (obj, VIEW(it), "list", it_odd, style);
+                      (obj, VIEW(it), "list", it_odd, item_style);
                }
              stacking = edje_object_data_get(VIEW(it), "stacking");
              if (stacking)
@@ -2675,6 +2681,24 @@ _focus_on_selection_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
    *ret = sd->focus_on_selection_enabled;
 }
 
+EAPI void
+elm_list_item_style_set(Elm_Object_Item *it, const char *style)
+{
+   Elm_List_Item *item = (Elm_List_Item *)it;
+   EINA_SAFETY_ON_NULL_RETURN(it);
+   if (item->style)
+     eina_stringshare_del(item->style);
+   item->style = eina_stringshare_add(style);
+}
+
+EAPI const char *
+elm_list_item_style_get(const Elm_Object_Item *it)
+{
+   const Elm_List_Item *item = (Elm_List_Item *)it;
+   EINA_SAFETY_ON_NULL_RETURN_VAL(it, NULL);
+   return item->style;
+}
+
 static void
 _class_constructor(Eo_Class *klass)
 {
index 7dc588e..bb3e665 100644 (file)
 #include <elm_list_legacy.h>
 #endif
 
+EAPI void elm_list_item_style_set(Elm_Object_Item *it, const char *style);
+
+EAPI const char *elm_list_item_style_get(const Elm_Object_Item *it);
+
 /**
  * @}
  */
index bc72908..9952774 100644 (file)
@@ -65,6 +65,7 @@ struct _Elm_List_Item
 
    const char          *label;
    Eina_List           *node;
+   Eina_Stringshare    *style;
 
    Eina_Bool            is_separator : 1;
    Eina_Bool            highlighted : 1;