elementary, new widget: slideshow. See elementary_test
authorJonathan Atton <jonathan.atton@gmail.com>
Wed, 23 Sep 2009 22:56:47 +0000 (22:56 +0000)
committerJonathan Atton <jonathan.atton@gmail.com>
Wed, 23 Sep 2009 22:56:47 +0000 (22:56 +0000)
SVN revision: 42660

data/themes/default.edc
src/bin/Makefile.am
src/bin/test.c
src/lib/Elementary.h.in
src/lib/Makefile.am
src/lib/elm_genlist.c
src/lib/elm_priv.h
src/lib/elm_slideshow.c [new file with mode: 0644]
src/lib/elm_widget.c

index e3ac157..dc5f3d6 100644 (file)
@@ -6402,6 +6402,323 @@ collections {
            }
        }
    }
+
+///////////////////////////////////////////////////////////////////////////////
+    group { name: "elm/slideshow/base/default";
+        data {
+            item: transitions "fade black_fade horizontal vertical square";
+        }
+        parts {
+            part { name: "elm.image.1";
+                type: IMAGE;
+                description {
+                    state: "default" 0.0;
+                    color: 255 255 255 255;
+                }
+                description {
+                    state: "fade_prev_next" 0.0;
+                    inherit: "default" 0.0;
+                    color: 255 255 255 0;
+                }
+                description {
+                    state: "black_fade_prev_next_init" 0.0;
+                    inherit: "default" 0.0;
+                    color: 255 255 255 255;
+                }
+                description {
+                    state: "black_fade_prev_next" 0.0;
+                    inherit: "default" 0.0;
+                    color: 0 0 0 255;
+                }
+                description {
+                    state: "horizontal_next_init" 0.0;
+                    inherit: "default" 0.0;
+                }
+                description {
+                    state: "horizontal_next" 0.0;
+                    inherit: "default" 0.0;
+                    rel1.relative: -1.0 0.0;
+                    rel2.relative: 0.0 1.0;
+                }
+                description {
+                    state: "horizontal_prev_init" 0.0;
+                    inherit: "default" 0.0;
+                }
+                description {
+                    state: "horizontal_prev" 0.0;
+                    inherit: "default" 0.0;
+                    rel1.relative: 1.0 0.0;
+                    rel2.relative: 2.0 1.0;
+                }
+                description {
+                    state: "vertical_next_init" 0.0;
+                    inherit: "default" 0.0;
+                }
+                description {
+                    state: "vertical_next" 0.0;
+                    inherit: "default" 0.0;
+                    rel1.relative: 0.0 -1.0;
+                    rel2.relative: 1.0 0.0;
+                }
+                description {
+                    state: "vertical_prev_init" 0.0;
+                    inherit: "default" 0.0;
+                }
+                description {
+                    state: "vertical_prev" 0.0;
+                    inherit: "default" 0.0;
+                    rel1.relative: 0.0 1.0;
+                    rel2.relative: 1.0 2.0;
+                }
+            }
+            part { name: "elm.image.2";
+                type: IMAGE;
+                description {
+                    state: "default" 0.0;
+                    color: 255 255 255 0;
+                }
+                description {
+                    state: "fade_prev_next" 0.0;
+                    inherit: "default" 0.0;
+                    color: 255 255 255 255;
+                }
+                description {
+                    state: "black_fade_prev_next_init" 0.0;
+                    inherit: "default" 0.0;
+                    color: 0 0 0 0;
+                }
+                description {
+                    state: "black_fade_prev_next" 0.0;
+                    inherit: "default" 0.0;
+                    color: 255 255 255 255;
+                }
+                description {
+                    state: "horizontal_next_init" 0.0;
+                    inherit: "default" 0.0;
+                    rel1.relative: 1.0 0.0;
+                    rel2.relative: 2.0 1.0;
+                    color: 255 255 255 255;
+                }
+                description {
+                    state: "horizontal_next" 0.0;
+                    inherit: "default" 0.0;
+                    color: 255 255 255 255;
+                }
+                description {
+                    state: "horizontal_prev_init" 0.0;
+                    inherit: "default" 0.0;
+                    rel1.relative: -1.0 0.0;
+                    rel2.relative: 0.0 1.0;
+                    color: 255 255 255 255;
+                }
+                description {
+                    state: "horizontal_prev" 0.0;
+                    inherit: "default" 0.0;
+                    color: 255 255 255 255;
+                }
+                description {
+                    state: "vertical_next_init" 0.0;
+                    inherit: "default" 0.0;
+                    rel1.relative: 0.0 1.0;
+                    rel2.relative: 1.0 2.0;
+                    color: 255 255 255 255;
+                }
+                description {
+                    state: "vertical_next" 0.0;
+                    inherit: "default" 0.0;
+                    color: 255 255 255 255;
+                }
+                description {
+                    state: "vertical_prev_init" 0.0;
+                    inherit: "default" 0.0;
+                    rel1.relative: 0.0 -1.0;
+                    rel2.relative: 1.0 0.0;
+                    color: 255 255 255 255;
+                }
+                description {
+                    state: "vertical_prev" 0.0;
+                    inherit: "default" 0.0;
+                    color: 255 255 255 255;
+                }
+                description {
+                    state: "square_prev_next_init" 0.0;
+                    inherit: "default" 0.0;
+                    rel1.relative: 0.5 0.5;
+                    rel2.relative: 0.5 0.5;
+                    color: 255 255 255 255;
+                }
+                description {
+                    state: "square_prev_next" 0.0;
+                    inherit: "default" 0.0;
+                    rel1.relative: 0.0 0.0;
+                    rel2.relative: 1.0 1.0;
+                    color: 255 255 255 255;
+                }
+            }
+        }
+        programs {
+            program { name: "fade_next";
+                signal: "fade,next";
+                source: "slideshow";
+                action: STATE_SET "default" 0.0;
+                target: "elm.image.1";
+                target: "elm.image.2";
+                after: "fade_next_2";
+            }
+            program { name: "fade_next_2";
+                action: STATE_SET "fade_prev_next" 0.0;
+                target: "elm.image.1";
+                target: "elm.image.2";
+                transition: SINUSOIDAL 1.5;
+                after: "end";
+            }
+            program { name: "fade_previous";
+                signal: "fade,previous";
+                source: "slideshow";
+                action: STATE_SET "default" 0.0;
+                target: "elm.image.1";
+                target: "elm.image.2";
+                after: "fade_previous_2";
+            }
+            program { name: "fade_previous_2";
+                action: STATE_SET "fade_prev_next" 0.0;
+                target: "elm.image.1";
+                target: "elm.image.2";
+                transition: SINUSOIDAL 1.5;
+                after: "end";
+            }
+            program { name: "black_fade_next";
+                signal: "black_fade,next";
+                source: "slideshow";
+                action: STATE_SET "black_fade_prev_next_init" 0.0;
+                target: "elm.image.1";
+                target: "elm.image.2";
+                after: "black_fade_next_2";
+            }
+            program { name: "black_fade_next_2";
+                action: STATE_SET "black_fade_prev_next" 0.0;
+                target: "elm.image.1";
+                transition: SINUSOIDAL 0.75;
+                after: "black_fade_next_3";
+            }
+            program { name: "black_fade_next_3";
+                action: STATE_SET "black_fade_prev_next" 0.0;
+                target: "elm.image.2";
+                transition: SINUSOIDAL 0.75;
+                after: "end";
+            }
+            program { name: "black_fade_previous";
+                signal: "black_fade,previous";
+                source: "slideshow";
+                action: STATE_SET "black_fade_prev_next_init" 0.0;
+                target: "elm.image.1";
+                target: "elm.image.2";
+                after: "black_fade_previous_2";
+            }
+            program { name: "black_fade_previous_2";
+                action: STATE_SET "black_fade_prev_next" 0.0;
+                target: "elm.image.1";
+                transition: SINUSOIDAL 0.75;
+                after: "black_fade_previous_3";
+            }
+            program { name: "black_fade_previous_3";
+                action: STATE_SET "black_fade_prev_next" 0.0;
+                target: "elm.image.2";
+                transition: SINUSOIDAL 0.75;
+                after: "end";
+            }
+            program { name: "horizontal_next";
+                signal: "horizontal,next";
+                source: "slideshow";
+                action: STATE_SET "horizontal_next_init" 0.0;
+                target: "elm.image.1";
+                target: "elm.image.2";
+                after: "horizontal_next_2";
+            }
+            program { name: "horizontal_next_2";
+                action: STATE_SET "horizontal_next" 0.0;
+                target: "elm.image.1";
+                target: "elm.image.2";
+                transition: SINUSOIDAL 1.5;
+                after: "end";
+            }
+            program { name: "horizontal_previous";
+                signal: "horizontal,previous";
+                source: "slideshow";
+                action: STATE_SET "horizontal_prev_init" 0.0;
+                target: "elm.image.1";
+                target: "elm.image.2";
+                after: "horizontal_previous_2";
+            }
+            program { name: "horizontal_previous_2";
+                action: STATE_SET "horizontal_prev" 0.0;
+                target: "elm.image.1";
+                target: "elm.image.2";
+                transition: SINUSOIDAL 1.5;
+                after: "end";
+            }
+            program { name: "vertical_next";
+                signal: "vertical,next";
+                source: "slideshow";
+                action: STATE_SET "vertical_next_init" 0.0;
+                target: "elm.image.1";
+                target: "elm.image.2";
+                after: "vertical_next_2";
+            }
+            program { name: "vertical_next_2";
+                action: STATE_SET "vertical_next" 0.0;
+                target: "elm.image.1";
+                target: "elm.image.2";
+                transition: SINUSOIDAL 1.5;
+                after: "end";
+            }
+            program { name: "vertical_previous";
+                signal: "vertical,previous";
+                source: "slideshow";
+                action: STATE_SET "vertical_prev_init" 0.0;
+                target: "elm.image.1";
+                target: "elm.image.2";
+                after: "vertical_previous_2";
+            }
+            program { name: "vertical_previous_2";
+                action: STATE_SET "vertical_prev" 0.0;
+                target: "elm.image.1";
+                target: "elm.image.2";
+                transition: SINUSOIDAL 1.5;
+                after: "end";
+            }
+            program { name: "square_next";
+                signal: "square,next";
+                source: "slideshow";
+                action: STATE_SET "square_prev_next_init" 0.0;
+                target: "elm.image.2";
+                after: "square_next_2";
+            }
+            program { name: "square_next_2";
+                action: STATE_SET "square_prev_next" 0.0;
+                target: "elm.image.2";
+                transition: SINUSOIDAL 1.5;
+                after: "end";
+            }
+            program { name: "square_previous";
+                signal: "square,previous";
+                source: "slideshow";
+                action: STATE_SET "square_prev_next_init" 0.0;
+                target: "elm.image.2";
+                after: "square_next_2";
+            }
+            program { name: "end";
+                action: STATE_SET "default" 0.0;
+                target: "elm.image.1";
+                target: "elm.image.2";
+                after: "end_signal";
+            }
+            program { name: "end_signal";
+                action: SIGNAL_EMIT "end" "slideshow";
+            }
+        }
+    }
+
 ///////////////////////////////////////////////////////////////////////////////
    group { name: "elm/win/inwin/default";
       images {
index 8980cab..3cc41cc 100644 (file)
@@ -61,7 +61,8 @@ test_index.c \
 test_photocam.c \
 test_photo.c \
 test_icon_desktops.c \
-test_notify.c
+test_notify.c \
+test_slideshow.c
 
 elementary_test_LDADD = $(top_builddir)/src/lib/libelementary.la
 elementary_test_LDFLAGS =
index 355b467..1ef1e4d 100644 (file)
@@ -50,6 +50,7 @@ void test_photocam(void *data, Evas_Object *obj, void *event_info);
 void test_photo(void *data, Evas_Object *obj, void *event_info);
 void test_icon_desktops(void *data, Evas_Object *obj, void *event_info);
 void test_notify(void *data, Evas_Object *obj, void *event_info);
+void test_slideshow(void *data, Evas_Object *obj, void *event_info);
 
 static void
 my_win_del(void *data, Evas_Object *obj, void *event_info)
@@ -182,6 +183,8 @@ my_win_main(void)
    elm_list_item_append(li, "Photo", NULL, NULL, test_photo, NULL);
    elm_list_item_append(li, "Icon Desktops", NULL, NULL, test_icon_desktops, NULL);
    elm_list_item_append(li, "Notify", NULL, NULL, test_notify, NULL);
+   elm_list_item_append(li, "Slideshow", NULL, NULL, test_slideshow, NULL);
+
 
    elm_list_go(li);
 
index 122b3ba..4a37b98 100644 (file)
@@ -791,6 +791,17 @@ extern "C" {
    /* smart callbacks called:
     */
 
+   EAPI Evas_Object *elm_slideshow_add(Evas_Object *parent);
+   EAPI void         elm_slideshow_image_add(Evas_Object *obj, const char *file, const char *group);
+   EAPI void        elm_slideshow_goto(Evas_Object *obj, int pos);
+   EAPI void        elm_slideshow_next(Evas_Object *obj);
+   EAPI void        elm_slideshow_previous(Evas_Object *obj);
+   EAPI const Eina_List *elm_slideshow_transitions_get(Evas_Object *obj);
+   EAPI void        elm_slideshow_transition_set(Evas_Object *obj, const char *);
+   /* smart callbacks called:
+    */
+
+
    EAPI Evas_Object *elm_fileselector_add(Evas_Object *parent);
    EAPI void         elm_fileselector_is_save_set(Evas_Object *obj, Eina_Bool is_save);
    EAPI Eina_Bool    elm_fileselector_is_save_get(Evas_Object *obj);
index 986fb1c..40ade6b 100644 (file)
@@ -61,6 +61,7 @@ elm_spinner.c \
 elm_index.c \
 elm_photocam.c \
 elm_notify.c \
+elm_slideshow.c \
 \
 elc_notepad.c \
 elc_anchorview.c \
index 3c584b6..f686b5e 100644 (file)
@@ -300,7 +300,7 @@ struct _Elm_Genlist_Item
    Eina_List *icon_objs;
    Ecore_Timer *long_timer;
    Evas_Coord dx, dy;
-   
+
    Elm_Genlist_Item *rel;
    int relcount;
    Eina_Bool before : 1;
@@ -397,39 +397,6 @@ _sizing_eval(Evas_Object *obj)
    evas_object_size_hint_max_set(obj, maxw, maxh);
 }
 
-static Eina_List *
-_stringlist_get(const char *str)
-{
-   Eina_List *list = NULL;
-   const char *s, *b;
-   if (!str) return NULL;
-   for (b = s = str; 1; s++)
-     {
-       if ((*s == ' ') || (*s == 0))
-         {
-            char *t = malloc(s - b + 1);
-            if (t)
-              {
-                 strncpy(t, b, s - b);
-                 t[s - b] = 0;
-                 list = eina_list_append(list, eina_stringshare_add(t));
-                 free(t);
-              }
-            b = s + 1;
-         }
-       if (*s == 0) break;
-     }
-   return list;
-}
-
-static void
-_stringlist_free(Eina_List *list)
-{
-   const char *s;
-   EINA_LIST_FREE(list, s)
-     eina_stringshare_del(s);
-}
-
 static void
 _item_hilight(Elm_Genlist_Item *it)
 {
@@ -567,7 +534,7 @@ _long_press(void *data)
    it->wd->longpressed = EINA_TRUE;
    evas_object_smart_callback_call(it->wd->obj, "longpressed", it);
    return 0;
-}            
+}
 
 static void
 _mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event_info)
