From 451f6788cea2f7a90badcf2fb7e1e3679fa513cb Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 2 Jul 2013 13:17:50 +0200 Subject: command: add some playlist manipulation commands playlist_remove and playlist_move. --- core/playlist.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'core/playlist.c') diff --git a/core/playlist.c b/core/playlist.c index 4132ebec10..0d96ee5d0b 100644 --- a/core/playlist.c +++ b/core/playlist.c @@ -114,6 +114,20 @@ void playlist_clear(struct playlist *pl) pl->current_was_replaced = false; } +// Moves entry such that entry->prev = at (even if at is NULL) +void playlist_move(struct playlist *pl, struct playlist_entry *entry, + struct playlist_entry *at) +{ + struct playlist_entry *save_current = pl->current; + bool save_replaced = pl->current_was_replaced; + + playlist_unlink(pl, entry); + playlist_insert(pl, at ? at->prev : pl->last, entry); + + pl->current = save_current; + pl->current_was_replaced = save_replaced; +} + void playlist_add_file(struct playlist *pl, const char *filename) { playlist_add(pl, playlist_entry_new(filename)); -- cgit v1.2.3