comparison src/slideshow.c @ 1627:1a134b4dc88c

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
author nadvornik
date Thu, 04 Jun 2009 21:07:03 +0000
parents 24a12aa0cb54
children 956aab097ea7
comparison
equal deleted inserted replaced
1626:1d7941c147be 1627:1a134b4dc88c
49 { 49 {
50 GList *list = NULL; 50 GList *list = NULL;
51 51
52 if (ss->from_selection) 52 if (ss->from_selection)
53 { 53 {
54 list = layout_selection_list_by_index(ss->layout); 54 list = layout_selection_list_by_index(ss->lw);
55 } 55 }
56 else 56 else
57 { 57 {
58 guint i; 58 guint i;
59 for (i = 0; i < ss->slide_count; i++) 59 for (i = 0; i < ss->slide_count; i++)
157 FileData *imd_fd; 157 FileData *imd_fd;
158 FileData *dir_fd; 158 FileData *dir_fd;
159 159
160 if (!ss) return FALSE; 160 if (!ss) return FALSE;
161 161
162 imd_fd = image_get_fd(ss->imd); 162 if (ss->lw)
163 imd_fd = layout_image_get_fd(ss->lw);
164 else
165 imd_fd = image_get_fd(ss->imd);
163 166
164 if ( ((imd_fd == NULL) != (ss->slide_fd == NULL)) || 167 if ( ((imd_fd == NULL) != (ss->slide_fd == NULL)) ||
165 (imd_fd && ss->slide_fd && imd_fd != ss->slide_fd) ) return FALSE; 168 (imd_fd && ss->slide_fd && imd_fd != ss->slide_fd) ) return FALSE;
166 169
167 if (ss->filelist) return TRUE; 170 if (ss->filelist) return TRUE;
172 return TRUE; 175 return TRUE;
173 else 176 else
174 return FALSE; 177 return FALSE;
175 } 178 }
176 179
177 if (!ss->layout) return FALSE; 180 dir_fd = ss->lw->dir_fd;
178 dir_fd = ss->layout->dir_fd;
179 181
180 if (dir_fd && ss->dir_fd && dir_fd == ss->dir_fd) 182 if (dir_fd && ss->dir_fd && dir_fd == ss->dir_fd)
181 { 183 {
182 if (ss->from_selection && ss->slide_count == layout_selection_count(ss->layout, NULL)) return TRUE; 184 if (ss->from_selection && ss->slide_count == layout_selection_count(ss->lw, NULL)) return TRUE;
183 if (!ss->from_selection && ss->slide_count == layout_list_count(ss->layout, NULL)) return TRUE; 185 if (!ss->from_selection && ss->slide_count == layout_list_count(ss->lw, NULL)) return TRUE;
184 } 186 }
185 187
186 return FALSE; 188 return FALSE;
187 } 189 }
188 190
216 ss->slide_fd = NULL; 218 ss->slide_fd = NULL;
217 219
218 if (ss->filelist) 220 if (ss->filelist)
219 { 221 {
220 ss->slide_fd = file_data_ref((FileData *)g_list_nth_data(ss->filelist, row)); 222 ss->slide_fd = file_data_ref((FileData *)g_list_nth_data(ss->filelist, row));
221 image_change_fd(ss->imd, ss->slide_fd, image_zoom_get_default(ss->imd)); 223 if (ss->lw)
224 layout_set_fd(ss->lw, ss->slide_fd);
225 else
226 image_change_fd(ss->imd, ss->slide_fd, image_zoom_get_default(ss->imd));
222 } 227 }
223 else if (ss->cd) 228 else if (ss->cd)
224 { 229 {
225 CollectInfo *info; 230 CollectInfo *info;
226 231
227 info = g_list_nth_data(ss->cd->list, row); 232 info = g_list_nth_data(ss->cd->list, row);
228 ss->slide_fd = file_data_ref(info->fd); 233 ss->slide_fd = file_data_ref(info->fd);
229 234
230 image_change_from_collection(ss->imd, ss->cd, info, image_zoom_get_default(ss->imd)); 235 if (ss->lw)
231 } 236 image_change_from_collection(ss->lw->image, ss->cd, info, image_zoom_get_default(ss->lw->image));
232 else 237 else
233 { 238 image_change_from_collection(ss->imd, ss->cd, info, image_zoom_get_default(ss->imd));
234 ss->slide_fd = file_data_ref(layout_list_get_fd(ss->layout, row)); 239 }
240 else
241 {
242 ss->slide_fd = file_data_ref(layout_list_get_fd(ss->lw, row));
235 243
236 if (ss->from_selection) 244 if (ss->from_selection)
237 { 245 {
238 image_change_fd(ss->imd, ss->slide_fd, image_zoom_get_default(ss->imd)); 246 layout_set_fd(ss->lw, ss->slide_fd);
239 layout_status_update_info(ss->layout, NULL); 247 layout_status_update_info(ss->lw, NULL);
240 } 248 }
241 else 249 else
242 { 250 {
243 layout_image_set_index(ss->layout, row); 251 layout_image_set_index(ss->lw, row);
244 } 252 }
245 } 253 }
246 254
247 if (!ss->list && options->slideshow.repeat) 255 if (!ss->list && options->slideshow.repeat)
248 { 256 {
253 { 261 {
254 return FALSE; 262 return FALSE;
255 } 263 }
256 264
257 /* read ahead */ 265 /* read ahead */
258 266 if (options->image.enable_read_ahead && (!ss->lw || ss->from_selection))
259 if (options->image.enable_read_ahead)
260 { 267 {
261 gint r; 268 gint r;
262 if (forward) 269 if (forward)
263 { 270 {
264 if (!ss->list) return TRUE; 271 if (!ss->list) return TRUE;
280 info = g_list_nth_data(ss->cd->list, r); 287 info = g_list_nth_data(ss->cd->list, r);
281 if (info) image_prebuffer_set(ss->imd, info->fd); 288 if (info) image_prebuffer_set(ss->imd, info->fd);
282 } 289 }
283 else if (ss->from_selection) 290 else if (ss->from_selection)
284 { 291 {
285 image_prebuffer_set(ss->imd, layout_list_get_fd(ss->layout, r)); 292 image_prebuffer_set(ss->lw->image, layout_list_get_fd(ss->lw, r));
286 } 293 }
287 } 294 }
288 295
289 return TRUE; 296 return TRUE;
290 } 297 }
343 void slideshow_prev(SlideShowData *ss) 350 void slideshow_prev(SlideShowData *ss)
344 { 351 {
345 slideshow_move(ss, FALSE); 352 slideshow_move(ss, FALSE);
346 } 353 }
347 354
348 static SlideShowData *real_slideshow_start(ImageWindow *imd, LayoutWindow *lw, 355 static SlideShowData *real_slideshow_start(LayoutWindow *target_lw, ImageWindow *imd,
349 GList *filelist, gint start_point, 356 GList *filelist, gint start_point,
350 CollectionData *cd, CollectInfo *start_info, 357 CollectionData *cd, CollectInfo *start_info,
351 void (*stop_func)(SlideShowData *, gpointer), gpointer stop_data) 358 void (*stop_func)(SlideShowData *, gpointer), gpointer stop_data)
352 { 359 {
353 SlideShowData *ss; 360 SlideShowData *ss;
354 gint start_index = -1; 361 gint start_index = -1;
355 362
356 if (!filelist && !cd && layout_list_count(lw, NULL) < 1) return NULL; 363 if (!filelist && !cd && layout_list_count(target_lw, NULL) < 1) return NULL;
357 364
358 ss = g_new0(SlideShowData, 1); 365 ss = g_new0(SlideShowData, 1);
359 366
360 ss->imd = imd; 367 ss->lw = target_lw;
368 ss->imd = imd; /* FIXME: ss->imd is used only for img-view.c and can be dropped with it */
361 ss->filelist = filelist; 369 ss->filelist = filelist;
362 ss->cd = cd; 370 ss->cd = cd;
363 ss->layout = lw;
364 371
365 if (ss->filelist) 372 if (ss->filelist)
366 { 373 {
367 ss->slide_count = g_list_length(ss->filelist); 374 ss->slide_count = g_list_length(ss->filelist);
368 } 375 }
377 } 384 }
378 else 385 else
379 { 386 {
380 /* layout method */ 387 /* layout method */
381 388
382 ss->slide_count = layout_selection_count(ss->layout, NULL); 389 ss->slide_count = layout_selection_count(ss->lw, NULL);
383 ss->dir_fd = file_data_ref(ss->layout->dir_fd); 390 ss->dir_fd = file_data_ref(ss->lw->dir_fd);
384 if (ss->slide_count < 2) 391 if (ss->slide_count < 2)
385 { 392 {
386 ss->slide_count = layout_list_count(ss->layout, NULL); 393 ss->slide_count = layout_list_count(ss->lw, NULL);
387 if (!options->slideshow.random && start_point >= 0 && (guint) start_point < ss->slide_count) 394 if (!options->slideshow.random && start_point >= 0 && (guint) start_point < ss->slide_count)
388 { 395 {
389 start_index = start_point; 396 start_index = start_point;
390 } 397 }
391 } 398 }
394 ss->from_selection = TRUE; 401 ss->from_selection = TRUE;
395 } 402 }
396 } 403 }
397 404
398 slideshow_list_init(ss, start_index); 405 slideshow_list_init(ss, start_index);
399 406
400 ss->slide_fd = file_data_ref(image_get_fd(ss->imd)); 407 if (ss->lw)
408 ss->slide_fd = file_data_ref(layout_image_get_fd(ss->lw));
409 else
410 ss->slide_fd = file_data_ref(image_get_fd(ss->imd));
411
401 if (slideshow_step(ss, TRUE)) 412 if (slideshow_step(ss, TRUE))
402 { 413 {
403 slideshow_timer_reset(ss); 414 slideshow_timer_reset(ss);
404 415
405 ss->stop_func = stop_func; 416 ss->stop_func = stop_func;
412 } 423 }
413 424
414 return ss; 425 return ss;
415 } 426 }
416 427
417 SlideShowData *slideshow_start_from_filelist(ImageWindow *imd, GList *list, 428 SlideShowData *slideshow_start_from_filelist(LayoutWindow *target_lw, ImageWindow *imd, GList *list,
418 void (*stop_func)(SlideShowData *, gpointer), gpointer stop_data) 429 void (*stop_func)(SlideShowData *, gpointer), gpointer stop_data)
419 { 430 {
420 return real_slideshow_start(imd, NULL, list, -1, NULL, NULL, stop_func, stop_data); 431 return real_slideshow_start(target_lw, imd, list, -1, NULL, NULL, stop_func, stop_data);
421 } 432 }
422 433
423 SlideShowData *slideshow_start_from_collection(ImageWindow *imd, CollectionData *cd, 434 SlideShowData *slideshow_start_from_collection(LayoutWindow *target_lw, ImageWindow *imd, CollectionData *cd,
424 void (*stop_func)(SlideShowData *, gpointer), gpointer stop_data, 435 void (*stop_func)(SlideShowData *, gpointer), gpointer stop_data,
425 CollectInfo *start_info) 436 CollectInfo *start_info)
426 { 437 {
427 return real_slideshow_start(imd, NULL, NULL, -1, cd, start_info, stop_func, stop_data); 438 return real_slideshow_start(target_lw, imd, NULL, -1, cd, start_info, stop_func, stop_data);
428 } 439 }
429 440
430 SlideShowData *slideshow_start(ImageWindow *imd, LayoutWindow *lw, gint start_point, 441 SlideShowData *slideshow_start(LayoutWindow *lw, gint start_point,
431 void (*stop_func)(SlideShowData *, gpointer), gpointer stop_data) 442 void (*stop_func)(SlideShowData *, gpointer), gpointer stop_data)
432 { 443 {
433 return real_slideshow_start(imd, lw, NULL, start_point, NULL, NULL, stop_func, stop_data); 444 return real_slideshow_start(lw, NULL, NULL, start_point, NULL, NULL, stop_func, stop_data);
434 } 445 }
435 446
436 gboolean slideshow_paused(SlideShowData *ss) 447 gboolean slideshow_paused(SlideShowData *ss)
437 { 448 {
438 if (!ss) return FALSE; 449 if (!ss) return FALSE;