3 # copyright 2002 lmoore@tump.com under the terms of the GNU LGPL.
5 # whiptail has trouble being called in the foo=$(whiptail ...) fashion for
6 # some reason. this is very annoying. this means that we need to use
7 # temporary files to store the answers from the input and list based boxes
8 # and then read the answers into a REPLY variable. that just really
9 # stinks, oh well, that's what you get when you have a weak link
12 # inputBox and passwordBox could be refactored to use a common function
14 test -z "$WIDTH" && WIDTH=0
15 test -z "$HEIGHT" && HEIGHT=0
20 setApplicationTitle() {
34 $DIALOG --backtitle "$BACKTITLE" --title "$1" \
35 --yesno "$2" $HEIGHT $WIDTH
39 $DIALOG --backtitle "$BACKTITLE" --title "$1" \
40 --msgbox "$2" $HEIGHT $WIDTH
44 $DIALOG --backtitle "$BACKTITLE" --title "$1" \
45 --gauge "$2" $HEIGHT $WIDTH 0
49 local temp=$(mktemp -t) || exit 1
52 $DIALOG --backtitle "$BACKTITLE" --title "$1" \
53 --inputbox "$2" $HEIGHT $WIDTH "$3" 2> $temp
55 [ $status = 0 ] && REPLY=$(cat $temp)
60 # Xdialog and {dialog,whiptail} use different mechanism to "qoute" the
61 # values from a checklist. {dialog,whiptail} uses standard double quoting
62 # while Xdialog uses a "/" as the separator. the slash is arguably better,
63 # but the double quoting is more standard. anyway, this function can be
64 # overridden to allow a derived implementation to change it's quoting
65 # mechanism to the standard double-quoting one. it receives two
66 # arguements, the file that has the data and the box type.
71 # this is the base implementation of all the list based boxes, it works
72 # out nicely that way. the real function just passes it's arguments to
73 # this function with an extra argument specifying the actual box that
74 # needs to be rendered.
81 local temp=$(mktemp -t) || exit 1
84 $DIALOG $HELP --backtitle "$BACKTITLE" --title "$title" \
85 $box "$text" $HEIGHT $WIDTH 10 \
88 [ $status = 0 ] && REPLY=$(_listReplyHook $temp $box)
94 _genericListBox --menu "$@"
99 _genericListBox --menu "$@"
107 _genericListBox --menu "$@"
115 _genericListBox --checklist "$@"
119 _genericListBox --radiolist "$@"
123 $DIALOG --backtitle "$BACKTITLE" --title "$1" --textbox "$2" $HEIGHT $WIDTH
127 local temp=$(mktemp -t) || exit 1
130 $DIALOG --backtitle "$BACKTITLE" --title "$1" \
131 --passwordbox "$2" $HEIGHT $WIDTH 2> $temp
133 [ $status = 0 ] && REPLY=$(cat $temp)
147 _form_labels[$_form_items]=$1
148 _form_text[$_form_items]=$2
149 let "_form_items += 1"
153 local temp=$(mktemp -t) || exit 1
156 for ((i=0; i < ${#_form_labels[@]} ; i++)); do
157 label=${_form_labels[$i]}
158 length=`expr length $label`
159 if [ $length -gt $max_length ]; then
163 let "max_length += 2"
168 echo -n -e "--form '$_form_title' 0 0 20"
169 for ((i=0; i < $_form_items ; i++)); do
170 label=${_form_labels[$i]}
171 text=${_form_text[$i]}
172 if [ "$text" == "" ]; then
175 echo -n -e "$form $label $xpos 1 '$text' $xpos $max_length 30 30"
176 let "xpos += _form_gap"
178 ) | xargs $DIALOG 2> $temp
180 [ $status = 0 ] && REPLY=`cat $temp`