3 # Implements the "Motif" style file selection dialog for the
4 # Unix platform. This implementation is used only if the
5 # "::tk_strictMotif" flag is set.
7 # RCS: @(#) $Id: xmfbox.tcl,v 1.31.2.1 2009/10/22 10:27:58 dkf Exp $
9 # Copyright (c) 1996 Sun Microsystems, Inc.
10 # Copyright (c) 1998-2000 Scriptics Corporation
12 # See the file "license.terms" for information on usage and redistribution
13 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
15 namespace eval ::tk::dialog {}
16 namespace eval ::tk::dialog::file {}
19 # ::tk::MotifFDialog --
21 # Implements a file dialog similar to the standard Motif file
25 # type "open" or "save"
26 # args Options parsed by the procedure.
29 # When -multiple is set to 0, this returns the absolute pathname
30 # of the selected file. (NOTE: This is not the same as a single
33 # When -multiple is set to > 0, this returns a Tcl list of absolute
34 # pathnames. The argument for -multiple is ignored, but for consistency
35 # with Windows it defines the maximum amount of memory to allocate for
36 # the returned filenames.
38 proc ::tk::MotifFDialog {type args
} {
40 set dataName __tk_filedialog
41 upvar ::tk::dialog::file::$dataName data
43 set w
[MotifFDialog_Create
$dataName $type $args]
45 # Set a grab and claim the focus too.
47 ::tk::SetFocusGrab $w $data(sEnt
)
48 $data(sEnt
) selection range
0 end
50 # Wait for the user to respond, then restore the focus and
51 # return the index of the selected button. Restore the focus
52 # before deleting the window, since otherwise the window manager
53 # may take the focus away so we can't redirect it. Finally,
54 # restore any grab that was in effect.
56 vwait ::tk::Priv(selectFilePath
)
57 set result
$Priv(selectFilePath
)
58 ::tk::RestoreFocusGrab $w $data(sEnt
) withdraw
63 # ::tk::MotifFDialog_Create --
65 # Creates the Motif file dialog (if it doesn't exist yet) and
66 # initialize the internal data structure associated with the
69 # This procedure is used by ::tk::MotifFDialog to create the
70 # dialog. It's also used by the test suite to test the Motif
71 # file dialog implementation. User code shouldn't call this
75 # dataName Name of the global "data" array for the file dialog.
76 # type "Save" or "Open"
77 # argList Options parsed by the procedure.
80 # Pathname of the file dialog.
82 proc ::tk::MotifFDialog_Create {dataName type argList
} {
83 upvar ::tk::dialog::file::$dataName data
85 MotifFDialog_Config
$dataName $type $argList
87 if {$data(-parent) eq
"."} {
90 set w
$data(-parent).
$dataName
93 # (re)create the dialog box if necessary
95 if {![winfo exists
$w]} {
96 MotifFDialog_BuildUI
$w
97 } elseif
{[winfo class
$w] ne
"TkMotifFDialog"} {
99 MotifFDialog_BuildUI
$w
101 set data
(fEnt
) $w.top.f1.ent
102 set data
(dList
) $w.top.f2.a.l
103 set data
(fList
) $w.top.f2.b.l
104 set data
(sEnt
) $w.top.f3.ent
105 set data
(okBtn
) $w.bot.ok
106 set data
(filterBtn
) $w.bot.filter
107 set data
(cancelBtn
) $w.bot.cancel
109 MotifFDialog_SetListMode
$w
111 # Dialog boxes should be transient with respect to their parent,
112 # so that they will always stay on top of their parent window. However,
113 # some window managers will create the window as withdrawn if the parent
114 # window is withdrawn or iconified. Combined with the grab we put on the
115 # window, this can hang the entire application. Therefore we only make
116 # the dialog transient if the parent is viewable.
118 if {[winfo viewable
[winfo toplevel $data(-parent)]] } {
119 wm transient
$w $data(-parent)
122 MotifFDialog_FileTypes
$w
123 MotifFDialog_Update
$w
125 # Withdraw the window, then update all the geometry information
126 # so we know how big it wants to be, then center the window in the
127 # display (Motif style) and de-iconify it.
130 wm title
$w $data(-title)
135 # ::tk::MotifFDialog_FileTypes --
137 # Checks the -filetypes option. If present this adds a list of radio-
138 # buttons to pick the file types from.
141 # w Pathname of the tk_get*File dialogue.
146 proc ::tk::MotifFDialog_FileTypes {w
} {
147 upvar ::tk::dialog::file::[winfo name
$w] data
149 set f
$w.top.f3.types
152 # No file types: use "*" as the filter and display no radio-buttons
153 if {$data(-filetypes) eq
""} {
158 # The filetypes radiobuttons
159 # set data(fileType) $data(-defaulttype)
160 # Default type to first entry
161 set initialTypeName
[lindex $data(-filetypes) 0 0]
162 if {$data(-typevariable) ne
""} {
163 upvar #0 $data(-typevariable) typeVariable
164 if {[info exist typeVariable
]} {
165 set initialTypeName
$typeVariable
170 foreach fltr
$data(-filetypes) {
171 set fname
[lindex $fltr 0]
172 if {[string first
$initialTypeName $fname] == 0} {
173 set data
(fileType
) $ix
179 MotifFDialog_SetFilter
$w [lindex $data(-filetypes) $data(fileType
)]
181 #don't produce radiobuttons for only one filetype
182 if {[llength $data(-filetypes)] == 1} {
188 if {$data(-filetypes) ne
{}} {
189 foreach type
$data(-filetypes) {
190 set title
[lindex [lindex $type 0] 0]
191 set filter
[lindex $type 1]
192 radiobutton $f.b
$cnt \
194 -variable ::tk::dialog::file::[winfo name
$w](fileType
) \
196 -command [list tk::MotifFDialog_SetFilter $w $type]
197 pack $f.b
$cnt -side left
201 $f.b
$data(fileType
) invoke
203 pack $f -side bottom
-fill both
208 # This proc gets called whenever data(filter) is set
210 proc ::tk::MotifFDialog_SetFilter {w type
} {
211 upvar ::tk::dialog::file::[winfo name
$w] data
214 set data
(filter
) [lindex $type 1]
215 set Priv
(selectFileType
) [lindex [lindex $type 0] 0]
217 MotifFDialog_Update
$w
220 # ::tk::MotifFDialog_Config --
222 # Iterates over the optional arguments to determine the option
223 # values for the Motif file dialog; gives default values to
224 # unspecified options.
227 # dataName The name of the global variable in which
228 # data for the file dialog is stored.
229 # type "Save" or "Open"
230 # argList Options parsed by the procedure.
232 proc ::tk::MotifFDialog_Config {dataName type argList
} {
233 upvar ::tk::dialog::file::$dataName data
237 # 1: the configuration specs
240 {-defaultextension "" "" ""}
241 {-filetypes "" "" ""}
242 {-initialdir "" "" ""}
243 {-initialfile "" "" ""}
246 {-typevariable "" "" ""}
248 if {$type eq
"open"} {
249 lappend specs
{-multiple "" "" "0"}
252 set data
(-multiple) 0
253 # 2: default values depending on the type of the dialog
255 if {![info exists data
(selectPath
)]} {
256 # first time the dialog has been popped up
257 set data
(selectPath
) [pwd]
258 set data
(selectFile
) ""
261 # 3: parse the arguments
263 tclParseConfigSpec
::tk::dialog::file::$dataName $specs "" $argList
265 if {$data(-title) eq
""} {
266 if {$type eq
"open"} {
267 if {$data(-multiple) != 0} {
268 set data
(-title) "[mc {Open Multiple Files}]"
270 set data
(-title) [mc
"Open"]
273 set data
(-title) [mc
"Save As"]
277 # 4: set the default directory and selection according to the -initial
280 if {$data(-initialdir) ne
""} {
281 if {[file isdirectory
$data(-initialdir)]} {
282 set data
(selectPath
) [lindex [glob $data(-initialdir)] 0]
284 set data
(selectPath
) [pwd]
287 # Convert the initialdir to an absolute path name.
291 set data
(selectPath
) [pwd]
294 set data
(selectFile
) $data(-initialfile)
296 # 5. Parse the -filetypes option. It is not used by the motif
297 # file dialog, but we check for validity of the value to make sure
298 # the application code also runs fine with the TK file dialog.
300 set data
(-filetypes) [::tk::FDGetFileTypes $data(-filetypes)]
302 if {![info exists data
(filter
)]} {
305 if {![winfo exists
$data(-parent)]} {
306 error "bad window path name \"$data(-parent)\""
310 # ::tk::MotifFDialog_BuildUI --
312 # Builds the UI components of the Motif file dialog.
315 # w Pathname of the dialog to build.
320 proc ::tk::MotifFDialog_BuildUI {w
} {
321 set dataName
[lindex [split $w .
] end
]
322 upvar ::tk::dialog::file::$dataName data
324 # Create the dialog toplevel and internal frames.
326 toplevel $w -class TkMotifFDialog
327 set top
[frame $w.top
-relief raised
-bd 1]
328 set bot
[frame $w.bot
-relief raised
-bd 1]
330 pack $w.bot
-side bottom
-fill x
331 pack $w.top
-side top
-expand yes
-fill both
333 set f1
[frame $top.f1
]
334 set f2
[frame $top.f2
]
335 set f3
[frame $top.f3
]
337 pack $f1 -side top
-fill x
338 pack $f3 -side bottom
-fill x
339 pack $f2 -expand yes
-fill both
341 set f2a
[frame $f2.a
]
342 set f2b
[frame $f2.b
]
344 grid $f2a -row 0 -column 0 -rowspan 1 -columnspan 1 -padx 4 -pady 4 \
346 grid $f2b -row 0 -column 1 -rowspan 1 -columnspan 1 -padx 4 -pady 4 \
348 grid rowconfigure
$f2 0 -minsize 0 -weight 1
349 grid columnconfigure
$f2 0 -minsize 0 -weight 1
350 grid columnconfigure
$f2 1 -minsize 150 -weight 2
354 bind [::tk::AmpWidget label $f1.lab
-text [mc
"Fil&ter:"] -anchor w
] \
355 <<AltUnderlined
>> [list focus $f1.ent
]
357 pack $f1.lab
-side top
-fill x
-padx 6 -pady 4
358 pack $f1.ent
-side top
-fill x
-padx 4 -pady 0
359 set data
(fEnt
) $f1.ent
361 # The file and directory lists
363 set data
(dList
) [MotifFDialog_MakeSList
$w $f2a \
364 [mc
"&Directory:"] DList
]
365 set data
(fList
) [MotifFDialog_MakeSList
$w $f2b \
366 [mc
"Fi&les:"] FList
]
370 bind [::tk::AmpWidget label $f3.lab
-text [mc
"&Selection:"] -anchor w
] \
371 <<AltUnderlined
>> [list focus $f3.ent
]
373 pack $f3.lab
-side top
-fill x
-padx 6 -pady 0
374 pack $f3.ent
-side top
-fill x
-padx 4 -pady 4
375 set data
(sEnt
) $f3.ent
379 set maxWidth
[::tk::mcmaxamp &OK
&Filter
&Cancel
]
380 set maxWidth
[expr {$maxWidth<6?
6:$maxWidth}]
381 set data
(okBtn
) [::tk::AmpWidget button $bot.ok
-text [mc
"&OK"] \
383 -command [list tk::MotifFDialog_OkCmd $w]]
384 set data
(filterBtn
) [::tk::AmpWidget button $bot.filter
-text [mc
"&Filter"] \
386 -command [list tk::MotifFDialog_FilterCmd $w]]
387 set data
(cancelBtn
) [::tk::AmpWidget button $bot.cancel
-text [mc
"&Cancel"] \
389 -command [list tk::MotifFDialog_CancelCmd $w]]
391 pack $bot.ok
$bot.filter
$bot.cancel
-padx 10 -pady 10 -expand yes
\
394 # Create the bindings:
396 bind $w <Alt-Key
> [list ::tk::AltKeyInDialog $w %A
]
398 bind $data(fEnt
) <Return
> [list tk::MotifFDialog_ActivateFEnt $w]
399 bind $data(sEnt
) <Return
> [list tk::MotifFDialog_ActivateSEnt $w]
400 bind $w <Escape
> [list tk::MotifFDialog_CancelCmd $w]
401 bind $w.bot
<Destroy
> {set ::tk::Priv(selectFilePath
) {}}
403 wm protocol
$w WM_DELETE_WINDOW
[list tk::MotifFDialog_CancelCmd $w]
406 proc ::tk::MotifFDialog_SetListMode {w
} {
407 upvar ::tk::dialog::file::[winfo name
$w] data
409 if {$data(-multiple) != 0} {
410 set selectmode extended
412 set selectmode browse
415 $f.l configure
-selectmode $selectmode
418 # ::tk::MotifFDialog_MakeSList --
420 # Create a scrolled-listbox and set the keyboard accelerator
421 # bindings so that the list selection follows what the user
425 # w Pathname of the dialog box.
426 # f Frame widget inside which to create the scrolled
427 # listbox. This frame widget already exists.
428 # label The string to display on top of the listbox.
429 # under Sets the -under option of the label.
430 # cmdPrefix Specifies procedures to call when the listbox is
431 # browsed or activated.
433 proc ::tk::MotifFDialog_MakeSList {w f
label cmdPrefix
} {
434 bind [::tk::AmpWidget label $f.lab
-text $label -anchor w
] \
435 <<AltUnderlined
>> [list focus $f.l
]
436 listbox $f.l
-width 12 -height 5 -exportselection 0\
437 -xscrollcommand [list $f.h
set] -yscrollcommand [list $f.v
set]
438 scrollbar $f.v
-orient vertical
-takefocus 0 -command [list $f.l yview
]
439 scrollbar $f.h
-orient horizontal
-takefocus 0 -command [list $f.l xview
]
440 grid $f.lab
-row 0 -column 0 -sticky news
-rowspan 1 -columnspan 2 \
442 grid $f.l
-row 1 -column 0 -rowspan 1 -columnspan 1 -sticky news
443 grid $f.v
-row 1 -column 1 -rowspan 1 -columnspan 1 -sticky news
444 grid $f.h
-row 2 -column 0 -rowspan 1 -columnspan 1 -sticky news
446 grid rowconfigure
$f 0 -weight 0 -minsize 0
447 grid rowconfigure
$f 1 -weight 1 -minsize 0
448 grid columnconfigure
$f 0 -weight 1 -minsize 0
450 # bindings for the listboxes
453 bind $list <<ListboxSelect
>> [list tk::MotifFDialog_Browse$cmdPrefix $w]
454 bind $list <Double-ButtonRelease-1
> \
455 [list tk::MotifFDialog_Activate$cmdPrefix $w]
456 bind $list <Return
> "tk::MotifFDialog_Browse$cmdPrefix [list $w]; \
457 tk::MotifFDialog_Activate$cmdPrefix [list $w]"
459 bindtags $list [list Listbox
$list [winfo toplevel $list] all
]
460 ListBoxKeyAccel_Set
$list
465 # ::tk::MotifFDialog_InterpFilter --
467 # Interpret the string in the filter entry into two components:
468 # the directory and the pattern. If the string is a relative
469 # pathname, give a warning to the user and restore the pattern
473 # w pathname of the dialog box.
476 # A list of two elements. The first element is the directory
477 # specified # by the filter. The second element is the filter
480 proc ::tk::MotifFDialog_InterpFilter {w
} {
481 upvar ::tk::dialog::file::[winfo name
$w] data
483 set text [string trim
[$data(fEnt
) get
]]
485 # Perform tilde substitution
488 if {[string index
$text 0] eq
"~"} {
489 set list [file split $text]
490 set tilde
[lindex $list 0]
491 if {[catch {set tilde
[glob $tilde]}]} {
494 set text [eval file join [concat $tilde [lrange $list 1 end
]]]
498 # If the string is a relative pathname, combine it
499 # with the current selectPath.
502 if {[file pathtype
$text] eq
"relative"} {
504 } elseif
{$badTilde} {
509 tk_messageBox -icon warning
-type ok
\
510 -message "\"$text\" must be an absolute pathname"
512 $data(fEnt
) delete
0 end
513 $data(fEnt
) insert
0 [::tk::dialog::file::JoinFile $data(selectPath
) \
516 return [list $data(selectPath
) $data(filter
)]
519 set resolved
[::tk::dialog::file::JoinFile [file dirname
$text] [file tail
$text]]
521 if {[file isdirectory
$resolved]} {
523 set fil
$data(filter
)
525 set dir
[file dirname
$resolved]
526 set fil
[file tail
$resolved]
529 return [list $dir $fil]
532 # ::tk::MotifFDialog_Update
534 # Load the files and synchronize the "filter" and "selection" fields
538 # w pathname of the dialog box.
543 proc ::tk::MotifFDialog_Update {w
} {
544 upvar ::tk::dialog::file::[winfo name
$w] data
546 $data(fEnt
) delete
0 end
547 $data(fEnt
) insert
0 \
548 [::tk::dialog::file::JoinFile $data(selectPath
) $data(filter
)]
549 $data(sEnt
) delete
0 end
550 $data(sEnt
) insert
0 [::tk::dialog::file::JoinFile $data(selectPath
) \
553 MotifFDialog_LoadFiles
$w
556 # ::tk::MotifFDialog_LoadFiles --
558 # Loads the files and directories into the two listboxes according
559 # to the filter setting.
562 # w pathname of the dialog box.
567 proc ::tk::MotifFDialog_LoadFiles {w
} {
568 upvar ::tk::dialog::file::[winfo name
$w] data
570 $data(dList
) delete
0 end
571 $data(fList
) delete
0 end
574 if {[catch {cd $data(selectPath
)}]} {
577 $data(dList
) insert end
".."
581 # Make the dir and file lists
583 # For speed we only have one glob, which reduces the file system
584 # calls (good for slow NFS networks).
586 # We also do two smaller sorts (files + dirs) instead of one large sort,
587 # which gives a small speed increase.
592 foreach f
[glob -nocomplain .
* *] {
593 if {[file isdir .
/$f]} {
596 foreach pat
$data(filter
) {
597 if {[string match
$pat $f]} {
598 if {[string match .
* $f]} {
607 eval [list $data(dList
) insert end
] [lsort -dictionary $dlist]
608 eval [list $data(fList
) insert end
] [lsort -dictionary $flist]
610 # The user probably doesn't want to see the . files. We adjust the view
611 # so that the listbox displays all the non-dot files
612 $data(fList
) yview
$top
617 # ::tk::MotifFDialog_BrowseDList --
619 # This procedure is called when the directory list is browsed
620 # (clicked-over) by the user.
623 # w The pathname of the dialog box.
628 proc ::tk::MotifFDialog_BrowseDList {w
} {
629 upvar ::tk::dialog::file::[winfo name
$w] data
632 if {[$data(dList
) curselection
] eq
""} {
635 set subdir
[$data(dList
) get
[$data(dList
) curselection
]]
640 $data(fList
) selection clear
0 end
642 set list [MotifFDialog_InterpFilter
$w]
643 set data
(filter
) [lindex $list 1]
647 set newSpec
[::tk::dialog::file::JoinFile $data(selectPath
) $data(filter
)]
650 set newSpec
[::tk::dialog::file::JoinFile [file dirname
$data(selectPath
)] \
654 set newSpec
[::tk::dialog::file::JoinFile [::tk::dialog::file::JoinFile \
655 $data(selectPath
) $subdir] $data(filter
)]
659 $data(fEnt
) delete
0 end
660 $data(fEnt
) insert
0 $newSpec
663 # ::tk::MotifFDialog_ActivateDList --
665 # This procedure is called when the directory list is activated
666 # (double-clicked) by the user.
669 # w The pathname of the dialog box.
674 proc ::tk::MotifFDialog_ActivateDList {w
} {
675 upvar ::tk::dialog::file::[winfo name
$w] data
677 if {[$data(dList
) curselection
] eq
""} {
680 set subdir
[$data(dList
) get
[$data(dList
) curselection
]]
685 $data(fList
) selection clear
0 end
689 set newDir
$data(selectPath
)
692 set newDir
[file dirname
$data(selectPath
)]
695 set newDir
[::tk::dialog::file::JoinFile $data(selectPath
) $subdir]
699 set data
(selectPath
) $newDir
700 MotifFDialog_Update
$w
702 if {$subdir ne
".."} {
703 $data(dList
) selection set 0
704 $data(dList
) activate
0
706 $data(dList
) selection set 1
707 $data(dList
) activate
1
711 # ::tk::MotifFDialog_BrowseFList --
713 # This procedure is called when the file list is browsed
714 # (clicked-over) by the user.
717 # w The pathname of the dialog box.
722 proc ::tk::MotifFDialog_BrowseFList {w
} {
723 upvar ::tk::dialog::file::[winfo name
$w] data
726 set data
(selectFile
) ""
727 foreach item
[$data(fList
) curselection
] {
728 lappend data
(selectFile
) [$data(fList
) get
$item]
730 if {[llength $data(selectFile
)] == 0} {
734 $data(dList
) selection clear
0 end
736 $data(fEnt
) delete
0 end
737 $data(fEnt
) insert
0 [::tk::dialog::file::JoinFile $data(selectPath
) \
739 $data(fEnt
) xview end
741 # if it's a multiple selection box, just put in the filenames
742 # otherwise put in the full path as usual
743 $data(sEnt
) delete
0 end
744 if {$data(-multiple) != 0} {
745 $data(sEnt
) insert
0 $data(selectFile
)
747 $data(sEnt
) insert
0 [::tk::dialog::file::JoinFile $data(selectPath
) \
748 [lindex $data(selectFile
) 0]]
750 $data(sEnt
) xview end
753 # ::tk::MotifFDialog_ActivateFList --
755 # This procedure is called when the file list is activated
756 # (double-clicked) by the user.
759 # w The pathname of the dialog box.
764 proc ::tk::MotifFDialog_ActivateFList {w
} {
765 upvar ::tk::dialog::file::[winfo name
$w] data
767 if {[$data(fList
) curselection
] eq
""} {
770 set data
(selectFile
) [$data(fList
) get
[$data(fList
) curselection
]]
771 if {$data(selectFile
) eq
""} {
774 MotifFDialog_ActivateSEnt
$w
778 # ::tk::MotifFDialog_ActivateFEnt --
780 # This procedure is called when the user presses Return inside
781 # the "filter" entry. It updates the dialog according to the
782 # text inside the filter entry.
785 # w The pathname of the dialog box.
790 proc ::tk::MotifFDialog_ActivateFEnt {w
} {
791 upvar ::tk::dialog::file::[winfo name
$w] data
793 set list [MotifFDialog_InterpFilter
$w]
794 set data
(selectPath
) [lindex $list 0]
795 set data
(filter
) [lindex $list 1]
797 MotifFDialog_Update
$w
800 # ::tk::MotifFDialog_ActivateSEnt --
802 # This procedure is called when the user presses Return inside
803 # the "selection" entry. It sets the ::tk::Priv(selectFilePath)
804 # variable so that the vwait loop in tk::MotifFDialog will be
808 # w The pathname of the dialog box.
813 proc ::tk::MotifFDialog_ActivateSEnt {w
} {
815 upvar ::tk::dialog::file::[winfo name
$w] data
817 set selectFilePath
[string trim
[$data(sEnt
) get
]]
819 if {$selectFilePath eq
""} {
820 MotifFDialog_FilterCmd
$w
824 if {$data(-multiple) == 0} {
825 set selectFilePath
[list $selectFilePath]
828 if {[file isdirectory
[lindex $selectFilePath 0]]} {
829 set data
(selectPath
) [lindex [glob $selectFilePath] 0]
830 set data
(selectFile
) ""
831 MotifFDialog_Update
$w
836 foreach item
$selectFilePath {
837 if {[file pathtype
$item] ne
"absolute"} {
838 set item
[file join $data(selectPath
) $item]
839 } elseif
{![file exists
[file dirname
$item]]} {
840 tk_messageBox -icon warning
-type ok
\
841 -message [mc
{Directory
"%1$s" does not exist.
} \
842 [file dirname
$item]]
846 if {![file exists
$item]} {
847 if {$data(type
) eq
"open"} {
848 tk_messageBox -icon warning
-type ok
\
849 -message [mc
{File
"%1$s" does not exist.
} $item]
852 } elseif
{$data(type
) eq
"save"} {
853 set message [format %s
%s
\
854 [mc
"File \"%1\$s\" already exists.\n\n" $selectFilePath] \
855 [mc
{Replace existing
file?
}]]
856 set answer
[tk_messageBox -icon warning
-type yesno
\
858 if {$answer eq
"no"} {
863 lappend newFileList
$item
866 # Return selected filter
867 if {[info exists data
(-typevariable)] && $data(-typevariable) ne
""
868 && [info exists data
(-filetypes)] && $data(-filetypes) ne
""} {
869 upvar #0 $data(-typevariable) typeVariable
870 set typeVariable
[lindex $data(-filetypes) $data(fileType
) 0]
873 if {$data(-multiple) != 0} {
874 set Priv
(selectFilePath
) $newFileList
876 set Priv
(selectFilePath
) [lindex $newFileList 0]
879 # Set selectFile and selectPath to first item in list
880 set Priv
(selectFile
) [file tail
[lindex $newFileList 0]]
881 set Priv
(selectPath
) [file dirname
[lindex $newFileList 0]]
885 proc ::tk::MotifFDialog_OkCmd {w
} {
886 upvar ::tk::dialog::file::[winfo name
$w] data
888 MotifFDialog_ActivateSEnt
$w
891 proc ::tk::MotifFDialog_FilterCmd {w
} {
892 upvar ::tk::dialog::file::[winfo name
$w] data
894 MotifFDialog_ActivateFEnt
$w
897 proc ::tk::MotifFDialog_CancelCmd {w
} {
900 set Priv
(selectFilePath
) ""
901 set Priv
(selectFile
) ""
902 set Priv
(selectPath
) ""
905 proc ::tk::ListBoxKeyAccel_Set {w
} {
906 bind Listbox
<Any-KeyPress
> ""
907 bind $w <Destroy
> [list tk::ListBoxKeyAccel_Unset $w]
908 bind $w <Any-KeyPress
> [list tk::ListBoxKeyAccel_Key $w %A
]
911 proc ::tk::ListBoxKeyAccel_Unset {w
} {
914 catch {after cancel
$Priv(lbAccel
,$w,afterId
)}
915 unset -nocomplain Priv
(lbAccel
,$w) Priv
(lbAccel
,$w,afterId
)
918 # ::tk::ListBoxKeyAccel_Key--
920 # This procedure maintains a list of recently entered keystrokes
921 # over a listbox widget. It arranges an idle event to move the
922 # selection of the listbox to the entry that begins with the
926 # w The pathname of the listbox.
927 # key The key which the user just pressed.
932 proc ::tk::ListBoxKeyAccel_Key {w key
} {
938 append Priv
(lbAccel
,$w) $key
939 ListBoxKeyAccel_Goto
$w $Priv(lbAccel
,$w)
941 after cancel
$Priv(lbAccel
,$w,afterId
)
943 set Priv
(lbAccel
,$w,afterId
) [after 500 \
944 [list tk::ListBoxKeyAccel_Reset $w]]
947 proc ::tk::ListBoxKeyAccel_Goto {w
string} {
950 set string [string tolower
$string]
951 set end
[$w index end
]
954 for {set i
0} {$i < $end} {incr i
} {
955 set item
[string tolower
[$w get
$i]]
956 if {[string compare
$string $item] >= 0} {
959 if {[string compare
$string $item] <= 0} {
965 if {$theIndex >= 0} {
966 $w selection clear
0 end
967 $w selection set $theIndex $theIndex
968 $w activate
$theIndex
970 event generate
$w <<ListboxSelect
>>
974 proc ::tk::ListBoxKeyAccel_Reset {w
} {
977 unset -nocomplain Priv
(lbAccel
,$w)
980 proc ::tk_getFileType {} {
983 return $Priv(selectFileType
)