elementary: elm_genlist now use edje signal for even/odd state.
[framework/uifw/elementary.git] / src / lib / elm_genlist.c
1 #include <Elementary.h>
2 #include <Elementary_Cursor.h>
3 #include "elm_priv.h"
4
5 #define SWIPE_MOVES         12
6 #define MAX_ITEMS_PER_BLOCK 32
7
8 /**
9  * @defgroup Genlist Genlist
10  *
11  * The aim was to have more expansive list than the simple list in
12  * Elementary that could have more flexible items and allow many more entries
13  * while still being fast and low on memory usage. At the same time it was
14  * also made to be able to do tree structures. But the price to pay is more
15  * complex when it comes to usage. If all you want is a simple list with
16  * icons and a single label, use the normal List object.
17  *
18  * Genlist has a fairly large API, mostly because it's relatively complex,
19  * trying to be both expansive, powerful and efficient. First we will begin
20  * an overview on the theory behind genlist.
21  *
22  * Evas tracks every object you create. Every time it processes an event
23  * (mouse move, down, up etc.) it needs to walk through objects and find out
24  * what event that affects. Even worse every time it renders display updates,
25  * in order to just calculate what to re-draw, it needs to walk through many
26  * many many objects. Thus, the more objects you keep active, the more
27  * overhead Evas has in just doing its work. It is advisable to keep your
28  * active objects to the minimum working set you need. Also remember that
29  * object creation and deletion carries an overhead, so there is a
30  * middle-ground, which is not easily determined. But don't keep massive lists
31  * of objects you can't see or use. Genlist does this with list objects. It
32  * creates and destroys them dynamically as you scroll around. It groups them
33  * into blocks so it can determine the visibility etc. of a whole block at
34  * once as opposed to having to walk the whole list. This 2-level list allows
35  * for very large numbers of items to be in the list (tests have used up to
36  * 2,000,000 items). Also genlist employs a queue for adding items. As items
37  * may be different sizes, every item added needs to be calculated as to its
38  * size and thus this presents a lot of overhead on populating the list, this
39  * genlist employs a queue. Any item added is queued and spooled off over
40  * time, actually appearing some time later, so if your list has many members
41  * you may find it takes a while for them to all appear, with your process
42  * consuming a lot of CPU while it is busy spooling.
43  *
44  * Genlist also implements a tree structure, but it does so with callbacks to
45  * the application, with the application filling in tree structures when
46  * requested (allowing for efficient building of a very deep tree that could
47  * even be used for file-management). See the above smart signal callbacks for
48  * details.
49  *
50  * An item in the genlist world can have 0 or more text labels (they can be
51  * regular text or textblock - that's up to the style to determine), 0 or
52  * more icons (which are simply objects swallowed into the genlist item) and
53  * 0 or more boolean states that can be used for check, radio or other
54  * indicators by the edje theme style. An item may be one of several styles
55  * (Elementary provides 4 by default - "default", "double_label", "group_index"
56  * and "icon_top_text_bottom", but this can be extended by system or
57  * application custom themes/overlays/extensions).
58  *
59  * In order to implement the ability to add and delete items on the fly,
60  * Genlist implements a class/callback system where the application provides
61  * a structure with information about that type of item (genlist may contain
62  * multiple different items with different classes, states and styles).
63  * Genlist will call the functions in this struct (methods) when an item is
64  * "realized" (that is created dynamically while scrolling). All objects will
65  * simply be deleted  when no longer needed with evas_object_del(). The
66  * Elm_Genlist_Item_Class structure contains the following members:
67  *
68  * item_style - This is a constant string and simply defines the name of the
69  * item style. It must be specified and the default should be "default".
70  *
71  * func.label_get - This function is called when an actual item object is
72  * created. The data parameter is the data parameter passed to
73  * elm_genlist_item_append() and related item creation functions. The obj
74  * parameter is the genlist object and the part parameter is the string name
75  * of the text part in the edje design that is listed as one of the possible
76  * labels that can be set. This function must return a strudup()'ed string as
77  * the caller will free() it when done.
78  *
79  * func.icon_get - This function is called when an actual item object is
80  * created. The data parameter is the data parameter passed to
81  * elm_genlist_item_append() and related item creation functions. The obj
82  * parameter is the genlist object and the part parameter is the string name
83  * of the icon part in the edje design that is listed as one of the possible
84  * icons that can be set. This must return NULL for no object or a valid
85  * object. The object will be deleted by genlist on shutdown or when the item
86  * is unrealized.
87  *
88  * func.state_get - This function is called when an actual item object is
89  * created. The data parameter is the data parameter passed to
90  * elm_genlist_item_append() and related item creation functions. The obj
91  * parameter is the genlist object and the part parameter is the string name
92  * of the state part in the edje design that is listed as one of the possible
93  * states that can be set. Return 0 for false or 1 for true. Genlist will
94  * emit a signal to the edje object with "elm,state,XXX,active" "elm" when
95  * true (the default is false), where XXX is the name of the part.
96  *
97  * func.del - This is called when elm_genlist_item_del() is called on an
98  * item, elm_genlist_clear() is called on the genlist, or
99  * elm_genlist_item_subitems_clear() is called to clear sub-items. This is
100  * intended for use when actual genlist items are deleted, so any backing
101  * data attached to the item (e.g. its data parameter on creation) can be
102  * deleted.
103  *
104  * Items can be added by several calls. All of them return a Elm_Genlist_Item
105  * handle that is an internal member inside the genlist. They all take a data
106  * parameter that is meant to be used for a handle to the applications
107  * internal data (eg the struct with the original item data). The parent
108  * parameter is the parent genlist item this belongs to if it is a tree or
109  * an indexed group, and NULL if there is no parent. The flags can be a bitmask
110  * of ELM_GENLIST_ITEM_NONE, ELM_GENLIST_ITEM_SUBITEMS and
111  * ELM_GENLIST_ITEM_GROUP. If ELM_GENLIST_ITEM_SUBITEMS is set then this item
112  * is displayed as an item that is able to expand and have child items.
113  * If ELM_GENLIST_ITEM_GROUP is set then this item is group idex item that is
114  * displayed at the top until the next group comes. The func parameter is a
115  * convenience callback that is called when the item is selected and the data
116  * parameter will be the func_data parameter, obj be the genlist object and
117  * event_info will be the genlist item.
118  *
119  * elm_genlist_item_append() appends an item to the end of the list, or if
120  * there is a parent, to the end of all the child items of the parent.
121  * elm_genlist_item_prepend() is the same but prepends to the beginning of
122  * the list or children list. elm_genlist_item_insert_before() inserts at
123  * item before another item and elm_genlist_item_insert_after() inserts after
124  * the indicated item.
125  *
126  * The application can clear the list with elm_genlist_clear() which deletes
127  * all the items in the list and elm_genlist_item_del() will delete a specific
128  * item. elm_genlist_item_subitems_clear() will clear all items that are
129  * children of the indicated parent item.
130  *
131  * If the application wants multiple items to be able to be selected,
132  * elm_genlist_multi_select_set() can enable this. If the list is
133  * single-selection only (the default), then elm_genlist_selected_item_get()
134  * will return the selected item, if any, or NULL I none is selected. If the
135  * list is multi-select then elm_genlist_selected_items_get() will return a
136  * list (that is only valid as long as no items are modified (added, deleted,
137  * selected or unselected)).
138  *
139  * To help inspect list items you can jump to the item at the top of the list
140  * with elm_genlist_first_item_get() which will return the item pointer, and
141  * similarly elm_genlist_last_item_get() gets the item at the end of the list.
142  * elm_genlist_item_next_get() and elm_genlist_item_prev_get() get the next
143  * and previous items respectively relative to the indicated item. Using
144  * these calls you can walk the entire item list/tree. Note that as a tree
145  * the items are flattened in the list, so elm_genlist_item_parent_get() will
146  * let you know which item is the parent (and thus know how to skip them if
147  * wanted).
148  *
149  * There are also convenience functions. elm_genlist_item_genlist_get() will
150  * return the genlist object the item belongs to. elm_genlist_item_show()
151  * will make the scroller scroll to show that specific item so its visible.
152  * elm_genlist_item_data_get() returns the data pointer set by the item
153  * creation functions.
154  *
155  * If an item changes (state of boolean changes, label or icons change),
156  * then use elm_genlist_item_update() to have genlist update the item with
157  * the new state. Genlist will re-realize the item thus call the functions
158  * in the _Elm_Genlist_Item_Class for that item.
159  *
160  * To programmatically (un)select an item use elm_genlist_item_selected_set().
161  * To get its selected state use elm_genlist_item_selected_get(). Similarly
162  * to expand/contract an item and get its expanded state, use
163  * elm_genlist_item_expanded_set() and elm_genlist_item_expanded_get(). And
164  * again to make an item disabled (unable to be selected and appear
165  * differently) use elm_genlist_item_disabled_set() to set this and
166  * elm_genlist_item_disabled_get() to get the disabled state.
167  *
168  * In general to indicate how the genlist should expand items horizontally to
169  * fill the list area, use elm_genlist_horizontal_mode_set(). Valid modes are
170  * ELM_LIST_LIMIT and ELM_LIST_SCROLL . The default is ELM_LIST_SCROLL. This
171  * mode means that if items are too wide to fit, the scroller will scroll
172  * horizontally. Otherwise items are expanded to fill the width of the
173  * viewport of the scroller. If it is ELM_LIST_LIMIT, items will be expanded
174  * to the viewport width and limited to that size. This can be combined with
175  * a different style that uses edjes' ellipsis feature (cutting text off like
176  * this: "tex...").
177  *
178  * Items will only call their selection func and callback when first becoming
179  * selected. Any further clicks will do nothing, unless you enable always
180  * select with elm_genlist_always_select_mode_set(). This means even if
181  * selected, every click will make the selected callbacks be called.
182  * elm_genlist_no_select_mode_set() will turn off the ability to select
183  * items entirely and they will neither appear selected nor call selected
184  * callback functions.
185  *
186  * Remember that you can create new styles and add your own theme augmentation
187  * per application with elm_theme_extension_add(). If you absolutely must
188  * have a specific style that overrides any theme the user or system sets up
189  * you can use elm_theme_overlay_add() to add such a file.
190  *
191  * Signals that you can add callbacks for are:
192  *
193  * "clicked,double" - This is called when a user has double-clicked an item. The
194  *                    event_info parameter is the genlist item that was double-c
195  *                    licked.
196  * "selected" - This is called when a user has made an item selected. The
197  *              event_info parameter is the genlist item that was selected.
198  * "unselected" - This is called when a user has made an item unselected. The
199  *                 event_info parameter is the genlist item that was unselected.
200  * "expanded" - This is called when elm_genlist_item_expanded_set() is called
201  *              and the item is now meant to be expanded. The event_info
202  *              parameter is the genlist item that was indicated to expand. It
203  *              is the job of this callback to then fill in the child items.
204  * "contracted" - This is called when elm_genlist_item_expanded_set() is called
205  *                and the item is now meant to be contracted. The event_info
206  *                parameter is the genlist item that was indicated to contract.
207  *                It is the job of this callback to then delete the child items.
208  * "expand,request" - This is called when a user has indicated they want to
209  *                    expand a tree branch item. The callback should decide if
210  *                    the item can expand (has any children) and then call
211  *                    elm_genlist_item_expanded_set() appropriately to set the
212  *                    state. The event_info parameter is the genlist item that
213  *                    was indicated to expand.
214  * "contract,request" - This is called when a user has indicated they want to
215  *                      contract a tree branch item. The callback should decide
216  *                      if the item can contract (has any children) and then
217  *                      call elm_genlist_item_expanded_set() appropriately to
218  *                      set the state. The event_info parameter is the genlist
219  *                      item that was indicated to contract.
220  * "realized" - This is called when the item in the list is created as a real
221  *              evas object. event_info parameter is the genlist item that was
222  *              created. The object may be deleted at any time, so it is up to
223  *              the caller to not use the object pointer from
224  *              elm_genlist_item_object_get() in a way  where it may point to
225  *              freed objects.
226  * "unrealized" - This is called just before an item is unrealized. After this
227  *                call icon objects provided will be deleted and the item object
228  *                itself delete or be put into a floating cache.
229  * "drag,start,up" - This is called when the item in the list has been dragged
230  *                   (not scrolled) up.
231  * "drag,start,down" - This is called when the item in the list has been dragged
232  *                     (not scrolled) down.
233  * "drag,start,left" - This is called when the item in the list has been dragged
234  *                     (not scrolled) left.
235  * "drag,start,right" - This is called when the item in the list has been
236  *                      dragged (not scrolled) right.
237  * "drag,stop" - This is called when the item in the list has stopped being
238  *               dragged.
239  * "drag" - This is called when the item in the list is being dragged.
240  * "longpressed" - This is called when the item is pressed for a certain amount
241  *                 of time. By default it's 1 second.
242  * "scroll,edge,top" - This is called when the genlist is scrolled until the
243  *                     top edge.
244  * "scroll,edge,bottom" - This is called when the genlist is scrolled until the
245  *                         bottom edge.
246  * "scroll,edge,left" - This is called when the genlist is scrolled until the
247  *                      left edge.
248  * "scroll,edge,right" - This is called when the genlist is scrolled until the
249  *                       right edge.
250  * "multi,swipe,left" - This is called when the genlist is multi-touch swiped
251  *                       left.
252  * "multi,swipe,right" - This is called when the genlist is multi-touch swiped
253  *                       right.
254  * "multi,swipe,up" - This is called when the genlist is multi-touch swiped up.
255  * "multi,swipe,down" - This is called when the genlist is multi-touch swiped
256  *                      down.
257  * "multi,pinch,out" - This is called when the genlist is multi-touch pinched
258  *                     out.
259  * "multi,pinch,in" - This is called when the genlist is multi-touch pinched in.
260  */
261
262 typedef struct _Widget_Data Widget_Data;
263 typedef struct _Item_Block  Item_Block;
264 typedef struct _Pan         Pan;
265 typedef struct _Item_Cache  Item_Cache;
266
267 struct _Widget_Data
268 {
269    Evas_Object      *obj, *scr, *pan_smart;
270    Eina_Inlist      *items, *blocks;
271    Eina_List        *group_items;
272    Pan              *pan;
273    Evas_Coord        pan_x, pan_y, w, h, minw, minh, realminw, prev_viewport_w;
274    Ecore_Job        *calc_job, *update_job;
275    Ecore_Idler      *queue_idler, *must_recalc_idler;
276    Eina_List        *queue, *selected;
277    Elm_Genlist_Item *show_item, *last_selected_item, *anchor_item, *mode_item;
278    Eina_Inlist      *item_cache;
279    Evas_Coord        anchor_y;
280    Elm_List_Mode     mode;
281    Ecore_Timer      *multi_timer, *scr_hold_timer;
282    const char       *mode_type;
283    Evas_Coord        prev_x, prev_y, prev_mx, prev_my;
284    Evas_Coord        cur_x, cur_y, cur_mx, cur_my;
285    Eina_Bool         mouse_down : 1;
286    Eina_Bool         multi_down : 1;
287    Eina_Bool         multi_timeout : 1;
288    Eina_Bool         multitouched : 1;
289    Eina_Bool         on_hold : 1;
290    Eina_Bool         multi : 1;
291    Eina_Bool         always_select : 1;
292    Eina_Bool         longpressed : 1;
293    Eina_Bool         wasselected : 1;
294    Eina_Bool         no_select : 1;
295    Eina_Bool         bring_in : 1;
296    Eina_Bool         compress : 1;
297    Eina_Bool         height_for_width : 1;
298    Eina_Bool         homogeneous : 1;
299    Eina_Bool         clear_me : 1;
300    Eina_Bool         swipe : 1;
301    struct
302    {
303       Evas_Coord x, y;
304    } history[SWIPE_MOVES];
305    int               multi_device;
306    int               item_cache_count;
307    int               item_cache_max;
308    int               movements;
309    int               walking;
310    int               item_width;
311    int               item_height;
312    int               group_item_width;
313    int               group_item_height;
314    int               max_items_per_block;
315    double            longpress_timeout;
316 };
317
318 struct _Item_Block
319 {
320    EINA_INLIST;
321    int          count;
322    int          num;
323    Widget_Data *wd;
324    Eina_List   *items;
325    Evas_Coord   x, y, w, h, minw, minh;
326    Eina_Bool    want_unrealize : 1;
327    Eina_Bool    realized : 1;
328    Eina_Bool    changed : 1;
329    Eina_Bool    updateme : 1;
330    Eina_Bool    showme : 1;
331    Eina_Bool    must_recalc : 1;
332 };
333
334 struct _Elm_Genlist_Item
335 {
336    Elm_Widget_Item               base;
337    EINA_INLIST;
338    Widget_Data                  *wd;
339    Item_Block                   *block;
340    Eina_List                    *items;
341    Evas_Coord                    x, y, w, h, minw, minh;
342    const Elm_Genlist_Item_Class *itc;
343    Elm_Genlist_Item             *parent;
344    Elm_Genlist_Item             *group_item;
345    Elm_Genlist_Item_Flags        flags;
346    struct
347    {
348       Evas_Smart_Cb func;
349       const void   *data;
350    } func;
351
352    Evas_Object                  *spacer;
353    Eina_List                    *labels, *icons, *states, *icon_objs;
354    Eina_List                    *mode_labels, *mode_icons, *mode_states, *mode_icon_objs;
355    Ecore_Timer                  *long_timer;
356    Ecore_Timer                  *swipe_timer;
357    Evas_Coord                    dx, dy;
358    Evas_Coord                    scrl_x, scrl_y;
359
360    Elm_Genlist_Item             *rel;
361    Evas_Object                  *mode_view;
362
363    struct
364    {
365       const void                 *data;
366       Elm_Tooltip_Item_Content_Cb content_cb;
367       Evas_Smart_Cb               del_cb;
368       const char                 *style;
369    } tooltip;
370
371    const char                   *mouse_cursor;
372
373    int                           relcount;
374    int                           walking;
375    int                           expanded_depth;
376    int                           order_num_in;
377
378    Eina_Bool                     before : 1;
379
380    Eina_Bool                     want_unrealize : 1;
381    Eina_Bool                     want_realize : 1;
382    Eina_Bool                     realized : 1;
383    Eina_Bool                     selected : 1;
384    Eina_Bool                     highlighted : 1;
385    Eina_Bool                     expanded : 1;
386    Eina_Bool                     disabled : 1;
387    Eina_Bool                     display_only : 1;
388    Eina_Bool                     mincalcd : 1;
389    Eina_Bool                     queued : 1;
390    Eina_Bool                     showme : 1;
391    Eina_Bool                     delete_me : 1;
392    Eina_Bool                     down : 1;
393    Eina_Bool                     dragging : 1;
394    Eina_Bool                     updateme : 1;
395    Eina_Bool                     nocache : 1;
396    Eina_Bool                     stacking_even : 1;
397    Eina_Bool                     nostacking : 1;
398 };
399
400 struct _Item_Cache
401 {
402    EINA_INLIST;
403
404    Evas_Object *base_view, *spacer;
405
406    const char  *item_style; // it->itc->item_style
407    Eina_Bool    tree : 1; // it->flags & ELM_GENLIST_ITEM_SUBITEMS
408    Eina_Bool    compress : 1; // it->wd->compress
409
410    Eina_Bool    selected : 1; // it->selected
411    Eina_Bool    disabled : 1; // it->disabled
412    Eina_Bool    expanded : 1; // it->expanded
413 };
414
415 #define ELM_GENLIST_ITEM_FROM_INLIST(item) \
416   ((item) ? EINA_INLIST_CONTAINER_GET(item, Elm_Genlist_Item) : NULL)
417
418 struct _Pan
419 {
420    Evas_Object_Smart_Clipped_Data __clipped_data;
421    Widget_Data                   *wd;
422    Ecore_Job                     *resize_job;
423 };
424
425 static const char *widtype = NULL;
426 static void      _item_cache_zero(Widget_Data *wd);
427 static void      _del_hook(Evas_Object *obj);
428 static void      _mirrored_set(Evas_Object *obj,
429                                Eina_Bool    rtl);
430 static void      _theme_hook(Evas_Object *obj);
431 static void      _show_region_hook(void        *data,
432                                    Evas_Object *obj);
433 static void      _sizing_eval(Evas_Object *obj);
434 static void      _item_unrealize(Elm_Genlist_Item *it, Eina_Bool calc);
435 static void      _item_block_unrealize(Item_Block *itb);
436 static void      _calc_job(void *data);
437 static void      _on_focus_hook(void        *data,
438                                 Evas_Object *obj);
439 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
440 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
441 static Eina_Bool _item_single_select_up(Widget_Data *wd);
442 static Eina_Bool _item_single_select_down(Widget_Data *wd);
443 static Eina_Bool _event_hook(Evas_Object       *obj,
444                              Evas_Object       *src,
445                              Evas_Callback_Type type,
446                              void              *event_info);
447 static void      _signal_emit_hook(Evas_Object *obj,
448                                    const char *emission,
449                                    const char *source);
450 static Eina_Bool _deselect_all_items(Widget_Data *wd);
451 static void      _pan_calculate(Evas_Object *obj);
452 static void      _item_position(Elm_Genlist_Item *it, Evas_Object *obj);
453 static void      _mode_item_realize(Elm_Genlist_Item *it);
454 static void      _mode_item_unrealize(Elm_Genlist_Item *it);
455 static void      _item_mode_set(Elm_Genlist_Item *it);
456 static void      _item_mode_unset(Widget_Data *wd);
457
458 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
459
460 static Eina_Bool
461 _event_hook(Evas_Object       *obj,
462             Evas_Object       *src __UNUSED__,
463             Evas_Callback_Type type,
464             void              *event_info)
465 {
466    if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
467    Evas_Event_Key_Down *ev = event_info;
468    Widget_Data *wd = elm_widget_data_get(obj);
469    if (!wd) return EINA_FALSE;
470    if (!wd->items) return EINA_FALSE;
471    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
472    if (elm_widget_disabled_get(obj)) return EINA_FALSE;
473
474    Elm_Genlist_Item *it = NULL;
475    Evas_Coord x = 0;
476    Evas_Coord y = 0;
477    Evas_Coord step_x = 0;
478    Evas_Coord step_y = 0;
479    Evas_Coord v_w = 0;
480    Evas_Coord v_h = 0;
481    Evas_Coord page_x = 0;
482    Evas_Coord page_y = 0;
483
484    elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
485    elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
486    elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
487    elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
488
489    if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
490      {
491         x -= step_x;
492      }
493    else if ((!strcmp(ev->keyname, "Right")) ||
494             (!strcmp(ev->keyname, "KP_Right")))
495      {
496         x += step_x;
497      }
498    else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
499      {
500         if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
501              (_item_multi_select_up(wd)))
502             || (_item_single_select_up(wd)))
503           {
504              ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
505              return EINA_TRUE;
506           }
507         else
508           y -= step_y;
509      }
510    else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
511      {
512         if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
513              (_item_multi_select_down(wd)))
514             || (_item_single_select_down(wd)))
515           {
516              ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
517              return EINA_TRUE;
518           }
519         else
520           y += step_y;
521      }
522    else if ((!strcmp(ev->keyname, "Home")) ||
523             (!strcmp(ev->keyname, "KP_Home")))
524      {
525         it = elm_genlist_first_item_get(obj);
526         elm_genlist_item_bring_in(it);
527         ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
528         return EINA_TRUE;
529      }
530    else if ((!strcmp(ev->keyname, "End")) ||
531             (!strcmp(ev->keyname, "KP_End")))
532      {
533         it = elm_genlist_last_item_get(obj);
534         elm_genlist_item_bring_in(it);
535         ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
536         return EINA_TRUE;
537      }
538    else if ((!strcmp(ev->keyname, "Prior")) ||
539             (!strcmp(ev->keyname, "KP_Prior")))
540      {
541         if (page_y < 0)
542           y -= -(page_y * v_h) / 100;
543         else
544           y -= page_y;
545      }
546    else if ((!strcmp(ev->keyname, "Next")) ||
547             (!strcmp(ev->keyname, "KP_Next")))
548      {
549         if (page_y < 0)
550           y += -(page_y * v_h) / 100;
551         else
552           y += page_y;
553      }
554    else if(((!strcmp(ev->keyname, "Return")) ||
555             (!strcmp(ev->keyname, "KP_Enter")) ||
556             (!strcmp(ev->keyname, "space")))
557            && (!wd->multi) && (wd->selected))
558      {
559         it = elm_genlist_selected_item_get(obj);
560         elm_genlist_item_expanded_set(it,
561                                       !elm_genlist_item_expanded_get(it));
562      }
563    else if (!strcmp(ev->keyname, "Escape"))
564      {
565         if (!_deselect_all_items(wd)) return EINA_FALSE;
566         ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
567         return EINA_TRUE;
568      }
569    else return EINA_FALSE;
570
571    ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
572    elm_smart_scroller_child_pos_set(wd->scr, x, y);
573    return EINA_TRUE;
574 }
575
576 static Eina_Bool
577 _deselect_all_items(Widget_Data *wd)
578 {
579    if (!wd->selected) return EINA_FALSE;
580    while(wd->selected)
581      elm_genlist_item_selected_set(wd->selected->data, EINA_FALSE);
582
583    return EINA_TRUE;
584 }
585
586 static Eina_Bool
587 _item_multi_select_up(Widget_Data *wd)
588 {
589    if (!wd->selected) return EINA_FALSE;
590    if (!wd->multi) return EINA_FALSE;
591
592    Elm_Genlist_Item *prev = elm_genlist_item_prev_get(wd->last_selected_item);
593    if (!prev) return EINA_TRUE;
594
595    if (elm_genlist_item_selected_get(prev))
596      {
597         elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
598         wd->last_selected_item = prev;
599         elm_genlist_item_show(wd->last_selected_item);
600      }
601    else
602      {
603         elm_genlist_item_selected_set(prev, EINA_TRUE);
604         elm_genlist_item_show(prev);
605      }
606    return EINA_TRUE;
607 }
608
609 static Eina_Bool
610 _item_multi_select_down(Widget_Data *wd)
611 {
612    if (!wd->selected) return EINA_FALSE;
613    if (!wd->multi) return EINA_FALSE;
614
615    Elm_Genlist_Item *next = elm_genlist_item_next_get(wd->last_selected_item);
616    if (!next) return EINA_TRUE;
617
618    if (elm_genlist_item_selected_get(next))
619      {
620         elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
621         wd->last_selected_item = next;
622         elm_genlist_item_show(wd->last_selected_item);
623      }
624    else
625      {
626         elm_genlist_item_selected_set(next, EINA_TRUE);
627         elm_genlist_item_show(next);
628      }
629    return EINA_TRUE;
630 }
631
632 static Eina_Bool
633 _item_single_select_up(Widget_Data *wd)
634 {
635    Elm_Genlist_Item *prev;
636    if (!wd->selected)
637      {
638         prev = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
639         while ((prev) && (prev->delete_me))
640           prev = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
641      }
642    else prev = elm_genlist_item_prev_get(wd->last_selected_item);
643
644    if (!prev) return EINA_FALSE;
645
646    _deselect_all_items(wd);
647
648    elm_genlist_item_selected_set(prev, EINA_TRUE);
649    elm_genlist_item_show(prev);
650    return EINA_TRUE;
651 }
652
653 static Eina_Bool
654 _item_single_select_down(Widget_Data *wd)
655 {
656    Elm_Genlist_Item *next;
657    if (!wd->selected)
658      {
659         next = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
660         while ((next) && (next->delete_me))
661           next = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
662      }
663    else next = elm_genlist_item_next_get(wd->last_selected_item);
664
665    if (!next) return EINA_FALSE;
666
667    _deselect_all_items(wd);
668
669    elm_genlist_item_selected_set(next, EINA_TRUE);
670    elm_genlist_item_show(next);
671    return EINA_TRUE;
672 }
673
674 static void
675 _on_focus_hook(void        *data __UNUSED__,
676                Evas_Object *obj)
677 {
678    Widget_Data *wd = elm_widget_data_get(obj);
679    if (!wd) return;
680    if (elm_widget_focus_get(obj))
681      {
682         edje_object_signal_emit(wd->obj, "elm,action,focus", "elm");
683         evas_object_focus_set(wd->obj, EINA_TRUE);
684         if ((wd->selected) && (!wd->last_selected_item))
685           wd->last_selected_item = eina_list_data_get(wd->selected);
686      }
687    else
688      {
689         edje_object_signal_emit(wd->obj, "elm,action,unfocus", "elm");
690         evas_object_focus_set(wd->obj, EINA_FALSE);
691      }
692 }
693
694 static void
695 _del_hook(Evas_Object *obj)
696 {
697    Widget_Data *wd = elm_widget_data_get(obj);
698    if (!wd) return;
699    _item_cache_zero(wd);
700    if (wd->calc_job) ecore_job_del(wd->calc_job);
701    if (wd->update_job) ecore_job_del(wd->update_job);
702    if (wd->must_recalc_idler) ecore_idler_del(wd->must_recalc_idler);
703    if (wd->multi_timer) ecore_timer_del(wd->multi_timer);
704    if (wd->mode_type) eina_stringshare_del(wd->mode_type);
705    if (wd->scr_hold_timer) ecore_timer_del(wd->scr_hold_timer);
706    free(wd);
707 }
708
709 static void
710 _del_pre_hook(Evas_Object *obj)
711 {
712    Widget_Data *wd = elm_widget_data_get(obj);
713    if (!wd) return;
714    evas_object_del(wd->pan_smart);
715    wd->pan_smart = NULL;
716    elm_genlist_clear(obj);
717 }
718
719 static void
720 _mirrored_set(Evas_Object *obj,
721               Eina_Bool    rtl)
722 {
723    Widget_Data *wd = elm_widget_data_get(obj);
724    if (!wd) return;
725    _item_cache_zero(wd);
726    elm_smart_scroller_mirrored_set(wd->scr, rtl);
727 }
728
729 static void
730 _theme_hook(Evas_Object *obj)
731 {
732    Widget_Data *wd = elm_widget_data_get(obj);
733    Item_Block *itb;
734    if (!wd) return;
735    _item_cache_zero(wd);
736    _elm_widget_mirrored_reload(obj);
737    _mirrored_set(obj, elm_widget_mirrored_get(obj));
738    elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
739                                        elm_widget_style_get(obj));
740    edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
741    wd->item_width = wd->item_height = 0;
742    wd->group_item_width = wd->group_item_height = 0;
743    wd->minw = wd->minh = wd->realminw = 0;
744    EINA_INLIST_FOREACH(wd->blocks, itb)
745      {
746         Eina_List *l;
747         Elm_Genlist_Item *it;
748
749         if (itb->realized) _item_block_unrealize(itb);
750         EINA_LIST_FOREACH(itb->items, l, it)
751           it->mincalcd = EINA_FALSE;
752
753         itb->changed = EINA_TRUE;
754      }
755    if (wd->calc_job) ecore_job_del(wd->calc_job);
756    wd->calc_job = ecore_job_add(_calc_job, wd);
757    _sizing_eval(obj);
758 }
759
760 static void
761 _show_region_hook(void        *data,
762                   Evas_Object *obj)
763 {
764    Widget_Data *wd = elm_widget_data_get(data);
765    Evas_Coord x, y, w, h;
766    if (!wd) return;
767    elm_widget_show_region_get(obj, &x, &y, &w, &h);
768    //x & y are screen coordinates, Add with pan coordinates
769    x += wd->pan_x;
770    y += wd->pan_y;
771    elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
772 }
773
774 static void
775 _sizing_eval(Evas_Object *obj)
776 {
777    Widget_Data *wd = elm_widget_data_get(obj);
778    Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
779    if (!wd) return;
780    evas_object_size_hint_min_get(wd->scr, &minw, &minh);
781    evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
782    minh = -1;
783    if (wd->height_for_width)
784      {
785         Evas_Coord vw, vh;
786
787         elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
788         if ((vw != 0) && (vw != wd->prev_viewport_w))
789           {
790              Item_Block *itb;
791
792              wd->prev_viewport_w = vw;
793              EINA_INLIST_FOREACH(wd->blocks, itb)
794                {
795                   itb->must_recalc = EINA_TRUE;
796                }
797              if (wd->calc_job) ecore_job_del(wd->calc_job);
798              wd->calc_job = ecore_job_add(_calc_job, wd);
799           }
800      }
801    if (wd->mode == ELM_LIST_LIMIT)
802      {
803         Evas_Coord vmw, vmh, vw, vh;
804
805         minw = wd->realminw;
806         maxw = -1;
807         elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
808         if ((minw > 0) && (vw < minw)) vw = minw;
809         else if ((maxw > 0) && (vw > maxw))
810           vw = maxw;
811         edje_object_size_min_calc
812           (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
813         minw = vmw + minw;
814      }
815    else
816      {
817         Evas_Coord vmw, vmh;
818
819         edje_object_size_min_calc
820           (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
821         minw = vmw;
822         minh = vmh;
823      }
824    evas_object_size_hint_min_set(obj, minw, minh);
825    evas_object_size_hint_max_set(obj, maxw, maxh);
826 }
827
828 static void
829 _signal_emit_hook(Evas_Object *obj,
830                   const char  *emission,
831                   const char  *source)
832 {
833    Widget_Data *wd = elm_widget_data_get(obj);
834    edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
835                            emission, source);
836 }
837
838 static void
839 _item_highlight(Elm_Genlist_Item *it)
840 {
841    const char *selectraise;
842    if ((it->wd->no_select) || (it->delete_me) || (it->highlighted) ||
843        (it->disabled) || (it->display_only) || (it->mode_view))
844      return;
845    edje_object_signal_emit(it->base.view, "elm,state,selected", "elm");
846    selectraise = edje_object_data_get(it->base.view, "selectraise");
847    if ((selectraise) && (!strcmp(selectraise, "on")))
848      {
849         evas_object_raise(it->base.view);
850         if ((it->group_item) && (it->group_item->realized))
851           evas_object_raise(it->group_item->base.view);
852      }
853    it->highlighted = EINA_TRUE;
854 }
855
856 static void
857 _item_block_del(Elm_Genlist_Item *it)
858 {
859    Eina_Inlist *il;
860    Item_Block *itb = it->block;
861
862    itb->items = eina_list_remove(itb->items, it);
863    itb->count--;
864    itb->changed = EINA_TRUE;
865    if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
866    it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
867    if (itb->count < 1)
868      {
869         il = EINA_INLIST_GET(itb);
870         Item_Block *itbn = (Item_Block *)(il->next);
871         if (it->parent)
872           it->parent->items = eina_list_remove(it->parent->items, it);
873         else
874           it->wd->blocks = eina_inlist_remove(it->wd->blocks, il);
875         free(itb);
876         if (itbn) itbn->changed = EINA_TRUE;
877      }
878    else
879      {
880         if (itb->count < 16)
881           {
882              il = EINA_INLIST_GET(itb);
883              Item_Block *itbp = (Item_Block *)(il->prev);
884              Item_Block *itbn = (Item_Block *)(il->next);
885              if ((itbp) && ((itbp->count + itb->count) < 48))
886                {
887                   Elm_Genlist_Item *it2;
888
889                   EINA_LIST_FREE(itb->items, it2)
890                     {
891                        it2->block = itbp;
892                        itbp->items = eina_list_append(itbp->items, it2);
893                        itbp->count++;
894                        itbp->changed = EINA_TRUE;
895                     }
896                   it->wd->blocks = eina_inlist_remove(it->wd->blocks,
897                                                       EINA_INLIST_GET(itb));
898                   free(itb);
899                }
900              else if ((itbn) && ((itbn->count + itb->count) < 48))
901                {
902                   while (itb->items)
903                     {
904                        Eina_List *last = eina_list_last(itb->items);
905                        Elm_Genlist_Item *it2 = last->data;
906
907                        it2->block = itbn;
908                        itb->items = eina_list_remove_list(itb->items, last);
909                        itbn->items = eina_list_prepend(itbn->items, it2);
910                        itbn->count++;
911                        itbn->changed = EINA_TRUE;
912                     }
913                   it->wd->blocks =
914                     eina_inlist_remove(it->wd->blocks, EINA_INLIST_GET(itb));
915                   free(itb);
916                }
917           }
918      }
919 }
920
921 static void
922 _item_del(Elm_Genlist_Item *it)
923 {
924    elm_widget_item_pre_notify_del(it);
925    elm_genlist_item_subitems_clear(it);
926    it->wd->walking -= it->walking;
927    if (it->wd->show_item == it) it->wd->show_item = NULL;
928    if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
929    if (it->realized) _item_unrealize(it, EINA_FALSE);
930    if (it->block) _item_block_del(it);
931    if ((!it->delete_me) && (it->itc->func.del))
932      it->itc->func.del((void *)it->base.data, it->base.widget);
933    it->delete_me = EINA_TRUE;
934    if (it->queued)
935      it->wd->queue = eina_list_remove(it->wd->queue, it);
936    if (it->wd->anchor_item == it)
937      {
938         it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
939         if (!it->wd->anchor_item)
940           it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
941      }
942    it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
943    if (it->parent)
944      it->parent->items = eina_list_remove(it->parent->items, it);
945    if (it->flags & ELM_GENLIST_ITEM_GROUP)
946      it->wd->group_items = eina_list_remove(it->wd->group_items, it);
947    if (it->long_timer) ecore_timer_del(it->long_timer);
948    if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
949
950    if (it->tooltip.del_cb)
951      it->tooltip.del_cb((void *)it->tooltip.data, it->base.widget, it);
952
953    elm_widget_item_del(it);
954 }
955
956 static void
957 _item_select(Elm_Genlist_Item *it)
958 {
959    if ((it->wd->no_select) || (it->delete_me) || (it->mode_view)) return;
960    if (it->selected)
961      {
962         if (it->wd->always_select) goto call;
963         return;
964      }
965    it->selected = EINA_TRUE;
966    it->wd->selected = eina_list_append(it->wd->selected, it);
967 call:
968    it->walking++;
969    it->wd->walking++;
970    if (it->func.func) it->func.func((void *)it->func.data, it->base.widget, it);
971    if (!it->delete_me)
972      evas_object_smart_callback_call(it->base.widget, "selected", it);
973    it->walking--;
974    it->wd->walking--;
975    if ((it->wd->clear_me) && (!it->wd->walking))
976      elm_genlist_clear(it->base.widget);
977    else
978      {
979         if ((!it->walking) && (it->delete_me))
980           {
981              if (!it->relcount) _item_del(it);
982           }
983      }
984    it->wd->last_selected_item = it;
985 }
986
987 static void
988 _item_unselect(Elm_Genlist_Item *it)
989 {
990    const char *stacking, *selectraise;
991
992    if ((it->delete_me) || (!it->highlighted)) return;
993    edje_object_signal_emit(it->base.view, "elm,state,unselected", "elm");
994    stacking = edje_object_data_get(it->base.view, "stacking");
995    selectraise = edje_object_data_get(it->base.view, "selectraise");
996    if (!it->nostacking)
997      {
998        if ((it->order_num_in & 0x1) ^ it->stacking_even) evas_object_lower(it->base.view);
999        else evas_object_raise(it->base.view);
1000      }
1001    it->highlighted = EINA_FALSE;
1002    if (it->selected)
1003      {
1004         it->selected = EINA_FALSE;
1005         it->wd->selected = eina_list_remove(it->wd->selected, it);
1006         evas_object_smart_callback_call(it->base.widget, "unselected", it);
1007      }
1008 }
1009
1010 static void
1011 _mouse_move(void        *data,
1012             Evas        *evas __UNUSED__,
1013             Evas_Object *obj,
1014             void        *event_info)
1015 {
1016    Elm_Genlist_Item *it = data;
1017    Evas_Event_Mouse_Move *ev = event_info;
1018    Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
1019
1020    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1021      {
1022         if (!it->wd->on_hold)
1023           {
1024              it->wd->on_hold = EINA_TRUE;
1025              if (!it->wd->wasselected)
1026                _item_unselect(it);
1027           }
1028      }
1029    if (it->wd->multitouched)
1030      {
1031         it->wd->cur_x = ev->cur.canvas.x;
1032         it->wd->cur_y = ev->cur.canvas.y;
1033         return;
1034      }
1035    if ((it->dragging) && (it->down))
1036      {
1037         if (it->wd->movements == SWIPE_MOVES) it->wd->swipe = EINA_TRUE;
1038         else
1039           {
1040              it->wd->history[it->wd->movements].x = ev->cur.canvas.x;
1041              it->wd->history[it->wd->movements].y = ev->cur.canvas.y;
1042              if (abs((it->wd->history[it->wd->movements].x -
1043                       it->wd->history[0].x)) > 40)
1044                it->wd->swipe = EINA_TRUE;
1045              else
1046                it->wd->movements++;
1047           }
1048         if (it->long_timer)
1049           {
1050              ecore_timer_del(it->long_timer);
1051              it->long_timer = NULL;
1052           }
1053         evas_object_smart_callback_call(it->base.widget, "drag", it);
1054         return;
1055      }
1056    if ((!it->down) /* || (it->wd->on_hold)*/ || (it->wd->longpressed))
1057      {
1058         if (it->long_timer)
1059           {
1060              ecore_timer_del(it->long_timer);
1061              it->long_timer = NULL;
1062           }
1063         return;
1064      }
1065    if (!it->display_only)
1066      elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1067    evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1068    x = ev->cur.canvas.x - x;
1069    y = ev->cur.canvas.y - y;
1070    dx = x - it->dx;
1071    adx = dx;
1072    if (adx < 0) adx = -dx;
1073    dy = y - it->dy;
1074    ady = dy;
1075    if (ady < 0) ady = -dy;
1076    minw /= 2;
1077    minh /= 2;
1078    if ((adx > minw) || (ady > minh))
1079      {
1080         it->dragging = EINA_TRUE;
1081         if (it->long_timer)
1082           {
1083              ecore_timer_del(it->long_timer);
1084              it->long_timer = NULL;
1085           }
1086         if (!it->wd->wasselected)
1087           _item_unselect(it);
1088         if (dy < 0)
1089           {
1090              if (ady > adx)
1091                evas_object_smart_callback_call(it->base.widget,
1092                                                "drag,start,up", it);
1093              else
1094                {
1095                   if (dx < 0)
1096                     evas_object_smart_callback_call(it->base.widget,
1097                                                     "drag,start,left", it);
1098                   else
1099                     evas_object_smart_callback_call(it->base.widget,
1100                                                     "drag,start,right", it);
1101                }
1102           }
1103         else
1104           {
1105              if (ady > adx)
1106                evas_object_smart_callback_call(it->base.widget,
1107                                                "drag,start,down", it);
1108              else
1109                {
1110                   if (dx < 0)
1111                     evas_object_smart_callback_call(it->base.widget,
1112                                                     "drag,start,left", it);
1113                   else
1114                     evas_object_smart_callback_call(it->base.widget,
1115                                                     "drag,start,right", it);
1116                }
1117           }
1118      }
1119 }
1120
1121 static Eina_Bool
1122 _long_press(void *data)
1123 {
1124    Elm_Genlist_Item *it = data;
1125
1126    it->long_timer = NULL;
1127    if ((it->disabled) || (it->dragging) || (it->display_only))
1128      return ECORE_CALLBACK_CANCEL;
1129    it->wd->longpressed = EINA_TRUE;
1130    evas_object_smart_callback_call(it->base.widget, "longpressed", it);
1131    return ECORE_CALLBACK_CANCEL;
1132 }
1133
1134 static void
1135 _swipe(Elm_Genlist_Item *it)
1136 {
1137    int i, sum = 0;
1138
1139    if (!it) return;
1140    if ((it->display_only) || (it->disabled)) return;
1141    it->wd->swipe = EINA_FALSE;
1142    for (i = 0; i < it->wd->movements; i++)
1143      {
1144         sum += it->wd->history[i].x;
1145         if (abs(it->wd->history[0].y - it->wd->history[i].y) > 10) return;
1146      }
1147
1148    sum /= it->wd->movements;
1149    if (abs(sum - it->wd->history[0].x) <= 10) return;
1150    evas_object_smart_callback_call(it->base.widget, "swipe", it);
1151 }
1152
1153 static Eina_Bool
1154 _swipe_cancel(void *data)
1155 {
1156    Elm_Genlist_Item *it = data;
1157
1158    if (!it) return ECORE_CALLBACK_CANCEL;
1159    it->wd->swipe = EINA_FALSE;
1160    it->wd->movements = 0;
1161    return ECORE_CALLBACK_RENEW;
1162 }
1163
1164 static Eina_Bool
1165 _multi_cancel(void *data)
1166 {
1167    Widget_Data *wd = data;
1168
1169    if (!wd) return ECORE_CALLBACK_CANCEL;
1170    wd->multi_timeout = EINA_TRUE;
1171    return ECORE_CALLBACK_RENEW;
1172 }
1173
1174 static void
1175 _multi_touch_gesture_eval(void *data)
1176 {
1177    Elm_Genlist_Item *it = data;
1178
1179    it->wd->multitouched = EINA_FALSE;
1180    if (it->wd->multi_timer)
1181      {
1182         ecore_timer_del(it->wd->multi_timer);
1183         it->wd->multi_timer = NULL;
1184      }
1185    if (it->wd->multi_timeout)
1186      {
1187         it->wd->multi_timeout = EINA_FALSE;
1188         return;
1189      }
1190
1191    Evas_Coord minw = 0, minh = 0;
1192    Evas_Coord off_x, off_y, off_mx, off_my;
1193
1194    elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1195    off_x = abs(it->wd->cur_x - it->wd->prev_x);
1196    off_y = abs(it->wd->cur_y - it->wd->prev_y);
1197    off_mx = abs(it->wd->cur_mx - it->wd->prev_mx);
1198    off_my = abs(it->wd->cur_my - it->wd->prev_my);
1199
1200    if (((off_x > minw) || (off_y > minh)) && ((off_mx > minw) || (off_my > minh)))
1201      {
1202         if ((off_x + off_mx) > (off_y + off_my))
1203           {
1204              if ((it->wd->cur_x > it->wd->prev_x) && (it->wd->cur_mx > it->wd->prev_mx))
1205                evas_object_smart_callback_call(it->base.widget,
1206                                                "multi,swipe,right", it);
1207              else if ((it->wd->cur_x < it->wd->prev_x) && (it->wd->cur_mx < it->wd->prev_mx))
1208                evas_object_smart_callback_call(it->base.widget,
1209                                                "multi,swipe,left", it);
1210              else if (abs(it->wd->cur_x - it->wd->cur_mx) > abs(it->wd->prev_x - it->wd->prev_mx))
1211                evas_object_smart_callback_call(it->base.widget,
1212                                                "multi,pinch,out", it);
1213              else
1214                evas_object_smart_callback_call(it->base.widget,
1215                                                "multi,pinch,in", it);
1216           }
1217         else
1218           {
1219              if ((it->wd->cur_y > it->wd->prev_y) && (it->wd->cur_my > it->wd->prev_my))
1220                evas_object_smart_callback_call(it->base.widget,
1221                                                "multi,swipe,down", it);
1222              else if ((it->wd->cur_y < it->wd->prev_y) && (it->wd->cur_my < it->wd->prev_my))
1223                evas_object_smart_callback_call(it->base.widget,
1224                                                "multi,swipe,up", it);
1225              else if (abs(it->wd->cur_y - it->wd->cur_my) > abs(it->wd->prev_y - it->wd->prev_my))
1226                evas_object_smart_callback_call(it->base.widget,
1227                                                "multi,pinch,out", it);
1228              else
1229                evas_object_smart_callback_call(it->base.widget,
1230                                                "multi,pinch,in", it);
1231           }
1232      }
1233    it->wd->multi_timeout = EINA_FALSE;
1234 }
1235
1236 static void
1237 _multi_down(void        *data,
1238             Evas        *evas __UNUSED__,
1239             Evas_Object *obj __UNUSED__,
1240             void        *event_info)
1241 {
1242    Elm_Genlist_Item *it = data;
1243    Evas_Event_Multi_Down *ev = event_info;
1244
1245    if ((it->wd->multi_device != 0) || (it->wd->multitouched) || (it->wd->multi_timeout)) return;
1246    it->wd->multi_device = ev->device;
1247    it->wd->multi_down = EINA_TRUE;
1248    it->wd->multitouched = EINA_TRUE;
1249    it->wd->prev_mx = ev->canvas.x;
1250    it->wd->prev_my = ev->canvas.y;
1251    if (!it->wd->wasselected) _item_unselect(it);
1252    it->wd->wasselected = EINA_FALSE;
1253    it->wd->longpressed = EINA_FALSE;
1254    if (it->long_timer)
1255      {
1256         ecore_timer_del(it->long_timer);
1257         it->long_timer = NULL;
1258      }
1259    if (it->dragging)
1260      {
1261         it->dragging = EINA_FALSE;
1262         evas_object_smart_callback_call(it->base.widget, "drag,stop", it);
1263      }
1264    if (it->swipe_timer)
1265      {
1266         ecore_timer_del(it->swipe_timer);
1267         it->swipe_timer = NULL;
1268      }
1269    if (it->wd->on_hold)
1270      {
1271         it->wd->swipe = EINA_FALSE;
1272         it->wd->movements = 0;
1273         it->wd->on_hold = EINA_FALSE;
1274      }
1275 }
1276
1277 static void
1278 _multi_up(void        *data,
1279           Evas        *evas __UNUSED__,
1280           Evas_Object *obj __UNUSED__,
1281           void        *event_info)
1282 {
1283    Elm_Genlist_Item *it = data;
1284    Evas_Event_Multi_Up *ev = event_info;
1285
1286    if (it->wd->multi_device != ev->device) return;
1287    it->wd->multi_device = 0;
1288    it->wd->multi_down = EINA_FALSE;
1289    if (it->wd->mouse_down) return;
1290    _multi_touch_gesture_eval(data);
1291 }
1292
1293 static void
1294 _multi_move(void        *data,
1295             Evas        *evas __UNUSED__,
1296             Evas_Object *obj __UNUSED__,
1297             void        *event_info)
1298 {
1299    Elm_Genlist_Item *it = data;
1300    Evas_Event_Multi_Move *ev = event_info;
1301
1302    if (it->wd->multi_device != ev->device) return;
1303    it->wd->cur_mx = ev->cur.canvas.x;
1304    it->wd->cur_my = ev->cur.canvas.y;
1305 }
1306
1307 static void
1308 _mouse_down(void        *data,
1309             Evas        *evas __UNUSED__,
1310             Evas_Object *obj,
1311             void        *event_info)
1312 {
1313    Elm_Genlist_Item *it = data;
1314    Evas_Event_Mouse_Down *ev = event_info;
1315    Evas_Coord x, y;
1316
1317    if (ev->button != 1) return;
1318    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1319      {
1320         it->wd->on_hold = EINA_TRUE;
1321      }
1322
1323    it->down = EINA_TRUE;
1324    it->dragging = EINA_FALSE;
1325    evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1326    it->dx = ev->canvas.x - x;
1327    it->dy = ev->canvas.y - y;
1328    it->wd->mouse_down = EINA_TRUE;
1329    if (!it->wd->multitouched)
1330      {
1331         it->wd->prev_x = ev->canvas.x;
1332         it->wd->prev_y = ev->canvas.y;
1333         it->wd->multi_timeout = EINA_FALSE;
1334         if (it->wd->multi_timer) ecore_timer_del(it->wd->multi_timer);
1335         it->wd->multi_timer = ecore_timer_add(1, _multi_cancel, it->wd);
1336      }
1337    it->wd->longpressed = EINA_FALSE;
1338    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1339    else it->wd->on_hold = EINA_FALSE;
1340    if (it->wd->on_hold) return;
1341    it->wd->wasselected = it->selected;
1342    _item_highlight(it);
1343    if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1344      if ((!it->disabled) && (!it->display_only))
1345        {
1346           evas_object_smart_callback_call(it->base.widget, "clicked,double", it);
1347           evas_object_smart_callback_call(it->base.widget, "clicked", it); // will be removed
1348        }
1349    if (it->long_timer) ecore_timer_del(it->long_timer);
1350    if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
1351    it->swipe_timer = ecore_timer_add(0.4, _swipe_cancel, it);
1352    if (it->realized)
1353      it->long_timer = ecore_timer_add(it->wd->longpress_timeout, _long_press,
1354                                       it);
1355    else
1356      it->long_timer = NULL;
1357    it->wd->swipe = EINA_FALSE;
1358    it->wd->movements = 0;
1359 }
1360
1361 static void
1362 _mouse_up(void        *data,
1363           Evas        *evas __UNUSED__,
1364           Evas_Object *obj __UNUSED__,
1365           void        *event_info)
1366 {
1367    Elm_Genlist_Item *it = data;
1368    Evas_Event_Mouse_Up *ev = event_info;
1369    Eina_Bool dragged = EINA_FALSE;
1370
1371    if (ev->button != 1) return;
1372    it->down = EINA_FALSE;
1373    it->wd->mouse_down = EINA_FALSE;
1374    if (it->wd->multitouched)
1375      {
1376         if (it->wd->multi_down) return;
1377         _multi_touch_gesture_eval(data);
1378         return;
1379      }
1380    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1381    else it->wd->on_hold = EINA_FALSE;
1382    if (it->long_timer)
1383      {
1384         ecore_timer_del(it->long_timer);
1385         it->long_timer = NULL;
1386      }
1387    if (it->dragging)
1388      {
1389         it->dragging = EINA_FALSE;
1390         evas_object_smart_callback_call(it->base.widget, "drag,stop", it);
1391         dragged = 1;
1392      }
1393    if (it->swipe_timer)
1394      {
1395         ecore_timer_del(it->swipe_timer);
1396         it->swipe_timer = NULL;
1397      }
1398    if (it->wd->multi_timer)
1399      {
1400         ecore_timer_del(it->wd->multi_timer);
1401         it->wd->multi_timer = NULL;
1402         it->wd->multi_timeout = EINA_FALSE;
1403      }
1404    if (it->wd->on_hold)
1405      {
1406         if (it->wd->swipe) _swipe(data);
1407         it->wd->longpressed = EINA_FALSE;
1408         it->wd->on_hold = EINA_FALSE;
1409         return;
1410      }
1411    if (it->wd->longpressed)
1412      {
1413         it->wd->longpressed = EINA_FALSE;
1414         if (!it->wd->wasselected)
1415           _item_unselect(it);
1416         it->wd->wasselected = EINA_FALSE;
1417         return;
1418      }
1419    if (dragged)
1420      {
1421         if (it->want_unrealize)
1422           {
1423              _item_unrealize(it, EINA_FALSE);
1424              if (it->block->want_unrealize)
1425                _item_block_unrealize(it->block);
1426           }
1427      }
1428    if ((it->disabled) || (dragged) || (it->display_only)) return;
1429    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1430    if (it->wd->multi)
1431      {
1432         if (!it->selected)
1433           {
1434              _item_highlight(it);
1435              _item_select(it);
1436           }
1437         else _item_unselect(it);
1438      }
1439    else
1440      {
1441         if (!it->selected)
1442           {
1443              Widget_Data *wd = it->wd;
1444              if (wd)
1445                {
1446                   while (wd->selected) _item_unselect(wd->selected->data);
1447                }
1448           }
1449         else
1450           {
1451              const Eina_List *l, *l_next;
1452              Elm_Genlist_Item *it2;
1453
1454              EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, it2)
1455                if (it2 != it) _item_unselect(it2);
1456              //_item_highlight(it);
1457              //_item_select(it);
1458           }
1459         _item_highlight(it);
1460         _item_select(it);
1461      }
1462 }
1463
1464 static void
1465 _signal_expand_toggle(void        *data,
1466                       Evas_Object *obj __UNUSED__,
1467                       const char  *emission __UNUSED__,
1468                       const char  *source __UNUSED__)
1469 {
1470    Elm_Genlist_Item *it = data;
1471
1472    if (it->expanded)
1473      evas_object_smart_callback_call(it->base.widget, "contract,request", it);
1474    else
1475      evas_object_smart_callback_call(it->base.widget, "expand,request", it);
1476 }
1477
1478 static void
1479 _signal_expand(void        *data,
1480                Evas_Object *obj __UNUSED__,
1481                const char  *emission __UNUSED__,
1482                const char  *source __UNUSED__)
1483 {
1484    Elm_Genlist_Item *it = data;
1485
1486    if (!it->expanded)
1487      evas_object_smart_callback_call(it->base.widget, "expand,request", it);
1488 }
1489
1490 static void
1491 _signal_contract(void        *data,
1492                  Evas_Object *obj __UNUSED__,
1493                  const char  *emission __UNUSED__,
1494                  const char  *source __UNUSED__)
1495 {
1496    Elm_Genlist_Item *it = data;
1497
1498    if (it->expanded)
1499      evas_object_smart_callback_call(it->base.widget, "contract,request", it);
1500 }
1501
1502 static Eina_Bool
1503 _scr_hold_timer_cb(void *data)
1504 {
1505    if (!data) return ECORE_CALLBACK_CANCEL;
1506    Widget_Data *wd = data;
1507    elm_smart_scroller_hold_set(wd->scr, EINA_FALSE);
1508    wd->scr_hold_timer = NULL;
1509    return ECORE_CALLBACK_CANCEL;
1510 }
1511
1512 static void
1513 _mode_finished_signal_cb(void        *data,
1514                          Evas_Object *obj,
1515                          const char  *emission __UNUSED__,
1516                          const char  *source __UNUSED__)
1517 {
1518    if (!data) return;
1519    if (!obj) return;
1520    Elm_Genlist_Item *it = data;
1521    if ((it->delete_me) || (!it->realized) || (!it->mode_view)) return;
1522    char buf[1024];
1523
1524    it->nocache = EINA_FALSE;
1525    _mode_item_unrealize(it);
1526    snprintf(buf, sizeof(buf), "elm,state,%s,passive,finished", it->wd->mode_type);
1527    edje_object_signal_callback_del_full(obj, buf, "elm", _mode_finished_signal_cb, it);
1528 }
1529
1530 static void
1531 _item_cache_clean(Widget_Data *wd)
1532 {
1533    while ((wd->item_cache) && (wd->item_cache_count > wd->item_cache_max))
1534      {
1535         Item_Cache *itc;
1536
1537         itc = EINA_INLIST_CONTAINER_GET(wd->item_cache->last, Item_Cache);
1538         wd->item_cache = eina_inlist_remove(wd->item_cache,
1539                                             wd->item_cache->last);
1540         wd->item_cache_count--;
1541         if (itc->spacer) evas_object_del(itc->spacer);
1542         if (itc->base_view) evas_object_del(itc->base_view);
1543         if (itc->item_style) eina_stringshare_del(itc->item_style);
1544         free(itc);
1545      }
1546 }
1547
1548 static void
1549 _item_cache_zero(Widget_Data *wd)
1550 {
1551    int pmax = wd->item_cache_max;
1552    wd->item_cache_max = 0;
1553    _item_cache_clean(wd);
1554    wd->item_cache_max = pmax;
1555 }
1556
1557 static void
1558 _item_cache_add(Elm_Genlist_Item *it)
1559 {
1560    Item_Cache *itc;
1561
1562    if (it->wd->item_cache_max <= 0)
1563      {
1564         evas_object_del(it->base.view);
1565         it->base.view = NULL;
1566         evas_object_del(it->spacer);
1567         it->spacer = NULL;
1568         return;
1569      }
1570
1571    it->wd->item_cache_count++;
1572    itc = calloc(1, sizeof(Item_Cache));
1573    it->wd->item_cache = eina_inlist_prepend(it->wd->item_cache,
1574                                             EINA_INLIST_GET(itc));
1575    itc->spacer = it->spacer;
1576    it->spacer = NULL;
1577    itc->base_view = it->base.view;
1578    it->base.view = NULL;
1579    evas_object_hide(itc->base_view);
1580    evas_object_move(itc->base_view, -9999, -9999);
1581    itc->item_style = eina_stringshare_add(it->itc->item_style);
1582    if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) itc->tree = 1;
1583    itc->compress = (it->wd->compress);
1584    itc->selected = it->selected;
1585    itc->disabled = it->disabled;
1586    itc->expanded = it->expanded;
1587    if (it->long_timer)
1588      {
1589         ecore_timer_del(it->long_timer);
1590         it->long_timer = NULL;
1591      }
1592    if (it->swipe_timer)
1593      {
1594         ecore_timer_del(it->swipe_timer);
1595         it->swipe_timer = NULL;
1596      }
1597    // FIXME: other callbacks?
1598    edje_object_signal_callback_del_full(itc->base_view,
1599                                         "elm,action,expand,toggle",
1600                                         "elm", _signal_expand_toggle, it);
1601    edje_object_signal_callback_del_full(itc->base_view, "elm,action,expand",
1602                                         "elm",
1603                                         _signal_expand, it);
1604    edje_object_signal_callback_del_full(itc->base_view, "elm,action,contract",
1605                                         "elm", _signal_contract, it);
1606    evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_DOWN,
1607                                        _mouse_down, it);
1608    evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_UP,
1609                                        _mouse_up, it);
1610    evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_MOVE,
1611                                        _mouse_move, it);
1612    evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_DOWN,
1613                                        _multi_down, it);
1614    evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_UP,
1615                                        _multi_up, it);
1616    evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_MOVE,
1617                                        _multi_move, it);
1618    _item_cache_clean(it->wd);
1619 }
1620
1621 static Item_Cache *
1622 _item_cache_find(Elm_Genlist_Item *it)
1623 {
1624    Item_Cache *itc;
1625    Eina_Bool tree = 0;
1626
1627    if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) tree = 1;
1628    EINA_INLIST_FOREACH(it->wd->item_cache, itc)
1629      {
1630         if ((itc->selected) || (itc->disabled) || (itc->expanded))
1631           continue;
1632         if ((itc->tree == tree) &&
1633             (itc->compress == it->wd->compress) &&
1634             (!strcmp(it->itc->item_style, itc->item_style)))
1635           {
1636              it->wd->item_cache = eina_inlist_remove(it->wd->item_cache,
1637                                                      EINA_INLIST_GET(itc));
1638              it->wd->item_cache_count--;
1639              return itc;
1640           }
1641      }
1642    return NULL;
1643 }
1644
1645 static void
1646 _elm_genlist_item_odd_even_update(Elm_Genlist_Item *it)
1647 {
1648    if (!it->nostacking)
1649      {
1650        if ((it->order_num_in & 0x1) ^ it->stacking_even)
1651          evas_object_lower(it->base.view);
1652        else
1653          evas_object_raise(it->base.view);
1654      }
1655
1656    if (it->order_num_in & 0x1)
1657      edje_object_signal_emit(it->base.view, "elm,state,odd", "elm");
1658    else
1659      edje_object_signal_emit(it->base.view, "elm,state,even", "elm");
1660 }
1661
1662 static void
1663 _elm_genlist_item_state_update(Elm_Genlist_Item *it, Item_Cache *itc)
1664 {
1665   if (itc)
1666     {
1667       if (it->selected != itc->selected)
1668         {
1669           if (it->selected)
1670             edje_object_signal_emit(it->base.view,
1671                                     "elm,state,selected", "elm");
1672         }
1673       if (it->disabled != itc->disabled)
1674         {
1675           if (it->disabled)
1676             edje_object_signal_emit(it->base.view,
1677                                     "elm,state,disabled", "elm");
1678         }
1679       if (it->expanded != itc->expanded)
1680         {
1681           if (it->expanded)
1682             edje_object_signal_emit(it->base.view,
1683                                     "elm,state,expanded", "elm");
1684         }
1685     }
1686   else
1687     {
1688       if (it->selected)
1689         edje_object_signal_emit(it->base.view,
1690                                 "elm,state,selected", "elm");
1691       if (it->disabled)
1692         edje_object_signal_emit(it->base.view,
1693                                 "elm,state,disabled", "elm");
1694       if (it->expanded)
1695         edje_object_signal_emit(it->base.view,
1696                                 "elm,state,expanded", "elm");
1697     }
1698 }
1699
1700 static void
1701 _item_cache_free(Item_Cache *itc)
1702 {
1703    if (itc->spacer) evas_object_del(itc->spacer);
1704    if (itc->base_view) evas_object_del(itc->base_view);
1705    if (itc->item_style) eina_stringshare_del(itc->item_style);
1706    free(itc);
1707 }
1708
1709 static void
1710 _item_realize(Elm_Genlist_Item *it,
1711               int               in,
1712               Eina_Bool         calc)
1713 {
1714    Elm_Genlist_Item *it2;
1715    const char *treesize;
1716    char buf[1024];
1717    int depth, tsize = 20;
1718    Item_Cache *itc = NULL;
1719
1720    if (it->delete_me) return ;
1721    if (it->realized)
1722      {
1723        if (it->order_num_in != in)
1724          {
1725            it->order_num_in = in;
1726            _elm_genlist_item_odd_even_update(it);
1727            _elm_genlist_item_state_update(it, NULL);
1728          }
1729        return;
1730      }
1731    it->order_num_in = in;
1732
1733    if (it->nocache)
1734      it->nocache = EINA_FALSE;
1735    else
1736      itc = _item_cache_find(it);
1737    if (itc)
1738      {
1739         it->base.view = itc->base_view;
1740         itc->base_view = NULL;
1741         it->spacer = itc->spacer;
1742         itc->spacer = NULL;
1743      }
1744    else
1745      {
1746         const char *stacking_even;
1747         const char *stacking;
1748
1749         it->base.view = edje_object_add(evas_object_evas_get(it->base.widget));
1750         edje_object_scale_set(it->base.view,
1751                               elm_widget_scale_get(it->base.widget) *
1752                               _elm_config->scale);
1753         evas_object_smart_member_add(it->base.view, it->wd->pan_smart);
1754         elm_widget_sub_object_add(it->base.widget, it->base.view);
1755
1756         if (it->flags & ELM_GENLIST_ITEM_SUBITEMS)
1757           strncpy(buf, "tree", sizeof(buf));
1758         else strncpy(buf, "item", sizeof(buf));
1759         if (it->wd->compress)
1760           strncat(buf, "_compress", sizeof(buf) - strlen(buf));
1761
1762         strncat(buf, "/", sizeof(buf) - strlen(buf));
1763         strncat(buf, it->itc->item_style, sizeof(buf) - strlen(buf));
1764
1765         _elm_theme_object_set(it->base.widget, it->base.view, "genlist", buf,
1766                               elm_widget_style_get(it->base.widget));
1767
1768         stacking_even = edje_object_data_get(it->base.view, "stacking_even");
1769         if (!stacking_even) stacking_even = "above";
1770         it->stacking_even = !!strcmp("above", stacking_even);
1771
1772         stacking = edje_object_data_get(it->base.view, "stacking");
1773         if (!stacking) stacking = "yes";
1774         it->nostacking = !!strcmp("yes", stacking);
1775
1776         edje_object_mirrored_set(it->base.view,
1777                                  elm_widget_mirrored_get(it->base.widget));
1778         it->spacer =
1779           evas_object_rectangle_add(evas_object_evas_get(it->base.widget));
1780         evas_object_color_set(it->spacer, 0, 0, 0, 0);
1781         elm_widget_sub_object_add(it->base.widget, it->spacer);
1782      }
1783
1784    _elm_genlist_item_odd_even_update(it);
1785
1786    for (it2 = it, depth = 0; it2->parent; it2 = it2->parent)
1787      {
1788         if (it2->parent->flags != ELM_GENLIST_ITEM_GROUP) depth += 1;
1789      }
1790    it->expanded_depth = depth;
1791    treesize = edje_object_data_get(it->base.view, "treesize");
1792    if (treesize) tsize = atoi(treesize);
1793    evas_object_size_hint_min_set(it->spacer,
1794                                  (depth * tsize) * _elm_config->scale, 1);
1795    edje_object_part_swallow(it->base.view, "elm.swallow.pad", it->spacer);
1796    if (!calc)
1797      {
1798         edje_object_signal_callback_add(it->base.view,
1799                                         "elm,action,expand,toggle",
1800                                         "elm", _signal_expand_toggle, it);
1801         edje_object_signal_callback_add(it->base.view, "elm,action,expand",
1802                                         "elm", _signal_expand, it);
1803         edje_object_signal_callback_add(it->base.view, "elm,action,contract",
1804                                         "elm", _signal_contract, it);
1805         evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_DOWN,
1806                                        _mouse_down, it);
1807         evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_UP,
1808                                        _mouse_up, it);
1809         evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_MOVE,
1810                                        _mouse_move, it);
1811         evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_DOWN,
1812                                        _multi_down, it);
1813         evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_UP,
1814                                        _multi_up, it);
1815         evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_MOVE,
1816                                        _multi_move, it);
1817
1818         _elm_genlist_item_state_update(it, itc);
1819      }
1820
1821    if ((calc) && (it->wd->homogeneous) && ((it->wd->item_width) || ((it->wd->item_width) && (it->wd->group_item_width))))
1822      {
1823         /* homogenous genlist shortcut */
1824         if (!it->mincalcd)
1825           {
1826              if (it->flags & ELM_GENLIST_ITEM_GROUP)
1827                {
1828                   it->w = it->minw = it->wd->group_item_width;
1829                   it->h = it->minh = it->wd->group_item_height;
1830                }
1831              else
1832                {
1833                   it->w = it->minw = it->wd->item_width;
1834                   it->h = it->minh = it->wd->item_height;
1835                }
1836              it->mincalcd = EINA_TRUE;
1837           }
1838      }
1839    else
1840      {
1841         if (it->itc->func.label_get)
1842           {
1843              const Eina_List *l;
1844              const char *key;
1845
1846              it->labels =
1847                elm_widget_stringlist_get(edje_object_data_get(it->base.view,
1848                                                               "labels"));
1849              EINA_LIST_FOREACH(it->labels, l, key)
1850                {
1851                   char *s = it->itc->func.label_get
1852                       ((void *)it->base.data, it->base.widget, l->data);
1853
1854                   if (s)
1855                     {
1856                        edje_object_part_text_set(it->base.view, l->data, s);
1857                        free(s);
1858                     }
1859                   else if (itc)
1860                     edje_object_part_text_set(it->base.view, l->data, "");
1861                }
1862           }
1863         if (it->itc->func.icon_get)
1864           {
1865              const Eina_List *l;
1866              const char *key;
1867
1868              it->icons =
1869                elm_widget_stringlist_get(edje_object_data_get(it->base.view,
1870                                                               "icons"));
1871              EINA_LIST_FOREACH(it->icons, l, key)
1872                {
1873                   Evas_Object *ic = it->itc->func.icon_get
1874                       ((void *)it->base.data, it->base.widget, l->data);
1875
1876                   if (ic)
1877                     {
1878                        it->icon_objs = eina_list_append(it->icon_objs, ic);
1879                        edje_object_part_swallow(it->base.view, key, ic);
1880                        evas_object_show(ic);
1881                        elm_widget_sub_object_add(it->base.widget, ic);
1882                     }
1883                }
1884           }
1885         if (it->itc->func.state_get)
1886           {
1887              const Eina_List *l;
1888              const char *key;
1889
1890              it->states =
1891                elm_widget_stringlist_get(edje_object_data_get(it->base.view,
1892                                                               "states"));
1893              EINA_LIST_FOREACH(it->states, l, key)
1894                {
1895                   Eina_Bool on = it->itc->func.state_get
1896                       ((void *)it->base.data, it->base.widget, l->data);
1897
1898                   if (on)
1899                     {
1900                        snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
1901                        edje_object_signal_emit(it->base.view, buf, "elm");
1902                     }
1903                   else if (itc)
1904                     {
1905                        snprintf(buf, sizeof(buf), "elm,state,%s,passive", key);
1906                        edje_object_signal_emit(it->base.view, buf, "elm");
1907                     }
1908                }
1909           }
1910         if (!it->mincalcd)
1911           {
1912              Evas_Coord mw = -1, mh = -1;
1913
1914              if (it->wd->height_for_width) mw = it->wd->w;
1915
1916              if (!it->display_only)
1917                elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1918              if (it->wd->height_for_width) mw = it->wd->prev_viewport_w;
1919              edje_object_size_min_restricted_calc(it->base.view, &mw, &mh, mw,
1920                                                   mh);
1921              if (!it->display_only)
1922                elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1923              it->w = it->minw = mw;
1924              it->h = it->minh = mh;
1925              it->mincalcd = EINA_TRUE;
1926
1927              if ((!it->wd->group_item_width) && (it->flags == ELM_GENLIST_ITEM_GROUP))
1928                {
1929                   it->wd->group_item_width = mw;
1930                   it->wd->group_item_height = mh;
1931                }
1932              else if ((!it->wd->item_width) && (it->flags == ELM_GENLIST_ITEM_NONE))
1933                {
1934                   it->wd->item_width = mw;
1935                   it->wd->item_height = mh;
1936                }
1937           }
1938         if (!calc) evas_object_show(it->base.view);
1939      }
1940
1941    if (it->tooltip.content_cb)
1942      {
1943         elm_widget_item_tooltip_content_cb_set(it,
1944                                                it->tooltip.content_cb,
1945                                                it->tooltip.data, NULL);
1946         elm_widget_item_tooltip_style_set(it, it->tooltip.style);
1947      }
1948
1949    if (it->mouse_cursor)
1950      elm_widget_item_cursor_set(it, it->mouse_cursor);
1951
1952    it->realized = EINA_TRUE;
1953    it->want_unrealize = EINA_FALSE;
1954
1955    if (itc) _item_cache_free(itc);
1956    if (!calc) evas_object_smart_callback_call(it->base.widget, "realized", it);
1957 }
1958
1959 static void
1960 _item_unrealize(Elm_Genlist_Item *it, Eina_Bool calc)
1961 {
1962    Evas_Object *icon;
1963
1964    if (!it->realized) return;
1965    if (!calc) evas_object_smart_callback_call(it->base.widget, "unrealized", it);
1966    if (it->long_timer)
1967      {
1968         ecore_timer_del(it->long_timer);
1969         it->long_timer = NULL;
1970      }
1971    if (it->nocache)
1972      {
1973         evas_object_del(it->base.view);
1974         it->base.view = NULL;
1975         evas_object_del(it->spacer);
1976         it->spacer = NULL;
1977      }
1978    else
1979      {
1980         edje_object_mirrored_set(it->base.view, elm_widget_mirrored_get(it->base.widget));
1981         _item_cache_add(it);
1982      }
1983    elm_widget_stringlist_free(it->labels);
1984    it->labels = NULL;
1985    elm_widget_stringlist_free(it->icons);
1986    it->icons = NULL;
1987    elm_widget_stringlist_free(it->states);
1988
1989    EINA_LIST_FREE(it->icon_objs, icon)
1990      evas_object_del(icon);
1991
1992    _mode_item_unrealize(it);
1993    it->states = NULL;
1994    it->realized = EINA_FALSE;
1995    it->want_unrealize = EINA_FALSE;
1996 }
1997
1998 static Eina_Bool
1999 _item_block_recalc(Item_Block *itb,
2000                    int         in,
2001                    int         qadd,
2002                    int         norender)
2003 {
2004    const Eina_List *l;
2005    Elm_Genlist_Item *it;
2006    Evas_Coord minw = 0, minh = 0;
2007    Eina_Bool showme = EINA_FALSE, changed = EINA_FALSE;
2008    Evas_Coord y = 0;
2009
2010    itb->num = in;
2011    EINA_LIST_FOREACH(itb->items, l, it)
2012      {
2013         if (it->delete_me) continue;
2014         showme |= it->showme;
2015         if (!itb->realized)
2016           {
2017              if (qadd)
2018                {
2019                   if (!it->mincalcd) changed = EINA_TRUE;
2020                   if (changed)
2021                     {
2022                        _item_realize(it, in, EINA_TRUE);
2023                        _item_unrealize(it, EINA_TRUE);
2024                     }
2025                }
2026              else
2027                {
2028                   _item_realize(it, in, EINA_TRUE);
2029                   _item_unrealize(it, EINA_TRUE);
2030                }
2031           }
2032         else
2033           _item_realize(it, in, EINA_FALSE);
2034         minh += it->minh;
2035         if (minw < it->minw) minw = it->minw;
2036         in++;
2037         it->x = 0;
2038         it->y = y;
2039         y += it->h;
2040      }
2041    itb->minw = minw;
2042    itb->minh = minh;
2043    itb->changed = EINA_FALSE;
2044    /* force an evas norender to garbage collect deleted objects */
2045    if (norender) evas_norender(evas_object_evas_get(itb->wd->obj));
2046    return showme;
2047 }
2048
2049 static void
2050 _item_block_realize(Item_Block *itb,
2051                     int         in,
2052                     int         full)
2053 {
2054    const Eina_List *l;
2055    Elm_Genlist_Item *it;
2056
2057    if (itb->realized) return;
2058    EINA_LIST_FOREACH(itb->items, l, it)
2059      {
2060         if (it->delete_me) continue;
2061         if (full) _item_realize(it, in, EINA_FALSE);
2062         in++;
2063      }
2064    itb->realized = EINA_TRUE;
2065    itb->want_unrealize = EINA_FALSE;
2066 }
2067
2068 static void
2069 _item_block_unrealize(Item_Block *itb)
2070 {
2071    const Eina_List *l;
2072    Elm_Genlist_Item *it;
2073    Eina_Bool dragging = EINA_FALSE;
2074
2075    if (!itb->realized) return;
2076    EINA_LIST_FOREACH(itb->items, l, it)
2077      {
2078         if (it->flags != ELM_GENLIST_ITEM_GROUP)
2079           {
2080              if (it->dragging)
2081                {
2082                   dragging = EINA_TRUE;
2083                   it->want_unrealize = EINA_TRUE;
2084                }
2085              else
2086                _item_unrealize(it, EINA_FALSE);
2087           }
2088      }
2089    if (!dragging)
2090      {
2091         itb->realized = EINA_FALSE;
2092         itb->want_unrealize = EINA_TRUE;
2093      }
2094    else
2095      itb->want_unrealize = EINA_FALSE;
2096 }
2097
2098 static void
2099 _item_position(Elm_Genlist_Item *it, Evas_Object *view)
2100 {
2101    if (!it) return;
2102    if (!view) return;
2103
2104    evas_object_resize(view, it->w, it->h);
2105    evas_object_move(view, it->scrl_x, it->scrl_y);
2106    evas_object_show(view);
2107 }
2108
2109 static void
2110 _item_block_position(Item_Block *itb,
2111                      int         in)
2112 {
2113    const Eina_List *l;
2114    Elm_Genlist_Item *it;
2115    Elm_Genlist_Item *git;
2116    Evas_Coord y = 0, ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2117    int vis;
2118
2119    evas_object_geometry_get(itb->wd->pan_smart, &ox, &oy, &ow, &oh);
2120    evas_output_viewport_get(evas_object_evas_get(itb->wd->obj), &cvx, &cvy,
2121                             &cvw, &cvh);
2122    EINA_LIST_FOREACH(itb->items, l, it)
2123      {
2124         if (it->delete_me) continue;
2125         it->x = 0;
2126         it->y = y;
2127         it->w = itb->w;
2128         it->scrl_x = itb->x + it->x - it->wd->pan_x + ox;
2129         it->scrl_y = itb->y + it->y - it->wd->pan_y + oy;
2130
2131         vis = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
2132                                    cvx, cvy, cvw, cvh));
2133         if (it->flags != ELM_GENLIST_ITEM_GROUP)
2134           {
2135              if ((itb->realized) && (!it->realized))
2136                {
2137                   if (vis) _item_realize(it, in, EINA_FALSE);
2138                }
2139              if (it->realized)
2140                {
2141                   if (vis)
2142                     {
2143                        git = it->group_item;
2144                        if (git)
2145                          {
2146                             if (git->scrl_y < oy)
2147                               git->scrl_y = oy;
2148                             if ((git->scrl_y + git->h) > (it->scrl_y + it->h))
2149                               git->scrl_y = (it->scrl_y + it->h) - git->h;
2150                             git->want_realize = EINA_TRUE;
2151                          }
2152                        if (it->mode_view)
2153                           _item_position(it, it->mode_view);
2154                        else
2155                           _item_position(it, it->base.view);
2156                     }
2157                   else
2158                     {
2159                        if (!it->dragging) _item_unrealize(it, EINA_FALSE);
2160                     }
2161                }
2162              in++;
2163           }
2164         else
2165           {
2166              if (vis) it->want_realize = EINA_TRUE;
2167           }
2168         y += it->h;
2169      }
2170 }
2171
2172 static void
2173 _group_items_recalc(void *data)
2174 {
2175    Widget_Data *wd = data;
2176    Eina_List *l;
2177    Elm_Genlist_Item *git;
2178
2179    EINA_LIST_FOREACH(wd->group_items, l, git)
2180      {
2181         if (git->want_realize)
2182           {
2183              if (!git->realized)
2184                _item_realize(git, 0, EINA_FALSE);
2185              evas_object_resize(git->base.view, wd->minw, git->h);
2186              evas_object_move(git->base.view, git->scrl_x, git->scrl_y);
2187              evas_object_show(git->base.view);
2188              evas_object_raise(git->base.view);
2189           }
2190         else if (!git->want_realize && git->realized)
2191           {
2192              if (!git->dragging)
2193                _item_unrealize(git, EINA_FALSE);
2194           }
2195      }
2196 }
2197
2198 static Eina_Bool
2199 _must_recalc_idler(void *data)
2200 {
2201    Widget_Data *wd = data;
2202    if (wd->calc_job) ecore_job_del(wd->calc_job);
2203    wd->calc_job = ecore_job_add(_calc_job, wd);
2204    wd->must_recalc_idler = NULL;
2205    return ECORE_CALLBACK_CANCEL;
2206 }
2207
2208 static void
2209 _calc_job(void *data)
2210 {
2211    Widget_Data *wd = data;
2212    Item_Block *itb;
2213    Evas_Coord minw = -1, minh = 0, y = 0, ow;
2214    Item_Block *chb = NULL;
2215    int in = 0, minw_change = 0;
2216    Eina_Bool changed = EINA_FALSE;
2217    double t0, t;
2218    Eina_Bool did_must_recalc = EINA_FALSE;
2219    if (!wd) return;
2220
2221    t0 = ecore_time_get();
2222    evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &wd->h);
2223    if (wd->w != ow)
2224      {
2225         wd->w = ow;
2226         //        if (wd->height_for_width) changed = EINA_TRUE;
2227      }
2228
2229    EINA_INLIST_FOREACH(wd->blocks, itb)
2230      {
2231         Eina_Bool showme = EINA_FALSE;
2232
2233         itb->num = in;
2234         showme = itb->showme;
2235         itb->showme = EINA_FALSE;
2236         if (chb)
2237           {
2238              if (itb->realized) _item_block_unrealize(itb);
2239           }
2240         if ((itb->changed) || (changed) ||
2241             ((itb->must_recalc) && (!did_must_recalc)))
2242           {
2243              if ((changed) || (itb->must_recalc))
2244                {
2245                   Eina_List *l;
2246                   Elm_Genlist_Item *it;
2247                   EINA_LIST_FOREACH(itb->items, l, it)
2248                     if (it->mincalcd) it->mincalcd = EINA_FALSE;
2249                   itb->changed = EINA_TRUE;
2250                   if (itb->must_recalc) did_must_recalc = EINA_TRUE;
2251                   itb->must_recalc = EINA_FALSE;
2252                }
2253              if (itb->realized) _item_block_unrealize(itb);
2254              showme = _item_block_recalc(itb, in, 0, 1);
2255              chb = itb;
2256           }
2257         itb->y = y;
2258         itb->x = 0;
2259         minh += itb->minh;
2260         if (minw == -1) minw = itb->minw;
2261         else if ((!itb->must_recalc) && (minw < itb->minw))
2262           {
2263              minw = itb->minw;
2264              minw_change = 1;
2265           }
2266         itb->w = minw;
2267         itb->h = itb->minh;
2268         y += itb->h;
2269         in += itb->count;
2270         if ((showme) && (wd->show_item) && (!wd->show_item->queued))
2271           {
2272              wd->show_item->showme = EINA_FALSE;
2273              if (wd->bring_in)
2274                elm_smart_scroller_region_bring_in(wd->scr,
2275                                                   wd->show_item->x +
2276                                                   wd->show_item->block->x,
2277                                                   wd->show_item->y +
2278                                                   wd->show_item->block->y,
2279                                                   wd->show_item->block->w,
2280                                                   wd->show_item->h);
2281              else
2282                elm_smart_scroller_child_region_show(wd->scr,
2283                                                     wd->show_item->x +
2284                                                     wd->show_item->block->x,
2285                                                     wd->show_item->y +
2286                                                     wd->show_item->block->y,
2287                                                     wd->show_item->block->w,
2288                                                     wd->show_item->h);
2289              wd->show_item = NULL;
2290           }
2291      }
2292    if (minw_change)
2293      {
2294         EINA_INLIST_FOREACH(wd->blocks, itb)
2295           {
2296              itb->minw = minw;
2297              itb->w = itb->minw;
2298           }
2299      }
2300    if ((chb) && (EINA_INLIST_GET(chb)->next))
2301      {
2302         EINA_INLIST_FOREACH(EINA_INLIST_GET(chb)->next, itb)
2303           {
2304              if (itb->realized) _item_block_unrealize(itb);
2305           }
2306      }
2307    wd->realminw = minw;
2308    if (minw < wd->w) minw = wd->w;
2309    if ((minw != wd->minw) || (minh != wd->minh))
2310      {
2311         wd->minw = minw;
2312         wd->minh = minh;
2313         evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
2314         _sizing_eval(wd->obj);
2315         if ((wd->anchor_item) && (wd->anchor_item->block))
2316           {
2317              Elm_Genlist_Item *it;
2318              Evas_Coord it_y;
2319
2320              it = wd->anchor_item;
2321              it_y = wd->anchor_y;
2322              elm_smart_scroller_child_pos_set(wd->scr, wd->pan_x,
2323                                               it->block->y + it->y + it_y);
2324              wd->anchor_item = it;
2325              wd->anchor_y = it_y;
2326           }
2327      }
2328    t = ecore_time_get();
2329    if (did_must_recalc)
2330      {
2331         if (!wd->must_recalc_idler)
2332           wd->must_recalc_idler = ecore_idler_add(_must_recalc_idler, wd);
2333      }
2334    wd->calc_job = NULL;
2335    evas_object_smart_changed(wd->pan_smart);
2336 }
2337
2338 static void
2339 _update_job(void *data)
2340 {
2341    Widget_Data *wd = data;
2342    Eina_List *l2;
2343    Item_Block *itb;
2344    int num, num0, position = 0, recalc = 0;
2345    if (!wd) return;
2346    wd->update_job = NULL;
2347    num = 0;
2348    EINA_INLIST_FOREACH(wd->blocks, itb)
2349      {
2350         Evas_Coord itminw, itminh;
2351         Elm_Genlist_Item *it;
2352
2353         if (!itb->updateme)
2354           {
2355              num += itb->count;
2356              if (position)
2357                _item_block_position(itb, num);
2358              continue;
2359           }
2360         num0 = num;
2361         recalc = 0;
2362         EINA_LIST_FOREACH(itb->items, l2, it)
2363           {
2364              if (it->updateme)
2365                {
2366                   itminw = it->minw;
2367                   itminh = it->minh;
2368
2369                   it->updateme = EINA_FALSE;
2370                   if (it->realized)
2371                     {
2372                        _item_unrealize(it, EINA_FALSE);
2373                        _item_realize(it, num, EINA_FALSE);
2374                        position = 1;
2375                     }
2376                   else
2377                     {
2378                        _item_realize(it, num, EINA_TRUE);
2379                        _item_unrealize(it, EINA_TRUE);
2380                     }
2381                   if ((it->minw != itminw) || (it->minh != itminh))
2382                     recalc = 1;
2383                }
2384              num++;
2385           }
2386         itb->updateme = EINA_FALSE;
2387         if (recalc)
2388           {
2389              position = 1;
2390              itb->changed = EINA_TRUE;
2391              _item_block_recalc(itb, num0, 0, 1);
2392              _item_block_position(itb, num0);
2393           }
2394      }
2395    if (position)
2396      {
2397         if (wd->calc_job) ecore_job_del(wd->calc_job);
2398         wd->calc_job = ecore_job_add(_calc_job, wd);
2399      }
2400 }
2401
2402 static void
2403 _pan_set(Evas_Object *obj,
2404          Evas_Coord   x,
2405          Evas_Coord   y)
2406 {
2407    Pan *sd = evas_object_smart_data_get(obj);
2408    Item_Block *itb;
2409
2410    //   Evas_Coord ow, oh;
2411    //   evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2412    //   ow = sd->wd->minw - ow;
2413    //   if (ow < 0) ow = 0;
2414    //   oh = sd->wd->minh - oh;
2415    //   if (oh < 0) oh = 0;
2416    //   if (x < 0) x = 0;
2417    //   if (y < 0) y = 0;
2418    //   if (x > ow) x = ow;
2419    //   if (y > oh) y = oh;
2420    if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
2421    sd->wd->pan_x = x;
2422    sd->wd->pan_y = y;
2423
2424    EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2425      {
2426         if ((itb->y + itb->h) > y)
2427           {
2428              Elm_Genlist_Item *it;
2429              Eina_List *l2;
2430
2431              EINA_LIST_FOREACH(itb->items, l2, it)
2432                {
2433                   if ((itb->y + it->y) >= y)
2434                     {
2435                        sd->wd->anchor_item = it;
2436                        sd->wd->anchor_y = -(itb->y + it->y - y);
2437                        goto done;
2438                     }
2439                }
2440           }
2441      }
2442 done:
2443    evas_object_smart_changed(obj);
2444 }
2445
2446 static void
2447 _pan_get(Evas_Object *obj,
2448          Evas_Coord  *x,
2449          Evas_Coord  *y)
2450 {
2451    Pan *sd = evas_object_smart_data_get(obj);
2452
2453    if (x) *x = sd->wd->pan_x;
2454    if (y) *y = sd->wd->pan_y;
2455 }
2456
2457 static void
2458 _pan_max_get(Evas_Object *obj,
2459              Evas_Coord  *x,
2460              Evas_Coord  *y)
2461 {
2462    Pan *sd = evas_object_smart_data_get(obj);
2463    Evas_Coord ow, oh;
2464
2465    evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2466    ow = sd->wd->minw - ow;
2467    if (ow < 0) ow = 0;
2468    oh = sd->wd->minh - oh;
2469    if (oh < 0) oh = 0;
2470    if (x) *x = ow;
2471    if (y) *y = oh;
2472 }
2473
2474 static void
2475 _pan_min_get(Evas_Object *obj __UNUSED__,
2476              Evas_Coord  *x,
2477              Evas_Coord  *y)
2478 {
2479    if (x) *x = 0;
2480    if (y) *y = 0;
2481 }
2482
2483 static void
2484 _pan_child_size_get(Evas_Object *obj,
2485                     Evas_Coord  *w,
2486                     Evas_Coord  *h)
2487 {
2488    Pan *sd = evas_object_smart_data_get(obj);
2489
2490    if (w) *w = sd->wd->minw;
2491    if (h) *h = sd->wd->minh;
2492 }
2493
2494 static void
2495 _pan_add(Evas_Object *obj)
2496 {
2497    Pan *sd;
2498    Evas_Object_Smart_Clipped_Data *cd;
2499
2500    _pan_sc.add(obj);
2501    cd = evas_object_smart_data_get(obj);
2502    sd = ELM_NEW(Pan);
2503    if (!sd) return;
2504    sd->__clipped_data = *cd;
2505    free(cd);
2506    evas_object_smart_data_set(obj, sd);
2507 }
2508
2509 static void
2510 _pan_del(Evas_Object *obj)
2511 {
2512    Pan *sd = evas_object_smart_data_get(obj);
2513
2514    if (!sd) return;
2515    if (sd->resize_job)
2516      {
2517         ecore_job_del(sd->resize_job);
2518         sd->resize_job = NULL;
2519      }
2520    _pan_sc.del(obj);
2521 }
2522
2523 static void
2524 _pan_resize_job(void *data)
2525 {
2526    Pan *sd = data;
2527    _sizing_eval(sd->wd->obj);
2528    sd->resize_job = NULL;
2529 }
2530
2531 static void
2532 _pan_resize(Evas_Object *obj,
2533             Evas_Coord   w,
2534             Evas_Coord   h)
2535 {
2536    Pan *sd = evas_object_smart_data_get(obj);
2537    Evas_Coord ow, oh;
2538
2539    evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2540    if ((ow == w) && (oh == h)) return;
2541    if ((sd->wd->height_for_width) && (ow != w))
2542      {
2543         if (sd->resize_job) ecore_job_del(sd->resize_job);
2544         sd->resize_job = ecore_job_add(_pan_resize_job, sd);
2545      }
2546    if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2547    sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2548 }
2549
2550 static void
2551 _pan_calculate(Evas_Object *obj)
2552 {
2553    Pan *sd = evas_object_smart_data_get(obj);
2554    Item_Block *itb;
2555    Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2556    int in = 0;
2557    Elm_Genlist_Item *git;
2558    Eina_List *l;
2559
2560    evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
2561    evas_output_viewport_get(evas_object_evas_get(obj), &cvx, &cvy, &cvw, &cvh);
2562    EINA_LIST_FOREACH(sd->wd->group_items, l, git)
2563      {
2564         git->want_realize = EINA_FALSE;
2565      }
2566    EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2567      {
2568         itb->w = sd->wd->minw;
2569         if (ELM_RECTS_INTERSECT(itb->x - sd->wd->pan_x + ox,
2570                                 itb->y - sd->wd->pan_y + oy,
2571                                 itb->w, itb->h,
2572                                 cvx, cvy, cvw, cvh))
2573           {
2574              if ((!itb->realized) || (itb->changed))
2575                _item_block_realize(itb, in, 0);
2576              _item_block_position(itb, in);
2577           }
2578         else
2579           {
2580              if (itb->realized) _item_block_unrealize(itb);
2581           }
2582         in += itb->count;
2583      }
2584    _group_items_recalc(sd->wd);
2585 }
2586
2587 static void
2588 _pan_move(Evas_Object *obj,
2589           Evas_Coord   x __UNUSED__,
2590           Evas_Coord   y __UNUSED__)
2591 {
2592    Pan *sd = evas_object_smart_data_get(obj);
2593
2594    if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2595    sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2596 }
2597
2598 static void
2599 _hold_on(void        *data __UNUSED__,
2600          Evas_Object *obj,
2601          void        *event_info __UNUSED__)
2602 {
2603    Widget_Data *wd = elm_widget_data_get(obj);
2604    if (!wd) return;
2605    elm_smart_scroller_hold_set(wd->scr, 1);
2606 }
2607
2608 static void
2609 _hold_off(void        *data __UNUSED__,
2610           Evas_Object *obj,
2611           void        *event_info __UNUSED__)
2612 {
2613    Widget_Data *wd = elm_widget_data_get(obj);
2614    if (!wd) return;
2615    elm_smart_scroller_hold_set(wd->scr, 0);
2616 }
2617
2618 static void
2619 _freeze_on(void        *data __UNUSED__,
2620            Evas_Object *obj,
2621            void        *event_info __UNUSED__)
2622 {
2623    Widget_Data *wd = elm_widget_data_get(obj);
2624    if (!wd) return;
2625    elm_smart_scroller_freeze_set(wd->scr, 1);
2626 }
2627
2628 static void
2629 _freeze_off(void        *data __UNUSED__,
2630             Evas_Object *obj,
2631             void        *event_info __UNUSED__)
2632 {
2633    Widget_Data *wd = elm_widget_data_get(obj);
2634    if (!wd) return;
2635    elm_smart_scroller_freeze_set(wd->scr, 0);
2636 }
2637
2638 static void
2639 _scroll_edge_left(void        *data,
2640                   Evas_Object *scr __UNUSED__,
2641                   void        *event_info __UNUSED__)
2642 {
2643    Evas_Object *obj = data;
2644    evas_object_smart_callback_call(obj, "scroll,edge,left", NULL);
2645 }
2646
2647 static void
2648 _scroll_edge_right(void        *data,
2649                    Evas_Object *scr __UNUSED__,
2650                    void        *event_info __UNUSED__)
2651 {
2652    Evas_Object *obj = data;
2653    evas_object_smart_callback_call(obj, "scroll,edge,right", NULL);
2654 }
2655
2656 static void
2657 _scroll_edge_top(void        *data,
2658                  Evas_Object *scr __UNUSED__,
2659                  void        *event_info __UNUSED__)
2660 {
2661    Evas_Object *obj = data;
2662    evas_object_smart_callback_call(obj, "scroll,edge,top", NULL);
2663 }
2664
2665 static void
2666 _scroll_edge_bottom(void        *data,
2667                     Evas_Object *scr __UNUSED__,
2668                     void        *event_info __UNUSED__)
2669 {
2670    Evas_Object *obj = data;
2671    evas_object_smart_callback_call(obj, "scroll,edge,bottom", NULL);
2672 }
2673
2674 static void
2675 _mode_item_realize(Elm_Genlist_Item *it)
2676 {
2677    char buf[1024];
2678
2679    if ((it->mode_view) || (it->delete_me)) return;
2680
2681    it->mode_view = edje_object_add(evas_object_evas_get(it->base.widget));
2682    edje_object_scale_set(it->mode_view,
2683                          elm_widget_scale_get(it->base.widget) *
2684                          _elm_config->scale);
2685    evas_object_smart_member_add(it->mode_view, it->wd->pan_smart);
2686    elm_widget_sub_object_add(it->base.widget, it->mode_view);
2687
2688    strncpy(buf, "item", sizeof(buf));
2689    if (it->wd->compress)
2690      strncat(buf, "_compress", sizeof(buf) - strlen(buf));
2691
2692    if (it->order_num_in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
2693    strncat(buf, "/", sizeof(buf) - strlen(buf));
2694    strncat(buf, it->itc->mode_item_style, sizeof(buf) - strlen(buf));
2695
2696    _elm_theme_object_set(it->base.widget, it->mode_view, "genlist", buf,
2697                          elm_widget_style_get(it->base.widget));
2698    edje_object_mirrored_set(it->mode_view,
2699                             elm_widget_mirrored_get(it->base.widget));
2700
2701    /* signal callback add */
2702    evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_DOWN,
2703                                   _mouse_down, it);
2704    evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_UP,
2705                                   _mouse_up, it);
2706    evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_MOVE,
2707                                   _mouse_move, it);
2708
2709    /* label_get, icon_get, state_get */
2710    if (it->itc->func.label_get)
2711      {
2712         const Eina_List *l;
2713         const char *key;
2714
2715         it->mode_labels =
2716            elm_widget_stringlist_get(edje_object_data_get(it->mode_view,
2717                                                           "labels"));
2718         EINA_LIST_FOREACH(it->mode_labels, l, key)
2719           {
2720              char *s = it->itc->func.label_get
2721                 ((void *)it->base.data, it->base.widget, l->data);
2722
2723              if (s)
2724                {
2725                   edje_object_part_text_set(it->mode_view, l->data, s);
2726                   free(s);
2727                }
2728           }
2729      }
2730    if (it->itc->func.icon_get)
2731      {
2732         const Eina_List *l;
2733         const char *key;
2734
2735         it->mode_icons =
2736            elm_widget_stringlist_get(edje_object_data_get(it->mode_view,
2737                                                           "icons"));
2738         EINA_LIST_FOREACH(it->mode_icons, l, key)
2739           {
2740              Evas_Object *ic = it->itc->func.icon_get
2741                 ((void *)it->base.data, it->base.widget, l->data);
2742
2743              if (ic)
2744                {
2745                   it->mode_icon_objs = eina_list_append(it->mode_icon_objs, ic);
2746                   edje_object_part_swallow(it->mode_view, key, ic);
2747                   evas_object_show(ic);
2748                   elm_widget_sub_object_add(it->base.widget, ic);
2749                }
2750           }
2751      }
2752    if (it->itc->func.state_get)
2753      {
2754         const Eina_List *l;
2755         const char *key;
2756
2757         it->mode_states =
2758            elm_widget_stringlist_get(edje_object_data_get(it->mode_view,
2759                                                           "states"));
2760         EINA_LIST_FOREACH(it->mode_states, l, key)
2761           {
2762              Eina_Bool on = it->itc->func.state_get
2763                 ((void *)it->base.data, it->base.widget, l->data);
2764
2765              if (on)
2766                {
2767                   snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
2768                   edje_object_signal_emit(it->mode_view, buf, "elm");
2769                }
2770           }
2771      }
2772
2773    edje_object_part_swallow(it->mode_view,
2774                             edje_object_data_get(it->mode_view, "mode_part"),
2775                             it->base.view);
2776
2777    it->want_unrealize = EINA_FALSE;
2778 }
2779
2780 static void
2781 _mode_item_unrealize(Elm_Genlist_Item *it)
2782 {
2783    Widget_Data *wd = it->wd;
2784    Evas_Object *icon;
2785    if (!it->mode_view) return;
2786
2787    elm_widget_stringlist_free(it->mode_labels);
2788    it->mode_labels = NULL;
2789    elm_widget_stringlist_free(it->mode_icons);
2790    it->mode_icons = NULL;
2791    elm_widget_stringlist_free(it->mode_states);
2792
2793    EINA_LIST_FREE(it->mode_icon_objs, icon)
2794      evas_object_del(icon);
2795
2796    edje_object_part_unswallow(it->mode_view, it->base.view);
2797    evas_object_smart_member_add(it->base.view, wd->pan_smart);
2798    evas_object_del(it->mode_view);
2799    it->mode_view = NULL;
2800
2801    if (wd->mode_item == it)
2802      wd->mode_item = NULL;
2803 }
2804
2805 static void
2806 _item_mode_set(Elm_Genlist_Item *it)
2807 {
2808    if (!it) return;
2809    Widget_Data *wd = it->wd;
2810    if (!wd) return;
2811    char buf[1024];
2812
2813    wd->mode_item = it;
2814    it->nocache = EINA_TRUE;
2815
2816    if (wd->scr_hold_timer)
2817      {
2818         ecore_timer_del(wd->scr_hold_timer);
2819         wd->scr_hold_timer = NULL;
2820      }
2821    elm_smart_scroller_hold_set(wd->scr, EINA_TRUE);
2822    wd->scr_hold_timer = ecore_timer_add(0.1, _scr_hold_timer_cb, wd);
2823
2824    _mode_item_realize(it);
2825    _item_position(it, it->mode_view);
2826
2827    snprintf(buf, sizeof(buf), "elm,state,%s,active", wd->mode_type);
2828    edje_object_signal_emit(it->mode_view, buf, "elm");
2829 }
2830
2831 static void
2832 _item_mode_unset(Widget_Data *wd)
2833 {
2834    if (!wd) return;
2835    if (!wd->mode_item) return;
2836    char buf[1024], buf2[1024];
2837    Elm_Genlist_Item *it;
2838
2839    it = wd->mode_item;
2840    it->nocache = EINA_TRUE;
2841
2842    snprintf(buf, sizeof(buf), "elm,state,%s,passive", wd->mode_type);
2843    snprintf(buf2, sizeof(buf2), "elm,state,%s,passive,finished", wd->mode_type);
2844
2845    edje_object_signal_emit(it->mode_view, buf, "elm");
2846    edje_object_signal_callback_add(it->mode_view, buf2, "elm", _mode_finished_signal_cb, it);
2847
2848    wd->mode_item = NULL;
2849 }
2850
2851 /**
2852  * Add a new Genlist object
2853  *
2854  * @param parent The parent object
2855  * @return The new object or NULL if it cannot be created
2856  *
2857  * @ingroup Genlist
2858  */
2859 EAPI Evas_Object *
2860 elm_genlist_add(Evas_Object *parent)
2861 {
2862    Evas_Object *obj;
2863    Evas *e;
2864    Widget_Data *wd;
2865    Evas_Coord minw, minh;
2866    static Evas_Smart *smart = NULL;
2867
2868    if (!smart)
2869      {
2870         static Evas_Smart_Class sc;
2871
2872         evas_object_smart_clipped_smart_set(&_pan_sc);
2873         sc = _pan_sc;
2874         sc.name = "elm_genlist_pan";
2875         sc.version = EVAS_SMART_CLASS_VERSION;
2876         sc.add = _pan_add;
2877         sc.del = _pan_del;
2878         sc.resize = _pan_resize;
2879         sc.move = _pan_move;
2880         sc.calculate = _pan_calculate;
2881         if (!(smart = evas_smart_class_new(&sc))) return NULL;
2882      }
2883
2884    ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
2885
2886    ELM_SET_WIDTYPE(widtype, "genlist");
2887    elm_widget_type_set(obj, "genlist");
2888    elm_widget_sub_object_add(parent, obj);
2889    elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
2890    elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
2891    elm_widget_data_set(obj, wd);
2892    elm_widget_del_hook_set(obj, _del_hook);
2893    elm_widget_del_pre_hook_set(obj, _del_pre_hook);
2894    elm_widget_theme_hook_set(obj, _theme_hook);
2895    elm_widget_can_focus_set(obj, EINA_TRUE);
2896    elm_widget_event_hook_set(obj, _event_hook);
2897    elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
2898
2899    wd->scr = elm_smart_scroller_add(e);
2900    elm_smart_scroller_widget_set(wd->scr, obj);
2901    elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
2902                                        elm_widget_style_get(obj));
2903    elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE,
2904                                        _elm_config->thumbscroll_bounce_enable);
2905    elm_widget_resize_object_set(obj, wd->scr);
2906
2907    evas_object_smart_callback_add(wd->scr, "edge,left", _scroll_edge_left, obj);
2908    evas_object_smart_callback_add(wd->scr, "edge,right", _scroll_edge_right,
2909                                   obj);
2910    evas_object_smart_callback_add(wd->scr, "edge,top", _scroll_edge_top, obj);
2911    evas_object_smart_callback_add(wd->scr, "edge,bottom", _scroll_edge_bottom,
2912                                   obj);
2913
2914    wd->obj = obj;
2915    wd->mode = ELM_LIST_SCROLL;
2916    wd->max_items_per_block = MAX_ITEMS_PER_BLOCK;
2917    wd->item_cache_max = wd->max_items_per_block * 2;
2918    wd->longpress_timeout = _elm_config->longpress_timeout;
2919
2920    evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
2921    evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
2922    evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
2923    evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
2924
2925    wd->pan_smart = evas_object_smart_add(e, smart);
2926    wd->pan = evas_object_smart_data_get(wd->pan_smart);
2927    wd->pan->wd = wd;
2928
2929    elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
2930                                      _pan_set, _pan_get, _pan_max_get,
2931                                      _pan_min_get, _pan_child_size_get);
2932
2933    edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
2934                              &minw, &minh);
2935    evas_object_size_hint_min_set(obj, minw, minh);
2936
2937    _mirrored_set(obj, elm_widget_mirrored_get(obj));
2938    _sizing_eval(obj);
2939    return obj;
2940 }
2941
2942 static Elm_Genlist_Item *
2943 _item_new(Widget_Data                  *wd,
2944           const Elm_Genlist_Item_Class *itc,
2945           const void                   *data,
2946           Elm_Genlist_Item             *parent,
2947           Elm_Genlist_Item_Flags        flags,
2948           Evas_Smart_Cb                 func,
2949           const void                   *func_data)
2950 {
2951    Elm_Genlist_Item *it;
2952
2953    it = elm_widget_item_new(wd->obj, Elm_Genlist_Item);
2954    if (!it) return NULL;
2955    it->wd = wd;
2956    it->itc = itc;
2957    it->base.data = data;
2958    it->parent = parent;
2959    it->flags = flags;
2960    it->func.func = func;
2961    it->func.data = func_data;
2962    it->mouse_cursor = NULL;
2963    it->expanded_depth = 0;
2964    return it;
2965 }
2966
2967 static void
2968 _item_block_add(Widget_Data      *wd,
2969                 Elm_Genlist_Item *it)
2970 {
2971    Item_Block *itb = NULL;
2972
2973    if (!it->rel)
2974      {
2975 newblock:
2976         if (it->rel)
2977           {
2978              itb = calloc(1, sizeof(Item_Block));
2979              if (!itb) return;
2980              itb->wd = wd;
2981              if (!it->rel->block)
2982                {
2983                   wd->blocks =
2984                     eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
2985                   itb->items = eina_list_append(itb->items, it);
2986                }
2987              else
2988                {
2989                   if (it->before)
2990                     {
2991                        wd->blocks = eina_inlist_prepend_relative
2992                            (wd->blocks, EINA_INLIST_GET(itb),
2993                            EINA_INLIST_GET(it->rel->block));
2994                        itb->items =
2995                          eina_list_prepend_relative(itb->items, it, it->rel);
2996                     }
2997                   else
2998                     {
2999                        wd->blocks = eina_inlist_append_relative
3000                            (wd->blocks, EINA_INLIST_GET(itb),
3001                            EINA_INLIST_GET(it->rel->block));
3002                        itb->items =
3003                          eina_list_append_relative(itb->items, it, it->rel);
3004                     }
3005                }
3006           }
3007         else
3008           {
3009              if (it->before)
3010                {
3011                   if (wd->blocks)
3012                     {
3013                        itb = (Item_Block *)(wd->blocks);
3014                        if (itb->count >= wd->max_items_per_block)
3015                          {
3016                             itb = calloc(1, sizeof(Item_Block));
3017                             if (!itb) return;
3018                             itb->wd = wd;
3019                             wd->blocks =
3020                               eina_inlist_prepend(wd->blocks,
3021                                                   EINA_INLIST_GET(itb));
3022                          }
3023                     }
3024                   else
3025                     {
3026                        itb = calloc(1, sizeof(Item_Block));
3027                        if (!itb) return;
3028                        itb->wd = wd;
3029                        wd->blocks =
3030                          eina_inlist_prepend(wd->blocks, EINA_INLIST_GET(itb));
3031                     }
3032                   itb->items = eina_list_prepend(itb->items, it);
3033                }
3034              else
3035                {
3036                   if (wd->blocks)
3037                     {
3038                        itb = (Item_Block *)(wd->blocks->last);
3039                        if (itb->count >= wd->max_items_per_block)
3040                          {
3041                             itb = calloc(1, sizeof(Item_Block));
3042                             if (!itb) return;
3043                             itb->wd = wd;
3044                             wd->blocks =
3045                               eina_inlist_append(wd->blocks,
3046                                                  EINA_INLIST_GET(itb));
3047                          }
3048                     }
3049                   else
3050                     {
3051                        itb = calloc(1, sizeof(Item_Block));
3052                        if (!itb) return;
3053                        itb->wd = wd;
3054                        wd->blocks =
3055                          eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3056                     }
3057                   itb->items = eina_list_append(itb->items, it);
3058                }
3059           }
3060      }
3061    else
3062      {
3063         itb = it->rel->block;
3064         if (!itb) goto newblock;
3065         if (it->before)
3066           itb->items = eina_list_prepend_relative(itb->items, it, it->rel);
3067         else
3068           itb->items = eina_list_append_relative(itb->items, it, it->rel);
3069      }
3070    itb->count++;
3071    itb->changed = EINA_TRUE;
3072    it->block = itb;
3073    if (itb->wd->calc_job) ecore_job_del(itb->wd->calc_job);
3074    itb->wd->calc_job = ecore_job_add(_calc_job, itb->wd);
3075    if (it->rel)
3076      {
3077         it->rel->relcount--;
3078         if ((it->rel->delete_me) && (!it->rel->relcount))
3079           _item_del(it->rel);
3080         it->rel = NULL;
3081      }
3082    if (itb->count > itb->wd->max_items_per_block)
3083      {
3084         int newc;
3085         Item_Block *itb2;
3086         Elm_Genlist_Item *it2;
3087
3088         newc = itb->count / 2;
3089         itb2 = calloc(1, sizeof(Item_Block));
3090         if (!itb2) return;
3091         itb2->wd = wd;
3092         wd->blocks =
3093           eina_inlist_append_relative(wd->blocks, EINA_INLIST_GET(itb2),
3094                                       EINA_INLIST_GET(itb));
3095         itb2->changed = EINA_TRUE;
3096         while ((itb->count > newc) && (itb->items))
3097           {
3098              Eina_List *l;
3099
3100              l = eina_list_last(itb->items);
3101              it2 = l->data;
3102              itb->items = eina_list_remove_list(itb->items, l);
3103              itb->count--;
3104
3105              itb2->items = eina_list_prepend(itb2->items, it2);
3106              it2->block = itb2;
3107              itb2->count++;
3108           }
3109      }
3110 }
3111
3112 static int
3113 _queue_process(Widget_Data *wd,
3114                int          norender)
3115 {
3116    int n;
3117    Eina_Bool showme = EINA_FALSE;
3118    double t0, t;
3119
3120    t0 = ecore_time_get();
3121    for (n = 0; (wd->queue) && (n < 128); n++)
3122      {
3123         Elm_Genlist_Item *it;
3124
3125         it = wd->queue->data;
3126         wd->queue = eina_list_remove_list(wd->queue, wd->queue);
3127         it->queued = EINA_FALSE;
3128         _item_block_add(wd, it);
3129         t = ecore_time_get();
3130         if (it->block->changed)
3131           {
3132              showme = _item_block_recalc(it->block, it->block->num, 1,
3133                                          norender);
3134              it->block->changed = 0;
3135           }
3136         if (showme) it->block->showme = EINA_TRUE;
3137         if (eina_inlist_count(wd->blocks) > 1)
3138           {
3139              if ((t - t0) > (ecore_animator_frametime_get())) break;
3140           }
3141      }
3142    return n;
3143 }
3144
3145 static Eina_Bool
3146 _item_idler(void *data)
3147 {
3148    Widget_Data *wd = data;
3149
3150    //xxx
3151    //static double q_start = 0.0;
3152    //if (q_start == 0.0) q_start = ecore_time_get();
3153    //xxx
3154
3155    if (_queue_process(wd, 1) > 0)
3156      {
3157         if (wd->calc_job) ecore_job_del(wd->calc_job);
3158         wd->calc_job = ecore_job_add(_calc_job, wd);
3159      }
3160    if (!wd->queue)
3161      {
3162         //xxx
3163         //printf("PROCESS TIME: %3.3f\n", ecore_time_get() - q_start);
3164         //xxx
3165         wd->queue_idler = NULL;
3166         return ECORE_CALLBACK_CANCEL;
3167      }
3168    return ECORE_CALLBACK_RENEW;
3169 }
3170
3171 static void
3172 _item_queue(Widget_Data      *wd,
3173             Elm_Genlist_Item *it)
3174 {
3175    if (it->queued) return;
3176    it->queued = EINA_TRUE;
3177    wd->queue = eina_list_append(wd->queue, it);
3178    while ((wd->queue) && ((!wd->blocks) || (!wd->blocks->next)))
3179      {
3180         if (wd->queue_idler)
3181           {
3182              ecore_idler_del(wd->queue_idler);
3183              wd->queue_idler = NULL;
3184           }
3185         _queue_process(wd, 0);
3186      }
3187    if (!wd->queue_idler) wd->queue_idler = ecore_idler_add(_item_idler, wd);
3188 }
3189
3190 /**
3191  * Append item to the end of the genlist
3192  *
3193  * This appends the given item to the end of the list or the end of
3194  * the children if the parent is given.
3195  *
3196  * @param obj The genlist object
3197  * @param itc The item class for the item
3198  * @param data The item data
3199  * @param parent The parent item, or NULL if none
3200  * @param flags Item flags
3201  * @param func Convenience function called when item selected
3202  * @param func_data Data passed to @p func above.
3203  * @return A handle to the item added or NULL if not possible
3204  *
3205  * @ingroup Genlist
3206  */
3207 EAPI Elm_Genlist_Item *
3208 elm_genlist_item_append(Evas_Object                  *obj,
3209                         const Elm_Genlist_Item_Class *itc,
3210                         const void                   *data,
3211                         Elm_Genlist_Item             *parent,
3212                         Elm_Genlist_Item_Flags        flags,
3213                         Evas_Smart_Cb                 func,
3214                         const void                   *func_data)
3215 {
3216    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3217    Widget_Data *wd = elm_widget_data_get(obj);
3218    if (!wd) return NULL;
3219    Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3220                                     func_data);
3221    if (!it) return NULL;
3222    if (!it->parent)
3223      {
3224         if (flags & ELM_GENLIST_ITEM_GROUP)
3225           wd->group_items = eina_list_append(wd->group_items, it);
3226         wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
3227         it->rel = NULL;
3228      }
3229    else
3230      {
3231         Elm_Genlist_Item *it2 = NULL;
3232         Eina_List *ll = eina_list_last(it->parent->items);
3233         if (ll) it2 = ll->data;
3234         it->parent->items = eina_list_append(it->parent->items, it);
3235         if (!it2) it2 = it->parent;
3236         wd->items =
3237           eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3238                                       EINA_INLIST_GET(it2));
3239         it->rel = it2;
3240         it->rel->relcount++;
3241
3242         if (it->parent->flags & ELM_GENLIST_ITEM_GROUP)
3243           it->group_item = parent;
3244         else if (it->parent->group_item)
3245           it->group_item = it->parent->group_item;
3246      }
3247    it->before = EINA_FALSE;
3248    _item_queue(wd, it);
3249    return it;
3250 }
3251
3252 /**
3253  * Prepend item at start of the genlist
3254  *
3255  * This adds an item to the beginning of the list or beginning of the
3256  * children of the parent if given.
3257  *
3258  * @param obj The genlist object
3259  * @param itc The item class for the item
3260  * @param data The item data
3261  * @param parent The parent item, or NULL if none
3262  * @param flags Item flags
3263  * @param func Convenience function called when item selected
3264  * @param func_data Data passed to @p func above.
3265  * @return A handle to the item added or NULL if not possible
3266  *
3267  * @ingroup Genlist
3268  */
3269 EAPI Elm_Genlist_Item *
3270 elm_genlist_item_prepend(Evas_Object                  *obj,
3271                          const Elm_Genlist_Item_Class *itc,
3272                          const void                   *data,
3273                          Elm_Genlist_Item             *parent,
3274                          Elm_Genlist_Item_Flags        flags,
3275                          Evas_Smart_Cb                 func,
3276                          const void                   *func_data)
3277 {
3278    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3279    Widget_Data *wd = elm_widget_data_get(obj);
3280    if (!wd) return NULL;
3281    Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3282                                     func_data);
3283    if (!it) return NULL;
3284    if (!it->parent)
3285      {
3286         if (flags & ELM_GENLIST_ITEM_GROUP)
3287           wd->group_items = eina_list_prepend(wd->group_items, it);
3288         wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
3289         it->rel = NULL;
3290      }
3291    else
3292      {
3293         Elm_Genlist_Item *it2 = NULL;
3294         Eina_List *ll = it->parent->items;
3295         if (ll) it2 = ll->data;
3296         it->parent->items = eina_list_prepend(it->parent->items, it);
3297         if (!it2) it2 = it->parent;
3298         wd->items =
3299           eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3300                                        EINA_INLIST_GET(it2));
3301         it->rel = it2;
3302         it->rel->relcount++;
3303      }
3304    it->before = EINA_TRUE;
3305    _item_queue(wd, it);
3306    return it;
3307 }
3308
3309 /**
3310  * Insert item before another in the genlist
3311  *
3312  * This inserts an item before another in the list. It will be in the
3313  * same tree level or group as the item it is inseted before.
3314  *
3315  * @param obj The genlist object
3316  * @param itc The item class for the item
3317  * @param data The item data
3318  * @param before The item to insert before
3319  * @param flags Item flags
3320  * @param func Convenience function called when item selected
3321  * @param func_data Data passed to @p func above.
3322  * @return A handle to the item added or NULL if not possible
3323  *
3324  * @ingroup Genlist
3325  */
3326 EAPI Elm_Genlist_Item *
3327 elm_genlist_item_insert_before(Evas_Object                  *obj,
3328                                const Elm_Genlist_Item_Class *itc,
3329                                const void                   *data,
3330                                Elm_Genlist_Item             *parent,
3331                                Elm_Genlist_Item             *before,
3332                                Elm_Genlist_Item_Flags        flags,
3333                                Evas_Smart_Cb                 func,
3334                                const void                   *func_data)
3335 {
3336    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3337    EINA_SAFETY_ON_NULL_RETURN_VAL(before, NULL);
3338    Widget_Data *wd = elm_widget_data_get(obj);
3339    if (!wd) return NULL;
3340    Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3341                                     func_data);
3342    if (!it) return NULL;
3343    if (it->parent)
3344      {
3345         it->parent->items = eina_list_prepend_relative(it->parent->items, it,
3346                                                        before);
3347      }
3348    wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3349                                             EINA_INLIST_GET(before));
3350    it->rel = before;
3351    it->rel->relcount++;
3352    it->before = EINA_TRUE;
3353    _item_queue(wd, it);
3354    return it;
3355 }
3356
3357 /**
3358  * Insert an item after another in the genlst
3359  *
3360  * This inserts an item after another in the list. It will be in the
3361  * same tree level or group as the item it is inseted after.
3362  *
3363  * @param obj The genlist object
3364  * @param itc The item class for the item
3365  * @param data The item data
3366  * @param after The item to insert after
3367  * @param flags Item flags
3368  * @param func Convenience function called when item selected
3369  * @param func_data Data passed to @p func above.
3370  * @return A handle to the item added or NULL if not possible
3371  *
3372  * @ingroup Genlist
3373  */
3374 EAPI Elm_Genlist_Item *
3375 elm_genlist_item_insert_after(Evas_Object                  *obj,
3376                               const Elm_Genlist_Item_Class *itc,
3377                               const void                   *data,
3378                               Elm_Genlist_Item             *parent,
3379                               Elm_Genlist_Item             *after,
3380                               Elm_Genlist_Item_Flags        flags,
3381                               Evas_Smart_Cb                 func,
3382                               const void                   *func_data)
3383 {
3384    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3385    EINA_SAFETY_ON_NULL_RETURN_VAL(after, NULL);
3386    Widget_Data *wd = elm_widget_data_get(obj);
3387    if (!wd) return NULL;
3388    Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3389                                     func_data);
3390    if (!it) return NULL;
3391    wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3392                                            EINA_INLIST_GET(after));
3393    if (it->parent)
3394      {
3395         it->parent->items = eina_list_append_relative(it->parent->items, it,
3396                                                       after);
3397      }
3398    it->rel = after;
3399    it->rel->relcount++;
3400    it->before = EINA_FALSE;
3401    _item_queue(wd, it);
3402    return it;
3403 }
3404
3405 /**
3406  * Clear the genlist
3407  *
3408  * This clears all items in the list, leaving it empty.
3409  *
3410  * @param obj The genlist object
3411  *
3412  * @ingroup Genlist
3413  */
3414 EAPI void
3415 elm_genlist_clear(Evas_Object *obj)
3416 {
3417    ELM_CHECK_WIDTYPE(obj, widtype);
3418    Widget_Data *wd = elm_widget_data_get(obj);
3419    if (!wd) return;
3420    if (wd->walking > 0)
3421      {
3422         Elm_Genlist_Item *it;
3423
3424         wd->clear_me = EINA_TRUE;
3425         EINA_INLIST_FOREACH(wd->items, it)
3426           {
3427              it->delete_me = EINA_TRUE;
3428           }
3429         return;
3430      }
3431    while (wd->items)
3432      {
3433         Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3434
3435         if (wd->anchor_item == it)
3436           {
3437              wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3438              if (!wd->anchor_item)
3439                wd->anchor_item =
3440                  ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3441           }
3442         wd->items = eina_inlist_remove(wd->items, wd->items);
3443         if (it->flags & ELM_GENLIST_ITEM_GROUP)
3444           it->wd->group_items = eina_list_remove(it->wd->group_items, it);
3445         elm_widget_item_pre_notify_del(it);
3446         if (it->realized) _item_unrealize(it, EINA_FALSE);
3447         if (((wd->clear_me) || (!it->delete_me)) && (it->itc->func.del))
3448           it->itc->func.del((void *)it->base.data, it->base.widget);
3449         if (it->long_timer) ecore_timer_del(it->long_timer);
3450         if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
3451         elm_widget_item_del(it);
3452      }
3453    wd->clear_me = EINA_FALSE;
3454    wd->anchor_item = NULL;
3455    while (wd->blocks)
3456      {
3457         Item_Block *itb = (Item_Block *)(wd->blocks);
3458
3459         wd->blocks = eina_inlist_remove(wd->blocks, wd->blocks);
3460         if (itb->items) eina_list_free(itb->items);
3461         free(itb);
3462      }
3463    if (wd->calc_job)
3464      {
3465         ecore_job_del(wd->calc_job);
3466         wd->calc_job = NULL;
3467      }
3468    if (wd->queue_idler)
3469      {
3470         ecore_idler_del(wd->queue_idler);
3471         wd->queue_idler = NULL;
3472      }
3473    if (wd->must_recalc_idler)
3474      {
3475         ecore_idler_del(wd->must_recalc_idler);
3476         wd->must_recalc_idler = NULL;
3477      }
3478    if (wd->queue)
3479      {
3480         eina_list_free(wd->queue);
3481         wd->queue = NULL;
3482      }
3483    if (wd->selected)
3484      {
3485         eina_list_free(wd->selected);
3486         wd->selected = NULL;
3487      }
3488    wd->show_item = NULL;
3489    wd->pan_x = 0;
3490    wd->pan_y = 0;
3491    wd->minw = 0;
3492    wd->minh = 0;
3493    if (wd->pan_smart)
3494      {
3495         evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
3496         evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
3497      }
3498    _sizing_eval(obj);
3499 }
3500
3501 /**
3502  * Enable or disable multi-select in the genlist
3503  *
3504  * This enables (EINA_TRUE) or disables (EINA_FALSE) multi-select in
3505  * the list. This allows more than 1 item to be selected.
3506  *
3507  * @param obj The genlist object
3508  * @param multi Multi-select enable/disable
3509  *
3510  * @ingroup Genlist
3511  */
3512 EAPI void
3513 elm_genlist_multi_select_set(Evas_Object *obj,
3514                              Eina_Bool    multi)
3515 {
3516    ELM_CHECK_WIDTYPE(obj, widtype);
3517    Widget_Data *wd = elm_widget_data_get(obj);
3518    if (!wd) return;
3519    wd->multi = multi;
3520 }
3521
3522 /**
3523  * Gets if multi-select in genlist is enable or disable
3524  *
3525  * @param obj The genlist object
3526  * @return Multi-select enable/disable
3527  * (EINA_TRUE = enabled/EINA_FALSE = disabled)
3528  *
3529  * @ingroup Genlist
3530  */
3531 EAPI Eina_Bool
3532 elm_genlist_multi_select_get(const Evas_Object *obj)
3533 {
3534    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3535    Widget_Data *wd = elm_widget_data_get(obj);
3536    if (!wd) return EINA_FALSE;
3537    return wd->multi;
3538 }
3539
3540 /**
3541  * Get the selectd item in the genlist
3542  *
3543  * This gets the selected item in the list (if multi-select is enabled
3544  * only the first item in the list is selected - which is not very
3545  * useful, so see elm_genlist_selected_items_get() for when
3546  * multi-select is used).
3547  *
3548  * If no item is selected, NULL is returned.
3549  *
3550  * @param obj The genlist object
3551  * @return The selected item, or NULL if none.
3552  *
3553  * @ingroup Genlist
3554  */
3555 EAPI Elm_Genlist_Item *
3556 elm_genlist_selected_item_get(const Evas_Object *obj)
3557 {
3558    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3559    Widget_Data *wd = elm_widget_data_get(obj);
3560    if (!wd) return NULL;
3561    if (wd->selected) return wd->selected->data;
3562    return NULL;
3563 }
3564
3565 /**
3566  * Get a list of selected items in the genlist
3567  *
3568  * This returns a list of the selected items. This list pointer is
3569  * only valid so long as no items are selected or unselected (or
3570  * unselected implicitly by deletion). The list contains
3571  * Elm_Genlist_Item pointers.
3572  *
3573  * @param obj The genlist object
3574  * @return The list of selected items, nor NULL if none are selected.
3575  *
3576  * @ingroup Genlist
3577  */
3578 EAPI const Eina_List *
3579 elm_genlist_selected_items_get(const Evas_Object *obj)
3580 {
3581    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3582    Widget_Data *wd = elm_widget_data_get(obj);
3583    if (!wd) return NULL;
3584    return wd->selected;
3585 }
3586
3587 /**
3588  * Get a list of realized items in genlist
3589  *
3590  * This returns a list of the realized items in the genlist. The list
3591  * contains Elm_Genlist_Item pointers. The list must be freed by the
3592  * caller when done with eina_list_free(). The item pointers in the
3593  * list are only valid so long as those items are not deleted or the
3594  * genlist is not deleted.
3595  *
3596  * @param obj The genlist object
3597  * @return The list of realized items, nor NULL if none are realized.
3598  *
3599  * @ingroup Genlist
3600  */
3601 EAPI Eina_List *
3602 elm_genlist_realized_items_get(const Evas_Object *obj)
3603 {
3604    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3605    Widget_Data *wd = elm_widget_data_get(obj);
3606    Eina_List *list = NULL;
3607    Item_Block *itb;
3608    Eina_Bool done = EINA_FALSE;
3609    if (!wd) return NULL;
3610    EINA_INLIST_FOREACH(wd->blocks, itb)
3611      {
3612         if (itb->realized)
3613           {
3614              Eina_List *l;
3615              Elm_Genlist_Item *it;
3616
3617              done = 1;
3618              EINA_LIST_FOREACH(itb->items, l, it)
3619                {
3620                   if (it->realized) list = eina_list_append(list, it);
3621                }
3622           }
3623         else
3624           {
3625              if (done) break;
3626           }
3627      }
3628    return list;
3629 }
3630
3631 /**
3632  * Get the item that is at the x, y canvas coords
3633  *
3634  * This returns the item at the given coordinates (which are canvas
3635  * relative not object-relative). If an item is at that coordinate,
3636  * that item handle is returned, and if @p posret is not NULL, the
3637  * integer pointed to is set to a value of -1, 0 or 1, depending if
3638  * the coordinate is on the upper portion of that item (-1), on the
3639  * middle section (0) or on the lower part (1). If NULL is returned as
3640  * an item (no item found there), then posret may indicate -1 or 1
3641  * based if the coordinate is above or below all items respectively in
3642  * the genlist.
3643  *
3644  * @param it The item
3645  * @param x The input x coordinate
3646  * @param y The input y coordinate
3647  * @param posret The position relative to the item returned here
3648  * @return The item at the coordinates or NULL if none
3649  *
3650  * @ingroup Genlist
3651  */
3652 EAPI Elm_Genlist_Item *
3653 elm_genlist_at_xy_item_get(const Evas_Object *obj,
3654                            Evas_Coord         x,
3655                            Evas_Coord         y,
3656                            int               *posret)
3657 {
3658    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3659    Widget_Data *wd = elm_widget_data_get(obj);
3660    Evas_Coord ox, oy, ow, oh;
3661    Item_Block *itb;
3662    Evas_Coord lasty;
3663    if (!wd) return NULL;
3664    evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
3665    lasty = oy;
3666    EINA_INLIST_FOREACH(wd->blocks, itb)
3667      {
3668         Eina_List *l;
3669         Elm_Genlist_Item *it;
3670
3671         if (!ELM_RECTS_INTERSECT(ox + itb->x - itb->wd->pan_x,
3672                                  oy + itb->y - itb->wd->pan_y,
3673                                  itb->w, itb->h, x, y, 1, 1))
3674           continue;
3675         EINA_LIST_FOREACH(itb->items, l, it)
3676           {
3677              Evas_Coord itx, ity;
3678
3679              itx = ox + itb->x + it->x - itb->wd->pan_x;
3680              ity = oy + itb->y + it->y - itb->wd->pan_y;
3681              if (ELM_RECTS_INTERSECT(itx, ity, it->w, it->h, x, y, 1, 1))
3682                {
3683                   if (posret)
3684                     {
3685                        if (y <= (ity + (it->h / 4))) *posret = -1;
3686                        else if (y >= (ity + it->h - (it->h / 4)))
3687                          *posret = 1;
3688                        else *posret = 0;
3689                     }
3690                   return it;
3691                }
3692              lasty = ity + it->h;
3693           }
3694      }
3695    if (posret)
3696      {
3697         if (y > lasty) *posret = 1;
3698         else *posret = -1;
3699      }
3700    return NULL;
3701 }
3702
3703 /**
3704  * Get the first item in the genlist
3705  *
3706  * This returns the first item in the list.
3707  *
3708  * @param obj The genlist object
3709  * @return The first item, or NULL if none
3710  *
3711  * @ingroup Genlist
3712  */
3713 EAPI Elm_Genlist_Item *
3714 elm_genlist_first_item_get(const Evas_Object *obj)
3715 {
3716    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3717    Widget_Data *wd = elm_widget_data_get(obj);
3718    if (!wd) return NULL;
3719    if (!wd->items) return NULL;
3720    Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3721    while ((it) && (it->delete_me))
3722      it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3723    return it;
3724 }
3725
3726 /**
3727  * Get the last item in the genlist
3728  *
3729  * This returns the last item in the list.
3730  *
3731  * @return The last item, or NULL if none
3732  *
3733  * @ingroup Genlist
3734  */
3735 EAPI Elm_Genlist_Item *
3736 elm_genlist_last_item_get(const Evas_Object *obj)
3737 {
3738    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3739    Widget_Data *wd = elm_widget_data_get(obj);
3740    if (!wd) return NULL;
3741    if (!wd->items) return NULL;
3742    Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
3743    while ((it) && (it->delete_me))
3744      it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3745    return it;
3746 }
3747
3748 /**
3749  * Get the next item in the genlist
3750  *
3751  * This returns the item after the item @p it.
3752  *
3753  * @param it The item
3754  * @return The item after @p it, or NULL if none
3755  *
3756  * @ingroup Genlist
3757  */
3758 EAPI Elm_Genlist_Item *
3759 elm_genlist_item_next_get(const Elm_Genlist_Item *it)
3760 {
3761    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3762    while (it)
3763      {
3764         it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3765         if ((it) && (!it->delete_me)) break;
3766      }
3767    return (Elm_Genlist_Item *)it;
3768 }
3769
3770 /**
3771  * Get the previous item in the genlist
3772  *
3773  * This returns the item before the item @p it.
3774  *
3775  * @param it The item
3776  * @return The item before @p it, or NULL if none
3777  *
3778  * @ingroup Genlist
3779  */
3780 EAPI Elm_Genlist_Item *
3781 elm_genlist_item_prev_get(const Elm_Genlist_Item *it)
3782 {
3783    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3784    while (it)
3785      {
3786         it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3787         if ((it) && (!it->delete_me)) break;
3788      }
3789    return (Elm_Genlist_Item *)it;
3790 }
3791
3792 /**
3793  * Get the genlist object from an item
3794  *
3795  * This returns the genlist object itself that an item belongs to.
3796  *
3797  * @param it The item
3798  * @return The genlist object
3799  *
3800  * @ingroup Genlist
3801  */
3802 EAPI Evas_Object *
3803 elm_genlist_item_genlist_get(const Elm_Genlist_Item *it)
3804 {
3805    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3806    return it->base.widget;
3807 }
3808
3809 /**
3810  * Get the parent item of the given item
3811  *
3812  * This returns the parent item of the item @p it given.
3813  *
3814  * @param it The item
3815  * @return The parent of the item or NULL if none
3816  *
3817  * @ingroup Genlist
3818  */
3819 EAPI Elm_Genlist_Item *
3820 elm_genlist_item_parent_get(const Elm_Genlist_Item *it)
3821 {
3822    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3823    return it->parent;
3824 }
3825
3826 /**
3827  * Clear all sub-items (children) of the given item
3828  *
3829  * This clears all items that are children (or their descendants) of the
3830  * given item @p it.
3831  *
3832  * @param it The item
3833  *
3834  * @ingroup Genlist
3835  */
3836 EAPI void
3837 elm_genlist_item_subitems_clear(Elm_Genlist_Item *it)
3838 {
3839    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3840    Eina_List *tl = NULL, *l;
3841    Elm_Genlist_Item *it2;
3842
3843    EINA_LIST_FOREACH(it->items, l, it2)
3844      tl = eina_list_append(tl, it2);
3845    EINA_LIST_FREE(tl, it2)
3846      elm_genlist_item_del(it2);
3847 }
3848
3849 /**
3850  * Set the selected state of an item
3851  *
3852  * This sets the selected state (1 selected, 0 not selected) of the given
3853  * item @p it.
3854  *
3855  * @param it The item
3856  * @param selected The selected state
3857  *
3858  * @ingroup Genlist
3859  */
3860 EAPI void
3861 elm_genlist_item_selected_set(Elm_Genlist_Item *it,
3862                               Eina_Bool         selected)
3863 {
3864    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3865    Widget_Data *wd = elm_widget_data_get(it->base.widget);
3866    if (!wd) return;
3867    if (it->delete_me) return;
3868    selected = !!selected;
3869    if (it->selected == selected) return;
3870
3871    if (selected)
3872      {
3873         if (!wd->multi)
3874           {
3875              while (wd->selected)
3876                _item_unselect(wd->selected->data);
3877           }
3878         _item_highlight(it);
3879         _item_select(it);
3880      }
3881    else
3882      _item_unselect(it);
3883 }
3884
3885 /**
3886  * Get the selected state of an item
3887  *
3888  * This gets the selected state of an item (1 selected, 0 not selected).
3889  *
3890  * @param it The item
3891  * @return The selected state
3892  *
3893  * @ingroup Genlist
3894  */
3895 EAPI Eina_Bool
3896 elm_genlist_item_selected_get(const Elm_Genlist_Item *it)
3897 {
3898    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
3899    return it->selected;
3900 }
3901
3902 /**
3903  * Sets the expanded state of an item (if it's a parent)
3904  *
3905  * This expands or contracts a parent item (thus showing or hiding the
3906  * children).
3907  *
3908  * @param it The item
3909  * @param expanded The expanded state (1 expanded, 0 not expanded).
3910  *
3911  * @ingroup Genlist
3912  */
3913 EAPI void
3914 elm_genlist_item_expanded_set(Elm_Genlist_Item *it,
3915                               Eina_Bool         expanded)
3916 {
3917    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3918    if (it->expanded == expanded) return;
3919    it->expanded = expanded;
3920    if (it->expanded)
3921      {
3922         if (it->realized)
3923           edje_object_signal_emit(it->base.view, "elm,state,expanded", "elm");
3924         evas_object_smart_callback_call(it->base.widget, "expanded", it);
3925      }
3926    else
3927      {
3928         if (it->realized)
3929           edje_object_signal_emit(it->base.view, "elm,state,contracted", "elm");
3930         evas_object_smart_callback_call(it->base.widget, "contracted", it);
3931      }
3932 }
3933
3934 /**
3935  * Get the expanded state of an item
3936  *
3937  * This gets the expanded state of an item
3938  *
3939  * @param it The item
3940  * @return Thre expanded state
3941  *
3942  * @ingroup Genlist
3943  */
3944 EAPI Eina_Bool
3945 elm_genlist_item_expanded_get(const Elm_Genlist_Item *it)
3946 {
3947    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
3948    return it->expanded;
3949 }
3950
3951 /**
3952  * Get the depth of expanded item
3953  *
3954  * @param it The genlist item object
3955  * @return The depth of expanded item
3956  *
3957  * @ingroup Genlist
3958  */
3959 EAPI int
3960 elm_genlist_item_expanded_depth_get(const Elm_Genlist_Item *it)
3961 {
3962    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, 0);
3963    return it->expanded_depth;
3964 }
3965
3966 /**
3967  * Sets the disabled state of an item.
3968  *
3969  * A disabled item cannot be selected or unselected. It will also
3970  * change appearance to appear disabled. This sets the disabled state
3971  * (1 disabled, 0 not disabled).
3972  *
3973  * @param it The item
3974  * @param disabled The disabled state
3975  *
3976  * @ingroup Genlist
3977  */
3978 EAPI void
3979 elm_genlist_item_disabled_set(Elm_Genlist_Item *it,
3980                               Eina_Bool         disabled)
3981 {
3982    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3983    if (it->disabled == disabled) return;
3984    if (it->delete_me) return;
3985    it->disabled = disabled;
3986    if (it->realized)
3987      {
3988         if (it->disabled)
3989           edje_object_signal_emit(it->base.view, "elm,state,disabled", "elm");
3990         else
3991           edje_object_signal_emit(it->base.view, "elm,state,enabled", "elm");
3992      }
3993 }
3994
3995 /**
3996  * Get the disabled state of an item
3997  *
3998  * This gets the disabled state of the given item.
3999  *
4000  * @param it The item
4001  * @return The disabled state
4002  *
4003  * @ingroup Genlist
4004  */
4005 EAPI Eina_Bool
4006 elm_genlist_item_disabled_get(const Elm_Genlist_Item *it)
4007 {
4008    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4009    if (it->delete_me) return EINA_FALSE;
4010    return it->disabled;
4011 }
4012
4013 /**
4014  * Sets the display only state of an item.
4015  *
4016  * A display only item cannot be selected or unselected. It is for
4017  * display only and not selecting or otherwise clicking, dragging
4018  * etc. by the user, thus finger size rules will not be applied to
4019  * this item.
4020  *
4021  * @param it The item
4022  * @param display_only The display only state
4023  *
4024  * @ingroup Genlist
4025  */
4026 EAPI void
4027 elm_genlist_item_display_only_set(Elm_Genlist_Item *it,
4028                                   Eina_Bool         display_only)
4029 {
4030    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4031    if (it->display_only == display_only) return;
4032    if (it->delete_me) return;
4033    it->display_only = display_only;
4034    it->mincalcd = EINA_FALSE;
4035    it->updateme = EINA_TRUE;
4036    if (it->block) it->block->updateme = EINA_TRUE;
4037    if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4038    it->wd->update_job = ecore_job_add(_update_job, it->wd);
4039 }
4040
4041 /**
4042  * Get the display only state of an item
4043  *
4044  * This gets the display only state of the given item.
4045  *
4046  * @param it The item
4047  * @return The display only state
4048  *
4049  * @ingroup Genlist
4050  */
4051 EAPI Eina_Bool
4052 elm_genlist_item_display_only_get(const Elm_Genlist_Item *it)
4053 {
4054    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4055    if (it->delete_me) return EINA_FALSE;
4056    return it->display_only;
4057 }
4058
4059 /**
4060  * Show the given item
4061  *
4062  * This causes genlist to jump to the given item @p it and show it (by
4063  * scrolling), if it is not fully visible.
4064  *
4065  * @param it The item
4066  *
4067  * @ingroup Genlist
4068  */
4069 EAPI void
4070 elm_genlist_item_show(Elm_Genlist_Item *it)
4071 {
4072    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4073    Evas_Coord gith = 0;
4074    if (it->delete_me) return;
4075    if ((it->queued) || (!it->mincalcd))
4076      {
4077         it->wd->show_item = it;
4078         it->wd->bring_in = EINA_TRUE;
4079         it->showme = EINA_TRUE;
4080         return;
4081      }
4082    if (it->wd->show_item)
4083      {
4084         it->wd->show_item->showme = EINA_FALSE;
4085         it->wd->show_item = NULL;
4086      }
4087    if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4088      gith = it->group_item->h;
4089    elm_smart_scroller_child_region_show(it->wd->scr,
4090                                         it->x + it->block->x,
4091                                         it->y + it->block->y - gith,
4092                                         it->block->w, it->h);
4093 }
4094
4095 /**
4096  * Bring in the given item
4097  *
4098  * This causes genlist to jump to the given item @p it and show it (by
4099  * scrolling), if it is not fully visible. This may use animation to
4100  * do so and take a period of time
4101  *
4102  * @param it The item
4103  *
4104  * @ingroup Genlist
4105  */
4106 EAPI void
4107 elm_genlist_item_bring_in(Elm_Genlist_Item *it)
4108 {
4109    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4110    Evas_Coord gith = 0;
4111    if (it->delete_me) return;
4112    if ((it->queued) || (!it->mincalcd))
4113      {
4114         it->wd->show_item = it;
4115         it->wd->bring_in = EINA_TRUE;
4116         it->showme = EINA_TRUE;
4117         return;
4118      }
4119    if (it->wd->show_item)
4120      {
4121         it->wd->show_item->showme = EINA_FALSE;
4122         it->wd->show_item = NULL;
4123      }
4124    if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4125      gith = it->group_item->h;
4126    elm_smart_scroller_region_bring_in(it->wd->scr,
4127                                       it->x + it->block->x,
4128                                       it->y + it->block->y - gith,
4129                                       it->block->w, it->h);
4130 }
4131
4132 /**
4133  * Show the given item at the top
4134  *
4135  * This causes genlist to jump to the given item @p it and show it (by
4136  * scrolling), if it is not fully visible.
4137  *
4138  * @param it The item
4139  *
4140  * @ingroup Genlist
4141  */
4142 EAPI void
4143 elm_genlist_item_top_show(Elm_Genlist_Item *it)
4144 {
4145    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4146    Evas_Coord ow, oh;
4147    Evas_Coord gith = 0;
4148
4149    if (it->delete_me) return;
4150    if ((it->queued) || (!it->mincalcd))
4151      {
4152         it->wd->show_item = it;
4153         it->wd->bring_in = EINA_TRUE;
4154         it->showme = EINA_TRUE;
4155         return;
4156      }
4157    if (it->wd->show_item)
4158      {
4159         it->wd->show_item->showme = EINA_FALSE;
4160         it->wd->show_item = NULL;
4161      }
4162    evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4163    if (it->group_item) gith = it->group_item->h;
4164    elm_smart_scroller_child_region_show(it->wd->scr,
4165                                         it->x + it->block->x,
4166                                         it->y + it->block->y - gith,
4167                                         it->block->w, oh);
4168 }
4169
4170 /**
4171  * Bring in the given item at the top
4172  *
4173  * This causes genlist to jump to the given item @p it and show it (by
4174  * scrolling), if it is not fully visible. This may use animation to
4175  * do so and take a period of time
4176  *
4177  * @param it The item
4178  *
4179  * @ingroup Genlist
4180  */
4181 EAPI void
4182 elm_genlist_item_top_bring_in(Elm_Genlist_Item *it)
4183 {
4184    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4185    Evas_Coord ow, oh;
4186    Evas_Coord gith = 0;
4187
4188    if (it->delete_me) return;
4189    if ((it->queued) || (!it->mincalcd))
4190      {
4191         it->wd->show_item = it;
4192         it->wd->bring_in = EINA_TRUE;
4193         it->showme = EINA_TRUE;
4194         return;
4195      }
4196    if (it->wd->show_item)
4197      {
4198         it->wd->show_item->showme = EINA_FALSE;
4199         it->wd->show_item = NULL;
4200      }
4201    evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4202    if (it->group_item) gith = it->group_item->h;
4203    elm_smart_scroller_region_bring_in(it->wd->scr,
4204                                       it->x + it->block->x,
4205                                       it->y + it->block->y - gith,
4206                                       it->block->w, oh);
4207 }
4208
4209 /**
4210  * Show the given item at the middle
4211  *
4212  * This causes genlist to jump to the given item @p it and show it (by
4213  * scrolling), if it is not fully visible.
4214  *
4215  * @param it The item
4216  *
4217  * @ingroup Genlist
4218  */
4219 EAPI void
4220 elm_genlist_item_middle_show(Elm_Genlist_Item *it)
4221 {
4222    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4223    Evas_Coord ow, oh;
4224
4225    if (it->delete_me) return;
4226    if ((it->queued) || (!it->mincalcd))
4227      {
4228         it->wd->show_item = it;
4229         it->wd->bring_in = EINA_TRUE;
4230         it->showme = EINA_TRUE;
4231         return;
4232      }
4233    if (it->wd->show_item)
4234      {
4235         it->wd->show_item->showme = EINA_FALSE;
4236         it->wd->show_item = NULL;
4237      }
4238    evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4239    elm_smart_scroller_child_region_show(it->wd->scr,
4240                                         it->x + it->block->x,
4241                                         it->y + it->block->y - oh / 2 +
4242                                         it->h / 2, it->block->w, oh);
4243 }
4244
4245 /**
4246  * Bring in the given item at the middle
4247  *
4248  * This causes genlist to jump to the given item @p it and show it (by
4249  * scrolling), if it is not fully visible. This may use animation to
4250  * do so and take a period of time
4251  *
4252  * @param it The item
4253  *
4254  * @ingroup Genlist
4255  */
4256 EAPI void
4257 elm_genlist_item_middle_bring_in(Elm_Genlist_Item *it)
4258 {
4259    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4260    Evas_Coord ow, oh;
4261
4262    if (it->delete_me) return;
4263    if ((it->queued) || (!it->mincalcd))
4264      {
4265         it->wd->show_item = it;
4266         it->wd->bring_in = EINA_TRUE;
4267         it->showme = EINA_TRUE;
4268         return;
4269      }
4270    if (it->wd->show_item)
4271      {
4272         it->wd->show_item->showme = EINA_FALSE;
4273         it->wd->show_item = NULL;
4274      }
4275    evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4276    elm_smart_scroller_region_bring_in(it->wd->scr,
4277                                       it->x + it->block->x,
4278                                       it->y + it->block->y - oh / 2 + it->h / 2,
4279                                       it->block->w, oh);
4280 }
4281
4282 /**
4283  * Delete a given item
4284  *
4285  * This deletes the item from genlist and calls the genlist item del
4286  * class callback defined in the item class, if it is set. This clears all
4287  * subitems if it is a tree.
4288  *
4289  * @param it The item
4290  *
4291  * @ingroup Genlist
4292  */
4293 EAPI void
4294 elm_genlist_item_del(Elm_Genlist_Item *it)
4295 {
4296    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4297    if ((it->relcount > 0) || (it->walking > 0))
4298      {
4299         elm_widget_item_pre_notify_del(it);
4300         elm_genlist_item_subitems_clear(it);
4301         it->delete_me = EINA_TRUE;
4302         if (it->wd->show_item == it) it->wd->show_item = NULL;
4303         if (it->selected)
4304           it->wd->selected = eina_list_remove(it->wd->selected,
4305                                               it);
4306         if (it->block)
4307           {
4308              if (it->realized) _item_unrealize(it, EINA_FALSE);
4309              it->block->changed = EINA_TRUE;
4310              if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
4311              it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
4312           }
4313         if (it->itc->func.del)
4314           it->itc->func.del((void *)it->base.data, it->base.widget);
4315         return;
4316      }
4317    _item_del(it);
4318 }
4319
4320 /**
4321  * Set the data item from the genlist item
4322  *
4323  * This set the data value passed on the elm_genlist_item_append() and
4324  * related item addition calls. This function will also call
4325  * elm_genlist_item_update() so the item will be updated to reflect the
4326  * new data.
4327  *
4328  * @param it The item
4329  * @param data The new data pointer to set
4330  *
4331  * @ingroup Genlist
4332  */
4333 EAPI void
4334 elm_genlist_item_data_set(Elm_Genlist_Item *it,
4335                           const void       *data)
4336 {
4337    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4338    elm_widget_item_data_set(it, data);
4339    elm_genlist_item_update(it);
4340 }
4341
4342 /**
4343  * Get the data item from the genlist item
4344  *
4345  * This returns the data value passed on the elm_genlist_item_append()
4346  * and related item addition calls and elm_genlist_item_data_set().
4347  *
4348  * @param it The item
4349  * @return The data pointer provided when created
4350  *
4351  * @ingroup Genlist
4352  */
4353 EAPI void *
4354 elm_genlist_item_data_get(const Elm_Genlist_Item *it)
4355 {
4356    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4357    return elm_widget_item_data_get(it);
4358 }
4359
4360 /**
4361  * Tells genlist to "orphan" icons fetchs by the item class
4362  *
4363  * This instructs genlist to release references to icons in the item,
4364  * meaning that they will no longer be managed by genlist and are
4365  * floating "orphans" that can be re-used elsewhere if the user wants
4366  * to.
4367  *
4368  * @param it The item
4369  *
4370  * @ingroup Genlist
4371  */
4372 EAPI void
4373 elm_genlist_item_icons_orphan(Elm_Genlist_Item *it)
4374 {
4375    Evas_Object *icon;
4376    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4377    EINA_LIST_FREE(it->icon_objs, icon)
4378      {
4379         elm_widget_sub_object_del(it->base.widget, icon);
4380         evas_object_smart_member_del(icon);
4381         evas_object_hide(icon);
4382      }
4383 }
4384
4385 /**
4386  * Get the real evas object of the genlist item
4387  *
4388  * This returns the actual evas object used for the specified genlist
4389  * item. This may be NULL as it may not be created, and may be deleted
4390  * at any time by genlist. Do not modify this object (move, resize,
4391  * show, hide etc.) as genlist is controlling it. This function is for
4392  * querying, emitting custom signals or hooking lower level callbacks
4393  * for events. Do not delete this object under any circumstances.
4394  *
4395  * @param it The item
4396  * @return The object pointer
4397  *
4398  * @ingroup Genlist
4399  */
4400 EAPI const Evas_Object *
4401 elm_genlist_item_object_get(const Elm_Genlist_Item *it)
4402 {
4403    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4404    return it->base.view;
4405 }
4406
4407 /**
4408  * Update the contents of an item
4409  *
4410  * This updates an item by calling all the item class functions again
4411  * to get the icons, labels and states. Use this when the original
4412  * item data has changed and the changes are desired to be reflected.
4413  *
4414  * @param it The item
4415  *
4416  * @ingroup Genlist
4417  */
4418 EAPI void
4419 elm_genlist_item_update(Elm_Genlist_Item *it)
4420 {
4421    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4422    if (!it->block) return;
4423    if (it->delete_me) return;
4424    it->mincalcd = EINA_FALSE;
4425    it->updateme = EINA_TRUE;
4426    it->block->updateme = EINA_TRUE;
4427    if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4428    it->wd->update_job = ecore_job_add(_update_job, it->wd);
4429 }
4430
4431 /**
4432  * Update the item class of an item
4433  *
4434  * @param it The item
4435  * @parem itc The item class for the item
4436  *
4437  * @ingroup Genlist
4438  */
4439 EAPI void
4440 elm_genlist_item_item_class_update(Elm_Genlist_Item             *it,
4441                                    const Elm_Genlist_Item_Class *itc)
4442 {
4443    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4444    if (!it->block) return;
4445    EINA_SAFETY_ON_NULL_RETURN(itc);
4446    if (it->delete_me) return;
4447    it->itc = itc;
4448    it->nocache = EINA_TRUE;
4449    elm_genlist_item_update(it);
4450 }
4451
4452 static Evas_Object *
4453 _elm_genlist_item_label_create(void        *data,
4454                                Evas_Object *obj,
4455                                void        *item __UNUSED__)
4456 {
4457    Evas_Object *label = elm_label_add(obj);
4458    if (!label)
4459      return NULL;
4460    elm_object_style_set(label, "tooltip");
4461    elm_label_label_set(label, data);
4462    return label;
4463 }
4464
4465 static void
4466 _elm_genlist_item_label_del_cb(void        *data,
4467                                Evas_Object *obj __UNUSED__,
4468                                void        *event_info __UNUSED__)
4469 {
4470    eina_stringshare_del(data);
4471 }
4472
4473 /**
4474  * Set the text to be shown in the genlist item.
4475  *
4476  * @param item Target item
4477  * @param text The text to set in the content
4478  *
4479  * Setup the text as tooltip to object. The item can have only one
4480  * tooltip, so any previous tooltip data is removed.
4481  *
4482  * @ingroup Genlist
4483  */
4484 EAPI void
4485 elm_genlist_item_tooltip_text_set(Elm_Genlist_Item *item,
4486                                   const char       *text)
4487 {
4488    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4489    text = eina_stringshare_add(text);
4490    elm_genlist_item_tooltip_content_cb_set(item, _elm_genlist_item_label_create,
4491                                            text,
4492                                            _elm_genlist_item_label_del_cb);
4493 }
4494
4495 /**
4496  * Set the content to be shown in the tooltip item
4497  *
4498  * Setup the tooltip to item. The item can have only one tooltip, so
4499  * any previous tooltip data is removed. @p func(with @p data) will be
4500  * called every time that need to show the tooltip and it should return a
4501  * valid Evas_Object. This object is then managed fully by tooltip
4502  * system and is deleted when the tooltip is gone.
4503  *
4504  * @param item the genlist item being attached by a tooltip.
4505  * @param func the function used to create the tooltip contents.
4506  * @param data what to provide to @a func as callback data/context.
4507  * @param del_cb called when data is not needed anymore, either when
4508  *        another callback replaces @func, the tooltip is unset with
4509  *        elm_genlist_item_tooltip_unset() or the owner @a item
4510  *        dies. This callback receives as the first parameter the
4511  *        given @a data, and @c event_info is the item.
4512  *
4513  * @ingroup Genlist
4514  */
4515 EAPI void
4516 elm_genlist_item_tooltip_content_cb_set(Elm_Genlist_Item           *item,
4517                                         Elm_Tooltip_Item_Content_Cb func,
4518                                         const void                 *data,
4519                                         Evas_Smart_Cb               del_cb)
4520 {
4521    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_GOTO(item, error);
4522
4523    if ((item->tooltip.content_cb == func) && (item->tooltip.data == data))
4524      return;
4525
4526    if (item->tooltip.del_cb)
4527      item->tooltip.del_cb((void *)item->tooltip.data,
4528                           item->base.widget, item);
4529
4530    item->tooltip.content_cb = func;
4531    item->tooltip.data = data;
4532    item->tooltip.del_cb = del_cb;
4533
4534    if (item->base.view)
4535      {
4536         elm_widget_item_tooltip_content_cb_set(item,
4537                                                item->tooltip.content_cb,
4538                                                item->tooltip.data, NULL);
4539         elm_widget_item_tooltip_style_set(item, item->tooltip.style);
4540      }
4541
4542    return;
4543
4544 error:
4545    if (del_cb) del_cb((void *)data, NULL, NULL);
4546 }
4547
4548 /**
4549  * Unset tooltip from item
4550  *
4551  * @param item genlist item to remove previously set tooltip.
4552  *
4553  * Remove tooltip from item. The callback provided as del_cb to
4554  * elm_genlist_item_tooltip_content_cb_set() will be called to notify
4555  * it is not used anymore.
4556  *
4557  * @see elm_genlist_item_tooltip_content_cb_set()
4558  *
4559  * @ingroup Genlist
4560  */
4561 EAPI void
4562 elm_genlist_item_tooltip_unset(Elm_Genlist_Item *item)
4563 {
4564    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4565    if ((item->base.view) && (item->tooltip.content_cb))
4566      elm_widget_item_tooltip_unset(item);
4567
4568    if (item->tooltip.del_cb)
4569      item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
4570    item->tooltip.del_cb = NULL;
4571    item->tooltip.content_cb = NULL;
4572    item->tooltip.data = NULL;
4573    if (item->tooltip.style)
4574      elm_genlist_item_tooltip_style_set(item, NULL);
4575 }
4576
4577 /**
4578  * Sets a different style for this item tooltip.
4579  *
4580  * @note before you set a style you should define a tooltip with
4581  *       elm_genlist_item_tooltip_content_cb_set() or
4582  *       elm_genlist_item_tooltip_text_set()
4583  *
4584  * @param item genlist item with tooltip already set.
4585  * @param style the theme style to use (default, transparent, ...)
4586  *
4587  * @ingroup Genlist
4588  */
4589 EAPI void
4590 elm_genlist_item_tooltip_style_set(Elm_Genlist_Item *item,
4591                                    const char       *style)
4592 {
4593    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4594    eina_stringshare_replace(&item->tooltip.style, style);
4595    if (item->base.view) elm_widget_item_tooltip_style_set(item, style);
4596 }
4597
4598 /**
4599  * Get the style for this item tooltip.
4600  *
4601  * @param item genlist item with tooltip already set.
4602  * @return style the theme style in use, defaults to "default". If the
4603  *         object does not have a tooltip set, then NULL is returned.
4604  *
4605  * @ingroup Genlist
4606  */
4607 EAPI const char *
4608 elm_genlist_item_tooltip_style_get(const Elm_Genlist_Item *item)
4609 {
4610    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4611    return item->tooltip.style;
4612 }
4613
4614 /**
4615  * Set the cursor to be shown when mouse is over the genlist item
4616  *
4617  * @param item Target item
4618  * @param cursor the cursor name to be used.
4619  *
4620  * @see elm_object_cursor_set()
4621  * @ingroup Genlist
4622  */
4623 EAPI void
4624 elm_genlist_item_cursor_set(Elm_Genlist_Item *item,
4625                             const char       *cursor)
4626 {
4627    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4628    eina_stringshare_replace(&item->mouse_cursor, cursor);
4629    if (item->base.view) elm_widget_item_cursor_set(item, cursor);
4630 }
4631
4632 /**
4633  * Get the cursor to be shown when mouse is over the genlist item
4634  *
4635  * @param item genlist item with cursor already set.
4636  * @return the cursor name.
4637  *
4638  * @ingroup Genlist
4639  */
4640 EAPI const char *
4641 elm_genlist_item_cursor_get(const Elm_Genlist_Item *item)
4642 {
4643    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4644    return elm_widget_item_cursor_get(item);
4645 }
4646
4647 /**
4648  * Unset the cursor to be shown when mouse is over the genlist item
4649  *
4650  * @param item Target item
4651  *
4652  * @see elm_object_cursor_unset()
4653  * @ingroup Genlist
4654  */
4655 EAPI void
4656 elm_genlist_item_cursor_unset(Elm_Genlist_Item *item)
4657 {
4658    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4659    if (!item->mouse_cursor)
4660      return;
4661
4662    if (item->base.view)
4663      elm_widget_item_cursor_unset(item);
4664
4665    eina_stringshare_del(item->mouse_cursor);
4666    item->mouse_cursor = NULL;
4667 }
4668
4669 /**
4670  * Sets a different style for this item cursor.
4671  *
4672  * @note before you set a style you should define a cursor with
4673  *       elm_genlist_item_cursor_set()
4674  *
4675  * @param item genlist item with cursor already set.
4676  * @param style the theme style to use (default, transparent, ...)
4677  *
4678  * @ingroup Genlist
4679  */
4680 EAPI void
4681 elm_genlist_item_cursor_style_set(Elm_Genlist_Item *item,
4682                                   const char       *style)
4683 {
4684    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4685    elm_widget_item_cursor_style_set(item, style);
4686 }
4687
4688 /**
4689  * Get the style for this item cursor.
4690  *
4691  * @param item genlist item with cursor already set.
4692  * @return style the theme style in use, defaults to "default". If the
4693  *         object does not have a cursor set, then NULL is returned.
4694  *
4695  * @ingroup Genlist
4696  */
4697 EAPI const char *
4698 elm_genlist_item_cursor_style_get(const Elm_Genlist_Item *item)
4699 {
4700    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4701    return elm_widget_item_cursor_style_get(item);
4702 }
4703
4704 /**
4705  * Set if the cursor set should be searched on the theme or should use
4706  * the provided by the engine, only.
4707  *
4708  * @note before you set if should look on theme you should define a
4709  * cursor with elm_object_cursor_set(). By default it will only look
4710  * for cursors provided by the engine.
4711  *
4712  * @param item widget item with cursor already set.
4713  * @param engine_only boolean to define it cursors should be looked
4714  * only between the provided by the engine or searched on widget's
4715  * theme as well.
4716  *
4717  * @ingroup Genlist
4718  */
4719 EAPI void
4720 elm_genlist_item_cursor_engine_only_set(Elm_Genlist_Item *item,
4721                                         Eina_Bool         engine_only)
4722 {
4723    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4724    elm_widget_item_cursor_engine_only_set(item, engine_only);
4725 }
4726
4727 /**
4728  * Get the cursor engine only usage for this item cursor.
4729  *
4730  * @param item widget item with cursor already set.
4731  * @return engine_only boolean to define it cursors should be looked
4732  * only between the provided by the engine or searched on widget's
4733  * theme as well. If the object does not have a cursor set, then
4734  * EINA_FALSE is returned.
4735  *
4736  * @ingroup Genlist
4737  */
4738 EAPI Eina_Bool
4739 elm_genlist_item_cursor_engine_only_get(const Elm_Genlist_Item *item)
4740 {
4741    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
4742    return elm_widget_item_cursor_engine_only_get(item);
4743 }
4744
4745 /**
4746  * This sets the horizontal stretching mode
4747  *
4748  * This sets the mode used for sizing items horizontally. Valid modes
4749  * are ELM_LIST_LIMIT and ELM_LIST_SCROLL. The default is
4750  * ELM_LIST_SCROLL. This mode means that if items are too wide to fit,
4751  * the scroller will scroll horizontally. Otherwise items are expanded
4752  * to fill the width of the viewport of the scroller. If it is
4753  * ELM_LIST_LIMIT, Items will be expanded to the viewport width and
4754  * limited to that size.
4755  *
4756  * @param obj The genlist object
4757  * @param mode The mode to use
4758  *
4759  * @ingroup Genlist
4760  */
4761 EAPI void
4762 elm_genlist_horizontal_mode_set(Evas_Object  *obj,
4763                                 Elm_List_Mode mode)
4764 {
4765    ELM_CHECK_WIDTYPE(obj, widtype);
4766    Widget_Data *wd = elm_widget_data_get(obj);
4767    if (!wd) return;
4768    if (wd->mode == mode) return;
4769    wd->mode = mode;
4770    _sizing_eval(obj);
4771 }
4772
4773 /**
4774  * Gets the horizontal stretching mode
4775  *
4776  * @param obj The genlist object
4777  * @return The mode to use
4778  * (ELM_LIST_LIMIT, ELM_LIST_SCROLL)
4779  *
4780  * @ingroup Genlist
4781  */
4782 EAPI Elm_List_Mode
4783 elm_genlist_horizontal_mode_get(const Evas_Object *obj)
4784 {
4785    ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
4786    Widget_Data *wd = elm_widget_data_get(obj);
4787    if (!wd) return ELM_LIST_LAST;
4788    return wd->mode;
4789 }
4790
4791 /**
4792  * Set the always select mode.
4793  *
4794  * Items will only call their selection func and callback when first
4795  * becoming selected. Any further clicks will do nothing, unless you
4796  * enable always select with elm_genlist_always_select_mode_set().
4797  * This means even if selected, every click will make the selected
4798  * callbacks be called.
4799  *
4800  * @param obj The genlist object
4801  * @param always_select The always select mode
4802  * (EINA_TRUE = on, EINA_FALSE = off)
4803  *
4804  * @ingroup Genlist
4805  */
4806 EAPI void
4807 elm_genlist_always_select_mode_set(Evas_Object *obj,
4808                                    Eina_Bool    always_select)
4809 {
4810    ELM_CHECK_WIDTYPE(obj, widtype);
4811    Widget_Data *wd = elm_widget_data_get(obj);
4812    if (!wd) return;
4813    wd->always_select = always_select;
4814 }
4815
4816 /**
4817  * Get the always select mode.
4818  *
4819  * @param obj The genlist object
4820  * @return The always select mode
4821  * (EINA_TRUE = on, EINA_FALSE = off)
4822  *
4823  * @ingroup Genlist
4824  */
4825 EAPI Eina_Bool
4826 elm_genlist_always_select_mode_get(const Evas_Object *obj)
4827 {
4828    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4829    Widget_Data *wd = elm_widget_data_get(obj);
4830    if (!wd) return EINA_FALSE;
4831    return wd->always_select;
4832 }
4833
4834 /**
4835  * Set no select mode
4836  *
4837  * This will turn off the ability to select items entirely and they
4838  * will neither appear selected nor call selected callback functions.
4839  *
4840  * @param obj The genlist object
4841  * @param no_select The no select mode
4842  * (EINA_TRUE = on, EINA_FALSE = off)
4843  *
4844  * @ingroup Genlist
4845  */
4846 EAPI void
4847 elm_genlist_no_select_mode_set(Evas_Object *obj,
4848                                Eina_Bool    no_select)
4849 {
4850    ELM_CHECK_WIDTYPE(obj, widtype);
4851    Widget_Data *wd = elm_widget_data_get(obj);
4852    if (!wd) return;
4853    wd->no_select = no_select;
4854 }
4855
4856 /**
4857  * Gets no select mode
4858  *
4859  * @param obj The genlist object
4860  * @return The no select mode
4861  * (EINA_TRUE = on, EINA_FALSE = off)
4862  *
4863  * @ingroup Genlist
4864  */
4865 EAPI Eina_Bool
4866 elm_genlist_no_select_mode_get(const Evas_Object *obj)
4867 {
4868    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4869    Widget_Data *wd = elm_widget_data_get(obj);
4870    if (!wd) return EINA_FALSE;
4871    return wd->no_select;
4872 }
4873
4874 /**
4875  * Set compress mode
4876  *
4877  * This will enable the compress mode where items are "compressed"
4878  * horizontally to fit the genlist scrollable viewport width. This is
4879  * special for genlist.  Do not rely on
4880  * elm_genlist_horizontal_mode_set() being set to ELM_LIST_COMPRESS to
4881  * work as genlist needs to handle it specially.
4882  *
4883  * @param obj The genlist object
4884  * @param compress The compress mode
4885  * (EINA_TRUE = on, EINA_FALSE = off)
4886  *
4887  * @ingroup Genlist
4888  */
4889 EAPI void
4890 elm_genlist_compress_mode_set(Evas_Object *obj,
4891                               Eina_Bool    compress)
4892 {
4893    ELM_CHECK_WIDTYPE(obj, widtype);
4894    Widget_Data *wd = elm_widget_data_get(obj);
4895    if (!wd) return;
4896    wd->compress = compress;
4897 }
4898
4899 /**
4900  * Get the compress mode
4901  *
4902  * @param obj The genlist object
4903  * @return The compress mode
4904  * (EINA_TRUE = on, EINA_FALSE = off)
4905  *
4906  * @ingroup Genlist
4907  */
4908 EAPI Eina_Bool
4909 elm_genlist_compress_mode_get(const Evas_Object *obj)
4910 {
4911    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4912    Widget_Data *wd = elm_widget_data_get(obj);
4913    if (!wd) return EINA_FALSE;
4914    return wd->compress;
4915 }
4916
4917 /**
4918  * Set height-for-width mode
4919  *
4920  * With height-for-width mode the item width will be fixed (restricted
4921  * to a minimum of) to the list width when calculating its size in
4922  * order to allow the height to be calculated based on it. This allows,
4923  * for instance, text block to wrap lines if the Edje part is
4924  * configured with "text.min: 0 1".
4925  *
4926  * @note This mode will make list resize slower as it will have to
4927  *       recalculate every item height again whenever the list width
4928  *       changes!
4929  *
4930  * @note When height-for-width mode is enabled, it also enables
4931  *       compress mode (see elm_genlist_compress_mode_set()) and
4932  *       disables homogeneous (see elm_genlist_homogeneous_set()).
4933  *
4934  * @param obj The genlist object
4935  * @param setting The height-for-width mode (EINA_TRUE = on,
4936  * EINA_FALSE = off)
4937  *
4938  * @ingroup Genlist
4939  */
4940 EAPI void
4941 elm_genlist_height_for_width_mode_set(Evas_Object *obj,
4942                                       Eina_Bool    height_for_width)
4943 {
4944    ELM_CHECK_WIDTYPE(obj, widtype);
4945    Widget_Data *wd = elm_widget_data_get(obj);
4946    if (!wd) return;
4947    wd->height_for_width = !!height_for_width;
4948    if (wd->height_for_width)
4949      {
4950         elm_genlist_homogeneous_set(obj, EINA_FALSE);
4951         elm_genlist_compress_mode_set(obj, EINA_TRUE);
4952      }
4953 }
4954
4955 /**
4956  * Get the height-for-width mode
4957  *
4958  * @param obj The genlist object
4959  * @return The height-for-width mode (EINA_TRUE = on, EINA_FALSE =
4960  * off)
4961  *
4962  * @ingroup Genlist
4963  */
4964 EAPI Eina_Bool
4965 elm_genlist_height_for_width_mode_get(const Evas_Object *obj)
4966 {
4967    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4968    Widget_Data *wd = elm_widget_data_get(obj);
4969    if (!wd) return EINA_FALSE;
4970    return wd->height_for_width;
4971 }
4972
4973 /**
4974  * Set bounce mode
4975  *
4976  * This will enable or disable the scroller bounce mode for the
4977  * genlist. See elm_scroller_bounce_set() for details
4978  *
4979  * @param obj The genlist object
4980  * @param h_bounce Allow bounce horizontally
4981  * @param v_bounce Allow bounce vertically
4982  *
4983  * @ingroup Genlist
4984  */
4985 EAPI void
4986 elm_genlist_bounce_set(Evas_Object *obj,
4987                        Eina_Bool    h_bounce,
4988                        Eina_Bool    v_bounce)
4989 {
4990    ELM_CHECK_WIDTYPE(obj, widtype);
4991    Widget_Data *wd = elm_widget_data_get(obj);
4992    if (!wd) return;
4993    elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
4994 }
4995
4996 /**
4997  * Get the bounce mode
4998  *
4999  * @param obj The genlist object
5000  * @param h_bounce Allow bounce horizontally
5001  * @param v_bounce Allow bounce vertically
5002  *
5003  * @ingroup Genlist
5004  */
5005 EAPI void
5006 elm_genlist_bounce_get(const Evas_Object *obj,
5007                        Eina_Bool         *h_bounce,
5008                        Eina_Bool         *v_bounce)
5009 {
5010    ELM_CHECK_WIDTYPE(obj, widtype);
5011    Widget_Data *wd = elm_widget_data_get(obj);
5012    if (!wd) return;
5013    elm_smart_scroller_bounce_allow_get(obj, h_bounce, v_bounce);
5014 }
5015
5016 /**
5017  * Set homogenous mode
5018  *
5019  * This will enable the homogeneous mode where items are of the same
5020  * height and width so that genlist may do the lazy-loading at its
5021  * maximum. This implies 'compressed' mode.
5022  *
5023  * @param obj The genlist object
5024  * @param homogeneous Assume the items within the genlist are of the
5025  * same height and width (EINA_TRUE = on, EINA_FALSE = off)
5026  *
5027  * @ingroup Genlist
5028  */
5029 EAPI void
5030 elm_genlist_homogeneous_set(Evas_Object *obj,
5031                             Eina_Bool    homogeneous)
5032 {
5033    ELM_CHECK_WIDTYPE(obj, widtype);
5034    Widget_Data *wd = elm_widget_data_get(obj);
5035    if (!wd) return;
5036    if (homogeneous) elm_genlist_compress_mode_set(obj, EINA_TRUE);
5037    wd->homogeneous = homogeneous;
5038 }
5039
5040 /**
5041  * Get the homogenous mode
5042  *
5043  * @param obj The genlist object
5044  * @return Assume the items within the genlist are of the same height
5045  * and width (EINA_TRUE = on, EINA_FALSE = off)
5046  *
5047  * @ingroup Genlist
5048  */
5049 EAPI Eina_Bool
5050 elm_genlist_homogeneous_get(const Evas_Object *obj)
5051 {
5052    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5053    Widget_Data *wd = elm_widget_data_get(obj);
5054    if (!wd) return EINA_FALSE;
5055    return wd->homogeneous;
5056 }
5057
5058 /**
5059  * Set the maximum number of items within an item block
5060  *
5061  * This will configure the block count to tune to the target with
5062  * particular performance matrix.
5063  *
5064  * @param obj The genlist object
5065  * @param n   Maximum number of items within an item block
5066  *
5067  * @ingroup Genlist
5068  */
5069 EAPI void
5070 elm_genlist_block_count_set(Evas_Object *obj,
5071                             int          n)
5072 {
5073    ELM_CHECK_WIDTYPE(obj, widtype);
5074    Widget_Data *wd = elm_widget_data_get(obj);
5075    if (!wd) return;
5076    wd->max_items_per_block = n;
5077    wd->item_cache_max = wd->max_items_per_block * 2;
5078    _item_cache_clean(wd);
5079 }
5080
5081 /**
5082  * Get the maximum number of items within an item block
5083  *
5084  * @param obj The genlist object
5085  * @return Maximum number of items within an item block
5086  *
5087  * @ingroup Genlist
5088  */
5089 EAPI int
5090 elm_genlist_block_count_get(const Evas_Object *obj)
5091 {
5092    ELM_CHECK_WIDTYPE(obj, widtype) 0;
5093    Widget_Data *wd = elm_widget_data_get(obj);
5094    if (!wd) return 0;
5095    return wd->max_items_per_block;
5096 }
5097
5098 /**
5099  * Set the timeout in seconds for the longpress event
5100  *
5101  * @param obj The genlist object
5102  * @param timeout timeout in seconds
5103  *
5104  * @ingroup Genlist
5105  */
5106 EAPI void
5107 elm_genlist_longpress_timeout_set(Evas_Object *obj,
5108                                   double       timeout)
5109 {
5110    ELM_CHECK_WIDTYPE(obj, widtype);
5111    Widget_Data *wd = elm_widget_data_get(obj);
5112    if (!wd) return;
5113    wd->longpress_timeout = timeout;
5114 }
5115
5116 /**
5117  * Get the timeout in seconds for the longpress event
5118  *
5119  * @param obj The genlist object
5120  * @return timeout in seconds
5121  *
5122  * @ingroup Genlist
5123  */
5124 EAPI double
5125 elm_genlist_longpress_timeout_get(const Evas_Object *obj)
5126 {
5127    ELM_CHECK_WIDTYPE(obj, widtype) 0;
5128    Widget_Data *wd = elm_widget_data_get(obj);
5129    if (!wd) return 0;
5130    return wd->longpress_timeout;
5131 }
5132
5133 /**
5134  * Set the scrollbar policy
5135  *
5136  * This sets the scrollbar visibility policy for the given genlist
5137  * scroller. ELM_SMART_SCROLLER_POLICY_AUTO means the scrollbar is
5138  * made visible if it is needed, and otherwise kept hidden.
5139  * ELM_SMART_SCROLLER_POLICY_ON turns it on all the time, and
5140  * ELM_SMART_SCROLLER_POLICY_OFF always keeps it off. This applies
5141  * respectively for the horizontal and vertical scrollbars.
5142  *
5143  * @param obj The genlist object
5144  * @param policy_h Horizontal scrollbar policy
5145  * @param policy_v Vertical scrollbar policy
5146  *
5147  * @ingroup Genlist
5148  */
5149 EAPI void
5150 elm_genlist_scroller_policy_set(Evas_Object        *obj,
5151                                 Elm_Scroller_Policy policy_h,
5152                                 Elm_Scroller_Policy policy_v)
5153 {
5154    ELM_CHECK_WIDTYPE(obj, widtype);
5155    Widget_Data *wd = elm_widget_data_get(obj);
5156    if (!wd) return;
5157    if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
5158        (policy_v >= ELM_SCROLLER_POLICY_LAST))
5159      return;
5160    if (wd->scr)
5161      elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
5162 }
5163
5164 /**
5165  * Get the scrollbar policy
5166  *
5167  * @param obj The genlist object
5168  * @param policy_h Horizontal scrollbar policy
5169  * @param policy_v Vertical scrollbar policy
5170  *
5171  * @ingroup Genlist
5172  */
5173 EAPI void
5174 elm_genlist_scroller_policy_get(const Evas_Object   *obj,
5175                                 Elm_Scroller_Policy *policy_h,
5176                                 Elm_Scroller_Policy *policy_v)
5177 {
5178    ELM_CHECK_WIDTYPE(obj, widtype);
5179    Widget_Data *wd = elm_widget_data_get(obj);
5180    Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
5181    if ((!wd) || (!wd->scr)) return;
5182    elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
5183    if (policy_h) *policy_h = (Elm_Scroller_Policy)s_policy_h;
5184    if (policy_v) *policy_v = (Elm_Scroller_Policy)s_policy_v;
5185 }
5186
5187 /**
5188  * Update the contents of all realized items
5189  *
5190  * This updates all realized items by calling all the item class functions again
5191  * to get the icons, labels and states. Use this when the original
5192  * item data has changed and the changes are desired to be reflected.
5193  *
5194  * @param it The item
5195  *
5196  * @ingroup Genlist
5197  */
5198 EAPI void
5199 elm_genlist_realized_items_update(Evas_Object *obj)
5200 {
5201    ELM_CHECK_WIDTYPE(obj, widtype);
5202
5203    Eina_List *list, *l;
5204    Elm_Genlist_Item *it;
5205
5206    list = elm_genlist_realized_items_get(obj);
5207    EINA_LIST_FOREACH(list, l, it)
5208      elm_genlist_item_update(it);
5209 }
5210
5211 /**
5212  * Set genlist item mode
5213  *
5214  * @param item The genlist item
5215  * @param mode Mode name
5216  * @param mode_set Boolean to define set or unset mode.
5217  *
5218  * @ingroup Genlist
5219  */
5220 EAPI void
5221 elm_genlist_item_mode_set(Elm_Genlist_Item *it,
5222                           const char       *mode_type,
5223                           Eina_Bool         mode_set)
5224 {
5225    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
5226    Widget_Data *wd = it->wd;
5227    Eina_List *l;
5228    Elm_Genlist_Item *it2;
5229
5230    if (!wd) return;
5231    if (!mode_type) return;
5232
5233    if ((wd->mode_item == it) &&
5234        (!strcmp(mode_type, wd->mode_type)) &&
5235        (mode_set))
5236       return;
5237    if (!it->itc->mode_item_style) return;
5238
5239    if (wd->multi)
5240      {
5241         EINA_LIST_FOREACH(wd->selected, l, it2)
5242           if (it2->realized)
5243             elm_genlist_item_selected_set(it2, EINA_FALSE);
5244      }
5245    else
5246      {
5247         it2 = elm_genlist_selected_item_get(wd->obj);
5248         if ((it2) && (it2->realized))
5249           elm_genlist_item_selected_set(it2, EINA_FALSE);
5250      }
5251
5252    if (((wd->mode_type) && (strcmp(mode_type, wd->mode_type))) ||
5253        (mode_set) ||
5254        ((it == wd->mode_item) && (!mode_set)))
5255      _item_mode_unset(wd);
5256
5257    eina_stringshare_replace(&wd->mode_type, mode_type);
5258    if (mode_set) _item_mode_set(it);
5259 }
5260
5261 /**
5262  * Get active genlist mode type
5263  *
5264  * @param obj The genlist object
5265  *
5266  * @ingroup Genlist
5267  */
5268 EAPI const char *
5269 elm_genlist_mode_get(const Evas_Object *obj)
5270 {
5271    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5272    Widget_Data *wd = elm_widget_data_get(obj);
5273    if (!wd) return NULL;
5274    return wd->mode_type;
5275 }
5276
5277 /**
5278  * Get active genlist mode item
5279  *
5280  * @param obj The genlist object
5281  *
5282  * @ingroup Genlist
5283  */
5284 EAPI const Elm_Genlist_Item *
5285 elm_genlist_mode_item_get(const Evas_Object *obj)
5286 {
5287    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5288    Widget_Data *wd = elm_widget_data_get(obj);
5289    if (!wd) return NULL;
5290    return wd->mode_item;
5291 }