diff options
author | Jonathan Gordon <rockbox@jdgordon.info> | 2007-10-29 12:02:55 +0000 |
---|---|---|
committer | Jonathan Gordon <rockbox@jdgordon.info> | 2007-10-29 12:02:55 +0000 |
commit | 4d18aa35462c1a1c01aa0c382cf60e3d01a392f6 (patch) | |
tree | 8d40d44f152d2337d64f354fa37cd4df22113207 /apps/tagtree.c | |
parent | bae8f4c3167a0b44ff6516d421e95baaf8937066 (diff) | |
download | rockbox-4d18aa35462c1a1c01aa0c382cf60e3d01a392f6.tar.gz rockbox-4d18aa35462c1a1c01aa0c382cf60e3d01a392f6.zip |
Accept FS#8008 - allows the current artist or album to be used in databse searches (use the #artist# or #album# keywords in tagnavi.config)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15354 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/tagtree.c')
-rw-r--r-- | apps/tagtree.c | 54 |
1 files changed, 42 insertions, 12 deletions
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 | } |