diff options
author | Dieter Plaetinck <dieter@plaetinck.be> | 2008-11-03 14:55:19 +0100 |
---|---|---|
committer | Dieter Plaetinck <dieter@plaetinck.be> | 2008-11-03 14:55:19 +0100 |
commit | 6e0e1ab2c395ceaadcdde0cf8a4fb8c0bc639265 (patch) | |
tree | 27264b04c581ea895e86bb0bfab5d4187abb8437 /src/core/libs | |
parent | 74dafa4f7bb98a3b629f9b3c76f711803085e14d (diff) |
moved some UI functions from fifa.sh to lib-ui (yeay) + some fixes
Diffstat (limited to 'src/core/libs')
-rw-r--r-- | src/core/libs/lib-ui.sh | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/core/libs/lib-ui.sh b/src/core/libs/lib-ui.sh index f012f05..f465645 100644 --- a/src/core/libs/lib-ui.sh +++ b/src/core/libs/lib-ui.sh @@ -9,6 +9,46 @@ ANSWER="/home/arch/fifa/runtime/.dialog-answer" ### Functions that your code can use. Cli/dialog mode is fully transparant. This library takes care of it ### +# display error message and die +die_error () +{ + notify "ERROR: $@" + exit 2 +} + + +# display warning message +# $1 title +# $2 item to show +# $3 type of item. msg or text if it's a file. (optional. defaults to msg) +show_warning () +{ + [ -z "$1" ] && die_error "show_warning needs a title" + [ -z "$2" ] && die_error "show_warning needs an item to show" + [ -n "$3" -a "$3" != msg -a "$3" != text ] && die_error "show_warning \$3 must be text or msg" + [ -z "$3" ] && 3=msg + if [ "$var_UI_TYPE" = dia ] + then + _dia_DIALOG --title "$1" --exit-label "Continue" --$3box "$2" 18 70 || die_error "dialog could not show --$3box $2. often this means a file does not exist" + else + echo "WARNING: $1" + [ "$3" = msg ] && echo -e "$2" + [ "$3" = text ] && cat $2 || die_error "Could not cat $2" + fi +} + + +#notify user +notify () +{ + if [ "$var_UI_TYPE" = dia ] + then + _dia_DIALOG --msgbox "$@" 20 50 + else + echo -e "$@" + fi +} + # ask the user a password. return is stored in $PASSWORD or $<TYPE>_PASSWORD # $1 type (optional. eg 'svn', 'ssh'). |