@@ -722,16 +689,16 @@ _item_realize(Elm_Genlist_Item *it, int in, int calc)
    for (it2 = it, depth = 0; it2->parent; it2 = it2->parent) depth += 1;
    treesize = edje_object_data_get(it->base, "treesize");
    if (treesize) tsize = atoi(treesize);
-   evas_object_size_hint_min_set(it->spacer, 
+   evas_object_size_hint_min_set(it->spacer,
                                  (depth * tsize) * _elm_config->scale, 1);
    edje_object_part_swallow(it->base, "elm.swallow.pad", it->spacer);
    if (!calc)
      {
-       edje_object_signal_callback_add(it->base, "elm,action,expand,toggle", 
+       edje_object_signal_callback_add(it->base, "elm,action,expand,toggle",
                                         "elm", _signal_expand_toggle, it);
-       edje_object_signal_callback_add(it->base, "elm,action,expand", "elm", 
+       edje_object_signal_callback_add(it->base, "elm,action,expand", "elm",
                                         _signal_expand, it);
-       edje_object_signal_callback_add(it->base, "elm,action,contract", 
+       edje_object_signal_callback_add(it->base, "elm,action,contract",
                                         "elm", _signal_contract, it);
        stacking = edje_object_data_get(it->base, "stacking");
        if (stacking)
@@ -1059,7 +1026,7 @@ _update_job(void *data)
         Evas_Coord pw;
         Evas_Coord itminw, itminh;
         Elm_Genlist_Item *it;
-        
+
         if (!itb->updateme)
           {
              num += itb->count;
@@ -1075,7 +1042,7 @@ _update_job(void *data)
                {
                   itminw = it->w;
                   itminh = it->h;
-                  
+
                   it->updateme = 0;
                   if (it->realized)
                     {
@@ -1293,7 +1260,7 @@ elm_genlist_add(Evas_Object *parent)
    evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
    evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
    evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
-   
+
    if (!smart)
      {
        static Evas_Smart_Class sc;
@@ -1319,7 +1286,7 @@ elm_genlist_add(Evas_Object *parent)
                                     _pan_set, _pan_get,
                                     _pan_max_get, _pan_child_size_get);
 
-   edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr), 
+   edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
                              &minw, &minh);
    evas_object_size_hint_min_set(obj, minw, minh);
 
@@ -1331,7 +1298,7 @@ static Elm_Genlist_Item *
 _item_new(Widget_Data *wd, const Elm_Genlist_Item_Class *itc,
          const void *data, Elm_Genlist_Item *parent,
          Elm_Genlist_Item_Flags flags,
-         void (*func) (void *data, Evas_Object *obj, void *event_info), 
+         void (*func) (void *data, Evas_Object *obj, void *event_info),
           const void *func_data)
 {
    Elm_Genlist_Item *it;
@@ -1534,7 +1501,7 @@ _item_block_add(Widget_Data *wd, Elm_Genlist_Item *it)
         int newc;
         Item_Block *itb2;
         Elm_Genlist_Item *it2;
-        
+
         newc = itb->count / 2;
         itb2 = calloc(1, sizeof(Item_Block));
         if (!itb2) return;
@@ -1544,12 +1511,12 @@ _item_block_add(Widget_Data *wd, Elm_Genlist_Item *it)
         while ((itb->count > newc) && (itb->items))
           {
              Eina_List *l;
-             
+
              l = eina_list_last(itb->items);
              it2 = l->data;
              itb->items = eina_list_remove_list(itb->items, l);
              itb->count--;
-             
+
              itb2->items = eina_list_prepend(itb2->items, it2);
              it2->block = itb2;
              itb2->count++;
@@ -1902,7 +1869,7 @@ elm_genlist_at_xy_item_get(const Evas_Object *obj, Evas_Coord x, Evas_Coord y, i
    Evas_Coord ox, oy, ow, oh;
    Item_Block *itb;
    Evas_Coord lasty;
-   
+
    evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
    lasty = oy;
    EINA_INLIST_FOREACH(wd->blocks, itb)
@@ -1910,14 +1877,14 @@ elm_genlist_at_xy_item_get(const Evas_Object *obj, Evas_Coord x, Evas_Coord y, i
        Eina_List *l;
        Elm_Genlist_Item *it;
 
-        if (!ELM_RECTS_INTERSECT(ox + itb->x - itb->wd->pan_x, 
+        if (!ELM_RECTS_INTERSECT(ox + itb->x - itb->wd->pan_x,
                                  oy + itb->y - itb->wd->pan_y,
                                  itb->w, itb->h, x, y, 1, 1))
           continue;
        EINA_LIST_FOREACH(itb->items, l, it)
          {
              Evas_Coord itx, ity;
-             
+
              itx = ox + itb->x + it->x - itb->wd->pan_x;
              ity = oy + itb->y + it->y - itb->wd->pan_y;
              if (ELM_RECTS_INTERSECT(itx, ity, it->w, it->h, x, y, 1, 1))
@@ -2369,7 +2336,7 @@ elm_genlist_item_top_bring_in(Elm_Genlist_Item *it)
  *
  * This deletes the item from genlist and calls the genlist item del class
  * callback defined in the item class, if it is set.
- * 
+ *
  * @param it The item
  *
  * @ingroup Genlist
index 5b6f08b..3631103 100644 (file)
@@ -20,6 +20,7 @@
 #include "els_icon.h"
 
 // FIXME: totally disorganised. clean this up!
+// Why EAPI in a private header ?
 
 typedef enum _Elm_Engine
 {
@@ -110,6 +111,10 @@ EAPI const char  *elm_widget_style_get(const Evas_Object *obj);
 EAPI void         elm_widget_type_set(Evas_Object *obj, const char *type);
 EAPI const char  *elm_widget_type_get(const Evas_Object *obj);
 
+EAPI Eina_List   *_stringlist_get(const char *str);
+EAPI void         _stringlist_free(Eina_List *list);
+
+
 extern char *_elm_appname;
 extern Elm_Config *_elm_config;
 extern const char *_elm_data_dir;
diff --git a/src/lib/elm_slideshow.c b/src/lib/elm_slideshow.c
new file mode 100644 (file)
index 0000000..f29cae8
--- /dev/null
@@ -0,0 +1,314 @@
+/*
+ * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
+ */
+#include <Elementary.h>
+#include "elm_priv.h"
+
+/**
+ * @defgroup Slideshow slideshow
+ *
+ * This object display a list of images and some actions like
+ * next/previous are used to naviguate. The animations are defined in the theme,
+ * consequently new animations can be added without having to update the
+ * applications.
+ *
+ */
+
+typedef struct _Widget_Data Widget_Data;
+typedef struct _Subinfo     Subinfo;
+typedef struct _Node Node;
+
+struct _Node
+{
+   const char *file;
+   const char *group;
+};
+
+struct _Widget_Data
+{
+   Evas_Object *slideshow;
+   Evas_Object *img1, *img2;
+
+   // list of char*
+   Eina_List *images;
+   int current;
+
+   Eina_List *transitions;
+   const char *transition;
+};
+
+static void _del_hook(Evas_Object *obj);
+static void _theme_hook(Evas_Object *obj);
+static void _sizing_eval(Evas_Object *obj);
+static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
+static void _signal_clicked(void *data, Evas *e, Evas_Object *obj, void *event_info);
+static void _signal_move(void *data, Evas *e, Evas_Object *obj, void *event_info);
+
+
+   static void
+_del_hook(Evas_Object *obj)
+{
+   Widget_Data *wd = elm_widget_data_get(obj);
+   free(wd);
+}
+
+   static void
+_theme_hook(Evas_Object *obj)
+{
+   Widget_Data *wd = elm_widget_data_get(obj);
+   if(!wd) return;
+   _elm_theme_set(wd->slideshow, "slideshow", "base", "default");
+   edje_object_scale_set(wd->slideshow, elm_widget_scale_get(obj) * _elm_config->scale);
+   _sizing_eval(obj);
+}
+
+   static void
+_sizing_eval(Evas_Object *obj)
+{
+   Widget_Data *wd = elm_widget_data_get(obj);
+   Evas_Coord minw = -1, minh = -1;
+
+   edje_object_size_min_calc(wd->slideshow, &minw, &minh);
+   evas_object_size_hint_min_set(obj, minw, minh);
+   evas_object_size_hint_max_set(obj, minw, minh);
+}
+
+   static void
+_changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+   Widget_Data *wd = elm_widget_data_get(data);
+   _sizing_eval(data);
+}
+
+   static void
+_sub_del(void *data, Evas_Object *obj, void *event_info)
+{
+   Widget_Data *wd = elm_widget_data_get(obj);
+   Evas_Object *sub = event_info;
+   evas_object_event_callback_del
+      (wd->img1, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints);
+   evas_object_del(wd->img1);
+
+   evas_object_event_callback_del
+      (wd->img2, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints);
+   evas_object_del(wd->img2);
+}
+
+static void
+_signal_clicked(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+   Widget_Data *wd = elm_widget_data_get(data);
+   if (!wd) return;
+   evas_object_smart_callback_call(data, "clicked", NULL);
+}
+
+static void
+_signal_move(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+   Widget_Data *wd = elm_widget_data_get(data);
+   if (!wd) return;
+   evas_object_smart_callback_call(data, "move", NULL);
+}
+
+static void
+_end(void *data, Evas_Object *obj, const char *emission, const char *source)
+{
+   Node *node;
+   const Evas_Object *o;
+
+   Widget_Data *wd = elm_widget_data_get(data);
+
+   node = eina_list_nth(wd->images, wd->current);
+   if(!node) return;
+
+   o = edje_object_part_object_get(wd->slideshow, "elm.image.1");
+   evas_object_image_file_set((Evas_Object *)o, node->file, node->group);
+}
+
+/**
+ * Add a new slideshow to the parent
+ *
+ * @param parent The parent object
+ * @return The new object or NULL if it cannot be created
+ *
+ * @ingroup Slideshow
+ */
+   EAPI Evas_Object *
+elm_slideshow_add(Evas_Object *parent)
+{
+   Evas_Object *obj;
+   Evas *e;
+   Widget_Data *wd;
+
+   wd = ELM_NEW(Widget_Data);
+   e = evas_object_evas_get(parent);
+   obj = elm_widget_add(e);
+   elm_widget_type_set(obj, "slideshow");
+   elm_widget_sub_object_add(parent, obj);
+   elm_widget_data_set(obj, wd);
+   elm_widget_del_hook_set(obj, _del_hook);
+   elm_widget_theme_hook_set(obj, _theme_hook);
+
+   wd->slideshow = edje_object_add(e);
+   _elm_theme_set(wd->slideshow, "slideshow", "base", "default");
+   elm_widget_resize_object_set(obj, wd->slideshow);
+   evas_object_show(wd->slideshow);
+
+   wd->transitions = _stringlist_get(edje_object_data_get(wd->slideshow, "transitions"));
+   if(eina_list_count(wd->transitions) > 0)
+     wd->transition = eina_stringshare_add(eina_list_data_get(wd->transitions));
+
+   edje_object_signal_callback_add(wd->slideshow, "end", "slideshow", _end, obj);
+
+   evas_object_event_callback_add(wd->slideshow, EVAS_CALLBACK_MOUSE_DOWN, _signal_clicked, obj);
+   evas_object_event_callback_add(wd->slideshow, EVAS_CALLBACK_MOUSE_MOVE, _signal_move, obj);
+
+   evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
+
+   _sizing_eval(obj);
+   return obj;
+}
+
+/**
+ * Add an image in the list
+ *
+ * @param obj The slideshow object
+ * @param file The image file
+ * @param group The edje group if the image is in an eet file
+ */
+   EAPI void
+elm_slideshow_image_add(Evas_Object *obj, const char *file, const char *group)
+{
+   Widget_Data *wd = elm_widget_data_get(obj);
+   if(!wd) return;
+
+   Node *node = ELM_NEW(Node);
+
+   node->file = eina_stringshare_add(file);
+   if(group)
+     node->group = eina_stringshare_add(group);
+
+   wd->images = eina_list_append(wd->images, node);
+
+   if(eina_list_count(wd->images) == 1)
+     elm_slideshow_goto(obj, 0);
+}
+
+/**
+ * Go to the image number @pos
+ *
+ * @param obj The slideshow object
+ * @param pos The position of the image
+ */
+   EAPI void
+elm_slideshow_goto(Evas_Object *obj, int pos)
+{
+   Node *node;
+   const Evas_Object *o;
+   Widget_Data *wd = elm_widget_data_get(obj);
+   if(!wd) return;
+
+   if(pos<0 || pos>=eina_list_count(wd->images))
+     return ;
+
+   if(wd->img1)
+     evas_object_del(wd->img1);
+
+   wd->current = pos;
+   node = eina_list_nth(wd->images, wd->current);
+
+   o = edje_object_part_object_get(wd->slideshow, "elm.image.1");
+   evas_object_image_file_set((Evas_Object *)o, node->file, node->group);
+}
+
+/**
+ * Go to the next image
+ *
+ * @param obj The slideshow object
+ */
+   EAPI void
+elm_slideshow_next(Evas_Object *obj)
+{
+   char buf[1024];
+   const Evas_Object *o;
+   Node *node;
+   Widget_Data *wd = elm_widget_data_get(obj);
+   if(!wd) return;
+
+   if(wd->current >= eina_list_count(wd->images) - 1)
+     return ;
+
+   node = eina_list_nth(wd->images, wd->current + 1);
+
+   _end(obj, obj, NULL, NULL);
+
+   o = edje_object_part_object_get(wd->slideshow, "elm.image.2");
+   evas_object_image_file_set((Evas_Object *)o, node->file, node->group);
+
+   snprintf(buf, 1024, "%s,next", wd->transition);
+   edje_object_signal_emit(wd->slideshow, buf, "slideshow");
+
+   wd->current++;
+}
+
+/**
+ * Go to the previous image
+ *
+ * @param obj The slideshow object
+ */
+   EAPI void
+elm_slideshow_previous(Evas_Object *obj)
+{
+   char buf[1024];
+   const Evas_Object *o;
+   Node *node;
+   Widget_Data *wd = elm_widget_data_get(obj);
+   if(!wd) return;
+
+   if(wd->current <= 0)
+     return ;
+
+   node = eina_list_nth(wd->images, wd->current - 1);
+
+   _end(obj, obj, NULL, NULL);
+
+   o = edje_object_part_object_get(wd->slideshow, "elm.image.2");
+   evas_object_image_file_set((Evas_Object *)o, node->file, node->group);
+
+   snprintf(buf, 1024, "%s,previous", wd->transition);
+   edje_object_signal_emit(wd->slideshow, buf, "slideshow");
+
+   wd->current--;
+}
+
+/**
+ * Returns the list of transitions available.
+ *
+ * @param obj The slideshow object
+ * @return Returns the list of transitions (list of char*)
+ */
+   const Eina_List *
+elm_slideshow_transitions_get(Evas_Object *obj)
+{
+   Widget_Data *wd = elm_widget_data_get(obj);
+   if(!wd) return;
+
+   return wd->transitions;
+}
+
+/**
+ * Set the transition to use
+ *
+ * @param obj The slideshow object
+ * @param transition the new transition
+ */
+   EAPI void
+elm_slideshow_transition_set(Evas_Object *obj, const char *transition)
+{
+   Widget_Data *wd = elm_widget_data_get(obj);
+   if(!wd) return;
+
+   eina_stringshare_del(wd->transition);
+   wd->transition = eina_stringshare_add(transition);
+}
+
index 64419de..2711e7a 100644 (file)
@@ -961,3 +961,39 @@ _smart_init(void)
        _e_smart = evas_smart_class_new(&sc);
      }
 }
+
+
+Eina_List *
+_stringlist_get(const char *str)
+{
+   Eina_List *list = NULL;
+   const char *s, *b;
+   if (!str) return NULL;
+   for (b = s = str; 1; s++)
+     {
+       if ((*s == ' ') || (*s == 0))
+         {
+            char *t = malloc(s - b + 1);
+            if (t)
+              {
+                 strncpy(t, b, s - b);
+                 t[s - b] = 0;
+                 list = eina_list_append(list, eina_stringshare_add(t));
+                 free(t);
+              }
+            b = s + 1;
+         }
+       if (*s == 0) break;
+     }
+   return list;
+}
+
+void
+_stringlist_free(Eina_List *list)
+{
+   const char *s;
+   EINA_LIST_FREE(list, s)
+     eina_stringshare_del(s);
+}
+
+