1 |
|
# SCCSid "$SunId$ LBL" |
2 |
|
# |
3 |
< |
# Usage: getfile [-win w] [-perm] [-glob pattern] [-view proc] [-send proc] |
3 |
> |
# Usage: getfile [-win w] [-grab] [-perm] [-glob pattern] [-view proc] [-send proc] |
4 |
|
# |
5 |
|
# Create a dialog box (in window w if given) to get file name. |
6 |
+ |
# If -grab option is given, then getfile does a local grab on its window. |
7 |
|
# Normally, a single file name and return as value. |
8 |
|
# If perm switch is given, keep window up for multiple file entries. |
9 |
|
# If pattern is given, start with list of all the specified files, |
20 |
|
# Set defaults |
21 |
|
set w .fpwin |
22 |
|
set topwin 1 |
23 |
+ |
set dograb 0 |
24 |
|
set curdir . |
25 |
|
set curpat * |
26 |
|
set transient 1 |
32 |
|
set topwin 0 |
33 |
|
set args [lreplace $args 1 1] |
34 |
|
} |
35 |
+ |
-grab { |
36 |
+ |
set dograb 1 |
37 |
+ |
} |
38 |
|
-perm* { |
39 |
|
set transient 0 |
40 |
|
} |
68 |
|
frame $w -geometry 400x410 |
69 |
|
pack $w |
70 |
|
} |
71 |
+ |
if $dograb { grab $w } |
72 |
+ |
$w configure -cursor top_left_arrow |
73 |
|
label $w.dt -text Directory: |
74 |
< |
place $w.dt -relx .0625 -rely .03125 -relwidth .15625 -relheight .0625 |
74 |
> |
place $w.dt -relx .025 -rely .03125 |
75 |
|
helplink $w.dt file directory intro |
76 |
|
button $w.ls -text List -command "update_dir $w" |
77 |
< |
place $w.ls -relx .0625 -rely .125 -relwidth .125 -relheight .0625 |
77 |
> |
place $w.ls -relx .025 -rely .125 -relwidth .15 -relheight .0625 |
78 |
|
helplink $w.ls file directory list |
79 |
|
entry $w.de -textvariable curdir -relief sunken |
80 |
|
place $w.de -relx .25 -rely .03125 -relwidth .6875 -relheight .0625 |
102 |
|
} else { |
103 |
|
bind $w.fm.fl <Double-Button-1> "set_curfile $w" |
104 |
|
label $w.fl -text File: |
105 |
< |
place $w.fl -relx .10625 -rely .875 \ |
99 |
< |
-relwidth .10625 -relheight .0625 |
105 |
> |
place $w.fl -relx .10625 -rely .875 |
106 |
|
entry $w.fn -relief sunken -textvariable curfile |
107 |
|
place $w.fn -relx .25 -rely .875 \ |
108 |
|
-relwidth .6875 -relheight .0625 |
116 |
|
} |
117 |
|
if {$transient != [info exists sendproc]} { |
118 |
|
button $w.ok -text OK -command "destroy $w" |
119 |
< |
place $w.ok -relx .0625 -rely .28125 \ |
120 |
< |
-relwidth .125 -relheight .0625 |
119 |
> |
place $w.ok -relx .025 -rely .28125 \ |
120 |
> |
-relwidth .15 -relheight .0625 |
121 |
|
} |
122 |
|
if {$transient || [info exists sendproc]} { |
123 |
|
button $w.cancel -text Cancel \ |
124 |
|
-command "destroy $w; unset curdir" |
125 |
< |
place $w.cancel -relx .0625 -rely .375 \ |
126 |
< |
-relwidth .125 -relheight .0625 |
125 |
> |
place $w.cancel -relx .025 -rely .375 \ |
126 |
> |
-relwidth .15 -relheight .0625 |
127 |
|
} |
128 |
|
if [info exists viewproc] { |
129 |
|
button $w.vi -text View -state disabled \ |
130 |
|
-command "$viewproc \[$w.fm.fl get \[$w.fm.fl curselection\]\]" |
131 |
< |
place $w.vi -relx .0625 -rely .46875 \ |
132 |
< |
-relwidth .125 -relheight .0625 |
131 |
> |
place $w.vi -relx .025 -rely .46875 \ |
132 |
> |
-relwidth .15 -relheight .0625 |
133 |
|
bind $w.fm.fl <ButtonRelease-1> "+chk_select $w" |
134 |
|
helplink $w.vi file file view |
135 |
|
} |
163 |
|
if {"$curpat" == ""} { |
164 |
|
set curpat * |
165 |
|
} |
166 |
+ |
if {"$curdir" == {}} {set curdir {~}} |
167 |
|
if [catch {cd $curdir} curdir] { |
168 |
|
set oldcol [lindex [$w.de config -foreground] 4] |
169 |
|
$w.de config -foreground Red |