#!/usr/bin/wish -f

set incpath "/usr/X11R6/lib/X11/xfm/rhs"

set name [lindex $argv 0]
source $incpath/$name.tcl
source $incpath/main.tcl

# Procedure to remove the icon from the Applications window
proc killicon {name} {
global homefile

set f [open ~/.xfm/$homefile r]
set f1 [open ~/.xfm/$homefile.new w]

while {[gets $f line] >= 0} {
	if { [regexp "^$name" $line] } {
		puts $f1 "#$line"
	} else {
		puts $f1 $line
	}
}

close $f
close $f1
exec bash -c "cp ~/.xfm/$homefile ~/.xfm/$homefile.orig"
exec bash -c "mv -f ~/.xfm/$homefile.new ~/.xfm/$homefile"
}

# Procedure to enable the "real" icon for a newly installed program
proc enable {name} {
global homefile

set f [open ~/.xfm/$homefile r]
set f1 [open ~/.xfm/$homefile.new w]

while {[gets $f line] >= 0} {
	if { [regexp "^#$name" $line] } {
		puts $f1 [string trimleft "$line" "#"]
	} elseif { [regexp "^$name" $line] } {
                puts $f1 "#$line"

	} else {
		puts $f1 $line
	}
}

close $f
close $f1
exec bash -c "cp ~/.xfm/$homefile ~/.xfm/$homefile.orig"
exec bash -c "mv -f ~/.xfm/$homefile.new ~/.xfm/$homefile"
}


frame .top
text .top.text -relief groove -bd 4 -height 18 -width 66 -yscrollcommand \
	".top.scroll set"
scrollbar .top.scroll -command ".top.text yview"
pack .top -side top -padx 1m -pady 1m
pack .top.scroll -side right -fill y
pack .top.text -side right
.top.text delete 1.0 end
.top.text insert end $textvar
if {[regexp $free "true"]} {
	.top.text insert end $freetext
} else {
	.top.text insert end $commtext
}
.top.text insert end $msg
.top.text insert end $endtext
frame .l
button .l.enable -text "Enable $name" -command {enable $name;exit 0} \
	-height 2 -width 15
button .l.disable -text "Disable icon" -command {killicon $name;exit 0} \
	-height 2 -width 15
button .l.dismiss -text "Dismiss" -command {exit 0} -bd 2 \
	-height 2 -width 15
pack .l -side left -padx 1m -pady 1m
pack .l.enable .l.disable .l.dismiss -side top -anchor w -fill y \
	-padx 3m -pady 1m -expand 1
frame .r
pack .r -side left
#label .r.pict -bitmap @~/.xfm/rhcl.xpm -relief raised -bd 3
#pack .r.pict -side left -fill x -expand 1




