From 34cf1d26e4432cd2e571e43f16d5377a072718f9 Mon Sep 17 00:00:00 2001 From: titan Date: Tue, 13 Mar 2007 07:35:09 +0000 Subject: [PATCH] Slideshow now works. SVN revision: 28686 --- src/bin/Makefile.am | 1 + src/bin/ephoto.h | 5 ++- src/bin/ephoto_main.c | 3 +- src/bin/ephoto_slideshow.c | 78 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 83 insertions(+), 4 deletions(-) create mode 100644 src/bin/ephoto_slideshow.c diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am index a31b77d..6da1ca3 100644 --- a/src/bin/Makefile.am +++ b/src/bin/Makefile.am @@ -13,6 +13,7 @@ ephoto_SOURCES = ephoto.c \ ephoto_main.c \ ephoto_nls.c \ ephoto_normal_view.c \ + ephoto_slideshow.c \ ephoto_utils.c ephoto_CFLAGS = @ewl_cflags@ -Wall -Werror diff --git a/src/bin/ephoto.h b/src/bin/ephoto.h index 3752b9a..892d963 100644 --- a/src/bin/ephoto.h +++ b/src/bin/ephoto.h @@ -2,6 +2,7 @@ #define _EPHOTO_H_ #include "config.h" +#include #include #include #include @@ -85,8 +86,8 @@ Ewl_Widget *add_ltree(Ewl_Widget *c); Ewl_Widget *add_normal_view(Ewl_Widget *c); void set_info(Ewl_Widget *w, void *event, void *data); -/* Ephoto Thumbnail */ -void generate_thumbnail(Ewl_Widget *image, char *path); +/* Ephoto Slideshow */ +void start_slideshow(Ewl_Widget *w, void *event, void *data); /* Ephoto Utilities*/ const char *file_size_get(int size); diff --git a/src/bin/ephoto_main.c b/src/bin/ephoto_main.c index 2519477..ef8d7cd 100644 --- a/src/bin/ephoto_main.c +++ b/src/bin/ephoto_main.c @@ -143,12 +143,11 @@ void create_main_gui(void) button = add_button(em->toolbar, NULL, PACKAGE_DATA_DIR "/images/get_exif.png", display_exif_dialog, NULL); ewl_image_size_set(EWL_IMAGE(EWL_BUTTON(button)->image_object), 30, 30); ewl_attach_tooltip_text_set(button, "View Exif Data"); - button = add_button(em->toolbar, NULL, PACKAGE_DATA_DIR "/images/stock_fullscreen.png", window_fullscreen, NULL); ewl_image_size_set(EWL_IMAGE(EWL_BUTTON(button)->image_object), 30, 30); ewl_attach_tooltip_text_set(button, "Toggle Fullscreen"); - button = add_button(em->toolbar, NULL, PACKAGE_DATA_DIR "/images/x-office-presentation.png", NULL, NULL); + button = add_button(em->toolbar, NULL, PACKAGE_DATA_DIR "/images/x-office-presentation.png", start_slideshow, NULL); ewl_image_size_set(EWL_IMAGE(EWL_BUTTON(button)->image_object), 30, 30); ewl_attach_tooltip_text_set(button, "Start a Slideshow"); diff --git a/src/bin/ephoto_slideshow.c b/src/bin/ephoto_slideshow.c new file mode 100644 index 0000000..3ad742a --- /dev/null +++ b/src/bin/ephoto_slideshow.c @@ -0,0 +1,78 @@ +#include "ephoto.h" + +static int change_picture(void *data); +static void destroy(Ewl_Widget *w, void *event, void *data); +static void show_first_image(Ewl_Widget *w, void *event, void *data); +static Ecore_Timer *change; +static Ewl_Widget *win; + +static int change_picture(void *data) +{ + char *image_path; + Ewl_Widget *image; + + image = data; + + ecore_dlist_next(em->images); + image_path = ecore_dlist_current(em->images); + + if(!image_path) + { + ecore_timer_del(change); + ewl_widget_destroy(win); + return 1; + } + + ewl_image_file_set(EWL_IMAGE(image), image_path, NULL); + + free(image_path); + return 1; +} + +static void destroy(Ewl_Widget *w, void *event, void *data) +{ + ewl_widget_destroy(win); +} + +static void show_first_image(Ewl_Widget *w, void *event, void *data) +{ + char *image_path; + + ecore_dlist_goto_first(em->images); + image_path = ecore_dlist_current(em->images); + + ewl_container_reset(EWL_CONTAINER(w)); + ewl_image_file_set(EWL_IMAGE(w), image_path, NULL); + + change = ecore_timer_add(5, change_picture, w); + + free(image_path); + return; +} + +void start_slideshow(Ewl_Widget *w, void *event, void *data) +{ + Ewl_Widget *cell, *image; + + win = ewl_window_new(); + ewl_window_title_set(EWL_WINDOW(win), "Ephoto Slideshow!"); + ewl_window_name_set(EWL_WINDOW(win), "Ephoto Slideshow!"); + ewl_window_fullscreen_set(EWL_WINDOW(win), 1); + ewl_callback_append(win, EWL_CALLBACK_CLICKED, destroy, NULL); + ewl_callback_append(win, EWL_CALLBACK_DELETE_WINDOW, destroy, NULL); + ewl_widget_show(win); + + cell = ewl_cell_new(); + ewl_object_fill_policy_set(EWL_OBJECT(cell), EWL_FLAG_FILL_ALL); + ewl_container_child_append(EWL_CONTAINER(win), cell); + ewl_widget_show(cell); + + image = add_image(cell, NULL, 0, NULL, NULL); + ewl_image_proportional_set(EWL_IMAGE(image), TRUE); + ewl_object_alignment_set(EWL_OBJECT(image), EWL_FLAG_ALIGN_CENTER); + ewl_object_fill_policy_set(EWL_OBJECT(image), EWL_FLAG_FILL_SHRINK); + ewl_callback_append(image, EWL_CALLBACK_SHOW, show_first_image, NULL); + ewl_widget_show(image); + + return; +}