summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2010-08-26 21:54:57 +0200
committerJon Bergli Heier <snakebite@jvnv.net>2010-08-26 21:54:57 +0200
commit89217bfc20237a4de1011dd4396b892d5db30af0 (patch)
treec43492145261d2a3fc2b1c8c9930c15bf8de84da
parent856d564690c858f7c9b92a81e9062328c75f193e (diff)
Generalized music search.
-rw-r--r--music.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/music.c b/music.c
index 0bbaa0f..0f6656a 100644
--- a/music.c
+++ b/music.c
@@ -165,18 +165,23 @@ void music_free() {
music_root = NULL;
}
-GSList *music_find_artist_rec(struct directory *directory, const gchar *name) {
+static GSList *music_find_rec(struct directory *directory, const gchar *name, enum tag_type type) {
GSList *list = NULL;
for(GSList *node = directory->sub; node; node = g_slist_next(node)) {
struct directory *d = node->data;
g_debug("searching in dir %s", d->path);
- list = g_slist_concat(list, music_find_artist_rec(d, name));
+ list = g_slist_concat(list, music_find_rec(d, name, type));
}
for(GSList *node = directory->files; node; node = g_slist_next(node)) {
struct file *f = node->data;
- gchar *str = g_utf8_casefold(f->name, strlen(f->name));
+ const gchar *tag_str = tag_get(f->tag, type);
+ if(tag_str == NULL) {
+ continue;
+ }
+
+ gchar *str = g_utf8_casefold(tag_str, strlen(tag_str));
if(strstr(str, name) != NULL) {
list = g_slist_prepend(list, f);
}
@@ -189,7 +194,7 @@ GSList *music_find_artist_rec(struct directory *directory, const gchar *name) {
GSList *music_find_artist(const gchar *_name) {
gchar *name = g_utf8_casefold(_name, strlen(_name));
- GSList *list = music_find_artist_rec(music_root, name);
+ GSList *list = music_find_rec(music_root, name, TAG_TYPE_ARTIST);
g_free(name);
return list;