[Slideshow] Applying Open source patch r72492 to fix Switching in slideshow with...
[framework/uifw/elementary.git] / src / lib / elm_slideshow.c
index f9914de..68549a4 100644 (file)
@@ -2,10 +2,6 @@
 #include "elm_priv.h"
 
 typedef struct _Widget_Data Widget_Data;
-<<<<<<< HEAD
-
-=======
->>>>>>> remotes/origin/upstream
 typedef struct _Elm_Slideshow_Item Elm_Slideshow_Item;
 
 struct _Elm_Slideshow_Item
@@ -37,10 +33,11 @@ struct _Widget_Data
    double timeout;
    Eina_Bool loop:1;
 
-   struct {
+   struct
+     {
         const char *current;
         Eina_List *list; //list of const char *
-   } layout;
+     } layout;
 };
 
 static const char *widtype = NULL;
@@ -73,13 +70,15 @@ _event_hook(Evas_Object *obj, Evas_Object *src __UNUSED__, Evas_Callback_Type ty
    if (!wd) return EINA_FALSE;
    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
    if (elm_widget_disabled_get(obj)) return EINA_FALSE;
-   if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
+   if ((!strcmp(ev->keyname, "Left")) ||
+       ((!strcmp(ev->keyname, "KP_Left")) && (!ev->string)))
      {
         elm_slideshow_previous(obj);
         ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
         return EINA_TRUE;
      }
-   if ((!strcmp(ev->keyname, "Right")) || (!strcmp(ev->keyname, "KP_Right")))
+   if ((!strcmp(ev->keyname, "Right")) ||
+       ((!strcmp(ev->keyname, "KP_Right")) && (!ev->string)))
      {
         elm_slideshow_next(obj);
         ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
@@ -224,6 +223,7 @@ _item_realize(Elm_Slideshow_Item *item)
         evas_object_smart_member_add(VIEW(item), obj);
         item->l_built = eina_list_append(NULL, item);
         wd->items_built = eina_list_merge(wd->items_built, item->l_built);
+        //FIXME: item could be showed by obj
         evas_object_hide(VIEW(item));
      }
    else if (item->l_built)
@@ -256,6 +256,7 @@ _item_realize(Elm_Slideshow_Item *item)
                        _item_next->l_built = eina_list_append(NULL, _item_next);
                        wd->items_built = eina_list_merge(wd->items_built,
                                                          _item_next->l_built);
+                       //FIXME: _item_next could be showed by obj later
                        evas_object_hide(VIEW(_item_next));
                     }
                   else if (_item_next && _item_next->l_built)
@@ -287,6 +288,7 @@ _item_realize(Elm_Slideshow_Item *item)
                        _item_prev->l_built = eina_list_append(NULL, _item_prev);
                        wd->items_built = eina_list_merge(wd->items_built,
                                                          _item_prev->l_built);
+                       //FIXME: _item_prev could be showed by obj later
                        evas_object_hide(VIEW(_item_prev));
                     }
                   else if (_item_prev && _item_prev->l_built)
@@ -355,13 +357,7 @@ _timer_cb(void *data)
 static Eina_Bool
 _item_del_pre_hook(Elm_Object_Item *it)
 {
-<<<<<<< HEAD
-   ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
-
-   Elm_Slideshow_Item *item = (Elm_Slideshow_Item *) it;
-=======
    Elm_Slideshow_Item *item = (Elm_Slideshow_Item *)it;
->>>>>>> remotes/origin/upstream
    Widget_Data *wd = elm_widget_data_get(WIDGET(item));
    if (!wd) return EINA_FALSE;
 
@@ -375,19 +371,11 @@ _item_del_pre_hook(Elm_Object_Item *it)
           {
              l2 = eina_list_prev(l);
              if (l2)
-<<<<<<< HEAD
-               elm_slideshow_show(eina_list_data_get(l2));
-
-          }
-        else
-          elm_slideshow_show(eina_list_data_get(l2));
-=======
                elm_slideshow_item_show(eina_list_data_get(l2));
 
           }
         else
           elm_slideshow_item_show(eina_list_data_get(l2));
->>>>>>> remotes/origin/upstream
      }
 
    wd->items = eina_list_remove_list(wd->items, item->l);
@@ -424,11 +412,9 @@ elm_slideshow_add(Evas_Object *parent)
 
    wd->slideshow = edje_object_add(e);
    _elm_theme_object_set(obj, wd->slideshow, "slideshow", "base", "default");
-   evas_object_smart_member_add(wd->slideshow, obj);
    wd->count_item_pre_before = 2;
    wd->count_item_pre_after = 2;
    elm_widget_resize_object_set(obj, wd->slideshow);
-   evas_object_show(wd->slideshow);
 
    wd->transitions = elm_widget_stringlist_get(edje_object_data_get(wd->slideshow, "transitions"));
    if (eina_list_count(wd->transitions) > 0)
@@ -467,15 +453,9 @@ elm_slideshow_item_add(Evas_Object *obj, const Elm_Slideshow_Item_Class *itc, co
 
    wd->items = eina_list_merge(wd->items, item->l);
 
-<<<<<<< HEAD
-   if (!wd->current) elm_slideshow_show((Elm_Object_Item *) item);
-
-   return (Elm_Object_Item *) item;
-=======
    if (!wd->current) elm_slideshow_item_show((Elm_Object_Item *)item);
 
    return (Elm_Object_Item *)item;
->>>>>>> remotes/origin/upstream
 }
 
 EAPI Elm_Object_Item*
