From 56d7376fb090c2f916062d0245252d6fdeaba8e4 Mon Sep 17 00:00:00 2001 From: hobbs Date: Tue, 12 Apr 2005 20:33:34 +0000 Subject: * 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. --- ChangeLog | 9 +++++++++ library/choosedir.tcl | 14 +++++++++++--- library/tkfbox.tcl | 52 ++++++++++++++++++++++++++++++++++++++++----------- 3 files changed, 61 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index c570081..d974f05 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2005-04-12 Jeff Hobbs + + * 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. + 2005-04-09 Daniel Steffen * macosx/README: updated requirements for OS & developer tool diff --git a/library/choosedir.tcl b/library/choosedir.tcl index f52cb94..073dedc 100644 --- a/library/choosedir.tcl +++ b/library/choosedir.tcl @@ -5,7 +5,7 @@ # Copyright (c) 1998-2000 by Scriptics Corporation. # All rights reserved. # -# RCS: @(#) $Id: choosedir.tcl,v 1.15 2002/07/22 21:25:39 mdejong Exp $ +# RCS: @(#) $Id: choosedir.tcl,v 1.15.2.1 2005/04/12 20:33:35 hobbs Exp $ # Make sure the tk::dialog namespace, in which all dialogs should live, exists namespace eval ::tk::dialog {} @@ -13,7 +13,7 @@ namespace eval ::tk::dialog::file {} # Make the chooseDir namespace inside the dialog namespace namespace eval ::tk::dialog::file::chooseDir { - namespace import ::tk::msgcat::* + namespace import -force ::tk::msgcat::* } # ::tk::dialog::file::chooseDir:: -- @@ -49,7 +49,15 @@ proc ::tk::dialog::file::chooseDir:: {args} { set data(icons) $w.icons set data(ent) $w.f2.ent set data(okBtn) $w.f2.ok - set data(cancelBtn) $w.f3.cancel + set data(cancelBtn) $w.f2.cancel + set data(hiddenBtn) $w.f2.hidden + } + if {$::tk::dialog::file::showHiddenBtn} { + $data(hiddenBtn) configure -state normal + grid $data(hiddenBtn) + } else { + $data(hiddenBtn) configure -state disabled + grid remove $data(hiddenBtn) } # Dialog boxes should be transient with respect to their parent, diff --git a/library/tkfbox.tcl b/library/tkfbox.tcl index 26606fb..0cfa409 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.7 2004/09/10 22:28:30 dkf Exp $ +# RCS: @(#) $Id: tkfbox.tcl,v 1.38.2.8 2005/04/12 20:33:35 hobbs Exp $ # # Copyright (c) 1994-1998 Sun Microsystems, Inc. # @@ -774,6 +774,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:: -- @@ -804,7 +806,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 { @@ -813,13 +815,22 @@ 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)} @@ -830,7 +841,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) } @@ -1018,7 +1029,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 @@ -1068,6 +1079,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 @@ -1075,10 +1099,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) [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 # @@ -1088,8 +1112,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 @@ -1125,6 +1150,7 @@ static char updir_bits[] = { bind $w [list focus $data(ent)] bind $w [list tk::ButtonInvoke $data(okBtn)] } + bind $w [list $data(hiddenBtn) invoke] # Build the focus group for all the entries # @@ -1236,10 +1262,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 ".."} { @@ -1256,7 +1285,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) } -- cgit v0.12