Magellan Linux

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

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

trunk/installer-simple/functions/common.sh revision 2337 by niro, Fri Jan 3 14:12:35 2014 UTC trunk/installer-simple/functions/common-dialogs.sh revision 2396 by niro, Tue Jan 7 13:01:02 2014 UTC
# Line 1  Line 1 
1  # $Id$  # $Id$
2    
3    OK_LABEL=$"Next"
4    CANCEL_LABEL=$"Back"
5    
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    
# Line 23  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="$1"   local header
77   local text="$2"   local text
78   local height="$3"   local height
79   local width="$4"   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"   #[[ -z ${header} ]] && die "no header given"
95   [[ -z ${text} ]] && die "no text given"   [[ -z ${text} ]] && die "no text given"
96   [[ -z ${height} ]] && height=0   [[ -z ${height} ]] && height=0
97   [[ -z ${width} ]] && width=0   [[ -z ${width} ]] && width=0
# Line 45  inputbox() Line 106  inputbox()
106    
107  passwordbox()  passwordbox()
108  {  {
109   local header="$1"   local header
110   local text="$2"   local text
111   local height="$3"   local height
112   local width="$4"   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"   #[[ -z ${header} ]] && die "no header given"
128   [[ -z ${text} ]] && die "no text given"   [[ -z ${text} ]] && die "no text given"
129   [[ -z ${height} ]] && height=0   [[ -z ${height} ]] && height=0
130   [[ -z ${width} ]] && width=0   [[ -z ${width} ]] && width=0
# Line 64  passwordbox() Line 138  passwordbox()
138   --passwordbox "${text}" "${height}" "${width}"   --passwordbox "${text}" "${height}" "${width}"
139  }  }
140    
141  gauge()  menubox()
142  {  {
143   local header="$1"   local header
144   local text="$2"   local text
145   local height="$3"   local height
146   local width="$4"   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} ]] && die "no header given"   #[[ -z ${header} ]] && header="empty header: add -h yourheader"
169   [[ -z ${text} ]] && die "no text given"   [[ -z ${text} ]] && die "no text given"
170   [[ -z ${height} ]] && height=0   [[ -z ${height} ]] && height=0
171   [[ -z ${width} ]] && width=0   [[ -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 \   dialog \
214   --colors \   --colors \
# Line 83  gauge() Line 217  gauge()
217   --gauge "${text}" "${height}" "${width}"   --gauge "${text}" "${height}" "${width}"
218  }  }
219    
220  yesno()  yesnobox()
221  {  {
222   local header="$1"   local header
223   local text="$2"   local text
224   local height="$3"   local height
225   local width="$4"   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"   #[[ -z ${header} ]] && die "no header given"
241   [[ -z ${text} ]] && die "no text given"   [[ -z ${text} ]] && die "no text given"
242   [[ -z ${height} ]] && height=0   [[ -z ${height} ]] && height=0
243   [[ -z ${width} ]] && width=0   [[ -z ${width} ]] && width=0

Legend:
Removed from v.2337  
changed lines
  Added in v.2396