--- trunk/installer-simple/functions/common-dialogs.sh 2014/01/07 12:44:17 2389 +++ trunk/installer-simple/functions/common-dialogs.sh 2014/01/07 13:47:35 2420 @@ -6,15 +6,28 @@ # common dialog boxes messagebox() { - local header="$1" - local text="$2" - local height="$3" - local width="$4" + local header + local text + local height + local width + + # very basic getops + local OPTIND opt + while getopts ":h:y:x:" opt + do + case ${opt} in + h) header="${OPTARG}" ;; + y) height="${OPTARG}" ;; + x) width="${OPTARG}" ;; + esac + done + shift $((OPTIND-1)) + text="$@" - [[ -z ${header} ]] && die "no header given" + #[[ -z ${header} ]] && die "no header given" [[ -z ${text} ]] && die "no text given" - [[ -z ${height} ]] && height=0 - [[ -z ${width} ]] && width=0 + [[ -z ${height} ]] && height=8 + [[ -z ${width} ]] && width=70 [[ -z ${OK_LABEL} ]] && OK_LABEL="Next" @@ -26,14 +39,59 @@ --msgbox "${text}" "${height}" "${width}" } +infobox() +{ + local header + local text + local height + local width + + # very basic getops + local OPTIND opt + while getopts ":h:y:x:" opt + do + case ${opt} in + h) header="${OPTARG}" ;; + y) height="${OPTARG}" ;; + x) width="${OPTARG}" ;; + esac + done + shift $((OPTIND-1)) + text="$@" + + #[[ -z ${header} ]] && die "no header given" + [[ -z ${text} ]] && die "no text given" + [[ -z ${height} ]] && height=3 + [[ -z ${width} ]] && width=70 + + dialog \ + --colors \ + --title "${header}" \ + --backtitle "${TITLE}" \ + --infobox "${text}" "${height}" "${width}" +} + inputbox() { - local header="$1" - local text="$2" - local height="$3" - local width="$4" + local header + local text + local height + local width + + # very basic getops + local OPTIND opt + while getopts ":h:y:x:" opt + do + case ${opt} in + h) header="${OPTARG}" ;; + y) height="${OPTARG}" ;; + x) width="${OPTARG}" ;; + esac + done + shift $((OPTIND-1)) + text="$@" - [[ -z ${header} ]] && die "no header given" + #[[ -z ${header} ]] && die "no header given" [[ -z ${text} ]] && die "no text given" [[ -z ${height} ]] && height=0 [[ -z ${width} ]] && width=0 @@ -48,12 +106,25 @@ passwordbox() { - local header="$1" - local text="$2" - local height="$3" - local width="$4" + local header + local text + local height + local width + + # very basic getops + local OPTIND opt + while getopts ":h:y:x:" opt + do + case ${opt} in + h) header="${OPTARG}" ;; + y) height="${OPTARG}" ;; + x) width="${OPTARG}" ;; + esac + done + shift $((OPTIND-1)) + text="$@" - [[ -z ${header} ]] && die "no header given" + #[[ -z ${header} ]] && die "no header given" [[ -z ${text} ]] && die "no text given" [[ -z ${height} ]] && height=0 [[ -z ${width} ]] && width=0 @@ -67,17 +138,77 @@ --passwordbox "${text}" "${height}" "${width}" } -gauge() +menubox() { - local header="$1" - local text="$2" - local height="$3" - local width="$4" + local header + local text + local height + local width + local items + local index + local dialog_opts + + # very basic getops + local OPTIND opt + while getopts ":h:y:x:i:n" opt + do + case ${opt} in + n) dialog_opts+=" --no-cancel" ;; + h) header="${OPTARG}" ;; + y) height="${OPTARG}" ;; + x) width="${OPTARG}" ;; + esac + done + shift $((OPTIND-1)) + text="$1" + shift + items=( "$@" ) + index="${#items[*]}" - [[ -z ${header} ]] && die "no header given" + #[[ -z ${header} ]] && header="empty header: add -h yourheader" [[ -z ${text} ]] && die "no text given" [[ -z ${height} ]] && height=0 - [[ -z ${width} ]] && width=0 + [[ -z ${width} ]] && width=70 + + [[ -z ${OK_LABEL} ]] && OK_LABEL="Next" + [[ -z ${CANCEL_LABEL} ]] && CANCEL_LABEL="Back" + + eval dialog \ + --stdout \ + --colors \ + --title "'${header}'" \ + --backtitle "'${TITLE}'" \ + --ok-label "'${OK_LABEL}'" \ + --cancel-label "'${CANCEL_LABEL}'" \ + "${dialog_opts}" \ + --menu "'${text}'" "${height}" "${width}" "${index}" \ + $(for ((i=0;i