#!/bin/sh
#
# Tcl/Tk script for installing the submit executable
#
# Bill Bynum
# December, 1998
# \
# these are the paths where tclsh and wish will be found \
PATH=$PATH:/usr/local/bin:/usr/lib:/usr/bin #\
export PATH #\
case $DISPLAY in #\
"") exec tclsh "$0" "$@" ;; #\
*) exec wish "$0" "$@" ;; #\
esac
######################################################################
#
# Tcl/Tk globals
#
# arrays
#
global IntialValue ;# initial & final values of editable entries
global FinalValue ;# in Tcl/Tk dialogs
global SubmitExe ;# filenames of the master submit executable
global exeArch ;# architecture of the submit exes, indexed by group
# lists
#
global NewGroups ;# groups in the user's new .installsubmitrc
global Windows ;# list of active windows
global Groups ;# groups to which user belongs
# The next two lists are used to cycle the selected group choice button
# in the X version. Their union is always Groups. When a exes for a
# group are installed, that group is moved from Unchosen to Chosen.
# When Unchosen is empty, the contents of the lists are switched.
global Chosen
global Unchosen
# procs
# These globals, along with the fact that Tcl is an interpreted
# provide a way of doing a little home-grown polymorphism.
# The program picks the right output proc (X11 or non-X11) based
# on whether the DISPLAY variable is set
global LocateExes ;# place the submit executable
global OK ;# warn user with modal OK? dialog
global Tell ;# show user verbose output
# flags
#
global UsingGroups ;# 1 if user belongs to more than one group
global Verbose ;# 1 if user wants verbose output
global WriteNeeded ;# 1 if fix_exes ever succeeds
# other variables
global ISfname ;# name of the install_submit startup file
global Version ;# install_submit version number
# most of these globals are initialized in the main program
# at the bottom of the file
######################################################################
#
# Window handling procs
# necessary for a graceful exit from X
#
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# add_window
# adds window 'w' to the Window list, if it's not already there
proc add_window { w } {
global Windows
set i [lsearch -exact $Windows $w]
if { $i < 0 } { ;# only add 'w' if it's not there
lappend Windows $w
}
} ;# add_window
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# destroy_window
# destoys window 'w'
# and if it was the only window left, kills the withdrawn .
proc destroy_window { w } {
global Windows
set i [lsearch -exact $Windows $w]
if { $i >= 0 } {
set Windows [lreplace $Windows $i $i]
}
destroy $w
if { [llength $Windows] == 0} {
destroy .
}
} ;# destroy_window
######################################################################
# I/O procs
#
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# ok_win
# displays s and waits for click of OK button
#
proc ok_win { s } {
global WTitle
if [winfo exists .td] { destroy .td}
toplevel .td
add_window .td
wm title .td "$WTitle -- OK?"
wm geometry .td +400+400
label .td.l -text "$s"
button .td.ok -text OK -command { destroy_window .td}
pack .td.l -pady 2m -padx 2m
pack .td.ok -fill x -expand 1
set win [grab current]
grab set .td
tkwait window .td
if { $win != "" } { grab set $win }
} ;# ok_win
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# ok_dlg
# displays s and waits for OK response
#
proc ok_dlg { s } {
puts stderr "=========================="
puts stderr "$s?"
puts stderr "=========================="
flush stderr
puts -nonewline stderr "(press any key to continue): "
gets stdin ans
return {}
} ;# ok_dlg
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# tell_win
# writes s to the verbose output window, if it's there,
# else writes s to stderr
#
proc tell_win { s } {
global Windows
global .v
if { [lsearch -exact $Windows .v ] < 0 } {
puts stderr "$s"
} else {
.v.f.t insert end "$s\n"
.v.f.t see end
update
}
} ;# tell_win
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# tell_dlg
# writes s to stderr
#
proc tell_dlg { s } {
puts stderr "$s"
flush stderr
} ;# tell_dlg
######################################################################
# tools to facilitate building Tk windows
#
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# set_rbutton
# An auxiliary proc to make_rbutton.
# This is the action performed when one of the radio buttons
# of the rbmenu is selected.
# Sets the global FinalValue($bname) to $val and resets the
# name of the "button" to $val.
#
proc set_rbutton { button bname val } {
global FinalValue
set FinalValue($bname) $val
$button configure -text "$val"
} ;# set_rbutton
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# make_rbmenu
# creates an menu button for a Tk display having the form
#
# +=================+
# |