--- ray/src/util/getfile3.6.tcl 1994/10/27 15:56:10 2.1 +++ ray/src/util/getfile3.6.tcl 1994/10/28 20:14:43 2.5 @@ -1,8 +1,9 @@ # SCCSid "$SunId$ LBL" # -# Usage: getfile [-win w] [-perm] [-glob pattern] [-view proc] [-send proc] +# Usage: getfile [-win w] [-grab] [-perm] [-glob pattern] [-view proc] [-send proc] # # Create a dialog box (in window w if given) to get file name. +# If -grab option is given, then getfile does a local grab on its window. # Normally, a single file name and return as value. # If perm switch is given, keep window up for multiple file entries. # If pattern is given, start with list of all the specified files, @@ -19,6 +20,7 @@ proc getfile args { # get filename interactively # Set defaults set w .fpwin set topwin 1 + set dograb 0 set curdir . set curpat * set transient 1 @@ -30,6 +32,9 @@ proc getfile args { # get filename interactively set topwin 0 set args [lreplace $args 1 1] } + -grab { + set dograb 1 + } -perm* { set transient 0 } @@ -55,19 +60,21 @@ proc getfile args { # get filename interactively # Create widgets catch {destroy $w} if $topwin { - toplevel $w -geometry 500x410 + toplevel $w -geometry 400x410 wm title $w "File Picker" wm iconname $w "Files" - wm minsize $w 300 250 + wm minsize $w 400 300 } else { - frame $w -geometry 500x410 + frame $w -geometry 400x410 pack $w } + if $dograb { grab $w } + $w configure -cursor top_left_arrow label $w.dt -text Directory: - place $w.dt -relx .0625 -rely .03125 -relwidth .15625 -relheight .0625 + place $w.dt -relx .025 -rely .03125 helplink $w.dt file directory intro button $w.ls -text List -command "update_dir $w" - place $w.ls -relx .0625 -rely .125 -relwidth .125 -relheight .0625 + place $w.ls -relx .025 -rely .125 -relwidth .15 -relheight .0625 helplink $w.ls file directory list entry $w.de -textvariable curdir -relief sunken place $w.de -relx .25 -rely .03125 -relwidth .6875 -relheight .0625 @@ -95,8 +102,7 @@ proc getfile args { # get filename interactively } else { bind $w.fm.fl "set_curfile $w" label $w.fl -text File: - place $w.fl -relx .10625 -rely .875 \ - -relwidth .10625 -relheight .0625 + place $w.fl -relx .10625 -rely .875 entry $w.fn -relief sunken -textvariable curfile place $w.fn -relx .25 -rely .875 \ -relwidth .6875 -relheight .0625 @@ -110,20 +116,20 @@ proc getfile args { # get filename interactively } if {$transient != [info exists sendproc]} { button $w.ok -text OK -command "destroy $w" - place $w.ok -relx .0625 -rely .28125 \ - -relwidth .125 -relheight .0625 + place $w.ok -relx .025 -rely .28125 \ + -relwidth .15 -relheight .0625 } if {$transient || [info exists sendproc]} { button $w.cancel -text Cancel \ -command "destroy $w; unset curdir" - place $w.cancel -relx .0625 -rely .375 \ - -relwidth .125 -relheight .0625 + place $w.cancel -relx .025 -rely .375 \ + -relwidth .15 -relheight .0625 } if [info exists viewproc] { button $w.vi -text View -state disabled \ -command "$viewproc \[$w.fm.fl get \[$w.fm.fl curselection\]\]" - place $w.vi -relx .0625 -rely .46875 \ - -relwidth .125 -relheight .0625 + place $w.vi -relx .025 -rely .46875 \ + -relwidth .15 -relheight .0625 bind $w.fm.fl "+chk_select $w" helplink $w.vi file file view } @@ -157,6 +163,7 @@ proc update_dir w { # Update working directory if {"$curpat" == ""} { set curpat * } + if {"$curdir" == {}} {set curdir {~}} if [catch {cd $curdir} curdir] { set oldcol [lindex [$w.de config -foreground] 4] $w.de config -foreground Red