elm genlist/list/gengrid: Removed deprecated signal "clicked". Use
[framework/uifw/elementary.git] / src / lib / elm_gengrid.c
index 817d824..8589638 100644 (file)
@@ -24,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:
@@ -61,7 +61,7 @@
  * 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.
  * Signals that you can add callbacks for are:
  *
  * "clicked,double" - The user has double-clicked or pressed enter on
- *                    a item. The event_infoparameter is the Gengrid item
+ *                    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.
  typedef struct _Pan         Pan;
 
 #define PRELOAD 1
+#define REORDER_EFFECT_TIME 0.5
 
  struct _Elm_Gengrid_Item
 {
    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
         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
      {
    Eina_Bool   disabled : 1;
    Eina_Bool   selected : 1;
    Eina_Bool   hilighted : 1;
+   Eina_Bool   moving : 1;
 };
 
 struct _Widget_Data
@@ -194,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;
@@ -212,6 +217,11 @@ 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) \
@@ -248,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__,
@@ -421,8 +471,7 @@ _event_hook(Evas_Object       *obj,
             (!strcmp(ev->keyname, "space")))
      {
         item = elm_gengrid_selected_item_get(obj);
-        evas_object_smart_callback_call(item->wd->self, "clicked,double", item);
-        evas_object_smart_callback_call(item->wd->self, "clicked", item); // will be removed
+        evas_object_smart_callback_call(item->wd->self, SIG_CLICKED_DOUBLE, item);
      }
    else return EINA_FALSE;
 
@@ -709,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)
      {
@@ -726,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))
@@ -736,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)
@@ -756,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;
@@ -776,7 +846,7 @@ _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
                {
@@ -789,7 +859,7 @@ _mouse_move(void        *data,
           {
              if (ady > adx)
                evas_object_smart_callback_call(item->wd->self,
-                                               "drag,start,down", item);
+                                               SIG_DRAG_START_DOWN, item);
              else
                {
                   if (dx < 0)
@@ -812,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;
 }
 
@@ -838,7 +916,7 @@ _mouse_down(void        *data,
    _item_hilight(item);
    if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
      {
-        evas_object_smart_callback_call(item->wd->self, "clicked,double", 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);
@@ -871,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)
@@ -880,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;
@@ -1084,6 +1173,45 @@ _item_unrealize(Elm_Gengrid_Item *item)
    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,
@@ -1091,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);
@@ -1165,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);
@@ -1174,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);
      }
 }
 
@@ -1237,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
@@ -1247,7 +1454,6 @@ call:
         if ((!item->walking) && (item->delete_me))
           if (!item->relcount) _item_del(item);
      }
-   item->wd->last_selected_item = item;
 }
 
 static void
@@ -1260,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);
      }
 }
 
@@ -1302,9 +1508,9 @@ _calc_job(void *data)
           }
 
         wd->nmax = nmax;
-        wd->calc_job = NULL;
         evas_object_smart_changed(wd->pan_smart);
      }
+   wd->calc_job = NULL;
 }
 
 static void
@@ -1419,9 +1625,12 @@ _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->reorder_item_changed) return;
         if (sd->wd->horizontal)
           {
              cy = (cy + 1) % sd->wd->nmax;
@@ -1433,7 +1642,17 @@ _pan_calculate(Evas_Object *obj)
              if (!cx) cy++;
           }
      }
-   evas_object_smart_callback_call(sd->wd->self, "changed", NULL);
+
+   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);
 }
 
 /**
@@ -1563,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);
@@ -1570,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;
@@ -1873,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.
@@ -1926,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.
@@ -2034,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.
@@ -2055,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
@@ -2076,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.
  *
@@ -2184,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.
  *
@@ -2221,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
@@ -2238,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
@@ -2256,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)
@@ -2267,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.
  *
@@ -2293,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;
 }
 
@@ -2341,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.
  *
@@ -2576,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
@@ -2676,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;
 }
 
 /**
@@ -2695,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;
 }
 
 /**
@@ -2748,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.
  *