summaryrefslogtreecommitdiffstats
path: root/library/tkfbox.tcl
diff options
context:
space:
mode:
Diffstat (limited to 'library/tkfbox.tcl')
-rw-r--r--library/tkfbox.tcl282
1 files changed, 144 insertions, 138 deletions
diff --git a/library/tkfbox.tcl b/library/tkfbox.tcl
index d81a5a2..8e2bd73 100644
--- a/library/tkfbox.tcl
+++ b/library/tkfbox.tcl
@@ -11,9 +11,9 @@
# files by clicking on the file icons or by entering a filename
# in the "Filename:" entry.
#
-# SCCS: @(#) tkfbox.tcl 1.13 97/10/01 14:51:01
+# SCCS: @(#) tkfbox.tcl 1.22 98/01/26 19:42:37
#
-# Copyright (c) 1994-1996 Sun Microsystems, Inc.
+# Copyright (c) 1994-1998 Sun Microsystems, Inc.
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
@@ -95,10 +95,10 @@ proc tkIconList_Create {w} {
bind $data(canvas) <1> "tkIconList_Btn1 $w %x %y"
bind $data(canvas) <B1-Motion> "tkIconList_Motion1 $w %x %y"
- bind $data(canvas) <Double-1> "tkIconList_Double1 $w %x %y"
- bind $data(canvas) <ButtonRelease-1> "tkCancelRepeat"
bind $data(canvas) <B1-Leave> "tkIconList_Leave1 $w %x %y"
bind $data(canvas) <B1-Enter> "tkCancelRepeat"
+ bind $data(canvas) <ButtonRelease-1> "tkCancelRepeat"
+ bind $data(canvas) <Double-ButtonRelease-1> "tkIconList_Double1 $w %x %y"
bind $data(canvas) <Up> "tkIconList_UpDown $w -1"
bind $data(canvas) <Down> "tkIconList_UpDown $w 1"
@@ -133,7 +133,7 @@ proc tkIconList_AutoScan {w} {
set x $tkPriv(x)
set y $tkPriv(y)
- if $data(noScroll) {
+ if {$data(noScroll)} {
return
}
if {$x >= [winfo width $data(canvas)]} {
@@ -188,8 +188,8 @@ proc tkIconList_Add {w image text} {
set rTag [$data(canvas) create rect 0 0 0 0 -fill "" -outline ""]
set b [$data(canvas) bbox $iTag]
- set iW [expr [lindex $b 2]-[lindex $b 0]]
- set iH [expr [lindex $b 3]-[lindex $b 1]]
+ set iW [expr {[lindex $b 2]-[lindex $b 0]}]
+ set iH [expr {[lindex $b 3]-[lindex $b 1]}]
if {$data(maxIW) < $iW} {
set data(maxIW) $iW
}
@@ -198,8 +198,8 @@ proc tkIconList_Add {w image text} {
}
set b [$data(canvas) bbox $tTag]
- set tW [expr [lindex $b 2]-[lindex $b 0]]
- set tH [expr [lindex $b 3]-[lindex $b 1]]
+ set tW [expr {[lindex $b 2]-[lindex $b 0]}]
+ set tH [expr {[lindex $b 3]-[lindex $b 1]}]
if {$data(maxTW) < $tW} {
set data(maxTW) $tW
}
@@ -218,7 +218,7 @@ proc tkIconList_Add {w image text} {
proc tkIconList_Arrange {w} {
upvar #0 $w data
- if ![info exists data(list)] {
+ if {![info exists data(list)]} {
if {[info exists data(canvas)] && [winfo exists $data(canvas)]} {
set data(noScroll) 1
$data(sbar) config -command ""
@@ -228,26 +228,26 @@ proc tkIconList_Arrange {w} {
set W [winfo width $data(canvas)]
set H [winfo height $data(canvas)]
- set pad [expr [$data(canvas) cget -highlightthickness] + \
- [$data(canvas) cget -bd]]
+ set pad [expr {[$data(canvas) cget -highlightthickness] + \
+ [$data(canvas) cget -bd]}]
if {$pad < 2} {
set pad 2
}
- incr W -[expr $pad*2]
- incr H -[expr $pad*2]
+ incr W -[expr {$pad*2}]
+ incr H -[expr {$pad*2}]
- set dx [expr $data(maxIW) + $data(maxTW) + 8]
+ set dx [expr {$data(maxIW) + $data(maxTW) + 8}]
if {$data(maxTH) > $data(maxIH)} {
set dy $data(maxTH)
} else {
set dy $data(maxIH)
}
incr dy 2
- set shift [expr $data(maxIW) + 4]
+ set shift [expr {$data(maxIW) + 4}]
- set x [expr $pad * 2]
- set y [expr $pad * 1]
+ set x [expr {$pad * 2}]
+ set y [expr {$pad * 1}] ; # Why * 1 ?
set usedColumn 0
foreach sublist $data(list) {
set usedColumn 1
@@ -259,24 +259,24 @@ proc tkIconList_Arrange {w} {
set tW [lindex $sublist 5]
set tH [lindex $sublist 6]
- set i_dy [expr ($dy - $iH)/2]
- set t_dy [expr ($dy - $tH)/2]
+ set i_dy [expr {($dy - $iH)/2}]
+ set t_dy [expr {($dy - $tH)/2}]
- $data(canvas) coords $iTag $x [expr $y + $i_dy]
- $data(canvas) coords $tTag [expr $x + $shift] [expr $y + $t_dy]
- $data(canvas) coords $tTag [expr $x + $shift] [expr $y + $t_dy]
- $data(canvas) coords $rTag $x $y [expr $x+$dx] [expr $y+$dy]
+ $data(canvas) coords $iTag $x [expr {$y + $i_dy}]
+ $data(canvas) coords $tTag [expr {$x + $shift}] [expr {$y + $t_dy}]
+ $data(canvas) coords $tTag [expr {$x + $shift}] [expr {$y + $t_dy}]
+ $data(canvas) coords $rTag $x $y [expr {$x+$dx}] [expr {$y+$dy}]
incr y $dy
- if {[expr $y + $dy] > $H} {
- set y [expr $pad * 1]
+ if {($y + $dy) > $H} {
+ set y [expr {$pad * 1}] ; # *1 ?
incr x $dx
set usedColumn 0
}
}
if {$usedColumn} {
- set sW [expr $x + $dx]
+ set sW [expr {$x + $dx}]
} else {
set sW $x
}
@@ -292,7 +292,7 @@ proc tkIconList_Arrange {w} {
set data(noScroll) 0
}
- set data(itemsPerColumn) [expr ($H-$pad)/$dy]
+ set data(itemsPerColumn) [expr {($H-$pad)/$dy}]
if {$data(itemsPerColumn) < 1} {
set data(itemsPerColumn) 1
}
@@ -321,47 +321,47 @@ proc tkIconList_See {w rTag} {
upvar #0 $w data
upvar #0 $w:itemList itemList
- if $data(noScroll) {
+ if {$data(noScroll)} {
return
}
set sRegion [$data(canvas) cget -scrollregion]
- if ![string compare $sRegion {}] {
+ if {![string compare $sRegion {}]} {
return
}
- if ![info exists itemList($rTag)] {
+ if {![info exists itemList($rTag)]} {
return
}
set bbox [$data(canvas) bbox $rTag]
- set pad [expr [$data(canvas) cget -highlightthickness] + \
- [$data(canvas) cget -bd]]
+ set pad [expr {[$data(canvas) cget -highlightthickness] + \
+ [$data(canvas) cget -bd]}]
set x1 [lindex $bbox 0]
set x2 [lindex $bbox 2]
- incr x1 -[expr $pad * 2]
- incr x2 -[expr $pad * 1]
+ incr x1 -[expr {$pad * 2}]
+ incr x2 -[expr {$pad * 1}] ; # *1 ?
- set cW [expr [winfo width $data(canvas)] - $pad*2]
+ set cW [expr {[winfo width $data(canvas)] - $pad*2}]
- set scrollW [expr [lindex $sRegion 2]-[lindex $sRegion 0]+1]
- set dispX [expr int([lindex [$data(canvas) xview] 0]*$scrollW)]
+ set scrollW [expr {[lindex $sRegion 2]-[lindex $sRegion 0]+1}]
+ set dispX [expr {int([lindex [$data(canvas) xview] 0]*$scrollW)}]
set oldDispX $dispX
# check if out of the right edge
#
- if {[expr $x2 - $dispX] >= $cW} {
- set dispX [expr $x2 - $cW]
+ if {($x2 - $dispX) >= $cW} {
+ set dispX [expr {$x2 - $cW}]
}
# check if out of the left edge
#
- if {[expr $x1 - $dispX] < 0} {
+ if {($x1 - $dispX) < 0} {
set dispX $x1
}
if {$oldDispX != $dispX} {
- set fraction [expr double($dispX)/double($scrollW)]
+ set fraction [expr {double($dispX)/double($scrollW)}]
$data(canvas) xview moveto $fraction
}
}
@@ -377,7 +377,7 @@ proc tkIconList_Select {w rTag {callBrowse 1}} {
upvar #0 $w data
upvar #0 $w:itemList itemList
- if ![info exists itemList($rTag)] {
+ if {![info exists itemList($rTag)]} {
return
}
set iTag [lindex $itemList($rTag) 0]
@@ -385,7 +385,7 @@ proc tkIconList_Select {w rTag {callBrowse 1}} {
set text [lindex $itemList($rTag) 2]
set serial [lindex $itemList($rTag) 3]
- if ![info exists data(rect)] {
+ if {![info exists data(rect)]} {
set data(rect) [$data(canvas) create rect 0 0 0 0 \
-fill #a0a0ff -outline #a0a0ff]
}
@@ -397,7 +397,7 @@ proc tkIconList_Select {w rTag {callBrowse 1}} {
set data(selected) $text
if {$callBrowse} {
- if [string compare $data(-browsecmd) ""] {
+ if {[string compare $data(-browsecmd) ""]} {
eval $data(-browsecmd) [list $text]
}
}
@@ -406,11 +406,11 @@ proc tkIconList_Select {w rTag {callBrowse 1}} {
proc tkIconList_Unselect {w} {
upvar #0 $w data
- if [info exists data(rect)] {
+ if {[info exists data(rect)]} {
$data(canvas) delete $data(rect)
unset data(rect)
}
- if [info exists data(selected)] {
+ if {[info exists data(selected)]} {
unset data(selected)
}
set data(curItem) {}
@@ -421,7 +421,7 @@ proc tkIconList_Unselect {w} {
proc tkIconList_Get {w} {
upvar #0 $w data
- if [info exists data(selected)] {
+ if {[info exists data(selected)]} {
return $data(selected)
} else {
return ""
@@ -469,7 +469,7 @@ proc tkIconList_Leave1 {w x y} {
proc tkIconList_FocusIn {w} {
upvar #0 $w data
- if ![info exists data(list)] {
+ if {![info exists data(list)]} {
return
}
@@ -490,7 +490,7 @@ proc tkIconList_FocusIn {w} {
proc tkIconList_UpDown {w amount} {
upvar #0 $w data
- if ![info exists data(list)] {
+ if {![info exists data(list)]} {
return
}
@@ -498,13 +498,13 @@ proc tkIconList_UpDown {w amount} {
set rTag [lindex [lindex $data(list) 0] 2]
} else {
set oldRTag [lindex [lindex $data(list) $data(curItem)] 2]
- set rTag [lindex [lindex $data(list) [expr $data(curItem)+$amount]] 2]
- if ![string compare $rTag ""] {
+ set rTag [lindex [lindex $data(list) [expr {$data(curItem)+$amount}]] 2]
+ if {![string compare $rTag ""]} {
set rTag $oldRTag
}
}
- if [string compare $rTag ""] {
+ if {[string compare $rTag ""]} {
tkIconList_Select $w $rTag
tkIconList_See $w $rTag
}
@@ -521,21 +521,21 @@ proc tkIconList_UpDown {w amount} {
proc tkIconList_LeftRight {w amount} {
upvar #0 $w data
- if ![info exists data(list)] {
+ if {![info exists data(list)]} {
return
}
if {$data(curItem) == {}} {
set rTag [lindex [lindex $data(list) 0] 2]
} else {
set oldRTag [lindex [lindex $data(list) $data(curItem)] 2]
- set newItem [expr $data(curItem)+($amount*$data(itemsPerColumn))]
+ set newItem [expr {$data(curItem)+($amount*$data(itemsPerColumn))}]
set rTag [lindex [lindex $data(list) $newItem] 2]
- if ![string compare $rTag ""] {
+ if {![string compare $rTag ""]} {
set rTag $oldRTag
}
}
- if [string compare $rTag ""] {
+ if {[string compare $rTag ""]} {
tkIconList_Select $w $rTag
tkIconList_See $w $rTag
}
@@ -565,7 +565,7 @@ proc tkIconList_Goto {w text} {
upvar #0 $w:textList textList
global tkPriv
- if ![info exists data(list)] {
+ if {![info exists data(list)]} {
return
}
@@ -583,7 +583,7 @@ proc tkIconList_Goto {w text} {
set theIndex -1
set less 0
set len [string length $text]
- set len0 [expr $len-1]
+ set len0 [expr {$len-1}]
set i $start
# Search forward until we find a filename whose prefix is an exact match
@@ -628,23 +628,22 @@ proc tkIconList_Reset {w} {
# the tk_strictMotif flag is set to false. This procedure shouldn't
# be called directly. Call tk_getOpenFile or tk_getSaveFile instead.
#
-proc tkFDialog {args} {
- global tkPriv
- set w __tk_filedialog
- upvar #0 $w data
+# Arguments:
+# type "open" or "save"
+# args Options parsed by the procedure.
+#
- if ![string compare [lindex [info level 0] 0] tk_getOpenFile] {
- set type open
- } else {
- set type save
- }
+proc tkFDialog {type args} {
+ global tkPriv
+ set dataName __tk_filedialog
+ upvar #0 $dataName data
- tkFDialog_Config $w $type $args
+ tkFDialog_Config $dataName $type $args
if {![string compare $data(-parent) .]} {
- set w .$w
+ set w .$dataName
} else {
- set w $data(-parent).$w
+ set w $data(-parent).$dataName
}
# (re)create the dialog box if necessary
@@ -657,7 +656,9 @@ proc tkFDialog {args} {
}
wm transient $w $data(-parent)
- # 5. Initialize the file types menu
+ trace variable data(selectPath) w "tkFDialog_SetPath $w"
+
+ # Initialize the file types menu
#
if {$data(-filetypes) != {}} {
$data(typeMenu) delete 0 end
@@ -678,21 +679,21 @@ proc tkFDialog {args} {
tkFDialog_UpdateWhenIdle $w
- # 6. Withdraw the window, then update all the geometry information
+ # Withdraw the window, then update all the geometry information
# so we know how big it wants to be, then center the window in the
# display and de-iconify it.
wm withdraw $w
update idletasks
- set x [expr [winfo screenwidth $w]/2 - [winfo reqwidth $w]/2 \
- - [winfo vrootx [winfo parent $w]]]
- set y [expr [winfo screenheight $w]/2 - [winfo reqheight $w]/2 \
- - [winfo vrooty [winfo parent $w]]]
+ set x [expr {[winfo screenwidth $w]/2 - [winfo reqwidth $w]/2 \
+ - [winfo vrootx [winfo parent $w]]}]
+ set y [expr {[winfo screenheight $w]/2 - [winfo reqheight $w]/2 \
+ - [winfo vrooty [winfo parent $w]]}]
wm geom $w [winfo reqwidth $w]x[winfo reqheight $w]+$x+$y
wm deiconify $w
wm title $w $data(-title)
- # 7. Set a grab and claim the focus too.
+ # Set a grab and claim the focus too.
set oldFocus [focus]
set oldGrab [grab current $w]
@@ -707,7 +708,7 @@ proc tkFDialog {args} {
$data(ent) select to end
$data(ent) icursor end
- # 8. Wait for the user to respond, then restore the focus and
+ # Wait for the user to respond, then restore the focus and
# return the index of the selected button. Restore the focus
# before deleting the window, since otherwise the window manager
# may take the focus away so we can't redirect it. Finally,
@@ -724,6 +725,7 @@ proc tkFDialog {args} {
grab $oldGrab
}
}
+
return $tkPriv(selectFilePath)
}
@@ -731,11 +733,19 @@ proc tkFDialog {args} {
#
# Configures the TK filedialog according to the argument list
#
-proc tkFDialog_Config {w type argList} {
- upvar #0 $w data
+proc tkFDialog_Config {dataName type argList} {
+ upvar #0 $dataName data
set data(type) $type
+ # 0: Delete all variable that were set on data(selectPath) the
+ # last time the file dialog is used. The traces may cause troubles
+ # if the dialog is now used with a different -parent option.
+
+ foreach trace [trace vinfo data(selectPath)] {
+ trace vdelete data(selectPath) [lindex $trace 0] [lindex $trace 1]
+ }
+
# 1: the configuration specs
#
set specs {
@@ -749,7 +759,7 @@ proc tkFDialog_Config {w type argList} {
# 2: default values depending on the type of the dialog
#
- if ![info exists data(selectPath)] {
+ if {![info exists data(selectPath)]} {
# first time the dialog has been popped up
set data(selectPath) [pwd]
set data(selectFile) ""
@@ -757,10 +767,10 @@ proc tkFDialog_Config {w type argList} {
# 3: parse the arguments
#
- tclParseConfigSpec $w $specs "" $argList
+ tclParseConfigSpec $dataName $specs "" $argList
- if ![string compare $data(-title) ""] {
- if ![string compare $type "open"] {
+ if {![string compare $data(-title) ""]} {
+ if {![string compare $type "open"]} {
set data(-title) "Open"
} else {
set data(-title) "Save As"
@@ -770,9 +780,9 @@ proc tkFDialog_Config {w type argList} {
# 4: set the default directory and selection according to the -initial
# settings
#
- if [string compare $data(-initialdir) ""] {
- if [file isdirectory $data(-initialdir)] {
- set data(selectPath) [glob $data(-initialdir)]
+ if {[string compare $data(-initialdir) ""]} {
+ if {[file isdirectory $data(-initialdir)]} {
+ set data(selectPath) [lindex [glob $data(-initialdir)] 0]
} else {
error "\"$data(-initialdir)\" is not a valid directory"
}
@@ -783,7 +793,7 @@ proc tkFDialog_Config {w type argList} {
#
set data(-filetypes) [tkFDGetFileTypes $data(-filetypes)]
- if ![winfo exists $data(-parent)] {
+ if {![winfo exists $data(-parent)]} {
error "bad window path name \"$data(-parent)\""
}
}
@@ -802,7 +812,7 @@ proc tkFDialog_Create {w} {
set data(dirMenuBtn) $f1.menu
set data(dirMenu) [tk_optionMenu $f1.menu [format %s(selectPath) $dataName] ""]
set data(upBtn) [button $f1.up]
- if ![info exists tkPriv(updirImage)] {
+ if {![info exists tkPriv(updirImage)]} {
set tkPriv(updirImage) [image create bitmap -data {
#define updir_width 28
#define updir_height 16
@@ -896,8 +906,6 @@ static char updir_bits[] = {
$data(okBtn) config -command "tkFDialog_OkCmd $w"
$data(cancelBtn) config -command "tkFDialog_CancelCmd $w"
- trace variable data(selectPath) w "tkFDialog_SetPath $w"
-
bind $w <Alt-d> "focus $data(dirMenuBtn)"
bind $w <Alt-t> [format {
if {"[%s cget -state]" == "normal"} {
@@ -929,7 +937,7 @@ static char updir_bits[] = {
proc tkFDialog_UpdateWhenIdle {w} {
upvar #0 [winfo name $w] data
- if [info exists data(updateId)] {
+ if {[info exists data(updateId)]} {
return
} else {
set data(updateId) [after idle tkFDialog_Update $w]
@@ -955,8 +963,7 @@ proc tkFDialog_Update {w} {
catch {unset data(updateId)}
}
- set TRANSPARENT_GIF_COLOR [$w cget -bg]
- if ![info exists tkPriv(folderImage)] {
+ if {![info exists tkPriv(folderImage)]} {
set tkPriv(folderImage) [image create photo -data {
R0lGODlhEAAMAKEAAAD//wAAAPD/gAAAACH5BAEAAAAALAAAAAAQAAwAAAIghINhyycvVFsB
QtmS3rjaH1Hg141WaT5ouprt2HHcUgAAOw==}]
@@ -968,9 +975,9 @@ rSASvJTGhnhcV3EJlo3kh53ltF5nAhQAOw==}]
set file $tkPriv(fileImage)
set appPWD [pwd]
- if [catch {
+ if {[catch {
cd $data(selectPath)
- }] {
+ }]} {
# We cannot change directory to $data(selectPath). $data(selectPath)
# should have been checked before tkFDialog_Update is called, so
# we normally won't come to here. Anyways, give an error and abort
@@ -996,14 +1003,14 @@ rSASvJTGhnhcV3EJlo3kh53ltF5nAhQAOw==}]
# Make the dir list
#
foreach f [lsort -dictionary [glob -nocomplain .* *]] {
- if ![string compare $f .] {
+ if {![string compare $f .]} {
continue
}
- if ![string compare $f ..] {
+ if {![string compare $f ..]} {
continue
}
- if [file isdir ./$f] {
- if ![info exists hasDoneDir($f)] {
+ if {[file isdir ./$f]} {
+ if {![info exists hasDoneDir($f)]} {
tkIconList_Add $data(icons) $folder $f
set hasDoneDir($f) 1
}
@@ -1011,7 +1018,7 @@ rSASvJTGhnhcV3EJlo3kh53ltF5nAhQAOw==}]
}
# Make the file list
#
- if ![string compare $data(filter) *] {
+ if {![string compare $data(filter) *]} {
set files [lsort -dictionary \
[glob -nocomplain .* *]]
} else {
@@ -1021,8 +1028,8 @@ rSASvJTGhnhcV3EJlo3kh53ltF5nAhQAOw==}]
set top 0
foreach f $files {
- if ![file isdir ./$f] {
- if ![info exists hasDoneFile($f)] {
+ if {![file isdir ./$f]} {
+ if {![info exists hasDoneFile($f)]} {
tkIconList_Add $data(icons) $file $f
set hasDoneFile($f) 1
}
@@ -1132,24 +1139,21 @@ proc tkFDialogResolveFile {context text defaultext} {
set path "$path$defaultext"
}
- if [catch {file exists $path}] {
- return [list ERROR $path ""]
- }
- if [catch {if [file exists $path] {}}] {
- # This "if" block can be safely removed if the following code returns
- # an error. It currently (7/22/97) doesn't
+ if {[catch {file exists $path}]} {
+ # This "if" block can be safely removed if the following code
+ # stop generating errors.
#
# file exists ~nonsuchuser
#
return [list ERROR $path ""]
}
- if [file exists $path] {
- if [file isdirectory $path] {
- if [catch {
+ if {[file exists $path]} {
+ if {[file isdirectory $path]} {
+ if {[catch {
cd $path
- }] {
+ }]} {
return [list CHDIR $path ""]
}
set directory [pwd]
@@ -1157,9 +1161,9 @@ proc tkFDialogResolveFile {context text defaultext} {
set flag OK
cd $appPWD
} else {
- if [catch {
+ if {[catch {
cd [file dirname $path]
- }] {
+ }]} {
return [list CHDIR [file dirname $path] ""]
}
set directory [pwd]
@@ -1169,15 +1173,15 @@ proc tkFDialogResolveFile {context text defaultext} {
}
} else {
set dirname [file dirname $path]
- if [file exists $dirname] {
- if [catch {
+ if {[file exists $dirname]} {
+ if {[catch {
cd $dirname
- }] {
+ }]} {
return [list CHDIR $dirname ""]
}
set directory [pwd]
set file [file tail $path]
- if [regexp {[*]|[?]} $file] {
+ if {[regexp {[*]|[?]} $file]} {
set flag PATTERN
} else {
set flag FILE
@@ -1201,7 +1205,7 @@ proc tkFDialogResolveFile {context text defaultext} {
proc tkFDialog_EntFocusIn {w} {
upvar #0 [winfo name $w] data
- if [string compare [$data(ent) get] ""] {
+ if {[string compare [$data(ent) get] ""]} {
$data(ent) selection from 0
$data(ent) selection to end
$data(ent) icursor end
@@ -1211,7 +1215,7 @@ proc tkFDialog_EntFocusIn {w} {
tkIconList_Unselect $data(icons)
- if ![string compare $data(type) open] {
+ if {![string compare $data(type) open]} {
$data(okBtn) config -text "Open"
} else {
$data(okBtn) config -text "Save"
@@ -1239,7 +1243,7 @@ proc tkFDialog_ActivateEnt {w} {
case $flag {
OK {
- if ![string compare $file ""] {
+ if {![string compare $file ""]} {
# user has entered an existing (sub)directory
set data(selectPath) $path
$data(ent) delete 0 end
@@ -1254,7 +1258,7 @@ proc tkFDialog_ActivateEnt {w} {
set data(filter) $file
}
FILE {
- if ![string compare $data(type) open] {
+ if {![string compare $data(type) open]} {
tk_messageBox -icon warning -type ok -parent $data(-parent) \
-message "File \"[file join $path $file]\" does not exist."
$data(ent) select from 0
@@ -1297,7 +1301,7 @@ proc tkFDialog_ActivateEnt {w} {
proc tkFDialog_InvokeBtn {w key} {
upvar #0 [winfo name $w] data
- if ![string compare [$data(okBtn) cget -text] $key] {
+ if {![string compare [$data(okBtn) cget -text] $key]} {
tkButtonInvoke $data(okBtn)
}
}
@@ -1307,7 +1311,7 @@ proc tkFDialog_InvokeBtn {w key} {
proc tkFDialog_UpDirCmd {w} {
upvar #0 [winfo name $w] data
- if [string compare $data(selectPath) "/"] {
+ if {[string compare $data(selectPath) "/"]} {
set data(selectPath) [file dirname $data(selectPath)]
}
}
@@ -1331,9 +1335,9 @@ proc tkFDialog_OkCmd {w} {
upvar #0 [winfo name $w] data
set text [tkIconList_Get $data(icons)]
- if [string compare $text ""] {
+ if {[string compare $text ""]} {
set file [tkFDialog_JoinFile $data(selectPath) $text]
- if [file isdirectory $file] {
+ if {[file isdirectory $file]} {
tkFDialog_ListInvoke $w $text
return
}
@@ -1362,11 +1366,11 @@ proc tkFDialog_ListBrowse {w text} {
}
set file [tkFDialog_JoinFile $data(selectPath) $text]
- if ![file isdirectory $file] {
+ if {![file isdirectory $file]} {
$data(ent) delete 0 end
$data(ent) insert 0 $text
- if ![string compare $data(type) open] {
+ if {![string compare $data(type) open]} {
$data(okBtn) config -text "Open"
} else {
$data(okBtn) config -text "Save"
@@ -1388,9 +1392,9 @@ proc tkFDialog_ListInvoke {w text} {
set file [tkFDialog_JoinFile $data(selectPath) $text]
- if [file isdirectory $file] {
+ if {[file isdirectory $file]} {
set appPWD [pwd]
- if [catch {cd $file}] {
+ if {[catch {cd $file}]} {
tk_messageBox -type ok -parent $data(-parent) -message \
"Cannot change to the directory \"$file\".\nPermission denied."\
-icon warning
@@ -1416,7 +1420,7 @@ proc tkFDialog_Done {w {selectFilePath ""}} {
upvar #0 [winfo name $w] data
global tkPriv
- if ![string compare $selectFilePath ""] {
+ if {![string compare $selectFilePath ""]} {
set selectFilePath [tkFDialog_JoinFile $data(selectPath) \
$data(selectFile)]
set tkPriv(selectFile) $data(selectFile)
@@ -1425,11 +1429,13 @@ proc tkFDialog_Done {w {selectFilePath ""}} {
if {[file exists $selectFilePath] &&
![string compare $data(type) save]} {
- set reply [tk_messageBox -icon warning -type yesno -parent $data(-parent) \
- -message "File \"$selectFilePath\" already exists.\nDo you want to overwrite it?"]
- if ![string compare $reply "no"] {
- return
- }
+ set reply [tk_messageBox -icon warning -type yesno\
+ -parent $data(-parent) -message "File\
+ \"$selectFilePath\" already exists.\nDo\
+ you want to overwrite it?"]
+ if {![string compare $reply "no"]} {
+ return
+ }
}
}
set tkPriv(selectFilePath) $selectFilePath