# HG changeset patch # User nadvornik # Date 1244149623 0 # Node ID 1a134b4dc88c1a08d379063d53e783fb53a948d6 # Parent 1d7941c147be5b4e397b4b156cf6bf0baeb39966 use layout_set_fd() for changing images from a slideshow - this updates folder and icon in recursive slideshow mode preserve slideshow on layout change - fixes https://sourceforge.net/tracker/?func=detail&aid=1998513&group_id=222125&atid=1054680 diff -r 1d7941c147be -r 1a134b4dc88c src/img-view.c --- a/src/img-view.c Thu Jun 04 19:51:20 2009 +0000 +++ b/src/img-view.c Thu Jun 04 21:07:03 2009 +0000 @@ -774,7 +774,7 @@ if (vw->list) { - vw->ss = slideshow_start_from_filelist(view_window_active_image(vw), + vw->ss = slideshow_start_from_filelist(NULL, view_window_active_image(vw), filelist_copy(vw->list), view_slideshow_stop_func, vw); vw->list_pointer = NULL; @@ -784,7 +784,7 @@ cd = image_get_collection(view_window_active_image(vw), &info); if (cd && info) { - vw->ss = slideshow_start_from_collection(view_window_active_image(vw), cd, + vw->ss = slideshow_start_from_collection(NULL, view_window_active_image(vw), cd, view_slideshow_stop_func, vw, info); } } diff -r 1d7941c147be -r 1a134b4dc88c src/layout.c --- a/src/layout.c Thu Jun 04 19:51:20 2009 +0000 +++ b/src/layout.c Thu Jun 04 21:07:03 2009 +0000 @@ -1530,7 +1530,7 @@ /* remember state */ - layout_image_slideshow_stop(lw); + /* layout_image_slideshow_stop(lw); slideshow should survive */ layout_image_full_screen_stop(lw); dir_fd = lw->dir_fd; diff -r 1d7941c147be -r 1a134b4dc88c src/layout_image.c --- a/src/layout_image.c Thu Jun 04 19:51:20 2009 +0000 +++ b/src/layout_image.c Thu Jun 04 21:07:03 2009 +0000 @@ -65,11 +65,6 @@ /* restore image window */ lw->image = fs->normal_imd; - if (lw->slideshow) - { - lw->slideshow->imd = lw->image; - } - lw->full_screen = NULL; } @@ -85,11 +80,6 @@ /* set to new image window */ lw->image = lw->full_screen->imd; - if (lw->slideshow) - { - lw->slideshow->imd = lw->image; - } - layout_image_set_buttons(lw); g_signal_connect(G_OBJECT(lw->full_screen->window), "key_press_event", @@ -175,12 +165,12 @@ if (cd && info) { - lw->slideshow = slideshow_start_from_collection(lw->image, cd, + lw->slideshow = slideshow_start_from_collection(lw, NULL, cd, layout_image_slideshow_stop_func, lw, info); } else { - lw->slideshow = slideshow_start(lw->image, lw, + lw->slideshow = slideshow_start(lw, layout_list_get_index(lw, layout_image_get_fd(lw)), layout_image_slideshow_stop_func, lw); } @@ -199,7 +189,7 @@ return; } - lw->slideshow = slideshow_start_from_filelist(lw->image, list, + lw->slideshow = slideshow_start_from_filelist(lw, NULL, list, layout_image_slideshow_stop_func, lw); layout_status_update_info(lw, NULL); diff -r 1d7941c147be -r 1a134b4dc88c src/slideshow.c --- a/src/slideshow.c Thu Jun 04 19:51:20 2009 +0000 +++ b/src/slideshow.c Thu Jun 04 21:07:03 2009 +0000 @@ -51,7 +51,7 @@ if (ss->from_selection) { - list = layout_selection_list_by_index(ss->layout); + list = layout_selection_list_by_index(ss->lw); } else { @@ -159,7 +159,10 @@ if (!ss) return FALSE; - imd_fd = image_get_fd(ss->imd); + if (ss->lw) + imd_fd = layout_image_get_fd(ss->lw); + else + imd_fd = image_get_fd(ss->imd); if ( ((imd_fd == NULL) != (ss->slide_fd == NULL)) || (imd_fd && ss->slide_fd && imd_fd != ss->slide_fd) ) return FALSE; @@ -174,13 +177,12 @@ return FALSE; } - if (!ss->layout) return FALSE; - dir_fd = ss->layout->dir_fd; + dir_fd = ss->lw->dir_fd; if (dir_fd && ss->dir_fd && dir_fd == ss->dir_fd) { - if (ss->from_selection && ss->slide_count == layout_selection_count(ss->layout, NULL)) return TRUE; - if (!ss->from_selection && ss->slide_count == layout_list_count(ss->layout, NULL)) return TRUE; + if (ss->from_selection && ss->slide_count == layout_selection_count(ss->lw, NULL)) return TRUE; + if (!ss->from_selection && ss->slide_count == layout_list_count(ss->lw, NULL)) return TRUE; } return FALSE; @@ -218,7 +220,10 @@ if (ss->filelist) { ss->slide_fd = file_data_ref((FileData *)g_list_nth_data(ss->filelist, row)); - image_change_fd(ss->imd, ss->slide_fd, image_zoom_get_default(ss->imd)); + if (ss->lw) + layout_set_fd(ss->lw, ss->slide_fd); + else + image_change_fd(ss->imd, ss->slide_fd, image_zoom_get_default(ss->imd)); } else if (ss->cd) { @@ -227,20 +232,23 @@ info = g_list_nth_data(ss->cd->list, row); ss->slide_fd = file_data_ref(info->fd); - image_change_from_collection(ss->imd, ss->cd, info, image_zoom_get_default(ss->imd)); + if (ss->lw) + image_change_from_collection(ss->lw->image, ss->cd, info, image_zoom_get_default(ss->lw->image)); + else + image_change_from_collection(ss->imd, ss->cd, info, image_zoom_get_default(ss->imd)); } else { - ss->slide_fd = file_data_ref(layout_list_get_fd(ss->layout, row)); + ss->slide_fd = file_data_ref(layout_list_get_fd(ss->lw, row)); if (ss->from_selection) { - image_change_fd(ss->imd, ss->slide_fd, image_zoom_get_default(ss->imd)); - layout_status_update_info(ss->layout, NULL); + layout_set_fd(ss->lw, ss->slide_fd); + layout_status_update_info(ss->lw, NULL); } else { - layout_image_set_index(ss->layout, row); + layout_image_set_index(ss->lw, row); } } @@ -255,8 +263,7 @@ } /* read ahead */ - - if (options->image.enable_read_ahead) + if (options->image.enable_read_ahead && (!ss->lw || ss->from_selection)) { gint r; if (forward) @@ -282,7 +289,7 @@ } else if (ss->from_selection) { - image_prebuffer_set(ss->imd, layout_list_get_fd(ss->layout, r)); + image_prebuffer_set(ss->lw->image, layout_list_get_fd(ss->lw, r)); } } @@ -345,7 +352,7 @@ slideshow_move(ss, FALSE); } -static SlideShowData *real_slideshow_start(ImageWindow *imd, LayoutWindow *lw, +static SlideShowData *real_slideshow_start(LayoutWindow *target_lw, ImageWindow *imd, GList *filelist, gint start_point, CollectionData *cd, CollectInfo *start_info, void (*stop_func)(SlideShowData *, gpointer), gpointer stop_data) @@ -353,14 +360,14 @@ SlideShowData *ss; gint start_index = -1; - if (!filelist && !cd && layout_list_count(lw, NULL) < 1) return NULL; + if (!filelist && !cd && layout_list_count(target_lw, NULL) < 1) return NULL; ss = g_new0(SlideShowData, 1); - ss->imd = imd; + ss->lw = target_lw; + ss->imd = imd; /* FIXME: ss->imd is used only for img-view.c and can be dropped with it */ ss->filelist = filelist; ss->cd = cd; - ss->layout = lw; if (ss->filelist) { @@ -379,11 +386,11 @@ { /* layout method */ - ss->slide_count = layout_selection_count(ss->layout, NULL); - ss->dir_fd = file_data_ref(ss->layout->dir_fd); + ss->slide_count = layout_selection_count(ss->lw, NULL); + ss->dir_fd = file_data_ref(ss->lw->dir_fd); if (ss->slide_count < 2) { - ss->slide_count = layout_list_count(ss->layout, NULL); + ss->slide_count = layout_list_count(ss->lw, NULL); if (!options->slideshow.random && start_point >= 0 && (guint) start_point < ss->slide_count) { start_index = start_point; @@ -396,8 +403,12 @@ } slideshow_list_init(ss, start_index); + + if (ss->lw) + ss->slide_fd = file_data_ref(layout_image_get_fd(ss->lw)); + else + ss->slide_fd = file_data_ref(image_get_fd(ss->imd)); - ss->slide_fd = file_data_ref(image_get_fd(ss->imd)); if (slideshow_step(ss, TRUE)) { slideshow_timer_reset(ss); @@ -414,23 +425,23 @@ return ss; } -SlideShowData *slideshow_start_from_filelist(ImageWindow *imd, GList *list, +SlideShowData *slideshow_start_from_filelist(LayoutWindow *target_lw, ImageWindow *imd, GList *list, void (*stop_func)(SlideShowData *, gpointer), gpointer stop_data) { - return real_slideshow_start(imd, NULL, list, -1, NULL, NULL, stop_func, stop_data); + return real_slideshow_start(target_lw, imd, list, -1, NULL, NULL, stop_func, stop_data); } -SlideShowData *slideshow_start_from_collection(ImageWindow *imd, CollectionData *cd, +SlideShowData *slideshow_start_from_collection(LayoutWindow *target_lw, ImageWindow *imd, CollectionData *cd, void (*stop_func)(SlideShowData *, gpointer), gpointer stop_data, CollectInfo *start_info) { - return real_slideshow_start(imd, NULL, NULL, -1, cd, start_info, stop_func, stop_data); + return real_slideshow_start(target_lw, imd, NULL, -1, cd, start_info, stop_func, stop_data); } -SlideShowData *slideshow_start(ImageWindow *imd, LayoutWindow *lw, gint start_point, +SlideShowData *slideshow_start(LayoutWindow *lw, gint start_point, void (*stop_func)(SlideShowData *, gpointer), gpointer stop_data) { - return real_slideshow_start(imd, lw, NULL, start_point, NULL, NULL, stop_func, stop_data); + return real_slideshow_start(lw, NULL, NULL, start_point, NULL, NULL, stop_func, stop_data); } gboolean slideshow_paused(SlideShowData *ss) diff -r 1d7941c147be -r 1a134b4dc88c src/slideshow.h --- a/src/slideshow.h Thu Jun 04 19:51:20 2009 +0000 +++ b/src/slideshow.h Thu Jun 04 21:07:03 2009 +0000 @@ -31,12 +31,12 @@ void slideshow_next(SlideShowData *ss); void slideshow_prev(SlideShowData *ss); -SlideShowData *slideshow_start_from_filelist(ImageWindow *imd, GList *list, +SlideShowData *slideshow_start_from_filelist(LayoutWindow *target_lw, ImageWindow *imd, GList *list, void (*stop_func)(SlideShowData *, gpointer), gpointer stop_data); -SlideShowData *slideshow_start_from_collection(ImageWindow *imd, CollectionData *cd, +SlideShowData *slideshow_start_from_collection(LayoutWindow *target_lw, ImageWindow *imd, CollectionData *cd, void (*stop_func)(SlideShowData *, gpointer), gpointer stop_data, CollectInfo *start_info); -SlideShowData *slideshow_start(ImageWindow *imd, LayoutWindow *lw, gint start_point, +SlideShowData *slideshow_start(LayoutWindow *lw, gint start_point, void (*stop_func)(SlideShowData *, gpointer), gpointer stop_data); gboolean slideshow_paused(SlideShowData *ss); diff -r 1d7941c147be -r 1a134b4dc88c src/typedefs.h --- a/src/typedefs.h Thu Jun 04 19:51:20 2009 +0000 +++ b/src/typedefs.h Thu Jun 04 21:07:03 2009 +0000 @@ -793,12 +793,13 @@ struct _SlideShowData { - ImageWindow *imd; + LayoutWindow *lw; /* use this window to display the slideshow */ + ImageWindow *imd; /* use this window only if lw is not available, + FIXME: it is probably required only by img-view.c and should be dropped with it */ GList *filelist; CollectionData *cd; FileData *dir_fd; - LayoutWindow *layout; GList *list; GList *list_done;