# #!/usr/bin/wish

set w .filebox
proc positionWindow w {
	wm geometry $w +300+300
	}

catch {destroy $w}

toplevel $w
wm title $w "ForensiX File Selection Dialog"
positionWindow $w

set font {Helvetica 14}
label $w.msg -font $font -wraplength 4i -justify left -text "Enter pathnames or click Browse."
pack $w.msg -side top

frame $w.buttons
pack $w.buttons -side bottom -fill x -pady 2m
button $w.buttons.dismiss -text Dismiss -command "destroy $w"
pack $w.buttons.dismiss -side left -expand 1

foreach i {pathname} {
    set f [frame $w.$i]
    label $f.lab -text "$i: " -width 10 -anchor e
    entry $f.ent -width 20
    button $f.but -text "Browse ..." -command "fileDialog $w $f.ent $i"
    pack $f.lab -side left
    pack $f.ent -side left -expand yes -fill x
    pack $f.but -side left
    pack $f -fill x -padx 1c -pady 3
}

proc fileDialog {w ent operation} {
	global location
		#   Type names		Extension(s)	Mac File Type(s)
		#
		#---------------------------------------------------------
	set types {
		{"All files"		*}
		{"Text files"		{.txt .doc}	}
		{"Text files"		{}		TEXT}
		{"Tcl Scripts"		{.tcl}		TEXT}
		{"C Source Files"	{.c .h}		}
		{"All Source Files"	{.tcl .c .h}	}
		{"Image Files"		{.gif}		}
		{"Image Files"		{.jpeg .jpg}	}
		{"Image Files"		""		{GIFF JPEG}}
	    }
	set pathname [tk_getOpenFile -filetypes $types -parent $w]
	if [string compare $file ""] {
		$ent delete 0 end
		$ent insert 0 $file
		$ent xview end
		}
	set location $pathname
}
