Mercurial > audlegacy
comparison src/audlegacy/playlist.c @ 4835:7ac9e8b91bbf
Add playlist_shift().
author | William Pitcock <nenolod@atheme.org> |
---|---|
date | Fri, 13 Mar 2009 14:22:07 -0500 |
parents | 7bf7f83a217e |
children | fb3386ba8498 |
comparison
equal
deleted
inserted
replaced
4834:38b491487bd8 | 4835:7ac9e8b91bbf |
---|---|
477 playlist->position = NULL; | 477 playlist->position = NULL; |
478 playlist->entries = NULL; | 478 playlist->entries = NULL; |
479 playlist->tail = NULL; | 479 playlist->tail = NULL; |
480 playlist->attribute = PLAYLIST_PLAIN; | 480 playlist->attribute = PLAYLIST_PLAIN; |
481 playlist->serial = 0; | 481 playlist->serial = 0; |
482 | |
483 PLAYLIST_UNLOCK(playlist); | |
484 } | |
485 | |
486 void | |
487 playlist_shift(Playlist *playlist, gint delta) | |
488 { | |
489 gint orig_delta; | |
490 GList *n, *tn; | |
491 g_return_if_fail(playlist != NULL); | |
492 | |
493 if (delta == 0) | |
494 return; | |
495 | |
496 PLAYLIST_LOCK(playlist); | |
497 | |
498 /* copy the delta over. */ | |
499 orig_delta = delta; | |
500 | |
501 /* even though it is unlikely we would ever be calling playlist_shift() | |
502 on an empty playlist... we should probably check for this. --nenolod */ | |
503 if ((n = playlist->entries) == NULL) | |
504 { | |
505 PLAYLIST_UNLOCK(playlist); | |
506 return; | |
507 } | |
508 | |
509 MOWGLI_ITER_FOREACH_SAFE(n, tn, playlist->entries) | |
510 { | |
511 PlaylistEntry *entry = PLAYLIST_ENTRY(n->data); | |
512 | |
513 if (!entry->selected) | |
514 continue; | |
515 | |
516 if (orig_delta > 0) | |
517 for (delta = orig_delta; delta > 0; delta--) | |
518 glist_movedown(n); | |
519 else (orig_delta < 0) | |
520 for (delta = orig_delta; delta > 0; delta--) | |
521 glist_moveup(n); | |
522 } | |
523 | |
524 /* do the remaining work. */ | |
525 playlist_generate_shuffle_list(playlist); | |
526 event_queue("playlist update", playlist); | |
527 PLAYLIST_INCR_SERIAL(playlist); | |
482 | 528 |
483 PLAYLIST_UNLOCK(playlist); | 529 PLAYLIST_UNLOCK(playlist); |
484 } | 530 } |
485 | 531 |
486 void | 532 void |