diff options
author | Max Kellermann <max@duempel.org> | 2008-09-19 14:48:22 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2008-09-19 14:48:22 +0200 |
commit | 28a463b53369e9f26d6fb0a755af588faac38e18 (patch) | |
tree | 1f8fee58a4150bf122876889808eb55fcd249e0a | |
parent | d13c5a10a758a453dce00990e58cff572c592be7 (diff) | |
download | mpd-28a463b53369e9f26d6fb0a755af588faac38e18.tar.gz mpd-28a463b53369e9f26d6fb0a755af588faac38e18.tar.xz mpd-28a463b53369e9f26d6fb0a755af588faac38e18.zip |
browser: use mpdclient_filelist_find_song() in set_highlight()
A song should not be twice in the browser. Simplify set_highlight()
by finding the entry with mpdclient_filelist_find_song().
Diffstat (limited to '')
-rw-r--r-- | src/screen_browser.c | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/src/screen_browser.c b/src/screen_browser.c index dbc7adad3..828cbe21c 100644 --- a/src/screen_browser.c +++ b/src/screen_browser.c @@ -54,26 +54,17 @@ clear_highlights(mpdclient_filelist_t *fl) static void set_highlight(mpdclient_filelist_t *fl, mpd_Song *song, int highlight) { - GList *list = g_list_first(fl->list); - - assert(song != NULL); + struct filelist_entry *entry = mpdclient_filelist_find_song(fl, song); + mpd_InfoEntity *entity; - while( list ) { - filelist_entry_t *entry = list->data; - mpd_InfoEntity *entity = entry->entity; + if (entry == NULL) + return; - if( entity && entity->type==MPD_INFO_ENTITY_TYPE_SONG ) { - mpd_Song *song2 = entity->info.song; - - if( strcmp(song->file, song2->file) == 0 ) { - if(highlight) - entry->flags |= HIGHLIGHT; - else - entry->flags &= ~HIGHLIGHT; - } - } - list = list->next; - } + entity = entry->entity; + if (highlight) + entry->flags |= HIGHLIGHT; + else + entry->flags &= ~HIGHLIGHT; } /* sync highlight flags with playlist */ |