use layout_set_fd() for changing images from a slideshow
authorVladimir Nadvornik <nadvornik@suse.cz>
Thu, 4 Jun 2009 21:07:03 +0000 (21:07 +0000)
committerVladimir Nadvornik <nadvornik@suse.cz>
Thu, 4 Jun 2009 21:07:03 +0000 (21:07 +0000)
- 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

src/img-view.c
src/layout.c
src/layout_image.c
src/slideshow.c
src/slideshow.h
src/typedefs.h

index 12f3dc8..c6100fa 100644 (file)
@@ -774,7 +774,7 @@ static void view_slideshow_start(ViewWindow *vw)
 
                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 @@ static void view_slideshow_start(ViewWindow *vw)
                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);
                        }
                }
index 85de627..d6afcd3 100644 (file)
@@ -1530,7 +1530,7 @@ void layout_style_set(LayoutWindow *lw, gint style, const gchar *order)
 
        /* 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;
index 33b8f19..ab2c415 100644 (file)
@@ -65,11 +65,6 @@ static void layout_image_full_screen_stop_func(FullScreenData *fs, gpointer data
        /* restore image window */
        lw->image = fs->normal_imd;
 
-       if (lw->slideshow)
-               {
-               lw->slideshow->imd = lw->image;
-               }
-
        lw->full_screen = NULL;
 }
 
@@ -85,11 +80,6 @@ void layout_image_full_screen_start(LayoutWindow *lw)
        /* 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 @@ void layout_image_slideshow_start(LayoutWindow *lw)
 
        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 @@ void layout_image_slideshow_start_from_list(LayoutWindow *lw, GList *list)
                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);
index 265707b..1167e07 100644 (file)
@@ -51,7 +51,7 @@ static GList *generate_list(SlideShowData *ss)
 
        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 @@ gboolean slideshow_should_continue(SlideShowData *ss)
 
        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 @@ gboolean slideshow_should_continue(SlideShowData *ss)
                        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 @@ static gboolean slideshow_step(SlideShowData *ss, gboolean forward)
        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 @@ static gboolean slideshow_step(SlideShowData *ss, gboolean forward)
                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 @@ static gboolean slideshow_step(SlideShowData *ss, gboolean forward)
                }
 
        /* 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 @@ static gboolean slideshow_step(SlideShowData *ss, gboolean forward)
                        }
                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 @@ void slideshow_prev(SlideShowData *ss)
        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 @@ static SlideShowData *real_slideshow_start(ImageWindow *imd, LayoutWindow *lw,
        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 @@ static SlideShowData *real_slideshow_start(ImageWindow *imd, LayoutWindow *lw,
                {
                /* 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 @@ static SlideShowData *real_slideshow_start(ImageWindow *imd, LayoutWindow *lw,
                }
 
        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 @@ static SlideShowData *real_slideshow_start(ImageWindow *imd, LayoutWindow *lw,
        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)
index 058965d..f170872 100644 (file)
@@ -31,12 +31,12 @@ gboolean slideshow_should_continue(SlideShowData *ss);
 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);
index 80f3fc6..256a8db 100644 (file)
@@ -793,12 +793,13 @@ struct _ViewFileInfoIcon
 
 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;