Magellan Linux

Diff of /trunk/installer-simple/functions/common-dialogs.sh

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2393 by niro, Tue Jan 7 12:56:52 2014 UTC revision 2420 by niro, Tue Jan 7 13:47:35 2014 UTC
# Line 26  messagebox() Line 26  messagebox()
26    
27   #[[ -z ${header} ]] && die "no header given"   #[[ -z ${header} ]] && die "no header given"
28   [[ -z ${text} ]] && die "no text given"   [[ -z ${text} ]] && die "no text given"
29   [[ -z ${height} ]] && height=0   [[ -z ${height} ]] && height=8
30   [[ -z ${width} ]] && width=0   [[ -z ${width} ]] && width=70
31    
32   [[ -z ${OK_LABEL} ]] && OK_LABEL="Next"   [[ -z ${OK_LABEL} ]] && OK_LABEL="Next"
33    
# Line 39  messagebox() Line 39  messagebox()
39   --msgbox "${text}" "${height}" "${width}"   --msgbox "${text}" "${height}" "${width}"
40  }  }
41    
42    infobox()
43    {
44     local header
45     local text
46     local height
47     local width
48    
49     # very basic getops
50     local OPTIND opt
51     while getopts ":h:y:x:" opt
52     do
53     case ${opt} in
54     h) header="${OPTARG}" ;;
55     y) height="${OPTARG}" ;;
56     x) width="${OPTARG}" ;;
57     esac
58     done
59     shift $((OPTIND-1))
60     text="$@"
61    
62     #[[ -z ${header} ]] && die "no header given"
63     [[ -z ${text} ]] && die "no text given"
64     [[ -z ${height} ]] && height=3
65     [[ -z ${width} ]] && width=70
66    
67     dialog \
68     --colors \
69     --title "${header}" \
70     --backtitle "${TITLE}" \
71     --infobox "${text}" "${height}" "${width}"
72    }
73    
74  inputbox()  inputbox()
75  {  {
76   local header   local header
# Line 106  passwordbox() Line 138  passwordbox()
138   --passwordbox "${text}" "${height}" "${width}"   --passwordbox "${text}" "${height}" "${width}"
139  }  }
140    
141    menubox()
142    {
143     local header
144     local text
145     local height
146     local width
147     local items
148     local index
149     local dialog_opts
150    
151     # very basic getops
152     local OPTIND opt
153     while getopts ":h:y:x:i:n" opt
154     do
155     case ${opt} in
156     n) dialog_opts+=" --no-cancel" ;;
157     h) header="${OPTARG}" ;;
158     y) height="${OPTARG}" ;;
159     x) width="${OPTARG}" ;;
160     esac
161     done
162     shift $((OPTIND-1))
163     text="$1"
164     shift
165     items=( "$@" )
166     index="${#items[*]}"
167    
168     #[[ -z ${header} ]] && header="empty header: add -h yourheader"
169     [[ -z ${text} ]] && die "no text given"
170     [[ -z ${height} ]] && height=0
171     [[ -z ${width} ]] && width=70
172    
173     [[ -z ${OK_LABEL} ]] && OK_LABEL="Next"
174     [[ -z ${CANCEL_LABEL} ]] && CANCEL_LABEL="Back"
175    
176     eval dialog \
177     --stdout \
178     --colors \
179     --title "'${header}'" \
180     --backtitle "'${TITLE}'" \
181     --ok-label "'${OK_LABEL}'" \
182     --cancel-label "'${CANCEL_LABEL}'" \
183     "${dialog_opts}" \
184     --menu "'${text}'" "${height}" "${width}" "${index}" \
185     $(for ((i=0;i<index;i++)); do echo "'${items[${i}]%%:*}'";echo "'${items[${i}]#*:}'"; done)
186    }
187    
188  gaugebox()  gaugebox()
189  {  {
190   local header   local header
# Line 129  gaugebox() Line 208  gaugebox()
208   #[[ -z ${header} ]] && die "no header given"   #[[ -z ${header} ]] && die "no header given"
209   [[ -z ${text} ]] && die "no text given"   [[ -z ${text} ]] && die "no text given"
210   [[ -z ${height} ]] && height=0   [[ -z ${height} ]] && height=0
211   [[ -z ${width} ]] && width=0   [[ -z ${width} ]] && width=70
212    
213   dialog \   dialog \
214   --colors \   --colors \
# Line 170  yesnobox() Line 249  yesnobox()
249   --defaultno \   --defaultno \
250   --yesno "${text}" "${height}" "${width}"   --yesno "${text}" "${height}" "${width}"
251  }  }
   
 welcome() { messagebox "Welcome" "Welcome to the ${DEFAULT_TITLE}.\n\n\nPress [Enter] to continue." 10 45; }  
 finish() { OK_LABEL="Exit" messagebox "Finish" "Installation was successfully finished." 10 40; }  

Legend:
Removed from v.2393  
changed lines
  Added in v.2420