From 35a62312c2abb7fe1b09f1ccf4f04599f13bed0f Mon Sep 17 00:00:00 2001 From: dkf Date: Wed, 11 Aug 2004 21:24:25 +0000 Subject: More fixing of [Bug 987169] and simple support for [FRQ 979101] --- ChangeLog | 8 ++++++++ library/tkfbox.tcl | 27 +++++++++++++++++++++------ library/xmfbox.tcl | 7 +++++-- 3 files changed, 34 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5f6e525..1756e98 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2004-08-11 Donal K. Fellows + + * library/tkfbox.tcl (ResolveFile): Added some environment + variable handling; this isn't perfect, but should do what most + people want most of the time. [FRQ 979101] + * library/xmfbox.tcl (MotifFDialog_BuildUI): Fix [Bug 987169] in + the Motif file dialogs as well. + 2004-08-10 Joe English * unix/tkUnixWm.c: Fix for #1006686 "wm resizable command diff --git a/library/tkfbox.tcl b/library/tkfbox.tcl index fff9cb3..de4b618 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.44 2004/07/22 22:22:39 hobbs Exp $ +# RCS: @(#) $Id: tkfbox.tcl,v 1.45 2004/08/11 21:24:25 dkf Exp $ # # Copyright (c) 1994-1998 Sun Microsystems, Inc. # @@ -1384,11 +1384,14 @@ proc ::tk::dialog::file::SetFilter {w type} { # (2) resolve all instances of . and .. # (3) check for non-existent files/directories # (4) check for chdir permissions +# (5) conversion of environment variable references to their +# contents (once only) # # Arguments: # context: the current directory you are in # text: the text entered by the user # defaultext: the default extension to add to files with no extension +# expandEnv: whether to expand environment variables (yes by default) # # Return vaue: # [list $flag $directory $file] @@ -1407,8 +1410,7 @@ proc ::tk::dialog::file::SetFilter {w type} { # directory may not be the same as context, because text may contain # a subdirectory name # -proc ::tk::dialog::file::ResolveFile {context text defaultext} { - +proc ::tk::dialog::file::ResolveFile {context text defaultext {expandEnv 1}} { set appPWD [pwd] set path [::tk::dialog::file::JoinFile $context $text] @@ -1420,7 +1422,6 @@ proc ::tk::dialog::file::ResolveFile {context text defaultext} { set path "$path$defaultext" } - if {[catch {file exists $path}]} { # This "if" block can be safely removed if the following code # stop generating errors. @@ -1455,17 +1456,31 @@ proc ::tk::dialog::file::ResolveFile {context text defaultext} { return [list CHDIR $dirname ""] } set directory [pwd] + cd $appPWD set file [file tail $path] - if {[regexp {[*]|[?]} $file]} { + # It's nothing else, so check to see if it is an env-reference + if {$expandEnv && [string match {$*} $file]} { + set var [string range $file 1 end] + if {[info exist ::env($var)]} { + return [ResolveFile $context $::env($var) $defaultext 0] + } + } + if {[regexp {[*?]} $file]} { set flag PATTERN } else { set flag FILE } - cd $appPWD } else { set directory $dirname set file [file tail $path] set flag PATH + # It's nothing else, so check to see if it is an env-reference + if {$expandEnv && [string match {$*} $file]} { + set var [string range $file 1 end] + if {[info exist ::env($var)]} { + return [ResolveFile $context $::env($var) $defaultext 0] + } + } } } diff --git a/library/xmfbox.tcl b/library/xmfbox.tcl index 67e2804..db79815 100644 --- a/library/xmfbox.tcl +++ b/library/xmfbox.tcl @@ -4,7 +4,7 @@ # Unix platform. This implementation is used only if the # "::tk_strictMotif" flag is set. # -# RCS: @(#) $Id: xmfbox.tcl,v 1.25 2003/02/18 21:19:35 hobbs Exp $ +# RCS: @(#) $Id: xmfbox.tcl,v 1.26 2004/08/11 21:24:25 dkf Exp $ # # Copyright (c) 1996 Sun Microsystems, Inc. # Copyright (c) 1998-2000 Scriptics Corporation @@ -54,9 +54,10 @@ proc ::tk::MotifFDialog {type args} { # restore any grab that was in effect. vwait ::tk::Priv(selectFilePath) + set result $Priv(selectFilePath) ::tk::RestoreFocusGrab $w $data(sEnt) withdraw - return $Priv(selectFilePath) + return $result } # ::tk::MotifFDialog_Create -- @@ -378,6 +379,8 @@ proc ::tk::MotifFDialog_BuildUI {w} { bind $data(fEnt) [list tk::MotifFDialog_ActivateFEnt $w] bind $data(sEnt) [list tk::MotifFDialog_ActivateSEnt $w] + bind $w [list tk::MotifFDialog_CancelCmd $w] + bind $w.bot {set ::tk::Priv(selectFilePath) {}} wm protocol $w WM_DELETE_WINDOW [list tk::MotifFDialog_CancelCmd $w] } -- cgit v0.12