#!/bin/sh
# the next line restarts using tixwish \
# exec tixwish "$0" "$@"\
exec wish "$0" "$@" 
package require Tix

# tcl/tk front-end for faxspool allows sending/managing of 
# fax messages through mgetty/vgetty fax queue.
#
# Maintained by: Peter Bruley
# email: pbruley@highstream.net
# The latest version of this script is available from:
# ftp://alpha.greenie.net/pub/mgetty/tools/

# I create to praise the one who created me. All the glory and praise for
# my creations belong to GOD.

###########################################################################

set tkFaxSpool 1
set TKFSREV "TKFaxSpool v0.1"
set TKFSDATE "Aug 1, 2002"
set font {Helvetica 14}
set bgcolor "#eeeeee"
set FAXRES "fine"
set FAXNRS ".faxnrs"
set RECIPLIST ""
set FAXRES ""
set FAXDELAY "0"
set FILES2FAXLIST ""
set DELAYHOUR ""
set DELAYMINUTE ""
set NULL ""

# puts $argc
# argv is the command line stuff that can be passed into this script
# puts $argv
# puts $argv0

# perhaps a future rev will do process locking
# set LOCKDIR "/var/run"
# set PID [pid]

wm title . "tkFAXSPOOL"
 

##############################################################################
proc startuperror {} {
  set WARNING0 "***********************************************"    
  set WARNING1 "*         Error starting tkfaxspool           *"    
  set WARNING2 "* Please change to the installation directory *"
  set WARNING5 "*     i.e. cd /usr/local/lib/tkfaxspool       *"
  set WARNING3 "*         and try starting again              *"
  set WARNING4 "                                               "
  puts $WARNING4
  puts $WARNING0
  puts $WARNING1
  puts $WARNING2
  puts $WARNING5
  puts $WARNING3
  puts $WARNING0
  puts $WARNING4
  catch [ cd ~/.tkfaxspool ]
  catch [ exec rm tkfaxspoolfax.dat ]
}

##############################################################################
#   READ the user preferences into the program and
#   load in some defaults if the files are not found
proc startup {} {
global HOME USERHOME TKFAXSPOOLDIR FAXCONFIGDIR FAXDIR FAXIN FAXOUT
# read in the paths information
  set STARTDIR [pwd]
  set TKFAXSPOOLDIR $STARTDIR
  set FILENAME tkfaxspoolfax.dat
  cd ~/
  set USERHOME [pwd]
# read in the FAX paths information
  set USERPREF ""
  set FILENAME tkfaxspoolfax.dat
  cd ~/
  if { [file isdirectory .tkfaxspool] == 0} {
       catch [exec mkdir .tkfaxspool] }
  cd ~/.tkfaxspool
  set HOME [pwd]
  if { [file writable $FILENAME] == 1} {
   catch {set file [open $FILENAME r+]}
     while {[gets $file string] >= 0} {
       append USERPREF $string
      }
    close $file} else {
   set USERPREF "$TKFAXSPOOLDIR /usr/local/etc/mgetty+sendfax /var/spool/fax /incoming /outgoing"
    }
   set TKFAXSPOOLDIR   [lindex $USERPREF 0]
   set FAXCONFIGDIR    [lindex $USERPREF 1]
   set FAXDIR          [lindex $USERPREF 2]
   set FAXIN           [lindex $USERPREF 3]
   set FAXOUT          [lindex $USERPREF 4]
##############################################################
# tkfaxspool directory checking START
#
# TEST for executable:
   if { [file executable $TKFAXSPOOLDIR/tkfaxspool] == 0} {
      if { [file executable /usr/local/lib/tkfaxspool/tkfaxspool] == 1} {
         set TKFAXSPOOLDIR /usr/local/lib/tkfaxspool
         savefaxspool
      } else {
         set TKFAXSPOOLDIR $STARTDIR
         if { [file executable $TKFAXSPOOLDIR/tkfaxspool] == 1} {
            savefaxspool
            } else {
            startuperror
            }
      }
   } else {
# TEST for the tkfaxspool.gif
      set test ""
      catch { exec ls $TKFAXSPOOLDIR/image/tkfaxspool.gif } test
      if { $test != "$TKFAXSPOOLDIR/image/tkfaxspool.gif" } {
         set TKFAXSPOOLDIR $STARTDIR
         set test ""
         catch { exec ls $TKFAXSPOOLDIR/image/tkfaxspool.gif } test
         if { $test == "$TKFAXSPOOLDIR/image/tkfaxspool.gif"} {
            savefaxspool
            } else {
            startuperror
            }
         }
   }
}
# tkfaxspool directory checking END
################ END proc startup ##################################
##############################################################

