--- trunk/installer-simple/functions/common-dialogs.sh 2014/01/07 12:54:43 2392 +++ trunk/installer-simple/functions/common-dialogs.sh 2014/01/07 13:47:35 2420 @@ -24,10 +24,10 @@ 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" @@ -39,6 +39,38 @@ --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 @@ -59,7 +91,7 @@ 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 @@ -92,7 +124,7 @@ 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 @@ -106,6 +138,53 @@ --passwordbox "${text}" "${height}" "${width}" } +menubox() +{ + 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} ]] && header="empty header: add -h yourheader" + [[ -z ${text} ]] && die "no text given" + [[ -z ${height} ]] && height=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