summaryrefslogtreecommitdiffstats
path: root/library
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2001-12-14 14:56:46 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2001-12-14 14:56:46 (GMT)
commitcb028bc2763e8b11a687f4d7ce2a4f663df20eae (patch)
treeded0be506dc2a4b3aef3e4c0225bde88e94706ac /library
parent0237d96dcf280293c2df424bca568c9023ffe783 (diff)
downloadtk-cb028bc2763e8b11a687f4d7ce2a4f663df20eae.zip
tk-cb028bc2763e8b11a687f4d7ce2a4f663df20eae.tar.gz
tk-cb028bc2763e8b11a687f4d7ce2a4f663df20eae.tar.bz2
Added code to guess the correct default extension from whatever value
was selected in the filetypes option menu. Adapted from code by Chris Nelson submitted in Patch #492220.
Diffstat (limited to 'library')
-rw-r--r--library/tkfbox.tcl33
1 files changed, 27 insertions, 6 deletions
diff --git a/library/tkfbox.tcl b/library/tkfbox.tcl
index 7fce44e..62b5b6b 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.31 2001/09/17 14:12:18 dkf Exp $
+# RCS: @(#) $Id: tkfbox.tcl,v 1.32 2001/12/14 14:56:46 dkf Exp $
#
# Copyright (c) 1994-1998 Sun Microsystems, Inc.
#
@@ -959,12 +959,10 @@ proc ::tk::dialog::file::Config {dataName type argList} {
# like "yes") so we can use it in tests more easily.
if {![string compare $type save]} {
set data(-multiple) 0
+ } elseif {$data(-multiple)} {
+ set data(-multiple) 1
} else {
- if {$data(-multiple)} {
- set data(-multiple) 1
- } else {
- set data(-multiple) 0
- }
+ set data(-multiple) 0
}
}
@@ -1365,6 +1363,29 @@ proc ::tk::dialog::file::SetFilter {w type} {
set data(filter) [lindex $type 1]
$data(typeMenuBtn) config -text [lindex $type 0] -indicatoron 1
+ # If we aren't using a default extension, use the one suppled
+ # by the filter.
+ if {![info exists data(extUsed)]} {
+ if {[string length $data(-defaultextension)]} {
+ set data(extUsed) 1
+ } else {
+ set data(extUsed) 0
+ }
+ }
+
+ if {!$data(extUsed)} {
+ # Get the first extension in the list that matches {^\*\.\w+$}
+ # and remove all * from the filter.
+ set index [lsearch -regexp $data(filter) {^\*\.\w+$}]
+ if {$index >= 0} {
+ set data(-defaultextension) \
+ [string trimleft [lindex $data(filter) $index] "*"]
+ } else {
+ # Couldn't find anything! Reset to a safe default...
+ set data(-defaultextension) ""
+ }
+ }
+
$icons(sbar) set 0.0 0.0
::tk::dialog::file::UpdateWhenIdle $w