#   Process to save the paths preferences
proc savefaxspool {} {
global TKFAXSPOOLDIR FAXCONFIGDIR FAXDIR FAXIN FAXOUT
  set USERPREF ""
  set SAVENAME "tkfaxspoolfax.dat"
  cd ~/
  if { [file isdirectory .tkfaxspool] == 0} {
       catch [exec mkdir .tkfaxspool] }
  cd ~/.tkfaxspool
  if { [file isfile $SAVENAME] == 1} {
       catch [exec rm $SAVENAME] }
  catch [exec touch $SAVENAME]
  set file [open "$SAVENAME" r+]
  foreach x "$TKFAXSPOOLDIR $FAXCONFIGDIR $FAXDIR $FAXIN $FAXOUT" {
    append USERPREF "$x\ "
  }
  puts $file $USERPREF
  close $file
}

####################################################################
# now run the startup proc or the rest of the script will bomb
startup
####################################################################

proc faxrecipremove {} {
global tkFaxSpool USERHOME RECIPLIST

  foreach i [lsort -integer -decreasing [.fr.faxrecip.list curselection]] {
    set RECIPLIST [lreplace $RECIPLIST $i $i]
    .fr.faxrecip.list delete $i
  }
}
######################## END proc faxrecipentdel  #######################
proc faxrecipientadd {} {
global TKFAXSPOOLDIR FAXDIR FAXOUT
global USERHOME tkFaxSpool

# eval exec /usr/local/bin/tkfax &
uplevel [list source [file join $TKFAXSPOOLDIR/TCL/tkfcontrol.tcl]]
.tkfcontrol.nb raise add
}
######################## END proc faxrecipientadd  #######################
proc faxaddress {} {
global TKFAXSPOOLDIR FAXDIR FAXOUT
global USERHOME tkFaxSpool

uplevel [list source [file join $TKFAXSPOOLDIR/TCL/tkfcontrol.tcl]]
.tkfcontrol.nb raise fab
}
######################## END proc faxaddress  #######################

proc faxqueue {} {
global TKFAXSPOOLDIR FAXDIR FAXOUT
global USERHOME tkFaxSpool

uplevel [list source [file join $TKFAXSPOOLDIR/TCL/tkfcontrol.tcl]]
.tkfcontrol.nb raise que

}
######################## END proc faxqueue  #######################
proc faxsend {} {
global RECIPLIST FILES2FAXLIST FAXRES DELAYHOUR DELAYMINUTE 


   foreach i $RECIPLIST {

               set sl [string length $i ]
               set cc 0
               set gs 0
               set gc 1
               while { $cc < $sl } {
                set char [string range $i $cc $cc]
                 if { $gc <= 2} {
                  if {$char == " "} {
                     if {$gc == 2 } {
                        set ge [expr $cc-1]
                        set RNUMBER [string range $i $gs $ge]
                        set gs [expr $cc+1]
                        set gc [expr $gc+1]
                     }
                     if {$gc == 1 } {
                        set ge [expr $cc-1]
                        set RALIAS [string range $i $gs $ge]
                        set gs [expr $cc+1]
                        set gc [expr $gc+1]
                     }
                  }
                 }
                 set cc [expr $cc+1]
               }
set msg "FAXRES= $FAXRES"
# puts $msg

set DELAYTIME ""
  if { $DELAYHOUR != "" } {
     if { $DELAYMINUTE != ""} {
        set DELAYTIME "-t $DELAYHOUR:$DELAYMINUTE"
# puts $DELAYTIME
        }
     } 

    set cmd "faxspool $FAXRES $DELAYTIME $RALIAS $FILES2FAXLIST"
# puts $cmd
set error ""
    catch [ eval exec faxspool $FAXRES $DELAYTIME $RALIAS $FILES2FAXLIST ] error
# puts $error
   }


}
######################## END proc faxsend  #######################

