diff options
author | hobbs <hobbs> | 2003-11-11 22:39:35 (GMT) |
---|---|---|
committer | hobbs <hobbs> | 2003-11-11 22:39:35 (GMT) |
commit | cf2d11dba3a14674460a3022a91de2d4618e6365 (patch) | |
tree | 25d0b10575628d331bc3773483e6db2454dfa730 | |
parent | 359e23ebdc992276e306cb81ac749dc725072d3f (diff) | |
download | tk-cf2d11dba3a14674460a3022a91de2d4618e6365.zip tk-cf2d11dba3a14674460a3022a91de2d4618e6365.tar.gz tk-cf2d11dba3a14674460a3022a91de2d4618e6365.tar.bz2 |
* library/tkfbox.tcl (::tk::dialog::file::Update): optimize the
dir/files list separation by using the -tails, -directory and
-type option of 'glob'. Also passes the glob the -filetypes
filters instead of calling string match over each file.
[Patch #833819]
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | library/tkfbox.tcl | 54 |
2 files changed, 25 insertions, 35 deletions
@@ -1,5 +1,11 @@ 2003-11-11 Jeff Hobbs <jeffh@ActiveState.com> + * library/tkfbox.tcl (::tk::dialog::file::Update): optimize the + dir/files list separation by using the -tails, -directory and + -type option of 'glob'. Also passes the glob the -filetypes + filters instead of calling string match over each file. + [Patch #833819] + * generic/tkListbox.c (ListboxDeleteSubCmd, ListboxListVarProc): free itemconfig data when removing it from table. [Bug #836483] diff --git a/library/tkfbox.tcl b/library/tkfbox.tcl index 384a473..f5431cd 100644 --- a/library/tkfbox.tcl +++ b/library/tkfbox.tcl @@ -11,7 +11,7 @@ # files by clicking on the file icons or by entering a filename # in the "Filename:" entry. # -# RCS: @(#) $Id: tkfbox.tcl,v 1.38.2.1 2003/10/29 09:40:34 dkf Exp $ +# RCS: @(#) $Id: tkfbox.tcl,v 1.38.2.2 2003/11/11 22:39:36 hobbs Exp $ # # Copyright (c) 1994-1998 Sun Microsystems, Inc. # @@ -773,7 +773,7 @@ proc ::tk::IconList_Reset {w} { namespace eval ::tk::dialog {} namespace eval ::tk::dialog::file { - namespace import ::tk::msgcat::* + namespace import -force ::tk::msgcat::* } # ::tk::dialog::file:: -- @@ -1195,8 +1195,7 @@ proc ::tk::dialog::file::Update {w} { return } set class [winfo class $w] - if { [string compare $class TkFDialog] && \ - [string compare $class TkChooseDir] } { + if {($class ne "TkFDialog") && ($class ne "TkChooseDir")} { return } @@ -1225,9 +1224,8 @@ rSASvJTGhnhcV3EJlo3kh53ltF5nAhQAOw==}] # should have been checked before ::tk::dialog::file::Update is called, so # we normally won't come to here. Anyways, give an error and abort # action. - tk_messageBox -type ok -parent $w -message \ - "[mc "Cannot change to the directory \"%1\$s\".\nPermission denied." $data(selectPath)]"\ - -icon warning + tk_messageBox -type ok -parent $w -icon warning -message \ + [mc "Cannot change to the directory \"%1\$s\".\nPermission denied." $data(selectPath)] cd $appPWD return } @@ -1240,47 +1238,33 @@ rSASvJTGhnhcV3EJlo3kh53ltF5nAhQAOw==}] $data(ent) config -cursor watch $w config -cursor watch update idletasks - + ::tk::IconList_DeleteAll $data(icons) # Make the dir list # - set completeFileList [lsort -dictionary -unique [glob -nocomplain .* *]] + set dirs [lsort -dictionary -unique \ + [glob -tails -directory . -type d -nocomplain .* *]] set dirList {} - foreach f $completeFileList { - if {[string equal $f .]} { - continue - } - if {[string equal $f ..]} { + foreach d $dirs { + if {$d eq "." || $d eq ".."} { continue } - if {[file isdir ./$f]} { - lappend dirList $f - } + lappend dirList $d } ::tk::IconList_Add $data(icons) $folder $dirList - if { [string equal $class TkFDialog] } { - # Make the file list if this is a File Dialog + + if {$class eq "TkFDialog"} { + # Make the file list if this is a File Dialog, selecting all + # but 'd'irectory type files. # + set cmd [list glob -tails -directory . -type {f b c l p s} -nocomplain] if {[string equal $data(filter) *]} { - set files $completeFileList + lappend cmd .* * } else { - set files {} - foreach f $completeFileList { - foreach pat $data(filter) { - if { [string match $pat $f] } { - lappend files $f - break - } - } - } - } - set fileList {} - foreach f $files { - if {![file isdir ./$f]} { - lappend fileList $f - } + eval [list lappend cmd] $data(filter) } + set fileList [lsort -dictionary -unique [eval $cmd]] ::tk::IconList_Add $data(icons) $file $fileList } |