From: Max Kellermann Date: Thu, 9 Jul 2009 17:21:38 +0000 (+0200) Subject: playlist: addded playlist_get_index_from_same_song() X-Git-Tag: release-0.15~40 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=817c49e1222e594ba4367b48b93792ed22fda382;p=ncmpc.git playlist: addded playlist_get_index_from_same_song() --- 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 }