proc removefiles2fax {} {
global FILES2FAXLIST

  foreach i [lsort -integer -decreasing [.ff.files2fax.list curselection]] {
    set FILES2FAXLIST [lreplace $FILES2FAXLIST $i $i]
    .ff.files2fax.list delete $i
  }
}
######################## END proc delete_files2fax #######################
# Pop up a file selection dialog
proc addfiles2fax {ent operation} {
global USERHOME TKFAXSPOOLDIR

cd $USERHOME 
    # [Hint]
    # The best way to use an ExFileSelectDialog is not to create one yourself
    # but to call the command "tix filedialog". This command creates one file
    # dialog box that is shared by different parts of the application.
    # This way, your application can save resources because it doesn't
    # need to create a lot of file dialog boxes even if it needs to input
    # file names at a lot of different occasions.
    #
    set dialog [tix filedialog tixExFileSelectDialog]
    $dialog config -command f2fax:select_file -title "Select files to FAX"

    $dialog subwidget fsbox config -filetypes {
	{{*.ps}		{*.ps  -- Post Script files}}
	{{*.txt}	{*.txt -- Text files}}
	{{*.asc}	{*.asc -- ASCII files}}
	{{*.g3}		{*.g3  -- g3 FAX files}}
	{{*.lj}		{*.lj  -- LaserJet files}}
	{{*.pcl}	{*.pcl -- Printer Control Language files}}
	{{*}		{*     -- All files}}
    } -pattern *.ps -directory $USERHOME

    wm transient $dialog ""
    $dialog popup
cd $TKFAXSPOOLDIR
}
########### end proc #########
proc f2fax:select_file {file} {
global FILES2FAXLIST USERHOME

    lappend FILES2FAXLIST $file
    .ff.files2fax.list insert end $file
}

proc ghostview {} {
global FILES2FAXLIST
 
  foreach i [lsort -integer -decreasing [.ff.files2fax.list curselection]] {
          set VIEWTHIS [lindex $FILES2FAXLIST $i]
  }

 catch [ eval exec gv $VIEWTHIS & ]


}
######################## END proc ghostview  #######################
proc launchtkvoice {} {
 
eval exec tkvoice &

}
######################## END proc ghostview  #######################

##############################################
# Under Options
##############################################
#---------------------------------------------
# FAX setup
proc faxsetup {} {
global tkFaxSpool TKFAXSPOOLDIR FAXCONFIGDIR FAXDIR FAXIN FAXOUT

 uplevel [list source [file join $TKFAXSPOOLDIR/TCL/tkfsetupfax.tcl]]
}
######################## END proc  ###########################
#---------------------------------------------
##############################################
# Under Help
proc faq {} {
global tkFaxSpool TKFAXSPOOLDIR
  uplevel [list source [file join $TKFAXSPOOLDIR/TCL/tkffaq.tcl]]
}

proc readme {} {
global tkFaxSpool TKFAXSPOOLDIR
  uplevel [list source [file join $TKFAXSPOOLDIR/TCL/tkfreadme.tcl]]
}

proc aboutBox {} {
global TKFSREV TKFSDATE tkFaxSpool TKFAXSPOOLDIR
  uplevel [list source [file join $TKFAXSPOOLDIR/TCL/tkfabout.tcl]]
}
######################## END proc aboutBox ########################

