Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2452 - (show annotations) (download) (as text)
Tue Jan 7 15:03:12 2014 UTC (10 years, 3 months ago) by niro
File MIME type: application/x-sh
File size: 4785 byte(s)
-apply SYSCONFDIR
1 # $Id$
2
3 OK_LABEL=$"Next"
4 CANCEL_LABEL=$"Back"
5
6 # common dialog boxes
7 messagebox()
8 {
9 local header
10 local text
11 local height
12 local width
13
14 # very basic getops
15 local OPTIND opt
16 while getopts ":h:y:x:" opt
17 do
18 case ${opt} in
19 h) header="${OPTARG}" ;;
20 y) height="${OPTARG}" ;;
21 x) width="${OPTARG}" ;;
22 esac
23 done
24 shift $((OPTIND-1))
25 text="$@"
26
27 #[[ -z ${header} ]] && die "no header given"
28 [[ -z ${text} ]] && die "no text given"
29 [[ -z ${height} ]] && height=8
30 [[ -z ${width} ]] && width=70
31
32 [[ -z ${OK_LABEL} ]] && OK_LABEL="Next"
33
34 echo "DEBUG: paused" >&2; read
35 dialog \
36 --colors \
37 --title "${header}" \
38 --backtitle "${TITLE}" \
39 --ok-label "${OK_LABEL}" \
40 --msgbox "${text}" "${height}" "${width}"
41 }
42
43 infobox()
44 {
45 local header
46 local text
47 local height
48 local width
49
50 # very basic getops
51 local OPTIND opt
52 while getopts ":h:y:x:" opt
53 do
54 case ${opt} in
55 h) header="${OPTARG}" ;;
56 y) height="${OPTARG}" ;;
57 x) width="${OPTARG}" ;;
58 esac
59 done
60 shift $((OPTIND-1))
61 text="$@"
62
63 #[[ -z ${header} ]] && die "no header given"
64 [[ -z ${text} ]] && die "no text given"
65 [[ -z ${height} ]] && height=3
66 [[ -z ${width} ]] && width=70
67
68 echo "DEBUG: paused" >&2; read
69 dialog \
70 --colors \
71 --title "${header}" \
72 --backtitle "${TITLE}" \
73 --infobox "${text}" "${height}" "${width}"
74 }
75
76 inputbox()
77 {
78 local header
79 local text
80 local height
81 local width
82
83 # very basic getops
84 local OPTIND opt
85 while getopts ":h:y:x:" opt
86 do
87 case ${opt} in
88 h) header="${OPTARG}" ;;
89 y) height="${OPTARG}" ;;
90 x) width="${OPTARG}" ;;
91 esac
92 done
93 shift $((OPTIND-1))
94 text="$@"
95
96 #[[ -z ${header} ]] && die "no header given"
97 [[ -z ${text} ]] && die "no text given"
98 [[ -z ${height} ]] && height=0
99 [[ -z ${width} ]] && width=0
100
101 echo "DEBUG: paused" >&2; read
102 dialog \
103 --stdout \
104 --colors \
105 --title "${header}" \
106 --backtitle "${TITLE}" \
107 --inputbox "${text}" "${height}" "${width}"
108 }
109
110 passwordbox()
111 {
112 local header
113 local text
114 local height
115 local width
116
117 # very basic getops
118 local OPTIND opt
119 while getopts ":h:y:x:" opt
120 do
121 case ${opt} in
122 h) header="${OPTARG}" ;;
123 y) height="${OPTARG}" ;;
124 x) width="${OPTARG}" ;;
125 esac
126 done
127 shift $((OPTIND-1))
128 text="$@"
129
130 #[[ -z ${header} ]] && die "no header given"
131 [[ -z ${text} ]] && die "no text given"
132 [[ -z ${height} ]] && height=0
133 [[ -z ${width} ]] && width=0
134
135 echo "DEBUG: paused" >&2; read
136 dialog \
137 --stdout \
138 --colors \
139 --title "${header}" \
140 --backtitle "${TITLE}" \
141 --insecure \
142 --passwordbox "${text}" "${height}" "${width}"
143 }
144
145 menubox()
146 {
147 local header
148 local text
149 local height
150 local width
151 local items
152 local index
153 local dialog_opts
154
155 # very basic getops
156 local OPTIND opt
157 while getopts ":h:y:x:i:n" opt
158 do
159 case ${opt} in
160 n) dialog_opts+=" --no-cancel" ;;
161 h) header="${OPTARG}" ;;
162 y) height="${OPTARG}" ;;
163 x) width="${OPTARG}" ;;
164 esac
165 done
166 shift $((OPTIND-1))
167 text="$1"
168 shift
169 items=( "$@" )
170 index="${#items[*]}"
171
172 #[[ -z ${header} ]] && header="empty header: add -h yourheader"
173 [[ -z ${text} ]] && die "no text given"
174 [[ -z ${height} ]] && height=0
175 [[ -z ${width} ]] && width=70
176
177 [[ -z ${OK_LABEL} ]] && OK_LABEL="Next"
178 [[ -z ${CANCEL_LABEL} ]] && CANCEL_LABEL="Back"
179
180 echo "DEBUG: paused" >&2; read
181 eval dialog \
182 --stdout \
183 --colors \
184 --title "'${header}'" \
185 --backtitle "'${TITLE}'" \
186 --ok-label "'${OK_LABEL}'" \
187 --cancel-label "'${CANCEL_LABEL}'" \
188 "${dialog_opts}" \
189 --menu "'${text}'" "${height}" "${width}" "${index}" \
190 $(for ((i=0;i<index;i++)); do echo "'${items[${i}]%%:*}'";echo "'${items[${i}]#*:}'"; done)
191 }
192
193 gaugebox()
194 {
195 local header
196 local text
197 local height
198 local width
199
200 # very basic getops
201 local OPTIND opt
202 while getopts ":h:y:x:" opt
203 do
204 case ${opt} in
205 h) header="${OPTARG}" ;;
206 y) height="${OPTARG}" ;;
207 x) width="${OPTARG}" ;;
208 esac
209 done
210 shift $((OPTIND-1))
211 text="$@"
212
213 #[[ -z ${header} ]] && die "no header given"
214 [[ -z ${text} ]] && die "no text given"
215 [[ -z ${height} ]] && height=0
216 [[ -z ${width} ]] && width=70
217
218 echo "DEBUG: paused" >&2; read
219 dialog \
220 --colors \
221 --title "${header}" \
222 --backtitle "${TITLE}" \
223 --gauge "${text}" "${height}" "${width}"
224 }
225
226 yesnobox()
227 {
228 local header
229 local text
230 local height
231 local width
232
233 # very basic getops
234 local OPTIND opt
235 while getopts ":h:y:x:" opt
236 do
237 case ${opt} in
238 h) header="${OPTARG}" ;;
239 y) height="${OPTARG}" ;;
240 x) width="${OPTARG}" ;;
241 esac
242 done
243 shift $((OPTIND-1))
244 text="$@"
245
246 #[[ -z ${header} ]] && die "no header given"
247 [[ -z ${text} ]] && die "no text given"
248 [[ -z ${height} ]] && height=0
249 [[ -z ${width} ]] && width=0
250
251 echo "DEBUG: paused" >&2; read
252 dialog \
253 --colors \
254 --title "${header}" \
255 --backtitle "${TITLE}" \
256 --defaultno \
257 --yesno "${text}" "${height}" "${width}"
258 }