diff options
author | Gerhard Brauer <gerbra@archlinux.de> | 2009-06-27 14:42:09 +0200 |
---|---|---|
committer | Dieter Plaetinck <dieter@plaetinck.be> | 2009-06-27 19:57:17 +0200 |
commit | 40d84859467d541438f8d3ccde44ee7d2ca58f8c (patch) | |
tree | e6d91e05683474c1f8106735f4d750c758932137 | |
parent | 07b421951a8229f4f9022ada0b31c081d43a4761 (diff) |
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 <gerbra@archlinux.de>
-rw-r--r-- | src/core/libs/lib-ui.sh | 7 |
1 files changed, 4 insertions, 3 deletions
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" |