# positionWindow --
# Arguments:
# w -           The name of the window to position.
 
proc positionWindow w {
    wm geometry $w +300+300
}

proc get_files2fax {} {
global argv TKFAXSPOOLDIR USERHOME FILES2FAXLIST

   if { $argv != "" } {
      set sl [string length $argv ]
      if { $sl > 3 } {
         # check for -f (file2fax) arg
         set f2f [string range $argv 0 2]
         if { "$f2f" == "-f "} {
            # okay someone wants to fax something
            set file [string range $argv 3 end]
            lappend FILES2FAXLIST $file
            .ff.files2fax.list insert end $file
         }
      }
   }
}
    
 
##############################################
##### End of subs
##############################################
##### Start of Frames
##############################################

# Create the menu bar at the top of the window.
 
frame .menu -relief raised -borderwidth 2 
pack .menu -side top -fill x
 
# Under the File button
 
menubutton .menu.file -text File -menu .menu.file.m -underline 0
menu .menu.file.m -tearoff 0
# .menu.file.m add command -label "Delete Selected" -underline 0 \
        -command "faxrm"
# .menu.file.m add command -label "Refresh List" -underline 0 \
        -command "faxq"
# .menu.file.m add command -label "Address Book" -underline 0 \
        -command "faxab"
# .menu.file.m add command -label "NEW FAX" -underline 0 \
        -command "faxspool"
.menu.file.m add separator
.menu.file.m add command -label "Exit" -underline 1 \
        -command "destroy ."
pack .menu.file -side left

# Under the Setup button
 
menubutton .menu.setup -text Setup -menu .menu.setup.m -underline 0
menu .menu.setup.m
.menu.setup.m add command -label "Setup tkFaxSpool" -underline 2 \
         -command {faxsetup}
 pack .menu.setup -side left

# Under the Help button
 
menubutton .menu.help -text Help -menu .menu.help.m -underline 0
menu .menu.help.m -tearoff 0
.menu.help.m add command -label "FAQ" -underline 0 \
        -command {faq}
.menu.help.m add command -label "README" -underline 0 \
        -command {readme}
.menu.help.m add command -label "About tkFAXSPOOL" -underline 0 \
        -command {aboutBox}

pack .menu.help -side right
 
# GIF frame on left of list
frame .gif -relief raised -borderwidth 2
pack .gif -side top -fill x

# tkfaxspool image
catch {image delete tkfaxspool}
image create photo tkfaxspool -file [file join $TKFAXSPOOLDIR/image/tkfaxspool.gif]
label .gif.tkfaxspool -image tkfaxspool -bd 1 -relief sunken

catch {image delete linux}
image create photo linux -file [file join $TKFAXSPOOLDIR/image/linux.gif]
label .gif.linux -image linux -bd 1 -relief sunken

catch {image delete faxmachine}
image create photo faxmachine -file [file join $TKFAXSPOOLDIR/image/faxmachine.gif]
label .gif.faxmachine -image faxmachine -bd 1 -relief sunken

catch {image delete penguin}
image create photo penguin -file [file join $TKFAXSPOOLDIR/image/penguin.gif]
label .gif.penguin -image penguin -bd 1 -relief sunken

pack .gif.faxmachine -side left 
pack .gif.tkfaxspool -side left -expand 1 -fill x
pack .gif.linux -side right 
pack .gif.penguin -side right

######### MAIN FAXRECIPIENT FRAME STARTS HERE ##############
frame .fr 

frame .fr.top
pack .fr.top -side top
# Split the window into left and right sides
frame .fr.top.right
pack .fr.top.right -side left -expand yes -pady .01c -padx .01c
frame .fr.top.left
pack .fr.top.left -side left -expand yes -pady .01c -padx .01c
 
