From 6541ee34b2c22954dcca210269f0130f971f1b95 Mon Sep 17 00:00:00 2001 From: Carsten Haitzler Date: Tue, 6 Dec 2011 09:03:01 +0000 Subject: [PATCH] From: Rajeev Ranjan (Rajeev) Subject: Re: [E-devel] [Patch] elm_slideshow patch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: PRINCE KUMAR DUBEY On behalf of Rajeev Ranjan, I am submitting the elm_slideshow patch which add support for getting notification when transition completes. Change Log: new signal “transition,end” has been introduced to get notification when transition completes. Detail Description: The actual requirement is to get user notified when the last item is visible in the slideshow. In this case, user wants to take some action, say updating button text to Restart if the slideshow does not have loop. The current implementation of slideshow has a signal called “changed” which has current visible item as event_info parameter in the callback. User can compare it with the last appended item and come to know that the last item is visible if even_info is equal to the data passed which should be the last appended item. The only problem is that this signal is emitted by C code asynchronously to the transition, hence if the transition involves an animation, user will most likely get it even before the transition completes. This may look bad to the user if the button label gets updated to Restart even before the last transition gets over. In order to fulfill the requirement, I have introduced another signal “transition,end” which is emitted once the transition is over. The same requirement could have been fulfilled by emitting “changed” signal after the transition gets over but then this will be different from the existing implementation for other widgets, hence I introduced the new signal “transition,end”. SVN revision: 65951 --- legacy/elementary/src/bin/test_slideshow.c | 12 ++++++++++-- legacy/elementary/src/lib/Elementary.h.in | 4 +++- legacy/elementary/src/lib/elm_slideshow.c | 6 +++++- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/legacy/elementary/src/bin/test_slideshow.c b/legacy/elementary/src/bin/test_slideshow.c index b351dc1655..c7834616f6 100644 --- a/legacy/elementary/src/bin/test_slideshow.c +++ b/legacy/elementary/src/bin/test_slideshow.c @@ -99,7 +99,13 @@ _get(void *data, Evas_Object *obj) return photo; } - +static void +_slide_transition(void *data, Evas_Object *obj __UNUSED__, void *event_info) +{ + Elm_Slideshow_Item *it = (Elm_Slideshow_Item *) event_info; + if (data == it) + printf("Reaches to End of slides\n"); +} void test_slideshow(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) @@ -107,6 +113,7 @@ test_slideshow(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_i Evas_Object *win, *bg, *notify, *bx, *bt, *hv, *spin; const Eina_List *l; const char *transition, *layout; + Elm_Slideshow_Item *last_item; win = elm_win_add(NULL, "slideshow", ELM_WIN_BASIC); elm_win_title_set(win, "Slideshow"); @@ -134,7 +141,8 @@ test_slideshow(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_i elm_slideshow_item_add(slideshow, &itc, img5); elm_slideshow_item_add(slideshow, &itc, img6); elm_slideshow_item_add(slideshow, &itc, img7); - elm_slideshow_item_add(slideshow, &itc, img8); + last_item = elm_slideshow_item_add(slideshow, &itc, img8); + evas_object_smart_callback_add(slideshow, "transition,end", _slide_transition, last_item); notify = elm_notify_add(win); elm_notify_orient_set(notify, ELM_NOTIFY_ORIENT_BOTTOM); diff --git a/legacy/elementary/src/lib/Elementary.h.in b/legacy/elementary/src/lib/Elementary.h.in index 407b9984d6..df74d9b099 100644 --- a/legacy/elementary/src/lib/Elementary.h.in +++ b/legacy/elementary/src/lib/Elementary.h.in @@ -20720,7 +20720,9 @@ extern "C" { * Smart events one can add callbacks for are: * * - @c "changed" - when the slideshow switches its view to a new - * item + * item. event_info parameter in callback contains the current visible item + * - @c "transition,end" - when a slide transition ends. event_info parameter + * in callback contains the current visible item * * List of examples for the slideshow widget: * @li @ref slideshow_example diff --git a/legacy/elementary/src/lib/elm_slideshow.c b/legacy/elementary/src/lib/elm_slideshow.c index 71876d6945..f430a8503e 100644 --- a/legacy/elementary/src/lib/elm_slideshow.c +++ b/legacy/elementary/src/lib/elm_slideshow.c @@ -51,9 +51,11 @@ static Eina_Bool _event_hook(Evas_Object *obj, Evas_Object *src, Evas_Callback_Type type, void *event_info); static const char SIG_CHANGED[] = "changed"; +static const char SIG_TRANSITION_END[] = "transition,end"; static const Evas_Smart_Cb_Description _signals[] = { {SIG_CHANGED, ""}, + {SIG_TRANSITION_END, ""}, {NULL, NULL} }; @@ -307,7 +309,7 @@ _item_realize(Elm_Slideshow_Item *item) } static void -_end(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__) +_end(void *data, Evas_Object *obj __UNUSED__, const char *emission, const char *source __UNUSED__) { Elm_Slideshow_Item *item; Widget_Data *wd = elm_widget_data_get(data); @@ -329,6 +331,8 @@ _end(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, c edje_object_part_swallow(wd->slideshow, "elm.swallow.1", VIEW(item)); edje_object_signal_emit(wd->slideshow, "anim,end", "slideshow"); + if (emission != NULL) + evas_object_smart_callback_call(data, SIG_TRANSITION_END, wd->current); } static Eina_Bool