summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog9
-rw-r--r--library/choosedir.tcl14
-rw-r--r--library/tkfbox.tcl53
3 files changed, 62 insertions, 14 deletions
diff --git a/ChangeLog b/ChangeLog
index 215128d..112dc0e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2005-04-12 Jeff Hobbs <jeffh@ActiveState.com>
+
+ * 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 <das@users.sourceforge.net>
* macosx/README: updated requirements for OS & developer tool
diff --git a/library/choosedir.tcl b/library/choosedir.tcl
index f52cb94..0307c15 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.16 2005/04/12 20:33:12 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 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)
}