diff options
-rw-r--r-- | apps/tagcache.h | 8 | ||||
-rw-r--r-- | apps/tagnavi.config | 6 | ||||
-rw-r--r-- | apps/tagtree.c | 54 |
3 files changed, 55 insertions, 13 deletions
diff --git a/apps/tagcache.h b/apps/tagcache.h index 6b2df6b984..16dac0b41f 100644 --- a/apps/tagcache.h +++ b/apps/tagcache.h | |||
@@ -109,12 +109,18 @@ struct tagcache_stat { | |||
109 | // const char *uimessage; /* Pending error message. Implement soon. */ | 109 | // const char *uimessage; /* Pending error message. Implement soon. */ |
110 | }; | 110 | }; |
111 | 111 | ||
112 | enum source_type {source_constant, source_input, | ||
113 | source_current_artist, source_current_album}; | ||
114 | |||
115 | #define SOURCE_CURRENT_ARTIST "#artist#" | ||
116 | #define SOURCE_CURRENT_ALBUM "#album#" | ||
117 | |||
112 | struct tagcache_search_clause | 118 | struct tagcache_search_clause |
113 | { | 119 | { |
114 | int tag; | 120 | int tag; |
115 | int type; | 121 | int type; |
116 | bool numeric; | 122 | bool numeric; |
117 | bool input; | 123 | int source; |
118 | long numeric_data; | 124 | long numeric_data; |
119 | char *str; | 125 | char *str; |
120 | }; | 126 | }; |
diff --git a/apps/tagnavi.config b/apps/tagnavi.config index 73773633b5..30fd371b3e 100644 --- a/apps/tagnavi.config +++ b/apps/tagnavi.config | |||
@@ -139,6 +139,11 @@ | |||
139 | "User Rating" -> title = "fmt_rating" ? rating > "" | 139 | "User Rating" -> title = "fmt_rating" ? rating > "" |
140 | "Comment" -> album ? comment ~ "" -> title = "fmt_title" | 140 | "Comment" -> album ? comment ~ "" -> title = "fmt_title" |
141 | 141 | ||
142 | # Define the "same as current" sub menu | ||
143 | %menu_start "same" "Same as current" | ||
144 | "Artist" -> album ? artist = "#artist#" -> title = "fmt_title" | ||
145 | "Album" -> title = "fmt_title" ? album = "#album#" | ||
146 | |||
142 | # Define the runtime sub menu | 147 | # Define the runtime sub menu |
143 | %menu_start "runtime" "Play history" | 148 | %menu_start "runtime" "Play history" |
144 | "Most played (Plays|Score)" -> title = "fmt_mostplayed" ? playcount > "0" | 149 | "Most played (Plays|Score)" -> title = "fmt_mostplayed" ? playcount > "0" |
@@ -166,6 +171,7 @@ | |||
166 | "Recently Added" -> album ? entryage < "4" & commitid > "0" -> title = "fmt_title" | 171 | "Recently Added" -> album ? entryage < "4" & commitid > "0" -> title = "fmt_title" |
167 | "A to Z..." ==> "a2z" | 172 | "A to Z..." ==> "a2z" |
168 | "History..." ==> "runtime" | 173 | "History..." ==> "runtime" |
174 | "Same as current..." ==> "same" | ||
169 | "Search..." ==> "search" | 175 | "Search..." ==> "search" |
170 | "Custom view..." ==> "custom" | 176 | "Custom view..." ==> "custom" |
171 | 177 | ||
diff --git a/apps/tagtree.c b/apps/tagtree.c index f9ae0bebd3..fd524712ac 100644 --- a/apps/tagtree.c +++ b/apps/tagtree.c | |||
@@ -50,7 +50,8 @@ | |||
50 | 50 | ||
51 | static int tagtree_play_folder(struct tree_context* c); | 51 | static int tagtree_play_folder(struct tree_context* c); |
52 | 52 | ||
53 | static char searchstring[128]; | 53 | #define SEARCHSTR_SIZE 128 |
54 | static char searchstring[SEARCHSTR_SIZE]; | ||
54 | 55 | ||
55 | enum variables { | 56 | enum variables { |
56 | var_sorttype = 100, | 57 | var_sorttype = 100, |
@@ -293,9 +294,13 @@ static bool read_clause(struct tagcache_search_clause *clause) | |||
293 | logf("got clause: %d/%d [%s]", clause->tag, clause->type, clause->str); | 294 | logf("got clause: %d/%d [%s]", clause->tag, clause->type, clause->str); |
294 | 295 | ||
295 | if (*(clause->str) == '\0') | 296 | if (*(clause->str) == '\0') |
296 | clause->input = true; | 297 | clause->source = source_input; |
298 | else if (!strcasecmp(clause->str, SOURCE_CURRENT_ALBUM)) | ||
299 | clause->source = source_current_album; | ||
300 | else if (!strcasecmp(clause->str, SOURCE_CURRENT_ARTIST)) | ||
301 | clause->source = source_current_artist; | ||
297 | else | 302 | else |
298 | clause->input = false; | 303 | clause->source = source_constant; |
299 | 304 | ||
300 | if (tagcache_is_numeric_tag(clause->tag)) | 305 | if (tagcache_is_numeric_tag(clause->tag)) |
301 | { | 306 | { |
@@ -1345,8 +1350,10 @@ int tagtree_enter(struct tree_context* c) | |||
1345 | { | 1350 | { |
1346 | int rc = 0; | 1351 | int rc = 0; |
1347 | struct tagentry *dptr; | 1352 | struct tagentry *dptr; |
1353 | struct mp3entry *id3; | ||
1348 | int newextra; | 1354 | int newextra; |
1349 | int seek; | 1355 | int seek; |
1356 | int source; | ||
1350 | 1357 | ||
1351 | dptr = tagtree_get_entry(c, c->selected_item); | 1358 | dptr = tagtree_get_entry(c, c->selected_item); |
1352 | 1359 | ||
@@ -1388,20 +1395,43 @@ int tagtree_enter(struct tree_context* c) | |||
1388 | { | 1395 | { |
1389 | for (j = 0; j < csi->clause_count[i]; j++) | 1396 | for (j = 0; j < csi->clause_count[i]; j++) |
1390 | { | 1397 | { |
1391 | if (!csi->clause[i][j]->input) | 1398 | *searchstring='\0'; |
1399 | source = csi->clause[i][j]->source; | ||
1400 | |||
1401 | if (source == source_constant) | ||
1392 | continue; | 1402 | continue; |
1393 | 1403 | ||
1394 | rc = kbd_input(searchstring, sizeof(searchstring)); | 1404 | id3 = audio_current_track(); |
1395 | if (rc == -1 || !searchstring[0]) | 1405 | |
1406 | if ((source == source_current_artist) && | ||
1407 | (id3) && (id3->artist)) | ||
1396 | { | 1408 | { |
1397 | tagtree_exit(c); | 1409 | strncpy(searchstring, id3->artist, SEARCHSTR_SIZE); |
1398 | return 0; | 1410 | searchstring[SEARCHSTR_SIZE-1] = '\0'; |
1399 | } | 1411 | } |
1400 | 1412 | ||
1413 | if ((source == source_current_album) && | ||
1414 | (id3) && (id3->album)) | ||
1415 | { | ||
1416 | strncpy(searchstring, id3->album, SEARCHSTR_SIZE); | ||
1417 | searchstring[SEARCHSTR_SIZE-1] = '\0'; | ||
1418 | } | ||
1419 | |||
1420 | if((source == source_input) || (*searchstring=='\0')) | ||
1421 | { | ||
1422 | rc = kbd_input(searchstring, SEARCHSTR_SIZE); | ||
1423 | if (rc == -1 || !searchstring[0]) | ||
1424 | { | ||
1425 | tagtree_exit(c); | ||
1426 | return 0; | ||
1427 | } | ||
1428 | } | ||
1429 | |||
1401 | if (csi->clause[i][j]->numeric) | 1430 | if (csi->clause[i][j]->numeric) |
1402 | csi->clause[i][j]->numeric_data = atoi(searchstring); | 1431 | csi->clause[i][j]->numeric_data = atoi(searchstring); |
1403 | else | 1432 | |
1404 | csi->clause[i][j]->str = searchstring; | 1433 | /* existing bug: only one dynamic string per clause! */ |
1434 | csi->clause[i][j]->str = searchstring; | ||
1405 | } | 1435 | } |
1406 | } | 1436 | } |
1407 | } | 1437 | } |