# xmfbox.tcl --
#
# Implements the "Motif" style file selection dialog for the
# Unix platform. This implementation is used only if the
# "tk_strictMotif" flag is set.
#
# SCCS: @(#) xmfbox.tcl 1.5 96/10/04 17:09:24
#
# Copyright (c) 1996 Sun Microsystems, Inc.
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
# tkMotifFDialog --
#
# Implements a file dialog similar to the standard Motif file
# selection box.
#
# Return value:
#
# A list of two members. The first member is the absolute
# pathname of the selected file or "" if user hits cancel. The
# second member is the name of the selected file type, or ""
# which stands for "default file type"
#
global tkPriv
set w .__tk_filedialog
upvar #0 $w data
set type open
} else {
}
# (re)create the dialog box if necessary
#
destroy $w
}
# 5. Withdraw the window, then update all the geometry information
# so we know how big it wants to be, then center the window in the
# display and de-iconify it.
update idletasks
# 6. Set a grab and claim the focus too.
set oldFocus [focus]
}
grab $w
# 7. Wait for the user to respond, then restore the focus and
# return the index of the selected button. Restore the focus
# before deleting the window, since otherwise the window manager
# may take the focus away so we can't redirect it. Finally,
# restore any grab that was in effect.
tkwait variable tkPriv(selectFilePath)
catch {focus $oldFocus}
grab -global $oldGrab
} else {
grab $oldGrab
}
}
return $tkPriv(selectFilePath)
}
upvar #0 $w data
# 1: the configuration specs
#
set specs {
{-defaultextension "" "" ""}
{-filetypes "" "" ""}
{-initialdir "" "" ""}
{-initialfile "" "" ""}
{-parent "" "" "."}
{-title "" "" ""}
}
# 2: default values depending on the type of the dialog
#
# first time the dialog has been popped up
set data(selectPath) [pwd]
}
# 3: parse the arguments
#
} else {
}
}
# 4: set the default directory and selection according to the -initial
# settings
#
} else {
error "\"$data(-initialdir)\" is not a valid directory"
}
}
# 5. Parse the -filetypes option. It is not used by the motif
# file dialog, but we check for validity of the value to make sure
# the application code also runs fine with the TK file dialog.
#
}
error "bad window path name \"$data(-parent)\""
}
}
upvar #0 $w data
# 1: Create the dialog ...
#
# The Filter box
#
# The file and directory lists
#
# The Selection box
#
# The buttons
#
-command "tkMotifFDialog_OkCmd $w"]
-command "tkMotifFDialog_FilterCmd $w"]
-command "tkMotifFDialog_CancelCmd $w"]
# Create the bindings:
#
}
-xscrollcommand "$f.h set" \
-yscrollcommand "$f.v set"
-command "$f.l yview"
-command "$f.l xview"
# bindings for the listboxes
#
bind $list <Up> "tkMotifFDialog_Browse$cmd $w"
bind $list <Down> "tkMotifFDialog_Browse$cmd $w"
bind $list <space> "tkMotifFDialog_Browse$cmd $w"
bind $list <1> "tkMotifFDialog_Browse$cmd $w"
bind $list <Return> "tkMotifFDialog_Browse$cmd $w; tkMotifFDialog_Activate$cmd $w"
bindtags $list "Listbox $list [winfo toplevel $list] all"
tkListBoxKeyAccel_Set $list
}
upvar #0 $w data
return
}
return
}
set list [tkMotifFDialog_InterpFilter $w]
. {
}
.. {
}
default {
}
}
}
upvar #0 $w data
return
}
return
}
. {
}
.. {
}
default {
}
}
} else {
}
}
upvar #0 $w data
return
}
return
}
}
upvar #0 $w data
return
}
return
} else {
}
}
upvar #0 $w data
set list [tkMotifFDialog_InterpFilter $w]
}
upvar #0 $w data
# Perform tilde substitution
#
set list [file split $text]
catch {
}
}
if [file isdirectory $resolved] {
} else {
}
}
global tkPriv
upvar #0 $w data
return
}
if {[file isdirectory $selectFilePath]} {
return
}
-message "\"$selectFilePath\" must be an absolute pathname"
return
}
if ![file exists $selectPath] {
-message "Directory \"$selectPath\" does not exist."
return
}
if ![file exists $selectFilePath] {
-message "File \"$selectFilePath\" does not exist."
return
}
} else {
"File \"$selectFilePath\" already exists.\n\n" \
"Replace existing file?"]
-message $message]
return
}
}
}
}
upvar #0 $w data
}
upvar #0 $w data
}
global tkPriv
}
# tkMotifFDialog_Update
#
# Load the files and synchronize the "filter" and "selection" fields
# boxes.
#
# popup:
# If this is true, then update the selection field according to the
# "-selection" flag
#
upvar #0 $w data
}
upvar #0 $w data
set appPWD [pwd]
if [catch {
cd $data(selectPath)
}] {
cd $appPWD
return
}
# Make the dir list
#
}
}
# Make the file list
#
} else {
}
incr top
}
}
}
# The user probably doesn't want to see the . files. We adjust the view
# so that the listbox displays all the non-dot files
cd $appPWD
}
}
global tkPriv
}
global tkPriv
catch {
}
}
global tkPriv
set string [string tolower $string]
}
break
}
}
}
}
global tkPriv
}