frame .fr.top.right.r1
pack .fr.top.right.r1 -side top
label .fr.top.right.r1.faxres -justify left -text "FAX Resolution" -width 17 -anchor c
pack .fr.top.right.r1.faxres -expand 1 -fill y -side top -pady 10
radiobutton .fr.top.right.r1.normal -text "Normal" -width 14 -anchor w  -variable FAXRES -value "-n"
radiobutton .fr.top.right.r1.fine -text "Fine" -width 14 -anchor w -variable FAXRES -value ""
pack .fr.top.right.r1.normal .fr.top.right.r1.fine  -expand 1 -fill y -side top  -pady 1
 
frame .fr.top.left.r1
pack .fr.top.left.r1 -side top
label .fr.top.left.r1.faxres -justify left -text "FAX Delay" -width 17 -anchor s
pack .fr.top.left.r1.faxres -expand 1 -fill y -side top -pady 9
frame .fr.top.left.r1.a
pack .fr.top.left.r1.a -expand 1 -fill y -side top 
frame .fr.top.left.r1.a.l
pack .fr.top.left.r1.a.l -expand 1 -fill y -side left 
frame .fr.top.left.r1.a.r
pack .fr.top.left.r1.a.r -expand 1 -fill y -side left
radiobutton .fr.top.left.r1.a.l.now -text "Send Now" -width 10 -anchor w \
         -variable FAXDELAY -value "0" -command " \
        set DELAYHOUR $NULL; .fr.top.left.r1.a.r.h configure -state disabled; \
        set DELAYMINUTE $NULL; .fr.top.left.r1.a.r.m configure -state disabled "
radiobutton .fr.top.left.r1.a.l.delay -text "Send At:" -width 10 -anchor w \
       -variable FAXDELAY -value "1" -command ".fr.top.left.r1.a.r.h  \
       configure -state normal; .fr.top.left.r1.a.r.m  configure -state normal "

     tixComboBox .fr.top.left.r1.a.r.h -label "Hour: " -dropdown true \
	-editable false -variable DELAYHOUR -listwidth 16 -state disabled \
        -background white \
	-options {
	    listbox.height 10
            listbox.background white
            entry.width  2
            entry.background white
            entry.selectbackground white
            entry.selectforeground white
            entry.activebackground white
            entry.activeforeground white
            entry.insertbackground white
	    label.width 6
	    label.anchor e
	}
     .fr.top.left.r1.a.r.h insert end 00
     .fr.top.left.r1.a.r.h insert end 01
     .fr.top.left.r1.a.r.h insert end 02
     .fr.top.left.r1.a.r.h insert end 03
     .fr.top.left.r1.a.r.h insert end 04
     .fr.top.left.r1.a.r.h insert end 05
     .fr.top.left.r1.a.r.h insert end 06
     .fr.top.left.r1.a.r.h insert end 07
     .fr.top.left.r1.a.r.h insert end 08
     .fr.top.left.r1.a.r.h insert end 09
     .fr.top.left.r1.a.r.h insert end 10
     .fr.top.left.r1.a.r.h insert end 11
     .fr.top.left.r1.a.r.h insert end 12
     .fr.top.left.r1.a.r.h insert end 13
     .fr.top.left.r1.a.r.h insert end 14
     .fr.top.left.r1.a.r.h insert end 15
     .fr.top.left.r1.a.r.h insert end 16
     .fr.top.left.r1.a.r.h insert end 17
     .fr.top.left.r1.a.r.h insert end 18
     .fr.top.left.r1.a.r.h insert end 19
     .fr.top.left.r1.a.r.h insert end 20
     .fr.top.left.r1.a.r.h insert end 21
     .fr.top.left.r1.a.r.h insert end 22
     .fr.top.left.r1.a.r.h insert end 23

     tixComboBox .fr.top.left.r1.a.r.m -label "Min.: " -dropdown true \
	-editable false -variable DELAYMINUTE -listwidth 16 -state disabled \
        -background white \
	-options {
	    listbox.height 10
            listbox.background white
            entry.width  2
            entry.background white
            entry.selectbackground white
	    label.width 6
	    label.anchor e
	}
     .fr.top.left.r1.a.r.m insert end 00
     .fr.top.left.r1.a.r.m insert end 05
     .fr.top.left.r1.a.r.m insert end 10
     .fr.top.left.r1.a.r.m insert end 15
     .fr.top.left.r1.a.r.m insert end 20
     .fr.top.left.r1.a.r.m insert end 25
     .fr.top.left.r1.a.r.m insert end 30
     .fr.top.left.r1.a.r.m insert end 35
     .fr.top.left.r1.a.r.m insert end 40
     .fr.top.left.r1.a.r.m insert end 45
     .fr.top.left.r1.a.r.m insert end 50
     .fr.top.left.r1.a.r.m insert end 55


