Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Side by Side Diff: third_party/xdg-utils/scripts/xdg-file-dialog.in

Issue 151098: Patch from mdm@google.com... (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/
Patch Set: Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 #!/bin/sh
2 #---------------------------------------------
3 # xdg-file-dialog
4 #
5 # Utility script to file selection dialogs
6 # on XDG compliant systems.
7 #
8 # Refer to the usage() function below for usage.
9 #
10 # Copyright 2006, Kevin Krammer <kevin.krammer@gmx.at>
11 #
12 # LICENSE:
13 #
14 #---------------------------------------------
15
16 manualpage()
17 {
18 cat << _MANUALPAGE
19 _MANUALPAGE
20 }
21
22 usage()
23 {
24 cat << _USAGE
25 _USAGE
26 }
27
28 #@xdg-utils-common@
29
30 open_kde()
31 {
32 DIALOG=`which kdialog`
33 if [ $? -eq 0 ]; then
34 if [ x"$TITLE" != x"" ]; then
35 $DIALOG --title "$TITLE" --getopenfilename "$1" ""
36 else
37 $DIALOG --getopenfilename "$1" ""
38 fi
39
40 if [ $? -eq 0 ]; then
41 exit_success
42 else
43 exit_failure_operation_failed
44 fi
45 else
46 exit_failure_operation_impossible
47 fi
48 }
49
50 open_zenity()
51 {
52 DIALOG=`which zenity`
53 if [ $? -eq 0 ]; then
54 if [ x"$1" != x"" ]; then
55 cd `dirname "$1"` 2>/dev/null
56 FILENAME=`basename "$1"`
57 if [ x"$FILENAME" != x"" ]; then
58 FILENAME="--filename=""$FILENAME"
59 fi
60 fi
61
62 if [ x"$FILENAME" != x"" ]; then
63 if [ x"$TITLE" != x"" ]; then
64 $DIALOG --title "$TITLE" --file-selection "$FILENAME"
65 else
66 $DIALOG --file-selection "$FILENAME"
67 fi
68 else
69 if [ x"$TITLE" != x"" ]; then
70 $DIALOG --title "$TITLE" --file-selection
71 else
72 $DIALOG --file-selection
73 fi
74 fi
75
76 if [ $? -eq 0 ]; then
77 exit_success
78 else
79 exit_failure_operation_failed
80 fi
81 else
82 exit_failure_operation_impossible
83 fi
84 }
85
86 open_multi_kde()
87 {
88 DIALOG=`which kdialog`
89 if [ $? -eq 0 ]; then
90 if [ x"$TITLE" != x"" ]; then
91 $DIALOG --title "$TITLE" --multiple --separate-output \
92 --getopenfilename "$1" ""
93 else
94 $DIALOG --multiple --separate-output --getopenfilename "$1" ""
95 fi
96
97 if [ $? -eq 0 ]; then
98 exit_success
99 else
100 exit_failure_operation_failed
101 fi
102 else
103 exit_failure_operation_impossible
104 fi
105 }
106
107 open_multi_zenity()
108 {
109 DIALOG=`which zenity`
110 if [ $? -eq 0 ]; then
111 if [ x"$1" != x"" ]; then
112 cd `dirname "$1"` 2>/dev/null
113 FILENAME=`basename "$1"`
114 if [ x"$FILENAME" != x"" ]; then
115 FILENAME="--filename=""$FILENAME"
116 fi
117 fi
118
119 if [ x"$FILENAME" != x"" ]; then
120 if [ x"$TITLE" != x"" ]; then
121 LIST=`$DIALOG --title "$TITLE" --multiple --file-selection "$FIL ENAME"`
122 else
123 LIST=`$DIALOG --multiple --file-selection "$FILENAME"`
124 fi
125 else
126 if [ x"$TITLE" != x"" ]; then
127 LIST=`$DIALOG --title "$TITLE" --multiple --file-selection`
128 else
129 LIST=`$DIALOG --multiple --file-selection`
130 fi
131 fi
132
133 if [ $? -eq 0 ]; then
134 echo "$LIST" | sed s#'|'#\\n#g
135 exit_success
136 else
137 exit_failure_operation_failed
138 fi
139 else
140 exit_failure_operation_impossible
141 fi
142 }
143
144 save_kde()
145 {
146 DIALOG=`which kdialog`
147 if [ $? -eq 0 ]; then
148 if [ x"$TITLE" != x"" ]; then
149 $DIALOG --title "$TITLE" --getsavefilename "$1" ""
150 else
151 $DIALOG --getsavefilename "$1" ""
152 fi
153
154 if [ $? -eq 0 ]; then
155 exit_success
156 else
157 exit_failure_operation_failed
158 fi
159 else
160 exit_failure_operation_impossible
161 fi
162 }
163
164 save_zenity()
165 {
166 DIALOG=`which zenity`
167 if [ $? -eq 0 ]; then
168 if [ x"$1" != x"" ]; then
169 cd `dirname "$1"` 2>/dev/null
170 FILENAME=`basename "$1"`
171 if [ x"$FILENAME" != x"" ]; then
172 FILENAME="--filename=""$FILENAME"
173 fi
174 fi
175
176 if [ x"$FILENAME" != x"" ]; then
177 if [ x"$TITLE" != x"" ]; then
178 $DIALOG --title "$TITLE" --save --file-selection "$FILENAME"
179 else
180 $DIALOG --save --file-selection "$FILENAME"
181 fi
182 else
183 if [ x"$TITLE" != x"" ]; then
184 $DIALOG --title "$TITLE" --save --file-selection
185 else
186 $DIALOG --save --file-selection
187 fi
188 fi
189
190 if [ $? -eq 0 ]; then
191 exit_success
192 else
193 exit_failure_operation_failed
194 fi
195 else
196 exit_failure_operation_impossible
197 fi
198 }
199
200 directory_kde()
201 {
202 DIALOG=`which kdialog`
203 if [ $? -eq 0 ]; then
204 if [ x"$TITLE" != x"" ]; then
205 $DIALOG --title "$TITLE" --getexistingdirectory "$1" ""
206 else
207 $DIALOG --getexistingdirectory "$1" ""
208 fi
209
210 if [ $? -eq 0 ]; then
211 exit_success
212 else
213 exit_failure_operation_failed
214 fi
215 else
216 exit_failure_operation_impossible
217 fi
218 }
219
220 directory_zenity()
221 {
222 DIALOG=`which zenity`
223 if [ $? -eq 0 ]; then
224 if [ x"$1" != x"" ]; then
225 cd "$1" 2>/dev/null
226 fi
227
228 if [ x"$TITLE" != x"" ]; then
229 $DIALOG --title "$TITLE" --directory --file-selection
230 else
231 $DIALOG --directory --file-selection
232 fi
233
234 if [ $? -eq 0 ]; then
235 exit_success
236 else
237 exit_failure_operation_failed
238 fi
239 else
240 exit_failure_operation_impossible
241 fi
242 }
243
244 [ x"$1" != x"" ] || exit_failure_syntax
245
246 TITLE=
247 action=
248 filename=
249
250 case $1 in
251 openfilename)
252 action=openfilename
253 ;;
254
255 openfilenamelist)
256 action=openfilenamelist
257 ;;
258
259 savefilename)
260 action=savefilename
261 ;;
262
263 directory)
264 action=directory
265 ;;
266
267 *)
268 exit_failure_syntax "unknown command '$1'"
269 ;;
270 esac
271
272 shift
273
274 while [ $# -gt 0 ] ; do
275 parm="$1"
276 shift
277
278 case "$parm" in
279 --title)
280 if [ -z "$1" ] ; then
281 exit_failure_syntax "TITLE argument missing for --title"
282 fi
283 TITLE="$1"
284 shift
285 ;;
286
287 -*)
288 exit_failure_syntax "unexpected option '$parm'"
289 ;;
290
291 *)
292 if [ -n "$filename" ] ; then
293 exit_failure_syntax "unexpected argument '$parm'"
294 fi
295 filename="$parm"
296 ;;
297 esac
298 done
299
300 # Shouldn't happen
301 if [ -z "$action" ] ; then
302 exit_failure_syntax "command argument missing"
303 fi
304
305 detectDE
306
307 if [ "$action" = "openfilename" ]; then
308 case "$DE" in
309 kde)
310 open_kde "$filename"
311 ;;
312
313 gnome|xfce)
314 open_zenity "$filename"
315 ;;
316
317 *)
318 exit_failure_operation_impossible "no method available for opening a fil ename dialog"
319 ;;
320 esac
321 elif [ "$action" = "openfilenamelist" ]; then
322 case "$DE" in
323 kde)
324 open_multi_kde "$filename"
325 ;;
326
327 gnome|xfce)
328 open_multi_zenity "$filename"
329 ;;
330
331 *)
332 exit_failure_operation_impossible "no method available for opening a fil ename dialog"
333 ;;
334 esac
335 elif [ "$action" = "savefilename" ]; then
336 case "$DE" in
337 kde)
338 save_kde "$filename"
339 ;;
340
341 gnome|xfce)
342 save_zenity "$filename"
343 ;;
344
345 *)
346 exit_failure_operation_impossible "no method available for opening a fil ename dialog"
347 ;;
348 esac
349 elif [ "$action" = "directory" ]; then
350 case "$DE" in
351 kde)
352 directory_kde "$filename"
353 ;;
354
355 gnome|xfce)
356 directory_zenity "$filename"
357 ;;
358
359 *)
360 exit_failure_operation_impossible "no method available for opening a dir ectory dialog"
361 ;;
362 esac
363 fi
OLDNEW
« no previous file with comments | « third_party/xdg-utils/scripts/xdg-file-dialog ('k') | third_party/xdg-utils/scripts/xdg-icon-resource » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698