summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/tagcache.h10
-rw-r--r--apps/tagnavi.config1
-rw-r--r--apps/tagtree.c70
3 files changed, 57 insertions, 24 deletions
diff --git a/apps/tagcache.h b/apps/tagcache.h
index 16dac0b..a33e79b 100644
--- a/apps/tagcache.h
+++ b/apps/tagcache.h
@@ -110,10 +110,12 @@ struct tagcache_stat {
};
enum source_type {source_constant, source_input,
- source_current_artist, source_current_album};
-
-#define SOURCE_CURRENT_ARTIST "#artist#"
-#define SOURCE_CURRENT_ALBUM "#album#"
+ source_current_path, /* has different handling to _id3
+ so it has to be seperate */
+ source_current_id3 /* dont add items after this.
+ it is used as an index
+ into id3_to_search_mapping */
+ };
struct tagcache_search_clause
{
diff --git a/apps/tagnavi.config b/apps/tagnavi.config
index 30fd371..4facdd2 100644
--- a/apps/tagnavi.config
+++ b/apps/tagnavi.config
@@ -143,6 +143,7 @@
%menu_start "same" "Same as current"
"Artist" -> album ? artist = "#artist#" -> title = "fmt_title"
"Album" -> title = "fmt_title" ? album = "#album#"
+"Directory" -> filename ? filename ~ "#directory#"
# Define the runtime sub menu
%menu_start "runtime" "Play history"
diff --git a/apps/tagtree.c b/apps/tagtree.c
index bac74cf..94bf726 100644
--- a/apps/tagtree.c
+++ b/apps/tagtree.c
@@ -53,7 +53,17 @@ static int tagtree_play_folder(struct tree_context* c);
#define SEARCHSTR_SIZE 128
static char searchstring[SEARCHSTR_SIZE];
-
+static const struct id3_to_search_mapping {
+ char *string;
+ size_t id3_offset;
+} id3_to_search_mapping[] = {
+ { "#title#", offsetof(struct mp3entry, title) },
+ { "#artist#", offsetof(struct mp3entry, artist) },
+ { "#album#", offsetof(struct mp3entry, album) },
+ { "#genre#", offsetof(struct mp3entry, genre_string) },
+ { "#composer#", offsetof(struct mp3entry, composer) },
+ { "#albumartist#", offsetof(struct mp3entry, albumartist) },
+};
enum variables {
var_sorttype = 100,
var_limit,
@@ -296,12 +306,25 @@ static bool read_clause(struct tagcache_search_clause *clause)
if (*(clause->str) == '\0')
clause->source = source_input;
- else if (!strcasecmp(clause->str, SOURCE_CURRENT_ALBUM))
- clause->source = source_current_album;
- else if (!strcasecmp(clause->str, SOURCE_CURRENT_ARTIST))
- clause->source = source_current_artist;
- else
- clause->source = source_constant;
+ else if (!strcasecmp(clause->str, "#directory#"))
+ clause->source = source_current_path;
+ else
+ {
+ unsigned int i;
+ bool found = false;
+ for (i=0; !found && i<ARRAYLEN(id3_to_search_mapping); i++)
+ {
+ if (!strcasecmp(clause->str, id3_to_search_mapping[i].string))
+ {
+ found = true;
+ break;
+ }
+ }
+ if (found)
+ clause->source = source_current_id3+i;
+ else
+ clause->source = source_constant;
+ }
if (tagcache_is_numeric_tag(clause->tag))
{
@@ -1403,21 +1426,28 @@ int tagtree_enter(struct tree_context* c)
continue;
id3 = audio_current_track();
-
- if ((source == source_current_artist) &&
- (id3) && (id3->artist))
+
+ if (source == source_current_path && id3)
{
- strncpy(searchstring, id3->artist, SEARCHSTR_SIZE);
- searchstring[SEARCHSTR_SIZE-1] = '\0';
- }
-
- if ((source == source_current_album) &&
- (id3) && (id3->album))
+ char *e;
+ strncpy(searchstring, id3->path, SEARCHSTR_SIZE);
+ e = strrchr(searchstring, '/');
+ if (e)
+ *e = '\0';
+ }
+
+ if (source >= source_current_id3 && id3)
{
- strncpy(searchstring, id3->album, SEARCHSTR_SIZE);
- searchstring[SEARCHSTR_SIZE-1] = '\0';
- }
-
+ int i = source-source_current_id3;
+ int offset = id3_to_search_mapping[i].id3_offset;
+ char **src = (char**)((char*)id3 + offset);
+ if (*src)
+ {
+ strncpy(searchstring, *src, SEARCHSTR_SIZE);
+ searchstring[SEARCHSTR_SIZE-1] = '\0';
+ }
+ }
+
if((source == source_input) || (*searchstring=='\0'))
{
rc = kbd_input(searchstring, SEARCHSTR_SIZE);