summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 17a8acb)
raw | patch | inline | side by side (parent: 17a8acb)
author | Max Kellermann <max@duempel.org> | |
Tue, 18 Nov 2008 20:51:28 +0000 (21:51 +0100) | ||
committer | Max Kellermann <max@duempel.org> | |
Tue, 18 Nov 2008 20:51:28 +0000 (21:51 +0100) |
Making the function return the index makes it more flexible: those who
want the pointer can use filelist_get(), and the others may use the
index for other purposes.
want the pointer can use filelist_get(), and the others may use the
index for other purposes.
src/filelist.c | patch | blob | history | |
src/filelist.h | patch | blob | history | |
src/screen_browser.c | patch | blob | history |
diff --git a/src/filelist.c b/src/filelist.c
index 415eec4021a6038c5def9f96a1d05b6871e52f5f..2e078635ad230a54e04db2c33fe611307068294a 100644 (file)
--- a/src/filelist.c
+++ b/src/filelist.c
compare_func);
}
-struct filelist_entry *
+int
filelist_find_song(struct filelist *fl, const struct mpd_song *song)
{
guint i;
struct mpd_song *song2 = entity->info.song;
if (strcmp(song->file, song2->file) == 0)
- return entry;
+ return i;
}
}
- return NULL;
+ return -1;
}
int
diff --git a/src/filelist.h b/src/filelist.h
index d7d4dff888ba107bbbccb76506ab86d355b216db..bc467fb65bb45ad1746b10a44485e8c4e6e8fb19 100644 (file)
--- a/src/filelist.h
+++ b/src/filelist.h
void
filelist_sort(struct filelist *filelist, GCompareFunc compare_func);
-struct filelist_entry *
+int
filelist_find_song(struct filelist *flist, const struct mpd_song *song);
int
diff --git a/src/screen_browser.c b/src/screen_browser.c
index b5ce64171721baec8d445eb660313eb5ea8a41cb..6a5bbd2331f549b57edb25b3e645e0bbc24a29b2 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)
{
- struct filelist_entry *entry = filelist_find_song(fl, song);
+ int i = filelist_find_song(fl, song);
+ struct filelist_entry *entry;
- if (entry == NULL)
+ if (i < 0)
return;
+ entry = filelist_get(fl, i);
if (highlight)
entry->flags |= HIGHLIGHT;
else