1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258
|
#
# filesl.tk
#
proc filesl(build) {name} {
global File
set File(WName) $name
build_Title $name "File"
set filtf [build_StdFrame $name filtf]
set fdirf [build_StdFrame $name fdirf]
set df [build_StdFrame $fdirf df]
set ff [build_StdFrame $fdirf ff]
set selcf [build_StdFrame $name selcf]
set botf [build_StdFrame $name botf]
build_Label $filtf lfil "Filter:"
build_LabelEntryColumns $filtf filter \
{lentry {} {File(Filter)} }
bind_LabelEntryColumns $filtf.filter 0 <Return> filesl(return)
# Changed to Standard listbox 8/21/97 BAM
set File(Dlistbox) [build_StdListbox $df files 10 10]
set File(Flistbox) [build_StdListbox $ff dirs 15 10]
bind $File(Dlistbox) <Double-Button-1> filesl(dlist)
bind $File(Flistbox) <Double-Button-1> filesl(flist)
build_Label $selcf ldir "Directory:"
build_LabelEntryColumns $selcf seldir \
{lentry {} {File(Directory)} }
bind_LabelEntryColumns $selcf.seldir 0 <Return> filesl(return)
build_Label $selcf lfile "Filename:"
build_LabelEntryColumns $selcf selfile \
{lentry {} {File(Filename)} }
bind_LabelEntryColumns $selcf.selfile 0 <Return> filesl(return)
build_DismissButtonbar $botf dbbar "window(dismiss) filesl" \
{"OK" filesl(ok)} \
{"Filter" filesl(filter)}
pack $filtf -side top -fill both -expand true
pack $fdirf -side top -fill both -expand true
pack $df -side left -fill both -expand true
pack $ff -side right -fill both -expand true
pack $selcf -side top -fill both -expand true
pack $botf -side top -fill x -expand false
}
proc filesl(cd) {dir} {
global File
cd $dir
}
proc filesl(flist) {} {
global File
set index [$File(Flistbox) curselection]
set File(Filename) [lindex $File(Flist) $index]
filesl(ok)
}
proc filesl(dlist) {} {
global File
set index [$File(Dlistbox) curselection]
switch $index {
0 {filesl(cd) "." }
1 {filesl(cd) ".."}
default {filesl(cd) [lindex $File(Dlist) [expr $index-2]]}
}
filesl(clear)
filesl(update)
}
proc filesl(update) {} {
global File
#set pdir [pwd]
#set File(Filter) "$pdir/*"
set File(Dlist) {}
set File(Flist) {}
set File(Dlist) [lsort [glob -nocomplain */]]
set File(raw) [lsort [glob -nocomplain $File(Filter)]]
foreach fil $File(raw) {
if { [file isfile $fil] == 1} {
lappend File(Flist) $fil
}
}
filesl(updir)
filesl(upfile)
}
proc filesl(updir) {} {
global File
$File(Dlistbox) insert end "."
$File(Dlistbox) insert end ".."
foreach dir $File(Dlist) {
$File(Dlistbox) insert end $dir
}
set File(Directory) [pwd]
}
proc filesl(upfile) {} {
global File
foreach fil $File(Flist) {
$File(Flistbox) insert end $fil
}
}
proc filesl(clear) {} {
global File
set File(Dlist) {}
set File(Flist) {}
if { [winfo exists .filesl] } {
$File(Flistbox) delete 0 end
$File(Dlistbox) delete 0 end
}
#set pdir [pwd]
#set File(Filter) "$pdir/*"
#set File(Filename) ""
}
proc filesl(init) {action filter dname fname update command} {
global File
# save or load
# filter string, for ex. *.ps or *.c
# default directory
# default file
# update command from calling proc
# execute command from calling proc
set File(Action) "$action"
set File(Filter) "$filter"
set File(Directory) "$dname"
set File(Filename) "$fname"
set File(Update) "$update"
set File(Command) "$command"
filesl(cd) $dname
filesl(clear)
filesl(update)
build_Title $File(WName) "File: $File(Action)"
}
proc filesl(return) {} {
global File
puts "filesl(return)"
filesl(cd) $File(Directory)
filesl(clear)
filesl(update)
}
proc filesl(ok) {} {
global File
set val [filesl(validate)]
switch $val {
0 { }
1 { eval $File(Update)
eval $File(Command)
filesl(confirm) }
}
# the close window call below produces a tk error ?
# window(dismiss) filesl
}
proc filesl(confirm) {} {
global File
set fpath "$File(Directory)/$File(Filename)"
set fstat [file isfile $fpath]
switch $fstat {
0 { puts "filesl: $File(Action) failed."
message_show "$File(Action) failed."
build_Dialog fileslfail "$File(Action)" \
"$File(Action) failed" \
0 Ok }
1 { puts "filesl: $File(Action) done."
message_show "$File(Action) done." }
}
}
proc filesl(validate) {} {
global File
set fpath "$File(Directory)/$File(Filename)"
set fstat [file isfile $fpath]
# To handle the specific case of no filename -- 8/21/97 BAM
if {$File(Filename) == ""} {set fstat 2}
switch $File(Action) {
Save { switch $fstat {
0 { puts "filesl: save $File(Filename) in progress..."
message_show "Save $File(Filename) in progress..."
return 1 }
1 { puts "filesl: verify overwrite"
return [build_Dialog fileslsave "File Save" \
"Overwrite $File(Filename) ?" \
0 No Yes ] }
2 { puts "filesl: save failed: no filename"
message_show "Save failed: no filename"
return [build_Dialog fileslsave "File Save" \
"Save failed: no filename" \
0 Ok] }
}
}
Load { switch $fstat {
0 { puts "filesl: load $File(Filename) failed."
message_show "Load $File(Filename) failed."
build_Dialog fileslload "File Load" \
"$File(Filename) not found" \
0 Ok
return 0 }
1 { puts "filesl: load $File(Filename) in progress..."
message_show "Load $File(Filename) in progress..."
return 1 }
}
}
}
}
proc filesl(filter) {} {
global File
filesl(clear)
filesl(update)
}
|