diff options
-rw-r--r-- | apps/tagcache.h | 10 | ||||
-rw-r--r-- | apps/tagnavi.config | 1 | ||||
-rw-r--r-- | apps/tagtree.c | 70 |
3 files changed, 57 insertions, 24 deletions
diff --git a/apps/tagcache.h b/apps/tagcache.h index 16dac0b41f..a33e79b56d 100644 --- a/apps/tagcache.h +++ b/apps/tagcache.h | |||
@@ -110,10 +110,12 @@ struct tagcache_stat { | |||
110 | }; | 110 | }; |
111 | 111 | ||
112 | enum source_type {source_constant, source_input, | 112 | enum source_type {source_constant, source_input, |
113 | source_current_artist, source_current_album}; | 113 | source_current_path, /* has different handling to _id3 |
114 | 114 | so it has to be seperate */ | |
115 | #define SOURCE_CURRENT_ARTIST "#artist#" | 115 | source_current_id3 /* dont add items after this. |
116 | #define SOURCE_CURRENT_ALBUM "#album#" | 116 | it is used as an index |
117 | into id3_to_search_mapping */ | ||
118 | }; | ||
117 | 119 | ||
118 | struct tagcache_search_clause | 120 | struct tagcache_search_clause |
119 | { | 121 | { |
diff --git a/apps/tagnavi.config b/apps/tagnavi.config index 30fd371b3e..4facdd25b9 100644 --- a/apps/tagnavi.config +++ b/apps/tagnavi.config | |||
@@ -143,6 +143,7 @@ | |||
143 | %menu_start "same" "Same as current" | 143 | %menu_start "same" "Same as current" |
144 | "Artist" -> album ? artist = "#artist#" -> title = "fmt_title" | 144 | "Artist" -> album ? artist = "#artist#" -> title = "fmt_title" |
145 | "Album" -> title = "fmt_title" ? album = "#album#" | 145 | "Album" -> title = "fmt_title" ? album = "#album#" |
146 | "Directory" -> filename ? filename ~ "#directory#" | ||
146 | 147 | ||
147 | # Define the runtime sub menu | 148 | # Define the runtime sub menu |
148 | %menu_start "runtime" "Play history" | 149 | %menu_start "runtime" "Play history" |
diff --git a/apps/tagtree.c b/apps/tagtree.c index bac74cf443..94bf726caa 100644 --- a/apps/tagtree.c +++ b/apps/tagtree.c | |||
@@ -53,7 +53,17 @@ static int tagtree_play_folder(struct tree_context* c); | |||
53 | 53 | ||
54 | #define SEARCHSTR_SIZE 128 | 54 | #define SEARCHSTR_SIZE 128 |
55 | static char searchstring[SEARCHSTR_SIZE]; | 55 | static char searchstring[SEARCHSTR_SIZE]; |
56 | 56 | static const struct id3_to_search_mapping { | |
57 | char *string; | ||
58 | size_t id3_offset; | ||
59 | } id3_to_search_mapping[] = { | ||
60 | { "#title#", offsetof(struct mp3entry, title) }, | ||
61 | { "#artist#", offsetof(struct mp3entry, artist) }, | ||
62 | { "#album#", offsetof(struct mp3entry, album) }, | ||
63 | { "#genre#", offsetof(struct mp3entry, genre_string) }, | ||
64 | { "#composer#", offsetof(struct mp3entry, composer) }, | ||
65 | { "#albumartist#", offsetof(struct mp3entry, albumartist) }, | ||
66 | }; | ||
57 | enum variables { | 67 | enum variables { |
58 | var_sorttype = 100, | 68 | var_sorttype = 100, |
59 | var_limit, | 69 | var_limit, |
@@ -296,12 +306,25 @@ static bool read_clause(struct tagcache_search_clause *clause) | |||
296 | 306 | ||
297 | if (*(clause->str) == '\0') | 307 | if (*(clause->str) == '\0') |
298 | clause->source = source_input; | 308 | clause->source = source_input; |
299 | else if (!strcasecmp(clause->str, SOURCE_CURRENT_ALBUM)) | 309 | else if (!strcasecmp(clause->str, "#directory#")) |
300 | clause->source = source_current_album; | 310 | clause->source = source_current_path; |
301 | else if (!strcasecmp(clause->str, SOURCE_CURRENT_ARTIST)) | 311 | else |
302 | clause->source = source_current_artist; | 312 | { |
303 | else | 313 | unsigned int i; |
304 | clause->source = source_constant; | 314 | bool found = false; |
315 | for (i=0; !found && i<ARRAYLEN(id3_to_search_mapping); i++) | ||
316 | { | ||
317 | if (!strcasecmp(clause->str, id3_to_search_mapping[i].string)) | ||
318 | { | ||
319 | found = true; | ||
320 | break; | ||
321 | } | ||
322 | } | ||
323 | if (found) | ||
324 | clause->source = source_current_id3+i; | ||
325 | else | ||
326 | clause->source = source_constant; | ||
327 | } | ||
305 | 328 | ||
306 | if (tagcache_is_numeric_tag(clause->tag)) | 329 | if (tagcache_is_numeric_tag(clause->tag)) |
307 | { | 330 | { |
@@ -1403,21 +1426,28 @@ int tagtree_enter(struct tree_context* c) | |||
1403 | continue; | 1426 | continue; |
1404 | 1427 | ||
1405 | id3 = audio_current_track(); | 1428 | id3 = audio_current_track(); |
1406 | 1429 | ||
1407 | if ((source == source_current_artist) && | 1430 | if (source == source_current_path && id3) |
1408 | (id3) && (id3->artist)) | ||
1409 | { | 1431 | { |
1410 | strncpy(searchstring, id3->artist, SEARCHSTR_SIZE); | 1432 | char *e; |
1411 | searchstring[SEARCHSTR_SIZE-1] = '\0'; | 1433 | strncpy(searchstring, id3->path, SEARCHSTR_SIZE); |
1412 | } | 1434 | e = strrchr(searchstring, '/'); |
1413 | 1435 | if (e) | |
1414 | if ((source == source_current_album) && | 1436 | *e = '\0'; |
1415 | (id3) && (id3->album)) | 1437 | } |
1438 | |||
1439 | if (source >= source_current_id3 && id3) | ||
1416 | { | 1440 | { |
1417 | strncpy(searchstring, id3->album, SEARCHSTR_SIZE); | 1441 | int i = source-source_current_id3; |
1418 | searchstring[SEARCHSTR_SIZE-1] = '\0'; | 1442 | int offset = id3_to_search_mapping[i].id3_offset; |
1419 | } | 1443 | char **src = (char**)((char*)id3 + offset); |
1420 | 1444 | if (*src) | |
1445 | { | ||
1446 | strncpy(searchstring, *src, SEARCHSTR_SIZE); | ||
1447 | searchstring[SEARCHSTR_SIZE-1] = '\0'; | ||
1448 | } | ||
1449 | } | ||
1450 | |||
1421 | if((source == source_input) || (*searchstring=='\0')) | 1451 | if((source == source_input) || (*searchstring=='\0')) |
1422 | { | 1452 | { |
1423 | rc = kbd_input(searchstring, SEARCHSTR_SIZE); | 1453 | rc = kbd_input(searchstring, SEARCHSTR_SIZE); |