Magellan Linux

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

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

revision 2389 by niro, Tue Jan 7 12:44:17 2014 UTC revision 2452 by niro, Tue Jan 7 15:03:12 2014 UTC
# Line 6  CANCEL_LABEL=$"Back" Line 6  CANCEL_LABEL=$"Back"
6  # common dialog boxes  # common dialog boxes
7  messagebox()  messagebox()
8  {  {
9   local header="$1"   local header
10   local text="$2"   local text
11   local height="$3"   local height
12   local width="$4"   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"   #[[ -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    
34     echo "DEBUG: paused" >&2; read
35   dialog \   dialog \
36   --colors \   --colors \
37   --title "${header}" \   --title "${header}" \
# Line 26  messagebox() Line 40  messagebox()
40   --msgbox "${text}" "${height}" "${width}"   --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()  inputbox()
77  {  {
78   local header="$1"   local header
79   local text="$2"   local text
80   local height="$3"   local height
81   local width="$4"   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"   #[[ -z ${header} ]] && die "no header given"
97   [[ -z ${text} ]] && die "no text given"   [[ -z ${text} ]] && die "no text given"
98   [[ -z ${height} ]] && height=0   [[ -z ${height} ]] && height=0
99   [[ -z ${width} ]] && width=0   [[ -z ${width} ]] && width=0
100    
101     echo "DEBUG: paused" >&2; read
102   dialog \   dialog \
103   --stdout \   --stdout \
104   --colors \   --colors \
# Line 48  inputbox() Line 109  inputbox()
109    
110  passwordbox()  passwordbox()
111  {  {
112   local header="$1"   local header
113   local text="$2"   local text
114   local height="$3"   local height
115   local width="$4"   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"   #[[ -z ${header} ]] && die "no header given"
131   [[ -z ${text} ]] && die "no text given"   [[ -z ${text} ]] && die "no text given"
132   [[ -z ${height} ]] && height=0   [[ -z ${height} ]] && height=0
133   [[ -z ${width} ]] && width=0   [[ -z ${width} ]] && width=0
134    
135     echo "DEBUG: paused" >&2; read
136   dialog \   dialog \
137   --stdout \   --stdout \
138   --colors \   --colors \
# Line 67  passwordbox() Line 142  passwordbox()
142   --passwordbox "${text}" "${height}" "${width}"   --passwordbox "${text}" "${height}" "${width}"
143  }  }
144    
145  gauge()  menubox()
146  {  {
147   local header="$1"   local header
148   local text="$2"   local text
149   local height="$3"   local height
150   local width="$4"   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} ]] && die "no header given"   #[[ -z ${header} ]] && header="empty header: add -h yourheader"
173   [[ -z ${text} ]] && die "no text given"   [[ -z ${text} ]] && die "no text given"
174   [[ -z ${height} ]] && height=0   [[ -z ${height} ]] && height=0
175   [[ -z ${width} ]] && width=0   [[ -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 \   dialog \
220   --colors \   --colors \
221   --title "${header}" \   --title "${header}" \
# Line 86  gauge() Line 223  gauge()
223   --gauge "${text}" "${height}" "${width}"   --gauge "${text}" "${height}" "${width}"
224  }  }
225    
226  yesno()  yesnobox()
227  {  {
228   local header="$1"   local header
229   local text="$2"   local text
230   local height="$3"   local height
231   local width="$4"   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"   #[[ -z ${header} ]] && die "no header given"
247   [[ -z ${text} ]] && die "no text given"   [[ -z ${text} ]] && die "no text given"
248   [[ -z ${height} ]] && height=0   [[ -z ${height} ]] && height=0
249   [[ -z ${width} ]] && width=0   [[ -z ${width} ]] && width=0
250    
251     echo "DEBUG: paused" >&2; read
252   dialog \   dialog \
253   --colors \   --colors \
254   --title "${header}" \   --title "${header}" \
# Line 105  yesno() Line 256  yesno()
256   --defaultno \   --defaultno \
257   --yesno "${text}" "${height}" "${width}"   --yesno "${text}" "${height}" "${width}"
258  }  }
   
 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.2389  
changed lines
  Added in v.2452