pack .fr.top.left.r1.a.l.now .fr.top.left.r1.a.l.delay -expand 1 -fill y -side top 
pack .fr.top.left.r1.a.r.h .fr.top.left.r1.a.r.m -expand 1 -fill y -side top


frame .fr.faxrecip
label .fr.faxrecip.msg -font {times 18} -justify center -text "FAX Recipients"
listbox .fr.faxrecip.list -relief sunken -font {fixed 14} -width 46 -height 5 \
	        -yscrollcommand ".fr.faxrecip.scroll set" -background $bgcolor
scrollbar .fr.faxrecip.scroll -command ".fr.faxrecip.list yview"

tixPopupMenu .fr.faxrecip.p -title "Recipent"
    .fr.faxrecip.p bind .fr.faxrecip.list
    set menur [.fr.faxrecip.p subwidget menu]
    $menur add command -label Remove -under 0 -command faxrecipremove
    $menur add command -label Add    -under 0 -command faxrecipientadd
    $menur add command -label FAB    -under 0 -command faxaddress

frame .fr.button
image create photo send -file [file join $TKFAXSPOOLDIR/image/send.gif]
button .fr.button.send -width 7 -image send -anchor center -command "faxsend"
tixBalloon .fr.button.sendb 
.fr.button.sendb bind .fr.button.send -balloonmsg "Send FAX to Queue"

image create photo faxque -file [file join $TKFAXSPOOLDIR/image/faxque.gif]
button .fr.button.faxque -width 7 -image faxque -anchor center -command "faxqueue"
tixBalloon .fr.button.faxqueb
.fr.button.faxqueb bind .fr.button.faxque -balloonmsg "Manipulate FAX Queue"

image create photo editfab -file [file join $TKFAXSPOOLDIR/image/editfab.gif]
button .fr.button.editfab  -width 7 -image editfab -anchor center -command "faxaddress"
tixBalloon .fr.button.editfabb
.fr.button.editfabb bind .fr.button.editfab -balloonmsg "Open Address Book"

image create photo add -file [file join $TKFAXSPOOLDIR/image/add.gif]
button .fr.button.add -width 7 -text "ADD" -image add -anchor center -command "faxrecipientadd"
tixBalloon .fr.button.addb
.fr.button.addb bind .fr.button.add -balloonmsg "Add Recipient to list"

image create photo remove -file [file join $TKFAXSPOOLDIR/image/remove.gif]
button .fr.button.del   -width 7 -image remove -anchor center -command "faxrecipremove"
tixBalloon .fr.button.delb
.fr.button.delb bind .fr.button.del -balloonmsg "Remove Recipent from list"
######### MAIN FAXRECIPIENT FRAME ENDS HERE ##############

######### MAIN FAXFILES FRAME STARTS HERE ##############
frame .ff
frame .ff.files2fax
label .ff.files2fax.msg -font {times 18} -justify center -text "FILES to FAX"
#                -background gray90 -relief sunken
listbox .ff.files2fax.list -relief sunken -font {fixed 14} -width 46 -height 5 \
               -yscrollcommand ".ff.files2fax.scroll set" -background $bgcolor
scrollbar .ff.files2fax.scroll -command ".ff.files2fax.list yview"

set f [frame .add]

