From: Richard Kettlewell Date: Sat, 17 May 2008 11:50:42 +0000 (+0100) Subject: exp_search, fold search into choose, not really finished X-Git-Tag: 4.0~76^2~27 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/disorder/commitdiff_plain/b43dc0cc5003562a37b52e744fd3d3e3b12b3c06 exp_search, fold search into choose, not really finished --- diff --git a/server/macros-disorder.c b/server/macros-disorder.c index 80eb476..189d51d 100644 --- a/server/macros-disorder.c +++ b/server/macros-disorder.c @@ -912,6 +912,31 @@ static int exp_dirs(int nargs, return exp__files_dirs(nargs, args, output, u, "dir", disorder_directories); } +static int exp__search_shim(disorder_client *c, const char *terms, + const char attribute((unused)) *re, + char ***vecp, int *nvecp) { + return disorder_search(c, terms, vecp, nvecp); +} + +/** @search{KEYWORDS}{TEMPLATE} + * + * For each track matching KEYWORDS, expands TEMPLATE with the + * following expansions: + * - @track to the UNQUOTED directory name + * - @index to the directory number from 0 + * - @parity to "even" or "odd" alternately + * - @first to "true" on the first directory and "false" otherwise + * - @last to "true" on the last directory and "false" otherwise + * - @sort to the sort key for this track + * - @display to the UNQUOTED display string for this track + */ +static int exp_search(int nargs, + const struct mx_node **args, + struct sink *output, + void *u) { + return exp__files_dirs(nargs, args, output, u, "track", exp__search_shim); +} + /** @brief Register DisOrder-specific expansions */ void dcgi_expansions(void) { mx_register("arg", 1, 1, exp_arg); @@ -951,6 +976,7 @@ void dcgi_expansions(void) { mx_register_magic("queue", 1, 1, exp_queue); mx_register_magic("recent", 1, 1, exp_recent); mx_register_magic("right", 1, 3, exp_right); + mx_register_magic("search", 2, 2, exp_search); mx_register_magic("tracks", 2, 3, exp_tracks); } diff --git a/templates/Makefile.am b/templates/Makefile.am index 16bc70a..bf55c08 100644 --- a/templates/Makefile.am +++ b/templates/Makefile.am @@ -19,7 +19,7 @@ # pkgdata_DATA=about.tmpl choose.tmpl playing.tmpl recent.tmpl \ - search.tmpl about.tmpl prefs.tmpl help.tmpl error.tmpl \ + about.tmpl prefs.tmpl help.tmpl error.tmpl \ new.tmpl login.tmpl macros.tmpl \ options options.labels \ options.columns diff --git a/templates/choose.tmpl b/templates/choose.tmpl index 0b08491..6277c12 100644 --- a/templates/choose.tmpl +++ b/templates/choose.tmpl @@ -86,6 +86,31 @@ USA

} +@# Always have a search form + + + @if{@ne{@arg{query}}{}} + { +@# There's a search query + @search{@arg{query}}{ +

TODO @quote{@track}

+ } + } + { +@# No search query + @# TODO navigation...
@@ -110,10 +135,10 @@ USA @rights{prefs}{ - @label:choose.prefs@ + @label:choose.prefs@ }@#
+ } + @credits diff --git a/templates/help.tmpl b/templates/help.tmpl index 86abea2..b5bd559 100644 --- a/templates/help.tmpl +++ b/templates/help.tmpl @@ -231,9 +231,12 @@ USA

Search

+
-

This screen allows you to search for keywords in track names. If you + TODO search is folded into choose now + +

This screen allows you to search for keywords in track names. If you specify more than one keyword then only tracks containing all of them are listed. Results are grouped by artist, album and title.

diff --git a/templates/macros.tmpl b/templates/macros.tmpl index 1a6554d..b471599 100644 --- a/templates/macros.tmpl +++ b/templates/macros.tmpl @@ -53,7 +53,6 @@ and then redefines macros as desired. {

@label:search.title@

- - - -
- @search{artist}{display}{ -
-

Artist: - @part:artist@

- @search{album}{display}{ -
-

Album: - @part:album@

- @search{title}{ -
-

Title: - @part:title@ - @if{@eq{@trackstate{@file@}@}{playing}@}{[playing]}@ - @if{@eq{@trackstate{@file@}@}{queued}@}{[queued]}@ -

-
- }@ -
- }@ -
- }@ -
- -@credits - - -@discard{ -Local variables: -mode:sgml -sgml-always-quote-attributes:nil -sgml-indent-step:1 -sgml-indent-data:t -indent-tabs-mode:nil -fill-column:79 -End: -}@#