From 40d84859467d541438f8d3ccde44ee7d2ca58f8c Mon Sep 17 00:00:00 2001 From: Gerhard Brauer Date: Sat, 27 Jun 2009 14:42:09 +0200 Subject: dia_ask_yesno honors default value now Modified dia_ask_yesno to correctly handle an default value to preset the YES or NO button. Signed-off-by: Gerhard Brauer --- src/core/libs/lib-ui.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/core/libs') diff --git a/src/core/libs/lib-ui.sh b/src/core/libs/lib-ui.sh index c039a71..5d5e4de 100644 --- a/src/core/libs/lib-ui.sh +++ b/src/core/libs/lib-ui.sh @@ -439,11 +439,12 @@ _dia_ask_string () _dia_ask_yesno () { + local default height=$((`echo -e "$1" | wc -l` +7)) str=$1 - #TODO: i think dialog doesnt support a default value for yes/no, so we need this workaround: - [ -n "$2" ] && str="$str (default: $2)" - dialog --yesno "$str" $height 55 # returns 0 for yes, 1 for no + # If $2 contains an explicit 'no' we set defaultno for yesno dialog + [ "$2" == "no" ] && default="--defaultno" + dialog $default --yesno "$str" $height 55 # returns 0 for yes, 1 for no ret=$? [ $ret -eq 0 ] && debug 'UI' "dia_ask_yesno: User picked YES" [ $ret -gt 0 ] && debug 'UI' "dia_ask_yesno: User picked NO" -- cgit v1.2.3-54-g00ecf