summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d13c5a1)
raw | patch | inline | side by side (parent: d13c5a1)
author | Max Kellermann <max@duempel.org> | |
Fri, 19 Sep 2008 12:48:22 +0000 (14:48 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Fri, 19 Sep 2008 12:48:22 +0000 (14:48 +0200) |
A song should not be twice in the browser. Simplify set_highlight()
by finding the entry with mpdclient_filelist_find_song().
by finding the entry with mpdclient_filelist_find_song().
src/screen_browser.c | patch | blob | history |
diff --git a/src/screen_browser.c b/src/screen_browser.c
index dbc7adad3c97054e19cf88a13a3de1b9ee39ef1c..828cbe21ca6c2749ffda7b909aeda3002e38d6ca 100644 (file)
--- a/src/screen_browser.c
+++ b/src/screen_browser.c
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 */