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