elm genlist/list/gengrid: Removed deprecated signal "clicked". Use
[framework/uifw/elementary.git] / src / lib / elm_gengrid.c
index 9140f64..8589638 100644 (file)
  * genlist: the user define a class for each item, specifying
  * functions that will be called at object creation and deletion.
  *
- * Signals that you can add callbacks for are:
- *
- * clicked - The user has double-clicked a item. The event_info
- * parameter is the Gengrid item that was double-clicked.
- *
- * selected - The user has made an item selected. The event_info
- * parameter is the Gengrid item that was selected.
- *
- * unselected - The user has made an item unselected. The event_info
- * parameter is the Gengrid item that was unselected.
- *
- * realized - This is called when the item in the Gengrid is created
- * as a real evas object. event_info is the Gengrid item that was
- * created. The object may be deleted at any time, so it is up to the
- * caller to not use the object pointer from
- * elm_gengrid_item_object_get() in a way where it may point to freed
- * objects.
- *
- * unrealized - This is called when the real evas object for this item
- * is deleted. event_info is the Gengrid item that was created.
- *
- * changed - Called when an item is added, removed, resized or moved
- * and when gengrid is resized or horizontal property changes.
- *
- * drag,start,up - Called when the item in the Gengrid has been
- * dragged (not scrolled) up.
- *
- * drag,start,down - Called when the item in the Gengrid has been
- * dragged (not scrolled) down.
- *
- * drag,start,left - Called when the item in the Gengrid has been
- * dragged (not scrolled) left.
- *
- * drag,start,right - Called when the item in the Gengrid has been
- * dragged (not scrolled) right.
- *
- * drag,stop - Called when the item in the Gengrid has stopped being
- * dragged.
- *
- * drag - Called when the item in the Gengrid is being dragged.
- *
- * scroll - called when the content has been scrolled (moved).
- *
- * scroll,drag,start - called when dragging the content has started.
- *
- * scroll,drag,stop - called when dragging the content has stopped.
- *
- *
  * A item in the Gengrid can have 0 or more text labels (they can be
  * regular text or textblock - that's up to the style to determine), 0
  * or more icons (which are simply objects swallowed into the Gengrid
@@ -72,7 +24,7 @@
  * application provides a structure with information about that type
  * of item (Gengrid may contain multiple different items with
  * different classes, states and styles). Gengrid will call the
- * functions in this struct (methods) when a item is "realized" (that
+ * functions in this struct (methods) when an item is "realized" (that
  * is created dynamically while scrolling). All objects will simply be
  * deleted when no longer needed with evas_object_del(). The
  * Elm_GenGrid_Item_Class structure contains the following members:
  * where XXX is the name of the part.
  *
  * func.del - This is called when elm_gengrid_item_del() is called on
- * a item or elm_gengrid_clear() is called on the Gengrid. This is
+ * an item or elm_gengrid_clear() is called on the Gengrid. This is
  * intended for use when actual Gengrid items are deleted, so any
  * backing data attached to the item (e.g. its data parameter on
  * creation) can be deleted.
  * only valid as long as no items are modified (added, deleted,
  * selected or unselected).
  *
- * If a item changes (state of boolean changes, label or icons
+ * If an item changes (state of boolean changes, label or icons
  * change), then use elm_gengrid_item_update() to have Gengrid update
  * the item with the new state. Gengrid will re-realize the item thus
  * call the functions in the _Elm_Gengrid_Item_Class for that item.
  *
- * To programmatically (un)select a item use
+ * To programmatically (un)select an item use
  * elm_gengrid_item_selected_set().  To get its selected state use
- * elm_gengrid_item_selected_get(). To make a item disabled (unable to
+ * elm_gengrid_item_selected_get(). To make an item disabled (unable to
  * be selected and appear differently) use
  * elm_gengrid_item_disabled_set() to set this and
  * elm_gengrid_item_disabled_get() to get the disabled state.
  * user or system sets up you can use elm_theme_overlay_add() to add
  * such a file.
  *
+ * Signals that you can add callbacks for are:
+ *
+ * "clicked,double" - The user has double-clicked or pressed enter on
+ *                    an item. The event_infoparameter is the Gengrid item
+ *                    that was double-clicked.
+ * "selected" - The user has made an item selected. The event_info
+ *              parameter is the Gengrid item that was selected.
+ * "unselected" - The user has made an item unselected. The event_info
+ *                parameter is the Gengrid item that was unselected.
+ * "realized" - This is called when the item in the Gengrid is created
+ *              as a real evas object. event_info is the Gengrid item that was
+ *              created. The object may be deleted at any time, so it is up to
+ *              the caller to not use the object pointer from
+ *              elm_gengrid_item_object_get() in a way where it may point to
+ *              freed objects.
+ * "unrealized" - This is called when the real evas object for this item
+ *                is deleted. event_info is the Gengrid item that was created.
+ * "changed" - Called when an item is added, removed, resized or moved
+ *             and when gengrid is resized or horizontal property changes.
+ * "drag,start,up" - Called when the item in the Gengrid has been
+ *                   dragged (not scrolled) up.
+ * "drag,start,down" - Called when the item in the Gengrid has been
+ *                     dragged (not scrolled) down.
+ * "drag,start,left" - Called when the item in the Gengrid has been
+ *                     dragged (not scrolled) left.
+ * "drag,start,right" - Called when the item in the Gengrid has been
+ *                      dragged (not scrolled) right.
+ * "drag,stop" - Called when the item in the Gengrid has stopped being
+ *               dragged.
+ * "drag" - Called when the item in the Gengrid is being dragged.
+ * "scroll" - called when the content has been scrolled (moved).
+ * "scroll,drag,start" - called when dragging the content has started.
+ * "scroll,drag,stop" - called when dragging the content has stopped.
+ *
  * --
  * TODO:
- *  * Handle non-homogeneous objects too.
+ * Handle non-homogeneous objects too.
  */
 
-typedef struct _Widget_Data Widget_Data;
-typedef struct _Pan         Pan;
+ typedef struct _Widget_Data Widget_Data;
+ typedef struct _Pan         Pan;
 
 #define PRELOAD 1
+#define REORDER_EFFECT_TIME 0.5
 
-struct _Elm_Gengrid_Item
+ struct _Elm_Gengrid_Item
 {
    Elm_Widget_Item               base;
    EINA_INLIST;
    Evas_Object                  *spacer;
    const Elm_Gengrid_Item_Class *gic;
    Ecore_Timer                  *long_timer;
+   Ecore_Animator               *item_moving_effect_timer;
    Widget_Data                  *wd;
    Eina_List                    *labels, *icons, *states, *icon_objs;
    struct
-   {
-      Evas_Smart_Cb func;
-      const void   *data;
-   } func;
+     {
+        Evas_Smart_Cb func;
+        const void   *data;
+     } func;
 
-   Evas_Coord x, y, dx, dy;
-   int        relcount;
-   int        walking;
+   Evas_Coord   x, y, dx, dy, ox, oy, tx, ty, rx, ry;
+   unsigned int moving_effect_start_time;
+   int          relcount;
+   int          walking;
 
    struct
-   {
-      const void                 *data;
-      Elm_Tooltip_Item_Content_Cb content_cb;
-      Evas_Smart_Cb               del_cb;
-      const char                 *style;
-   } tooltip;
+     {
+        const void                 *data;
+        Elm_Tooltip_Item_Content_Cb content_cb;
+        Evas_Smart_Cb               del_cb;
+        const char                 *style;
+     } tooltip;
 
    const char *mouse_cursor;
 
@@ -198,6 +187,7 @@ struct _Elm_Gengrid_Item
    Eina_Bool   disabled : 1;
    Eina_Bool   selected : 1;
    Eina_Bool   hilighted : 1;
+   Eina_Bool   moving : 1;
 };
 
 struct _Widget_Data
@@ -208,12 +198,13 @@ struct _Widget_Data
    Eina_Inlist      *items;
    Ecore_Job        *calc_job;
    Eina_List        *selected;
-   Elm_Gengrid_Item *last_selected_item;
+   Elm_Gengrid_Item *last_selected_item, *reorder_item;
    double            align_x, align_y;
 
-   Evas_Coord        pan_x, pan_y;
+   Evas_Coord        pan_x, pan_y, old_pan_x, old_pan_y;
    Evas_Coord        item_width, item_height; /* Each item size */
    Evas_Coord        minw, minh; /* Total obj size */
+   Evas_Coord        reorder_item_x, reorder_item_y;
    unsigned int      nmax;
    long              count;
    int               walking;
@@ -226,10 +217,15 @@ struct _Widget_Data
    Eina_Bool         wasselected : 1;
    Eina_Bool         always_select : 1;
    Eina_Bool         clear_me : 1;
+   Eina_Bool         h_bounce : 1;
+   Eina_Bool         v_bounce : 1;
+   Eina_Bool         reorder_mode : 1;
+   Eina_Bool         reorder_item_changed : 1;
+   Eina_Bool         move_effect_enabled : 1;
 };
 
 #define ELM_GENGRID_ITEM_FROM_INLIST(item) \
-  ((item) ? EINA_INLIST_CONTAINER_GET(item, Elm_Gengrid_Item) : NULL)
+   ((item) ? EINA_INLIST_CONTAINER_GET(item, Elm_Gengrid_Item) : NULL)
 
 struct _Pan
 {
@@ -262,6 +258,46 @@ static Eina_Bool _deselect_all_items(Widget_Data *wd);
 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
 static void _mirrored_set(Evas_Object *obj, Eina_Bool rtl);
 
+static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
+static const char SIG_SELECTED[] = "selected";
+static const char SIG_UNSELECTED[] = "unselected";
+static const char SIG_REALIZED[] = "realized";
+static const char SIG_UNREALIZED[] = "unrealized";
+static const char SIG_CHANGED[] = "changed";
+static const char SIG_DRAG_START_UP[] = "drag,start,up";
+static const char SIG_DRAG_START_DOWN[] = "drag,start,down";
+static const char SIG_DRAG_START_LEFT[] = "drag,start,left";
+static const char SIG_DRAG_START_RIGHT[] = "drag,start,right";
+static const char SIG_DRAG_STOP[] = "drag,stop";
+static const char SIG_DRAG[] = "drag";
+static const char SIG_SCROLL[] = "scroll";
+static const char SIG_SCROLL_DRAG_START[] = "scroll,drag,start";
+static const char SIG_SCROLL_DRAG_STOP[] = "scroll,drag,stop";
+static const char SIG_MOVED[] = "moved";
+
+static const Evas_Smart_Cb_Description _signals[] = {
+       {SIG_CLICKED_DOUBLE, ""},
+       {SIG_SELECTED, ""},
+       {SIG_UNSELECTED, ""},
+       {SIG_REALIZED, ""},
+       {SIG_UNREALIZED, ""},
+       {SIG_CHANGED, ""},
+       {SIG_DRAG_START_UP, ""},
+       {SIG_DRAG_START_DOWN, ""},
+       {SIG_DRAG_START_LEFT, ""},
+       {SIG_DRAG_START_RIGHT, ""},
+       {SIG_DRAG_STOP, ""},
+       {SIG_DRAG, ""},
+       {SIG_SCROLL, ""},
+       {SIG_SCROLL_DRAG_START, ""},
+       {SIG_SCROLL_DRAG_STOP, ""},
+       {SIG_MOVED, ""},
+       {NULL, NULL}
+};
+
+static Eina_Compare_Cb _elm_gengrid_item_compare_cb;
+static Eina_Compare_Cb _elm_gengrid_item_compare_data_cb;
+
 static Eina_Bool
 _event_hook(Evas_Object       *obj,
             Evas_Object *src   __UNUSED__,
@@ -430,6 +466,13 @@ _event_hook(Evas_Object       *obj,
         ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
         return EINA_TRUE;
      }
+   else if ((!strcmp(ev->keyname, "Return")) ||
+            (!strcmp(ev->keyname, "KP_Enter")) ||
+            (!strcmp(ev->keyname, "space")))
+     {
+        item = elm_gengrid_selected_item_get(obj);
+        evas_object_smart_callback_call(item->wd->self, SIG_CLICKED_DOUBLE, item);
+     }
    else return EINA_FALSE;
 
    ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
@@ -715,6 +758,7 @@ _mouse_move(void        *data,
    Elm_Gengrid_Item *item = data;
    Evas_Event_Mouse_Move *ev = event_info;
    Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
+   Evas_Coord ox, oy, ow, oh, it_scrl_x, it_scrl_y;
 
    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
      {
@@ -732,7 +776,7 @@ _mouse_move(void        *data,
              ecore_timer_del(item->long_timer);
              item->long_timer = NULL;
           }
-        evas_object_smart_callback_call(item->wd->self, "drag", item);
+        evas_object_smart_callback_call(item->wd->self, SIG_DRAG, item);
         return;
      }
    if ((!item->down) || (item->wd->longpressed))
@@ -742,6 +786,26 @@ _mouse_move(void        *data,
              ecore_timer_del(item->long_timer);
              item->long_timer = NULL;
           }
+        if ((item->wd->reorder_mode) && (item->wd->reorder_item))
+          {
+             evas_object_geometry_get(item->wd->pan_smart, &ox, &oy, &ow, &oh);
+
+             it_scrl_x = ev->cur.canvas.x - item->wd->reorder_item->dx;
+             it_scrl_y = ev->cur.canvas.y - item->wd->reorder_item->dy;
+
+             if (it_scrl_x < ox) item->wd->reorder_item_x = ox;
+             else if (it_scrl_x + item->wd->item_width > ox + ow)
+               item->wd->reorder_item_x = ox + ow - item->wd->item_width;
+             else item->wd->reorder_item_x = it_scrl_x;
+
+             if (it_scrl_y < oy) item->wd->reorder_item_y = oy;
+             else if (it_scrl_y + item->wd->item_height > oy + oh)
+               item->wd->reorder_item_y = oy + oh - item->wd->item_height;
+             else item->wd->reorder_item_y = it_scrl_y;
+
+             if (item->wd->calc_job) ecore_job_del(item->wd->calc_job);
+             item->wd->calc_job = ecore_job_add(_calc_job, item->wd);
+          }
         return;
      }
    if (!item->display_only)
@@ -762,13 +826,13 @@ _mouse_move(void        *data,
         const char *left_drag, *right_drag;
         if (!elm_widget_mirrored_get(item->wd->self))
           {
-             left_drag = "drag,start,left";
-             right_drag = "drag,start,right";
+             left_drag = SIG_DRAG_START_LEFT;
+             right_drag = SIG_DRAG_START_RIGHT;
           }
         else
           {
-             left_drag = "drag,start,right";
-             right_drag = "drag,start,left";
+             left_drag = SIG_DRAG_START_RIGHT;
+             right_drag = SIG_DRAG_START_LEFT;
           }
 
         item->dragging = 1;
@@ -782,28 +846,28 @@ _mouse_move(void        *data,
         if (dy < 0)
           {
              if (ady > adx)
-               evas_object_smart_callback_call(item->wd->self, "drag,start,up",
+               evas_object_smart_callback_call(item->wd->self, SIG_DRAG_START_UP,
                                                item);
              else
                {
                   if (dx < 0)
                     evas_object_smart_callback_call(item->wd->self,
-                          left_drag, item);
+                                                    left_drag, item);
                }
           }
         else
           {
              if (ady > adx)
                evas_object_smart_callback_call(item->wd->self,
-                                               "drag,start,down", item);
+                                               SIG_DRAG_START_DOWN, item);
              else
                {
                   if (dx < 0)
                     evas_object_smart_callback_call(item->wd->self,
-                                                   left_drag, item);
+                                                    left_drag, item);
                   else
                     evas_object_smart_callback_call(item->wd->self,
-                          right_drag, item);
+                                                    right_drag, item);
                }
           }
      }
@@ -818,6 +882,14 @@ _long_press(void *data)
    if ((item->disabled) || (item->dragging)) return ECORE_CALLBACK_CANCEL;
    item->wd->longpressed = EINA_TRUE;
    evas_object_smart_callback_call(item->wd->self, "longpressed", item);
+   if (item->wd->reorder_mode)
+     {
+        item->wd->reorder_item = item;
+        evas_object_raise(item->base.view);
+        elm_smart_scroller_hold_set(item->wd->scr, EINA_TRUE);
+        elm_smart_scroller_bounce_allow_set(item->wd->scr, EINA_FALSE, EINA_FALSE);
+        edje_object_signal_emit(item->base.view, "elm,state,reorder,enabled", "elm");
+     }
    return ECORE_CALLBACK_CANCEL;
 }
 
@@ -843,7 +915,10 @@ _mouse_down(void        *data,
    item->wd->wasselected = item->selected;
    _item_hilight(item);
    if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
-     evas_object_smart_callback_call(item->wd->self, "clicked", item);
+     {
+        evas_object_smart_callback_call(item->wd->self, SIG_CLICKED_DOUBLE, item);
+        evas_object_smart_callback_call(item->wd->self, "clicked", item); // will be removed
+     }
    if (item->long_timer) ecore_timer_del(item->long_timer);
    if (item->realized)
      item->long_timer = ecore_timer_add(_elm_config->longpress_timeout,
@@ -874,7 +949,7 @@ _mouse_up(void            *data,
    if (item->dragging)
      {
         item->dragging = EINA_FALSE;
-        evas_object_smart_callback_call(item->wd->self, "drag,stop", item);
+        evas_object_smart_callback_call(item->wd->self, SIG_DRAG_STOP, item);
         dragged = EINA_TRUE;
      }
    if (item->wd->on_hold)
@@ -883,6 +958,17 @@ _mouse_up(void            *data,
         item->wd->on_hold = EINA_FALSE;
         return;
      }
+   if ((item->wd->reorder_mode) && (item->wd->reorder_item))
+     {
+        if (item->wd->calc_job) ecore_job_del(item->wd->calc_job);
+          item->wd->calc_job = ecore_job_add(_calc_job, item->wd);
+
+        evas_object_smart_callback_call(item->wd->self, SIG_MOVED, item->wd->reorder_item);
+        item->wd->reorder_item = NULL;
+        elm_smart_scroller_hold_set(item->wd->scr, EINA_FALSE);
+        elm_smart_scroller_bounce_allow_set(item->wd->scr, item->wd->h_bounce, item->wd->v_bounce);
+        edje_object_signal_emit(item->base.view, "elm,state,reorder,disabled", "elm");
+     }
    if (item->wd->longpressed)
      {
         item->wd->longpressed = EINA_FALSE;
@@ -917,7 +1003,7 @@ _mouse_up(void            *data,
              Elm_Gengrid_Item *item2;
 
              EINA_LIST_FOREACH_SAFE(item->wd->selected, l, l_next, item2)
-               if (item2 != item) _item_unselect(item2);
+                if (item2 != item) _item_unselect(item2);
           }
         _item_hilight(item);
         _item_select(item);
@@ -950,7 +1036,7 @@ _item_realize(Elm_Gengrid_Item *item)
    _elm_theme_object_set(item->wd->self, item->base.view, "gengrid", style,
                          elm_widget_style_get(item->wd->self));
    item->spacer =
-       evas_object_rectangle_add(evas_object_evas_get(item->wd->self));
+      evas_object_rectangle_add(evas_object_evas_get(item->wd->self));
    evas_object_color_set(item->spacer, 0, 0, 0, 0);
    elm_widget_sub_object_add(item->wd->self, item->spacer);
    evas_object_size_hint_min_set(item->spacer, 2 * _elm_config->scale, 1);
@@ -962,12 +1048,12 @@ _item_realize(Elm_Gengrid_Item *item)
         const char *key;
 
         item->labels =
-            elm_widget_stringlist_get(edje_object_data_get(item->base.view,
-                                                           "labels"));
+           elm_widget_stringlist_get(edje_object_data_get(item->base.view,
+                                                          "labels"));
         EINA_LIST_FOREACH(item->labels, l, key)
           {
              char *s = item->gic->func.label_get
-                 ((void *)item->base.data, item->wd->self, l->data);
+                ((void *)item->base.data, item->wd->self, l->data);
              if (s)
                {
                   edje_object_part_text_set(item->base.view, l->data, s);
@@ -982,12 +1068,12 @@ _item_realize(Elm_Gengrid_Item *item)
         const char *key;
 
         item->icons =
-            elm_widget_stringlist_get(edje_object_data_get(item->base.view,
-                                                           "icons"));
+           elm_widget_stringlist_get(edje_object_data_get(item->base.view,
+                                                          "icons"));
         EINA_LIST_FOREACH(item->icons, l, key)
           {
              Evas_Object *ic = item->gic->func.icon_get
-                 ((void *)item->base.data, item->wd->self, l->data);
+                ((void *)item->base.data, item->wd->self, l->data);
              if (ic)
                {
                   item->icon_objs = eina_list_append(item->icon_objs, ic);
@@ -1004,12 +1090,12 @@ _item_realize(Elm_Gengrid_Item *item)
         const char *key;
 
         item->states =
-            elm_widget_stringlist_get(edje_object_data_get(item->base.view,
-                                                           "states"));
+           elm_widget_stringlist_get(edje_object_data_get(item->base.view,
+                                                          "states"));
         EINA_LIST_FOREACH(item->states, l, key)
           {
              Eina_Bool on = item->gic->func.state_get
-                 ((void *)item->base.data, item->wd->self, l->data);
+                ((void *)item->base.data, item->wd->self, l->data);
              if (on)
                {
                   snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
@@ -1081,12 +1167,51 @@ _item_unrealize(Elm_Gengrid_Item *item)
    item->states = NULL;
 
    EINA_LIST_FREE(item->icon_objs, icon)
-     evas_object_del(icon);
+      evas_object_del(icon);
 
    item->realized = EINA_FALSE;
    item->want_unrealize = EINA_FALSE;
 }
 
+static Eina_Bool
+_reorder_item_moving_effect_timer_cb(void *data)
+{
+   Elm_Gengrid_Item *item = data;
+   double time, t;
+   Evas_Coord dx, dy;
+
+   time = REORDER_EFFECT_TIME;
+   t = ((0.0 > (t = ecore_loop_time_get()-item->moving_effect_start_time)) ? 0.0 : t);
+   dx = ((item->tx - item->ox) / 10) * _elm_config->scale;
+   dy = ((item->ty - item->oy) / 10) * _elm_config->scale;
+
+   if (t <= time)
+     {
+        item->rx += (1 * sin((t / time) * (M_PI / 2)) * dx);
+        item->ry += (1 * sin((t / time) * (M_PI / 2)) * dy);
+     }
+   else
+     {
+        item->rx += dx;
+        item->ry += dy;
+     }
+
+   if ((((dx > 0) && (item->rx >= item->tx)) || ((dx <= 0) && (item->rx <= item->tx))) &&
+       (((dy > 0) && (item->ry >= item->ty)) || ((dy <= 0) && (item->ry <= item->ty))))
+     {
+        evas_object_move(item->base.view, item->tx, item->ty);
+        evas_object_resize(item->base.view, item->wd->item_width, item->wd->item_height);
+        item->moving = EINA_FALSE;
+        item->item_moving_effect_timer = NULL;
+        return ECORE_CALLBACK_CANCEL;
+     }
+
+   evas_object_move(item->base.view, item->rx, item->ry);
+   evas_object_resize(item->base.view, item->wd->item_width, item->wd->item_height);
+
+   return ECORE_CALLBACK_RENEW;
+}
+
 static void
 _item_place(Elm_Gengrid_Item *item,
             Evas_Coord        cx,
@@ -1094,6 +1219,7 @@ _item_place(Elm_Gengrid_Item *item,
 {
    Evas_Coord x, y, ox, oy, cvx, cvy, cvw, cvh;
    Evas_Coord tch, tcw, alignw = 0, alignh = 0, vw, vh;
+   Eina_Bool reorder_item_move_forward = EINA_FALSE;
    item->x = cx;
    item->y = cy;
    evas_object_geometry_get(item->wd->pan_smart, &ox, &oy, &vw, &vh);
@@ -1168,7 +1294,84 @@ _item_place(Elm_Gengrid_Item *item,
      {
         _item_realize(item);
         if (!was_realized)
-          evas_object_smart_callback_call(item->wd->self, "realized", item);
+          evas_object_smart_callback_call(item->wd->self, SIG_REALIZED, item);
+        if ((item->wd->reorder_mode) && (item->wd->reorder_item))
+          {
+             if (item->moving) return;
+
+             if (!item->wd->move_effect_enabled)
+               {
+                  item->ox = x;
+                  item->oy = y;
+               }
+             if (item->wd->reorder_item == item)
+               {
+                  evas_object_move(item->base.view,
+                                   item->wd->reorder_item_x, item->wd->reorder_item_y);
+                  evas_object_resize(item->base.view,
+                                     item->wd->item_width, item->wd->item_height);
+                  return;
+               }
+             else
+               {
+                  if (item->wd->move_effect_enabled)
+                    {
+                       if ((item->ox != x) || (item->oy != y))
+                         {
+                            if (((item->wd->old_pan_x == item->wd->pan_x) && (item->wd->old_pan_y == item->wd->pan_y)) ||
+                                ((item->wd->old_pan_x != item->wd->pan_x) && !(item->ox - item->wd->pan_x + item->wd->old_pan_x == x)) ||
+                                ((item->wd->old_pan_y != item->wd->pan_y) && !(item->oy - item->wd->pan_y + item->wd->old_pan_y == y)))
+                              {
+                                 item->tx = x;
+                                 item->ty = y;
+                                 item->rx = item->ox;
+                                 item->ry = item->oy;
+                                 item->moving = EINA_TRUE;
+                                 item->moving_effect_start_time = ecore_loop_time_get();
+                                 item->item_moving_effect_timer = ecore_animator_add(_reorder_item_moving_effect_timer_cb, item);
+                                 return;
+                              }
+                         }
+                    }
+
+                  if (ELM_RECTS_INTERSECT(item->wd->reorder_item_x, item->wd->reorder_item_y,
+                                          item->wd->item_width, item->wd->item_height,
+                                          x+(item->wd->item_width/2), y+(item->wd->item_height/2),
+                                          1, 1))
+                    {
+                       if (item->wd->horizontal)
+                         {
+                            if ((item->wd->nmax * item->wd->reorder_item->x + item->wd->reorder_item->y) >
+                                (item->wd->nmax * item->x + item->y))
+                              reorder_item_move_forward = EINA_TRUE;
+                         }
+                       else
+                         {
+                            if ((item->wd->nmax * item->wd->reorder_item->y + item->wd->reorder_item->x) >
+                                (item->wd->nmax * item->y + item->x))
+                              reorder_item_move_forward = EINA_TRUE;
+                         }
+
+                       item->wd->items = eina_inlist_remove(item->wd->items,
+                                                            EINA_INLIST_GET(item->wd->reorder_item));
+                       if (reorder_item_move_forward)
+                         item->wd->items = eina_inlist_prepend_relative(item->wd->items,
+                                                                        EINA_INLIST_GET(item->wd->reorder_item),
+                                                                        EINA_INLIST_GET(item));
+                       else
+                         item->wd->items = eina_inlist_append_relative(item->wd->items,
+                                                                       EINA_INLIST_GET(item->wd->reorder_item),
+                                                                       EINA_INLIST_GET(item));
+
+                       item->wd->reorder_item_changed = EINA_TRUE;
+                       item->wd->move_effect_enabled = EINA_TRUE;
+                       if (item->wd->calc_job) ecore_job_del(item->wd->calc_job);
+                         item->wd->calc_job = ecore_job_add(_calc_job, item->wd);
+
+                       return;
+                    }
+               }
+          }
         evas_object_move(item->base.view, x, y);
         evas_object_resize(item->base.view, item->wd->item_width,
                            item->wd->item_height);
@@ -1177,7 +1380,7 @@ _item_place(Elm_Gengrid_Item *item,
      {
         _item_unrealize(item);
         if (was_realized)
-          evas_object_smart_callback_call(item->wd->self, "unrealized", item);
+          evas_object_smart_callback_call(item->wd->self, SIG_UNREALIZED, item);
      }
 }
 
@@ -1240,9 +1443,10 @@ call:
    if (item->func.func)
      item->func.func((void *)item->func.data, item->wd->self, item);
    if (!item->delete_me)
-     evas_object_smart_callback_call(item->wd->self, "selected", item);
+     evas_object_smart_callback_call(item->wd->self, SIG_SELECTED, item);
    item->walking--;
    item->wd->walking--;
+   item->wd->last_selected_item = item;
    if ((item->wd->clear_me) && (!item->wd->walking))
      elm_gengrid_clear(item->base.widget);
    else
@@ -1250,7 +1454,6 @@ call:
         if ((!item->walking) && (item->delete_me))
           if (!item->relcount) _item_del(item);
      }
-   item->wd->last_selected_item = item;
 }
 
 static void
@@ -1263,7 +1466,7 @@ _item_unselect(Elm_Gengrid_Item *item)
      {
         item->selected = EINA_FALSE;
         item->wd->selected = eina_list_remove(item->wd->selected, item);
-        evas_object_smart_callback_call(item->wd->self, "unselected", item);
+        evas_object_smart_callback_call(item->wd->self, SIG_UNSELECTED, item);
      }
 }
 
@@ -1275,36 +1478,39 @@ _calc_job(void *data)
    int count;
 
    evas_object_geometry_get(wd->pan_smart, NULL, NULL, &cvw, &cvh);
-   if ((wd->horizontal) && (wd->item_height > 0))
-     nmax = cvh / wd->item_height;
-   else if (wd->item_width > 0)
-     nmax = cvw / wd->item_width;
+   if ((cvw != 0) || (cvh != 0))
+     {
+        if ((wd->horizontal) && (wd->item_height > 0))
+          nmax = cvh / wd->item_height;
+        else if (wd->item_width > 0)
+          nmax = cvw / wd->item_width;
 
-   if (nmax < 1)
-     nmax = 1;
+        if (nmax < 1)
+          nmax = 1;
 
-   count = wd->count;
-   if (wd->horizontal)
-     {
-        minw = ceil(count / (float)nmax) * wd->item_width;
-        minh = nmax * wd->item_height;
-     }
-   else
-     {
-        minw = nmax * wd->item_width;
-        minh = ceil(count / (float)nmax) * wd->item_height;
-     }
+        count = wd->count;
+        if (wd->horizontal)
+          {
+             minw = ceil(count / (float)nmax) * wd->item_width;
+             minh = nmax * wd->item_height;
+          }
+        else
+          {
+             minw = nmax * wd->item_width;
+             minh = ceil(count / (float)nmax) * wd->item_height;
+          }
 
-   if ((minw != wd->minw) || (minh != wd->minh))
-     {
-        wd->minh = minh;
-        wd->minw = minw;
-        evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
-     }
+        if ((minw != wd->minw) || (minh != wd->minh))
+          {
+             wd->minh = minh;
+             wd->minw = minw;
+             evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
+          }
 
-   wd->nmax = nmax;
+        wd->nmax = nmax;
+        evas_object_smart_changed(wd->pan_smart);
+     }
    wd->calc_job = NULL;
-   evas_object_smart_changed(wd->pan_smart);
 }
 
 static void
@@ -1419,21 +1625,34 @@ _pan_calculate(Evas_Object *obj)
    if (!sd) return;
    if (!sd->wd->nmax) return;
 
+   sd->wd->reorder_item_changed = EINA_FALSE;
+
    EINA_INLIST_FOREACH(sd->wd->items, item)
-   {
-      _item_place(item, cx, cy);
-      if (sd->wd->horizontal)
-        {
-           cy = (cy + 1) % sd->wd->nmax;
-           if (!cy) cx++;
-        }
-      else
-        {
-           cx = (cx + 1) % sd->wd->nmax;
-           if (!cx) cy++;
-        }
-   }
-   evas_object_smart_callback_call(sd->wd->self, "changed", NULL);
+     {
+        _item_place(item, cx, cy);
+        if (sd->wd->reorder_item_changed) return;
+        if (sd->wd->horizontal)
+          {
+             cy = (cy + 1) % sd->wd->nmax;
+             if (!cy) cx++;
+          }
+        else
+          {
+             cx = (cx + 1) % sd->wd->nmax;
+             if (!cx) cy++;
+          }
+     }
+
+   if ((sd->wd->reorder_mode) && (sd->wd->reorder_item))
+     {
+        if (!sd->wd->reorder_item_changed)
+          {
+             sd->wd->old_pan_x = sd->wd->pan_x;
+             sd->wd->old_pan_y = sd->wd->pan_y;
+          }
+        sd->wd->move_effect_enabled = EINA_FALSE;
+     }
+   evas_object_smart_callback_call(sd->wd->self, SIG_CHANGED, NULL);
 }
 
 static void
@@ -1492,7 +1711,7 @@ _scr_drag_start(void            *data,
                 Evas_Object *obj __UNUSED__,
                 void *event_info __UNUSED__)
 {
-   evas_object_smart_callback_call(data, "scroll,drag,start", NULL);
+   evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_START, NULL);
 }
 
 static void
@@ -1500,7 +1719,7 @@ _scr_drag_stop(void            *data,
                Evas_Object *obj __UNUSED__,
                void *event_info __UNUSED__)
 {
-   evas_object_smart_callback_call(data, "scroll,drag,stop", NULL);
+   evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_STOP, NULL);
 }
 
 static void
@@ -1508,7 +1727,25 @@ _scr_scroll(void            *data,
             Evas_Object *obj __UNUSED__,
             void *event_info __UNUSED__)
 {
-   evas_object_smart_callback_call(data, "scroll", NULL);
+   evas_object_smart_callback_call(data, SIG_SCROLL, NULL);
+}
+
+static int
+_elm_gengrid_item_compare_data(const void *data, const void *data1)
+{
+   const Elm_Gengrid_Item *item = data;
+   const Elm_Gengrid_Item *item1 = data1;
+
+   return _elm_gengrid_item_compare_data_cb(item->base.data, item1->base.data);
+}
+
+static int
+_elm_gengrid_item_compare(const void *data, const void *data1)
+{
+   Elm_Gengrid_Item *item, *item1;
+   item = ELM_GENGRID_ITEM_FROM_INLIST(data);
+   item1 = ELM_GENGRID_ITEM_FROM_INLIST(data1);
+   return _elm_gengrid_item_compare_cb(item, item1);
 }
 
 /**
@@ -1534,12 +1771,8 @@ elm_gengrid_add(Evas_Object *parent)
    static Evas_Smart *smart = NULL;
    Eina_Bool bounce = _elm_config->thumbscroll_bounce_enable;
 
-   EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
+   ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
 
-   wd = ELM_NEW(Widget_Data);
-   e = evas_object_evas_get(parent);
-   if (!e) return NULL;
-   obj = elm_widget_add(e);
    ELM_SET_WIDTYPE(widtype, "gengrid");
    elm_widget_type_set(obj, "gengrid");
    elm_widget_sub_object_add(parent, obj);
@@ -1567,6 +1800,8 @@ elm_gengrid_add(Evas_Object *parent)
    wd->self = obj;
    wd->align_x = 0.5;
    wd->align_y = 0.5;
+   wd->h_bounce = bounce;
+   wd->v_bounce = bounce;
    wd->no_select = EINA_FALSE;
 
    evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
@@ -1574,6 +1809,8 @@ elm_gengrid_add(Evas_Object *parent)
    evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
    evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
 
+   evas_object_smart_callbacks_descriptions_set(obj, _signals);
+
    if (!smart)
      {
         static Evas_Smart_Class sc;
@@ -1824,7 +2061,7 @@ elm_gengrid_item_insert_before(Evas_Object                  *obj,
    item = _item_create(wd, gic, data, func, func_data);
    if (!item) return NULL;
    wd->items = eina_inlist_prepend_relative
-       (wd->items, EINA_INLIST_GET(item), EINA_INLIST_GET(relative));
+      (wd->items, EINA_INLIST_GET(item), EINA_INLIST_GET(relative));
 
    if (wd->calc_job) ecore_job_del(wd->calc_job);
    wd->calc_job = ecore_job_add(_calc_job, wd);
@@ -1869,7 +2106,7 @@ elm_gengrid_item_insert_after(Evas_Object                  *obj,
    item = _item_create(wd, gic, data, func, func_data);
    if (!item) return NULL;
    wd->items = eina_inlist_append_relative
-       (wd->items, EINA_INLIST_GET(item), EINA_INLIST_GET(relative));
+      (wd->items, EINA_INLIST_GET(item), EINA_INLIST_GET(relative));
 
    if (wd->calc_job) ecore_job_del(wd->calc_job);
    wd->calc_job = ecore_job_add(_calc_job, wd);
@@ -1877,8 +2114,46 @@ elm_gengrid_item_insert_after(Evas_Object                  *obj,
    return item;
 }
 
+EAPI Elm_Gengrid_Item *
+elm_gengrid_item_direct_sorted_insert(Evas_Object                  *obj,
+                                     const Elm_Gengrid_Item_Class *gic,
+                                     const void                   *data,
+                                     Eina_Compare_Cb               comp,
+                                     Evas_Smart_Cb                 func,
+                                     const void                   *func_data)
+{
+   Elm_Gengrid_Item *item;
+   ELM_CHECK_WIDTYPE(obj, widtype) NULL;
+   Widget_Data *wd = elm_widget_data_get(obj);
+   if (!wd) return NULL;
+
+   item = _item_create(wd, gic, data, func, func_data);
+   if (!item) return NULL;
+
+   _elm_gengrid_item_compare_cb = comp;
+   wd->items = eina_inlist_sorted_insert(wd->items, EINA_INLIST_GET(item),
+                                         _elm_gengrid_item_compare);
+   if (wd->calc_job) ecore_job_del(wd->calc_job);
+   wd->calc_job = ecore_job_add(_calc_job, wd);
+
+   return item;
+}
+
+EAPI Elm_Gengrid_Item *
+elm_gengrid_item_sorted_insert(Evas_Object                  *obj,
+                               const Elm_Gengrid_Item_Class *gic,
+                               const void                   *data,
+                               Eina_Compare_Cb               comp,
+                               Evas_Smart_Cb                 func,
+                               const void                   *func_data)
+{
+   _elm_gengrid_item_compare_data_cb = comp;
+
+   return elm_gengrid_item_direct_sorted_insert(obj, gic, data, _elm_gengrid_item_compare_data, func, func_data);
+}
+
 /**
- * Remove a item from the Gengrid.
+ * Remove an item from the Gengrid.
  *
  * @param item The item to be removed.
  * @return @c EINA_TRUE on success or @c EINA_FALSE otherwise.
@@ -1930,6 +2205,24 @@ elm_gengrid_horizontal_set(Evas_Object *obj,
 }
 
 /**
+ * Get for what direction the Gengrid is expanded.
+ *
+ * @param obj The Gengrid object.
+ * @return If the Gengrid is expanded horizontally return @c EINA_TRUE
+ * else @c EINA_FALSE.
+ *
+ * @ingroup Gengrid
+ */
+EAPI Eina_Bool
+elm_gengrid_horizontal_get(const Evas_Object *obj)
+{
+   ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
+   Widget_Data *wd = elm_widget_data_get(obj);
+   if (!wd) return EINA_FALSE;
+   return wd->horizontal;
+}
+
+/**
  * Clear the Gengrid
  *
  * This clears all items in the Gengrid, leaving it empty.
@@ -1958,7 +2251,7 @@ elm_gengrid_clear(Evas_Object *obj)
         Elm_Gengrid_Item *item;
         wd->clear_me = 1;
         EINA_INLIST_FOREACH(wd->items, item)
-        item->delete_me = 1;
+           item->delete_me = 1;
         return;
      }
    wd->clear_me = 0;
@@ -2038,7 +2331,7 @@ elm_gengrid_item_update(Elm_Gengrid_Item *item)
 }
 
 /**
- * Returns the data associated to a item
+ * Returns the data associated to an item
  *
  * This returns the data value passed on the elm_gengrid_item_append()
  * and related item addition calls.
@@ -2059,7 +2352,7 @@ elm_gengrid_item_data_get(const Elm_Gengrid_Item *item)
 }
 
 /**
- * Set the data item from the gengrid item
+ * Set the datan item from the gengrid item
  *
  * This set the data value passed on the elm_gengrid_item_append() and
  * related item addition calls. This function will also call
@@ -2080,6 +2373,25 @@ elm_gengrid_item_data_set(Elm_Gengrid_Item *item,
    elm_gengrid_item_update(item);
 }
 
+EAPI const Elm_Gengrid_Item_Class *
+elm_gengrid_item_item_class_get(const Elm_Gengrid_Item *item)
+{
+   ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
+   if (item->delete_me) return NULL;
+   return item->gic;
+}
+
+EAPI void
+elm_gengrid_item_item_class_set(Elm_Gengrid_Item *item,
+                                const Elm_Gengrid_Item_Class *gic)
+{
+   ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
+   EINA_SAFETY_ON_NULL_RETURN(gic);
+   if (item->delete_me) return;
+   item->gic = gic;
+   elm_gengrid_item_update(item);
+}
+
 /**
  * Get the item's coordinates.
  *
@@ -2188,9 +2500,9 @@ elm_gengrid_selected_items_get(const Evas_Object *obj)
 }
 
 /**
- * Set the selected state of a item.
+ * Set the selected state of an item.
  *
- * This sets the selected state of a item. If multi-select is not
+ * This sets the selected state of an item. If multi-select is not
  * enabled and selected is EINA_TRUE, previously selected items are
  * unselected.
  *
@@ -2206,7 +2518,7 @@ elm_gengrid_item_selected_set(Elm_Gengrid_Item *item,
    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
    Widget_Data *wd = item->wd;
    if (!wd) return;
-   if ((!item) || (item->delete_me)) return;
+   if (item->delete_me) return;
    selected = !!selected;
    if (item->selected == selected) return;
 
@@ -2225,9 +2537,9 @@ elm_gengrid_item_selected_set(Elm_Gengrid_Item *item,
 }
 
 /**
- * Get the selected state of a item.
+ * Get the selected state of an item.
  *
- * This gets the selected state of a item (1 selected, 0 not selected).
+ * This gets the selected state of an item (1 selected, 0 not selected).
  *
  * @param item The item
  * @return The selected state
@@ -2242,7 +2554,7 @@ elm_gengrid_item_selected_get(const Elm_Gengrid_Item *item)
 }
 
 /**
- * Sets the disabled state of a item.
+ * Sets the disabled state of an item.
  *
  * A disabled item cannot be selected or unselected. It will also
  * change appearance to disabled. This sets the disabled state (1
@@ -2260,7 +2572,7 @@ elm_gengrid_item_disabled_set(Elm_Gengrid_Item *item,
    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
    if (item->disabled == disabled) return;
    if (item->delete_me) return;
-   item->disabled = disabled;
+   item->disabled = !!disabled;
    if (item->realized)
      {
         if (item->disabled)
@@ -2271,7 +2583,7 @@ elm_gengrid_item_disabled_set(Elm_Gengrid_Item *item,
 }
 
 /**
- * Get the disabled state of a item.
+ * Get the disabled state of an item.
  *
  * This gets the disabled state of the given item.
  *
@@ -2297,7 +2609,7 @@ _elm_gengrid_item_label_create(void        *data,
    if (!label)
      return NULL;
    elm_object_style_set(label, "tooltip");
-   elm_label_label_set(label, data);
+   elm_object_text_set(label, data);
    return label;
 }
 
@@ -2345,7 +2657,7 @@ elm_gengrid_item_tooltip_text_set(Elm_Gengrid_Item *item,
  * @param data what to provide to @a func as callback data/context.
  * @param del_cb called when data is not needed anymore, either when
  *        another callback replaces @func, the tooltip is unset with
- *        elm_gengrid_item_tooltip_unset() or the owner @a item
+ *        elm_gengrid_item_tooltip_unset() or the owner @an item
  *        dies. This callback receives as the first parameter the
  *        given @a data, and @c event_info is the item.
  *
@@ -2580,6 +2892,43 @@ elm_gengrid_item_cursor_engine_only_get(const Elm_Gengrid_Item *item)
 }
 
 /**
+ * Set the reorder mode
+ *
+ * @param obj The Gengrid object
+ * @param reorder_mode The reorder mode
+ * (EINA_TRUE = on, EINA_FALSE = off)
+ *
+ * @ingroup Gengrid
+ */
+EAPI void
+elm_gengrid_reorder_mode_set(Evas_Object *obj,
+                             Eina_Bool    reorder_mode)
+{
+   ELM_CHECK_WIDTYPE(obj, widtype);
+   Widget_Data *wd = elm_widget_data_get(obj);
+   if (!wd) return;
+   wd->reorder_mode = reorder_mode;
+}
+
+/**
+ * Get the reorder mode
+ *
+ * @param obj The Gengrid object
+ * @return The reorder mode
+ * (EINA_TRUE = on, EINA_FALSE = off)
+ *
+ * @ingroup Gengrid
+ */
+EAPI Eina_Bool
+elm_gengrid_reorder_mode_get(const Evas_Object *obj)
+{
+   ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
+   Widget_Data *wd = elm_widget_data_get(obj);
+   if (!wd) return EINA_FALSE;
+   return wd->reorder_mode;
+}
+
+/**
  * Set the always select mode.
  *
  * Cells will only call their selection func and callback when first
@@ -2680,6 +3029,8 @@ elm_gengrid_bounce_set(Evas_Object *obj,
    Widget_Data *wd = elm_widget_data_get(obj);
    if (!wd) return;
    elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
+   wd->h_bounce = h_bounce;
+   wd->v_bounce = v_bounce;
 }
 
 /**
@@ -2699,7 +3050,8 @@ elm_gengrid_bounce_get(const Evas_Object *obj,
    ELM_CHECK_WIDTYPE(obj, widtype);
    Widget_Data *wd = elm_widget_data_get(obj);
    if (!wd) return;
-   elm_smart_scroller_bounce_allow_get(wd->scr, h_bounce, v_bounce);
+   *h_bounce = wd->h_bounce;
+   *v_bounce = wd->v_bounce;
 }
 
 /**
@@ -2752,6 +3104,37 @@ elm_gengrid_page_relative_set(Evas_Object *obj,
                                  pagesize_v);
 }
 
+/*
+ * Get gengrid scroll page size relative to viewport size.
+ *
+ * The gengrid scroller is capable of limiting scrolling by the user
+ * to "pages" That is to jump by and only show a "whole page" at a
+ * time as if the continuous area of the scroller content is split
+ * into page sized pieces.  This sets the size of a page relative to
+ * the viewport of the scroller. 1.0 is "1 viewport" is size
+ * (horizontally or vertically). 0.0 turns it off in that axis. This
+ * is mutually exclusive with page size (see
+ * elm_gengrid_page_size_set() for more information). Likewise 0.5 is
+ * "half a viewport". Sane usable valus are normally between 0.0 and
+ * 1.0 including 1.0. If you only want 1 axis to be page "limited",
+ * use 0.0 for the other axis.
+ *
+ * @param obj The gengrid object
+ * @param h_pagerel The horizontal page relative size
+ * @param v_pagerel The vertical page relative size
+ *
+ @ingroup Gengrid
+ */
+EAPI void
+elm_gengrid_page_relative_get(const Evas_Object *obj, double *h_pagerel, double *v_pagerel)
+{
+   ELM_CHECK_WIDTYPE(obj, widtype);
+   Widget_Data *wd = elm_widget_data_get(obj);
+   if (!wd) return;
+
+   elm_smart_scroller_paging_get(wd->scr, h_pagerel, v_pagerel, NULL, NULL);
+}
+
 /**
  * Set gengrid scroll page size.
  *
@@ -2818,9 +3201,9 @@ elm_gengrid_last_item_get(const Evas_Object *obj)
 {
    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
    Widget_Data *wd = elm_widget_data_get(obj);
+   if (!wd) return NULL;
    if (!wd->items) return NULL;
    Elm_Gengrid_Item *item = ELM_GENGRID_ITEM_FROM_INLIST(wd->items->last);
-   if (!wd) return NULL;
    while ((item) && (item->delete_me))
      item = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->prev);
    return item;