diff options
Diffstat (limited to 'src/core/libs/lib-ui.sh')
-rw-r--r-- | src/core/libs/lib-ui.sh | 91 |
1 files changed, 45 insertions, 46 deletions
diff --git a/src/core/libs/lib-ui.sh b/src/core/libs/lib-ui.sh index 50d087a..c039a71 100644 --- a/src/core/libs/lib-ui.sh +++ b/src/core/libs/lib-ui.sh @@ -50,7 +50,7 @@ show_warning () debug 'UI' "show_warning '$1': $2 ($type)" if [ "$var_UI_TYPE" = dia ] then - _dia_DIALOG --title "$1" --exit-label "Continue" --${type}box "$2" 0 0 || die_error "dialog could not show --${type}box $2. often this means a file does not exist" + _dia_dialog --title "$1" --exit-label "Continue" --${type}box "$2" 0 0 || die_error "dialog could not show --${type}box $2. often this means a file does not exist" else echo "WARNING: $1" [ "${type}" = msg ] && echo -e "$2" @@ -67,7 +67,7 @@ notify () debug 'UI' "notify: $@" if [ "$var_UI_TYPE" = dia ] then - _dia_DIALOG --msgbox "$@" 0 0 + _dia_dialog --msgbox "$@" 0 0 else echo -e "$@" fi @@ -94,7 +94,7 @@ infofy () #TODO: when using successive things, the screen can become full and yo str=`cat $DIA_SUCCESSIVE_ITEMS-$successive` fi [ "$succ_last" = 1 ] && rm $DIA_SUCCESSIVE_ITEMS-$successive - _dia_DIALOG --infobox "$str" 0 0 + _dia_dialog --infobox "$str" 0 0 else echo -e "$1" fi @@ -160,6 +160,30 @@ _getavaildisks() } +# ask for a timezone. +# this is pretty similar to how tzselect looks, but we support dia+cli + we don't actually change the clock + we don't show a date/time and ask whether it's okay. that comes later. +ask_timezone () +{ + REGIONS="" + for i in $(grep '^[A-Z]' /usr/share/zoneinfo/zone.tab | cut -f 3 | sed -e 's#/.*##g'| sort -u); do + REGIONS="$REGIONS $i -" + done + while true; do + ask_option no "Please select a region" '' required $REGIONS + region=$ANSWER_OPTION + if [ $? -eq 0 ]; then + ZONES="" + for i in $(grep '^[A-Z]' /usr/share/zoneinfo/zone.tab | grep $region/ | cut -f 3 | sed -e "s#$region/##g"| sort -u); do + ZONES="$ZONES $i -" + done + ask_option no "Please select a timezone" '' required $ZONES + zone=$ANSWER_OPTION + [ $? -eq 0 ] && ANSWER_TIMEZONE="$region/$zone" && return + fi + done +} + + # ask the user to make a selection from a certain group of things # $1 question # shift;shift; $@ list of options. first tag, then item then ON/OFF. if item == ^ or - it will not be shown in cli mode. @@ -237,13 +261,6 @@ ask_string () } -ask_timezone () -{ - [ "$var_UI_TYPE" = dia ] && { _dia_ask_timezone "$@" ; return $? ; } - [ "$var_UI_TYPE" = cli ] && { _cli_ask_timezone "$@" ; return $? ; } -} - - # ask a yes/no question. # $1 question # $2 default answer yes/no (optional) @@ -285,7 +302,7 @@ follow_progress () # # parameters: see dialog(1) # returns: whatever dialog did -_dia_DIALOG() +_dia_dialog() { dialog --backtitle "$TITLE" --aspect 15 "$@" return $? @@ -305,7 +322,7 @@ _dia_ask_checklist () list="$list $1 $2 $3" shift 3 done - _dia_DIALOG --checklist "$str" 0 0 0 $list 2>$ANSWER + _dia_dialog --checklist "$str" 0 0 0 $list 2>$ANSWER ret=$? ANSWER_CHECKLIST=`cat $ANSWER` debug 'UI' "_dia_ask_checklist: user checked ON: $ANSWER_CHECKLIST" @@ -338,7 +355,7 @@ _dia_ask_number () [ -n $2 ] && str2="min $2" [ -n $3 -a $3 != '0' ] && str2="$str2 max $3" [ -n "$str2" ] && str="$str ( $str2 )" - _dia_DIALOG --inputbox "$str" 0 0 $4 2>$ANSWER + _dia_dialog --inputbox "$str" 0 0 $4 2>$ANSWER ret=$? ANSWER_NUMBER=`cat $ANSWER` if [[ $ANSWER_NUMBER = *[^0-9]* ]] #TODO: handle exit state @@ -377,7 +394,7 @@ _dia_ask_option () shift 4 CANCEL_LABEL=Cancel [ $TYPE == optional ] && CANCEL_LABEL='Skip' - _dia_DIALOG $DEFAULT --cancel-label $CANCEL_LABEL --colors --title " $DIA_MENU_TITLE " --menu "$DIA_MENU_TEXT $EXTRA_INFO" 0 0 0 "$@" 2>$ANSWER + _dia_dialog $DEFAULT --cancel-label $CANCEL_LABEL --colors --title " $DIA_MENU_TITLE " --menu "$DIA_MENU_TEXT $EXTRA_INFO" 0 0 0 "$@" 2>$ANSWER ret=$? ANSWER_OPTION=`cat $ANSWER` debug 'UI' "dia_ask_option: ANSWER_OPTION: $ANSWER_OPTION, returncode (skip/cancel): $ret ($DIA_MENU_TITLE)" @@ -397,7 +414,7 @@ _dia_ask_password () type_u= fi - _dia_DIALOG --passwordbox "Enter your $type_l password" 8 65 "$2" 2>$ANSWER + _dia_dialog --passwordbox "Enter your $type_l password" 8 65 "$2" 2>$ANSWER ret=$? [ -n "$type_u" ] && read ${type_u}_PASSWORD < $ANSWER [ -z "$type_u" ] && read PASSWORD < $ANSWER @@ -410,7 +427,7 @@ _dia_ask_password () _dia_ask_string () { exitcode=${3:-1} - _dia_DIALOG --inputbox "$1" 0 0 "$2" 2>$ANSWER + _dia_dialog --inputbox "$1" 0 0 "$2" 2>$ANSWER ret=$? ANSWER_STRING=`cat $ANSWER` debug 'UI' "_dia_ask_string: user entered $ANSWER_STRING" @@ -419,29 +436,6 @@ _dia_ask_string () } -_dia_ask_timezone () -{ - REGIONS="" - SET_ZONE="" - for i in $(grep ^[A-Z] /usr/share/zoneinfo/zone.tab | cut -f 3 | sed -e 's#/.*##g'| sort -u); do - REGIONS="$REGIONS $i -" - done - while [ "$SET_ZONE" != "1" ]; do - SET_REGION="" - ask_option no "Please select a region" '' required $REGIONS - region=ANSWER_OPTION - if [ $? -eq 0 ]; then - ZONES="" - for i in $(grep ^[A-Z] /usr/share/zoneinfo/zone.tab | grep $region/ | cut -f 3 | sed -e "s#$region/##g"| sort -u); do - ZONES="$ZONES $i -" - done - ask_option no "Please select a timezone" '' required $ZONES - zone=$ANSWER_OPTION - [ $? -gt 0 ] && ANSWER_TIMEZONE="$region/$zone" && return - fi - done -} - _dia_ask_yesno () { @@ -461,7 +455,18 @@ _dia_follow_progress () { title=$1 logfile=$2 - FOLLOW_PID=`_dia_DIALOG --title "$1" --no-kill --tailboxbg "$2" 0 0 2>&1 >/dev/null` + + _dia_dialog --title "$1" --no-kill --tailboxbg "$2" 0 0 2>$RUNTIME_DIR/aif-follow-pid + FOLLOW_PID=`cat $RUNTIME_DIR/aif-follow-pid` + rm $RUNTIME_DIR/aif-follow-pid + + # I wish something like this would work. anyone who can explain me why it doesn't get's to be aif contributor of the month. + # FOLLOW_PID=`_dia_dialog --title "$1" --no-kill --tailboxbg "$2" 0 0 2>&1 >/dev/null | head -n 1` + + # Also this doesn't work: + # _dia_dialog --title "$1" --no-kill --tailboxbg "$2" 0 0 &>/dev/null & + # FOLLOW_PID=$! + } @@ -611,12 +616,6 @@ _cli_ask_string () } -_cli_ask_timezone () -{ - ANSWER_TIMEZONE=`tzselect` -} - - _cli_ask_yesno () { [ -z "$2" ] && echo -n "$1 (y/n): " |