From af106f2dee658f1605891b4c69ca1036946c5147 Mon Sep 17 00:00:00 2001 Message-Id: From: Mark Wooding Date: Sun, 11 May 2008 15:04:08 +0100 Subject: [PATCH] extended @movable expansion; more template... Organization: Straylight/Edgeware From: Richard Kettlewell --- server/macros-disorder.c | 21 +++- templates/macros.tmpl | 15 +++ templates/playing.tmpl | 224 ++++++++++++++++----------------------- 3 files changed, 124 insertions(+), 136 deletions(-) diff --git a/server/macros-disorder.c b/server/macros-disorder.c index 6c81d56..8b5b486 100644 --- a/server/macros-disorder.c +++ b/server/macros-disorder.c @@ -265,11 +265,16 @@ static int exp_removable(int attribute((unused)) nargs, (dcgi_rights, disorder_user(dcgi_client), q)); } -/* @movable{ID} +/* @movable{ID}{DIR} * * Expands to "true" if track ID is movable and "false" otherwise. + * + * DIR (which is optional) should be a non-zero integer. If it is negative + * then the intended move is down (later in the queue), if it is positive then + * the intended move is up (earlier in the queue). The first track is not + * movable up and the last track not movable down. */ -static int exp_movable(int attribute((unused)) nargs, +static int exp_movable(int nargs, char **args, struct sink *output, void attribute((unused)) *u) { @@ -278,9 +283,19 @@ static int exp_movable(int attribute((unused)) nargs, if(!q || !dcgi_client) return mx_bool_result(output, 0); + if(nargs > 1) { + const long dir = atoi(args[1]); + + if(dir > 0 && q == dcgi_queue) + return mx_bool_result(output, 0); + if(dir < 0 && q->next == 0) + return mx_bool_result(output, 0); + } dcgi_lookup(DCGI_RIGHTS); return mx_bool_result(output, - right_movable(dcgi_rights, disorder_user(dcgi_client), q)); + right_movable(dcgi_rights, + disorder_user(dcgi_client), + q)); } /* @playing{TEMPLATE} diff --git a/templates/macros.tmpl b/templates/macros.tmpl index 8714a08..7c10938 100644 --- a/templates/macros.tmpl +++ b/templates/macros.tmpl @@ -75,4 +75,19 @@ USA title="@label{@what.removeverbose}" alt="@label{@what.scratch}">}} +@# Expand to a move button +@# @dir should be a direction: up, upall, down or downall +@# @delta should be the distance, +ve for up and -ve for down +@# This macro calls @movable to check that the move is possible. +@define {mmove} {id dir delta} + {@if{@movable{@id}{@delta}} + { + @label{playing.@dir} + } + {@label{playing.@dir}}} }@# diff --git a/templates/playing.tmpl b/templates/playing.tmpl index d0e0000..c910120 100644 --- a/templates/playing.tmpl +++ b/templates/playing.tmpl @@ -36,60 +36,61 @@ USA @ifmanage{

- @if{@paused}{ + @if{@paused}{ @# Paused - @label{playing.pause} - - - }{ + + + }{ @# Not paused - @label{playing.pause} - - - } - @if{@random-enabled}{ + @label{playing.pause} + + + } + @if{@random-enabled}{ @# Random play enabled - @label{playing.random} - - - }{ + @label{playing.random} + + + }{ @# Random play disabled - @label{playing.random} - - - } - @if{@enabled}{ + + + } + @if{@enabled}{ @# Play enabled - @label{playing.playing} - - - }{ + @label{playing.playing} + + + }{ @# Play disabled - @label{playing.playing} - - - } + @label{playing.playing} + + + } @# Volume form -

- + + @label{playing.volume} @# Volume up button @right{volume}{ + href="@url?action=volume&delta=-@label{volume.resolution}@back"> @label{volume.reduce} @@ -98,14 +99,17 @@ USA } @# Volume value widgets - @label{volume.left} - @label{volume.right} + @label{volume.left} + @label{volume.right} @# Volume set button @right{volume}{ + @label{volume.set} + + } @# Volume down button @right{volume}{ @@ -137,101 +141,55 @@ USA @label{heading.length}   @ifmanage{ -   -   -   -   +   +   +   +   }{} + @if{@isplaying}{ + + @label{playing.now} + + } @playing{ - - @label{playing.now} - - - @mwhen{playing}{@id} - @mwho{playing}{@id} - @martist{playing}{@track} - @malbum{playing}{@track} - @mtitle{playing}{@track} - @length{@id} - @mremove{playing}{@id} - @ifmanage{ -   -   -   -   - }{} - + + @mwhen{playing}{@id} + @mwho{playing}{@id} + @martist{playing}{@track} + @malbum{playing}{@track} + @mtitle{playing}{@track} + @length{@id} + @mremove{playing}{@id} + @ifmanage{ +   +   +   +   + }{} + } @if{@isqueue@}{ - - @label{playing.next} - + + @label{playing.next} + } @queue{ - - @mwhen{queue}{@id} - @mwho{queue}{@id} - @martist{queue}{@track} - @malbum{queue}{@track} - @mtitle{queue}{@track} - @length - @mremove{queue}{@id} - - @if{@eq{@arg{action}}{manage}}{ - @if{@or{@isfirst@} - {@not{@movable@}@}@}{ - - - - - - }{ - - - @label{playing.upall} - - @label{playing.up} - } - - @if{@or{@islast@} - {@not{@movable@}@}@}{ - - - - - - }{ - - - @label{playing.downall} - - @label{playing.down} - } - } - + + @mwhen{queue}{@id} + @mwho{queue}{@id} + @martist{queue}{@track} + @malbum{queue}{@track} + @mtitle{queue}{@track} + @length + @mremove{queue}{@id} + @ifmanage{ + @mmove{@id}{upall}{2147483647} + @mmove{@id}{up}{1} + @mmove{@id}{down}{-1} + @mmove{@id}{downall}{-2147483647} + } + } } -- [mdw]