tixPopupMenu .ff.files2fax.p -title "Files"
    .ff.files2fax.p bind .ff.files2fax.list
    set menur [.ff.files2fax.p subwidget menu]
    $menur add command -label Remove -under 0 -command "removefiles2fax"
    $menur add command -label Add    -under 0 -command "addfiles2fax $f.ent add"
    $menur add command -label GView  -under 0 -command "ghostview"

frame .ff.button
image create photo exit2 -file [file join $TKFAXSPOOLDIR/image/exit2.gif]
button .ff.button.quit -width 7  -text "Quit" -image exit2 -anchor center -command "destroy ."
tixBalloon .ff.button.quitb
.ff.button.quitb bind .ff.button.quit -balloonmsg "EXIT tkFaxSpool"

image create photo tkvbutton -file [file join $TKFAXSPOOLDIR/image/tkvbutton.gif]
button .ff.button.tkvoice -width 7 -text "tkVOICE" -image tkvbutton -anchor center -command "launchtkvoice"
tixBalloon .ff.button.tkvoiceb
.ff.button.tkvoiceb bind .ff.button.tkvoice -balloonmsg "View incoming FAX's using tkVOICE"

image create photo gv -file [file join $TKFAXSPOOLDIR/image/gv.gif]
button .ff.button.gv  -width 7 -text "GV" -image gv -anchor center -command "ghostview"
tixBalloon .ff.button.gvb
.ff.button.gvb bind .ff.button.gv -balloonmsg "View Post-Script File using GhostView"

button .ff.button.addfiles -width 7 -text "Add Files" -image add -anchor center -command "addfiles2fax $f.ent add"
tixBalloon .ff.button.addfilesb
.ff.button.addfilesb bind .ff.button.addfiles -balloonmsg "Add Files to FAX List"

button .ff.button.remove    -width 7 -text "Remove" -image remove -anchor center -command "removefiles2fax"
tixBalloon .ff.button.removeb
.ff.button.removeb bind .ff.button.remove -balloonmsg "Remove Files from FAX List"

######### MAIN FAX FRAME ENDS HERE ##############
# FAXRECIP PACKING
  pack .fr -padx 3 -pady 3
  pack .fr.faxrecip.msg -side top
  pack .fr.faxrecip -side top
  pack .fr.faxrecip.list -side left 
  pack .fr.faxrecip.scroll -side left -fill y -expand 1
  pack .fr.button -side top -fill x
  pack .fr.button.send  -side right -expand 1 -fill x -padx 3 -pady 3
  pack .fr.button.faxque -side right -expand 1 -fill x -padx 3 -pady 3
  pack .fr.button.editfab -side right -expand 1 -fill x -padx 3 -pady 3
  pack .fr.button.add   -side right -expand 1 -fill x -padx 3 -pady 3
  pack .fr.button.del   -side right -expand 1 -fill x -padx 3 -pady 3
  bind .fr.faxrecip.list <Double-Button-1> faxaddress

# FAXFILES PACKING
  pack .ff -padx 3 -pady 3
  pack .ff.files2fax.msg -side top
  pack .ff.files2fax -side top
  pack .ff.files2fax.list -side left
  pack .ff.files2fax.scroll -side left -fill y -expand 1
  pack .ff.button -side bottom -fill x
  pack .ff.button.quit  -side right -expand 1 -fill x -padx 3 -pady 3
  pack .ff.button.tkvoice -side right -expand 1 -fill x -padx 3 -pady 3
  pack .ff.button.gv -side right -expand 1 -fill x -padx 3 -pady 3
  pack .ff.button.addfiles   -side right -expand 1 -fill x -padx 3 -pady 3
  pack .ff.button.remove   -side right -expand 1 -fill x -padx 3 -pady 3
# this proc looks for the "-f /path/file" args
get_files2fax
  bind .ff.files2fax.list <Double-Button-1> ghostview


wm protocol . WM_DELETE_WINDOW "destroy ."
wm iconbitmap . @$TKFAXSPOOLDIR/image/icon.xbm

tkwait window .


