diff options
author | hobbs <hobbs> | 2005-04-12 20:33:09 (GMT) |
---|---|---|
committer | hobbs <hobbs> | 2005-04-12 20:33:09 (GMT) |
commit | ce797b74d036be07403642fbc7356d8713572f13 (patch) | |
tree | e1918dafa1282b7e59f3705e89d6bbc51a9daab5 /library/tkfbox.tcl | |
parent | a846194a7bf66a5b3c086ad3a5f8aeb97f41620e (diff) | |
download | tk-ce797b74d036be07403642fbc7356d8713572f13.zip tk-ce797b74d036be07403642fbc7356d8713572f13.tar.gz tk-ce797b74d036be07403642fbc7356d8713572f13.tar.bz2 |
* library/tkfbox.tcl (::tk::dialog::file::): fix typeMenuLab ref.
Add undoc'd ::tk::dialog::file::showHiddenBtn var (default 0) that
will add a "Show Hidden" checkbutton to tk_get*File and
tk_chooseDirectory if set to true.
* library/choosedir.tcl (::tk::dialog::file::chooseDir::): fix
cancelBtn ref, add hiddenBtn ref for "Show Hidden" button.
Diffstat (limited to 'library/tkfbox.tcl')
-rw-r--r-- | library/tkfbox.tcl | 53 |
1 files changed, 42 insertions, 11 deletions
diff --git a/library/tkfbox.tcl b/library/tkfbox.tcl index 5e5b630..0960aad 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.50 2005/01/13 10:16:14 dkf Exp $ +# RCS: @(#) $Id: tkfbox.tcl,v 1.51 2005/04/12 20:33:13 hobbs Exp $ # # Copyright (c) 1994-1998 Sun Microsystems, Inc. # @@ -784,6 +784,8 @@ proc ::tk::IconList_Reset {w} { namespace eval ::tk::dialog {} namespace eval ::tk::dialog::file { namespace import -force ::tk::msgcat::* + set ::tk::dialog::file::showHiddenBtn 0 + set ::tk::dialog::file::showHiddenVar 1 } # ::tk::dialog::file:: -- @@ -814,7 +816,7 @@ proc ::tk::dialog::file:: {type args} { # if {![winfo exists $w]} { ::tk::dialog::file::Create $w TkFDialog - } elseif {[string compare [winfo class $w] TkFDialog]} { + } elseif {[winfo class $w] ne "TkFDialog"} { destroy $w ::tk::dialog::file::Create $w TkFDialog } else { @@ -823,13 +825,23 @@ proc ::tk::dialog::file:: {type args} { set data(upBtn) $w.f1.up set data(icons) $w.icons set data(ent) $w.f2.ent - set data(typeMenuLab) $w.f2.lab + set data(typeMenuLab) $w.f2.lab2 set data(typeMenuBtn) $w.f2.menu set data(typeMenu) $data(typeMenuBtn).m set data(okBtn) $w.f2.ok set data(cancelBtn) $w.f2.cancel + set data(hiddenBtn) $w.f2.hidden ::tk::dialog::file::SetSelectMode $w $data(-multiple) } + if {$::tk::dialog::file::showHiddenBtn} { + $data(hiddenBtn) configure -state normal + grid $data(hiddenBtn) + } else { + $data(hiddenBtn) configure -state disabled + grid remove $data(hiddenBtn) + } + + # Make sure subseqent uses of this dialog are independent [Bug 845189] catch {unset data(extUsed)} # Dialog boxes should be transient with respect to their parent, @@ -839,7 +851,7 @@ proc ::tk::dialog::file:: {type args} { # window, this can hang the entire application. Therefore we only make # the dialog transient if the parent is viewable. - if {[winfo viewable [winfo toplevel $data(-parent)]] } { + if {[winfo viewable [winfo toplevel $data(-parent)]]} { wm transient $w $data(-parent) } @@ -1027,7 +1039,7 @@ static char updir_bits[] = { $data(upBtn) config -image $Priv(updirImage) $f1.menu config -takefocus 1 -highlightthickness 2 - + pack $data(upBtn) -side right -padx 4 -fill both pack $f1.lab -side left -padx 4 -fill both pack $f1.menu -expand yes -fill both -padx 4 @@ -1077,6 +1089,19 @@ static char updir_bits[] = { focus $data(typeMenuBtn)] } + # The hidden button is displayed when ::tk::dialog::file::showHiddenBtn + # is true. Create it disabled so the binding doesn't trigger if it + # isn't shown. + if {$class eq "TkFDialog"} { + set text [mc "Show &Hidden Files and Directories"] + } else { + set text [mc "Show &Hidden Directories"] + } + set data(hiddenBtn) [::tk::AmpWidget checkbutton $f2.hidden \ + -text $text -anchor w -padx 3 -state disabled \ + -variable ::tk::dialog::file::showHiddenVar \ + -command [list ::tk::dialog::file::UpdateWhenIdle $w]] + # the okBtn is created after the typeMenu so that the keyboard traversal # is in the right order, and add binding so that we find out when the # dialog is destroyed by the user (added here instead of to the overall @@ -1084,10 +1109,10 @@ static char updir_bits[] = { # once will do). [Bug 987169] set data(okBtn) [::tk::AmpWidget button $f2.ok \ - -text "[mc "&OK"]" -default active -pady 3] + -text [mc "&OK"] -default active -pady 3] bind $data(okBtn) <Destroy> [list ::tk::dialog::file::Destroyed $w] set data(cancelBtn) [::tk::AmpWidget button $f2.cancel \ - -text "[mc "&Cancel"]" -default normal -pady 3] + -text [mc "&Cancel"] -default normal -pady 3] # grid the widgets in f2 # @@ -1097,8 +1122,9 @@ static char updir_bits[] = { grid $data(typeMenuLab) $data(typeMenuBtn) $data(cancelBtn) \ -padx 4 -sticky ew grid configure $data(typeMenuBtn) -padx 0 + grid $data(hiddenBtn) -columnspan 2 -padx 4 -sticky ew } else { - grid x x $data(cancelBtn) -padx 4 -sticky ew + grid $data(hiddenBtn) - $data(cancelBtn) -padx 4 -sticky ew } grid columnconfigure $f2 1 -weight 1 @@ -1134,6 +1160,7 @@ static char updir_bits[] = { bind $w <Alt-s> [list focus $data(ent)] bind $w <Alt-o> [list tk::ButtonInvoke $data(okBtn)] } + bind $w <Alt-h> [list $data(hiddenBtn) invoke] # Build the focus group for all the entries # @@ -1245,10 +1272,13 @@ rSASvJTGhnhcV3EJlo3kh53ltF5nAhQAOw==}] ::tk::IconList_DeleteAll $data(icons) + set showHidden $::tk::dialog::file::showHiddenVar + # Make the dir list # Using -directory [pwd] is better in some VFS cases. - set dirs [lsort -dictionary -unique \ - [glob -tails -directory [pwd] -type d -nocomplain .* *]] + set cmd [list glob -tails -directory [pwd] -type d -nocomplain *] + if {$showHidden} { lappend cmd .* } + set dirs [lsort -dictionary -unique [eval $cmd]] set dirList {} foreach d $dirs { if {$d eq "." || $d eq ".."} { @@ -1265,7 +1295,8 @@ rSASvJTGhnhcV3EJlo3kh53ltF5nAhQAOw==}] set cmd [list glob -tails -directory [pwd] \ -type {f b c l p s} -nocomplain] if {[string equal $data(filter) *]} { - lappend cmd .* * + lappend cmd * + if {$showHidden} { lappend cmd .* } } else { eval [list lappend cmd] $data(filter) } |