From 817c49e1222e594ba4367b48b93792ed22fda382 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 9 Jul 2009 19:21:38 +0200 Subject: [PATCH] playlist: addded playlist_get_index_from_same_song() --- src/playlist.h | 7 +++++++ src/screen_browser.c | 6 +++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/playlist.h b/src/playlist.h index 77983f6..ca0950d 100644 --- a/src/playlist.h +++ b/src/playlist.h @@ -133,4 +133,11 @@ playlist_get_index_from_id(const struct mpdclient *c, gint id); gint playlist_get_index_from_file(const struct mpdclient *c, const gchar *filename); +static inline gint +playlist_get_index_from_same_song(const struct mpdclient *c, + const struct mpd_song *song) +{ + return playlist_get_index_from_file(c, song->file); +} + #endif diff --git a/src/screen_browser.c b/src/screen_browser.c index 152ee9a..f8386bb 100644 --- a/src/screen_browser.c +++ b/src/screen_browser.c @@ -79,7 +79,7 @@ sync_highlights(mpdclient_t *c, mpdclient_filelist_t *fl) if ( entity && entity->type==MPD_INFO_ENTITY_TYPE_SONG ) { mpd_Song *song = entity->info.song; - if( playlist_get_index_from_file(c, song->file) >= 0 ) + if (playlist_get_index_from_same_song(c, song) >= 0) entry->flags |= HIGHLIGHT; else entry->flags &= ~HIGHLIGHT; @@ -264,7 +264,7 @@ enqueue_and_play(mpdclient_t *c, filelist_entry_t *entry) } #endif - idx = playlist_get_index_from_file(c, song->file); + idx = playlist_get_index_from_same_song(c, song); mpdclient_cmd_play(c, idx); return true; } @@ -360,7 +360,7 @@ browser_select_entry(mpdclient_t *c, filelist_entry_t *entry, entry->flags &= ~HIGHLIGHT; - while ((idx = playlist_get_index_from_file(c, song->file)) >=0) + while ((idx = playlist_get_index_from_same_song(c, song)) >= 0) mpdclient_cmd_delete(c, idx); #endif } -- 2.30.2