@@ -495,15 +475,6 @@ elm_slideshow_item_sorted_insert(Evas_Object *obj, const Elm_Slideshow_Item_Clas
 
    wd->items = eina_list_sorted_merge(wd->items, item->l, func);
 
-<<<<<<< HEAD
-   if (!wd->current) elm_slideshow_show((Elm_Object_Item *) item);
-
-   return (Elm_Object_Item *) item;
-}
-
-EAPI void
-elm_slideshow_show(Elm_Object_Item *it)
-=======
    if (!wd->current) elm_slideshow_item_show((Elm_Object_Item *)item);
 
    return (Elm_Object_Item *)item;
@@ -511,18 +482,13 @@ elm_slideshow_show(Elm_Object_Item *it)
 
 EAPI void
 elm_slideshow_item_show(Elm_Object_Item *it)
->>>>>>> remotes/origin/upstream
 {
    ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
 
    char buf[1024];
    Elm_Slideshow_Item *item, *next = NULL;
    Widget_Data *wd;
-<<<<<<< HEAD
-   item = (Elm_Slideshow_Item *) it;
-=======
    item = (Elm_Slideshow_Item *)it;
->>>>>>> remotes/origin/upstream
    wd = elm_widget_data_get(WIDGET(item));
    if (!wd)  return;
    if (item == wd->current) return;
@@ -531,26 +497,22 @@ elm_slideshow_item_show(Elm_Object_Item *it)
    _end(WIDGET(item), WIDGET(item), NULL, NULL);
 
    if (wd->timer) ecore_timer_del(wd->timer);
+   wd->timer = NULL;
    if (wd->timeout > 0.0)
      wd->timer = ecore_timer_add(wd->timeout, _timer_cb, WIDGET(item));
    _item_realize(next);
    edje_object_part_swallow(wd->slideshow, "elm.swallow.2", VIEW(next));
-   snprintf(buf, sizeof(buf), "%s,next", wd->transition);
+
+   if (!wd->transition)
+     sprintf(buf, "none,next");
+   else
+     snprintf(buf, sizeof(buf), "%s,next", wd->transition);
    edje_object_signal_emit(wd->slideshow, buf, "slideshow");
    wd->previous = wd->current;
    wd->current = next;
    evas_object_smart_callback_call(WIDGET(item), SIG_CHANGED, wd->current);
 }
 
-<<<<<<< HEAD
-=======
-EINA_DEPRECATED EAPI void
-elm_slideshow_show(Elm_Object_Item *it)
-{
-   elm_slideshow_item_show(it);
-}
-
->>>>>>> remotes/origin/upstream
 EAPI void
 elm_slideshow_next(Evas_Object *obj)
 {
@@ -569,6 +531,7 @@ elm_slideshow_next(Evas_Object *obj)
    _end(obj, obj, NULL, NULL);
 
    if (wd->timer) ecore_timer_del(wd->timer);
+   wd->timer = NULL;
    if (wd->timeout > 0.0)
      wd->timer = ecore_timer_add(wd->timeout, _timer_cb, obj);
 
@@ -576,7 +539,10 @@ elm_slideshow_next(Evas_Object *obj)
 
    edje_object_part_swallow(wd->slideshow, "elm.swallow.2", VIEW(next));
 
-   snprintf(buf, sizeof(buf), "%s,next", wd->transition);
+   if (!wd->transition)
+     sprintf(buf, "none,next");
+   else
+     snprintf(buf, sizeof(buf), "%s,next", wd->transition);
    edje_object_signal_emit(wd->slideshow, buf, "slideshow");
 
    wd->previous = wd->current;
@@ -602,6 +568,7 @@ elm_slideshow_previous(Evas_Object *obj)
    _end(obj, obj, NULL, NULL);
 
    if (wd->timer) ecore_timer_del(wd->timer);
+   wd->timer = NULL;
    if (wd->timeout > 0.0)
      wd->timer = ecore_timer_add(wd->timeout, _timer_cb, obj);
 
@@ -609,7 +576,10 @@ elm_slideshow_previous(Evas_Object *obj)
 
    edje_object_part_swallow(wd->slideshow, "elm.swallow.2", VIEW(prev));
 
-   snprintf(buf, 1024, "%s,previous", wd->transition);
+   if (!wd->transition)
+     sprintf(buf, "none,previous");
+   else
+     snprintf(buf, sizeof(buf), "%s,previous", wd->transition);
    edje_object_signal_emit(wd->slideshow, buf, "slideshow");
 
    wd->previous = wd->current;
@@ -734,12 +704,6 @@ elm_slideshow_clear(Evas_Object *obj)
      elm_widget_item_free(item);
 }
 
-EAPI void
-elm_slideshow_item_del(Elm_Object_Item *it)
-{
-   elm_object_item_del(it);
-}
-
 EAPI const Eina_List *
 elm_slideshow_items_get(const Evas_Object *obj)
 {
@@ -765,12 +729,6 @@ elm_slideshow_item_object_get(const Elm_Object_Item * it)
    return VIEW(it);
 }
 
-EAPI void *
-elm_slideshow_item_data_get(const Elm_Object_Item * it)
-{
-   return elm_object_item_data_get(it);
-}
-
 EAPI int
 elm_slideshow_cache_before_get(const Evas_Object *obj)
 {