Contents of /trunk/installer-simple/functions/common-dialogs.sh
Parent Directory | Revision Log
Revision 2420 -
(show annotations)
(download)
(as text)
Tue Jan 7 13:47:35 2014 UTC (10 years, 8 months ago) by niro
File MIME type: application/x-sh
File size: 4561 byte(s)
Tue Jan 7 13:47:35 2014 UTC (10 years, 8 months ago) by niro
File MIME type: application/x-sh
File size: 4561 byte(s)
-moved welcome() and finish() to installer-dialogs and use messagebox()
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 | dialog \ |
35 | --colors \ |
36 | --title "${header}" \ |
37 | --backtitle "${TITLE}" \ |
38 | --ok-label "${OK_LABEL}" \ |
39 | --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() |
75 | { |
76 | local header |
77 | local text |
78 | local height |
79 | local width |
80 | |
81 | # very basic getops |
82 | local OPTIND opt |
83 | while getopts ":h:y:x:" opt |
84 | do |
85 | case ${opt} in |
86 | h) header="${OPTARG}" ;; |
87 | y) height="${OPTARG}" ;; |
88 | x) width="${OPTARG}" ;; |
89 | esac |
90 | done |
91 | shift $((OPTIND-1)) |
92 | text="$@" |
93 | |
94 | #[[ -z ${header} ]] && die "no header given" |
95 | [[ -z ${text} ]] && die "no text given" |
96 | [[ -z ${height} ]] && height=0 |
97 | [[ -z ${width} ]] && width=0 |
98 | |
99 | dialog \ |
100 | --stdout \ |
101 | --colors \ |
102 | --title "${header}" \ |
103 | --backtitle "${TITLE}" \ |
104 | --inputbox "${text}" "${height}" "${width}" |
105 | } |
106 | |
107 | passwordbox() |
108 | { |
109 | local header |
110 | local text |
111 | local height |
112 | local width |
113 | |
114 | # very basic getops |
115 | local OPTIND opt |
116 | while getopts ":h:y:x:" opt |
117 | do |
118 | case ${opt} in |
119 | h) header="${OPTARG}" ;; |
120 | y) height="${OPTARG}" ;; |
121 | x) width="${OPTARG}" ;; |
122 | esac |
123 | done |
124 | shift $((OPTIND-1)) |
125 | text="$@" |
126 | |
127 | #[[ -z ${header} ]] && die "no header given" |
128 | [[ -z ${text} ]] && die "no text given" |
129 | [[ -z ${height} ]] && height=0 |
130 | [[ -z ${width} ]] && width=0 |
131 | |
132 | dialog \ |
133 | --stdout \ |
134 | --colors \ |
135 | --title "${header}" \ |
136 | --backtitle "${TITLE}" \ |
137 | --insecure \ |
138 | --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() |
189 | { |
190 | local header |
191 | local text |
192 | local height |
193 | local width |
194 | |
195 | # very basic getops |
196 | local OPTIND opt |
197 | while getopts ":h:y:x:" opt |
198 | do |
199 | case ${opt} in |
200 | h) header="${OPTARG}" ;; |
201 | y) height="${OPTARG}" ;; |
202 | x) width="${OPTARG}" ;; |
203 | esac |
204 | done |
205 | shift $((OPTIND-1)) |
206 | text="$@" |
207 | |
208 | #[[ -z ${header} ]] && die "no header given" |
209 | [[ -z ${text} ]] && die "no text given" |
210 | [[ -z ${height} ]] && height=0 |
211 | [[ -z ${width} ]] && width=70 |
212 | |
213 | dialog \ |
214 | --colors \ |
215 | --title "${header}" \ |
216 | --backtitle "${TITLE}" \ |
217 | --gauge "${text}" "${height}" "${width}" |
218 | } |
219 | |
220 | yesnobox() |
221 | { |
222 | local header |
223 | local text |
224 | local height |
225 | local width |
226 | |
227 | # very basic getops |
228 | local OPTIND opt |
229 | while getopts ":h:y:x:" opt |
230 | do |
231 | case ${opt} in |
232 | h) header="${OPTARG}" ;; |
233 | y) height="${OPTARG}" ;; |
234 | x) width="${OPTARG}" ;; |
235 | esac |
236 | done |
237 | shift $((OPTIND-1)) |
238 | text="$@" |
239 | |
240 | #[[ -z ${header} ]] && die "no header given" |
241 | [[ -z ${text} ]] && die "no text given" |
242 | [[ -z ${height} ]] && height=0 |
243 | [[ -z ${width} ]] && width=0 |
244 | |
245 | dialog \ |
246 | --colors \ |
247 | --title "${header}" \ |
248 | --backtitle "${TITLE}" \ |
249 | --defaultno \ |
250 | --yesno "${text}" "${height}" "${width}" |
251 | } |