### Copyright (C) 1996 Rasmus Ingemann Hansen
### This program is free software; you can redistribute it and/or modify
### it under the terms of the GNU General Public License as published by
### the Free Software Foundation; either version 2 of the License, or
### (at your option) any later version.
###
### This program is distributed in the hope that it will be useful,
### but WITHOUT ANY WARRANTY; without even the implied warranty of
### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
### GNU General Public License for more details.
###
### You should have received a copy of the GNU General Public License
### along with this program; if not, write to the Free Software
### Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

proc signature {} {
    # Editing / Signature
    Desc "Signatures and preceeding dashes above these"
    ShortDesc "Signature"

### SIGNATURES ###
    Header signatureHead1 \
	-text "Have dashes above (if any) signature" \
	-background gray

    CheckBox signatureCheckBox1 \
	-text "Dashes \"--\" above signatures (News 2.11 compatibility and convention)" \
	-default 1

    foreach widget { signatureHead1 signatureCheckBox1 } {
	Help $widget "Selected to tell Elm that you wish to follow the convention of prefixing your signature with `newline dash dash blank newline'. This is placed in your message before your signature file. If OFF, the signature file, if any, is placed at the end of the message without any prefix. This way you could have the sigdashes \"--\" and optionally leave out the signature so as to shortly enter your name 'on the fly'. Default is to leave it selected."
    }

###
    Header signatureHead2 \
	-text "Have a signature (right below your sigdash)" \
	-background gray

    CheckBox editorOptionsCheckBox33 \
	-text "Have a signature at the bottom of your outgoing messages" \
	-help "This way you could have your cute once made signature with name, address, phone number, graphics etc. inserted as the first thing in your document when you start editing new outgoing messages." 

### local signature ###
    Header editorOptionsHead2 \
	-text "Your \".signature\" file(s) to append to appropriate outbound messages" \
	-background gray \
	-help "This defines the file that is automatically appended to all outbound mail before the editor is invoked."

    File-Dir-Browser editorOptionsDir3 \
	-text "Location of local \".signature\" file" \
	-exist 1

    foreach widget { editorOptionsDir3 } {
	Help $widget "Location of the `local' (any address without an \"!\" or \"@\" in it) signature to the bottom of outgoing messages." \
    }

    TextBox signatureTextBox1 \
	-height 3 \
	-width 80 \
	-help "This is how your \"~/.elm/localsignature\" file looked like when you started the current dotfile application. (In case of no such file this textbox isn't active)."


    ### remote ###
    File-Dir-Browser editorOptionsDir4 \
	-text "Location of remote \".signature\" file" \
	-exist 0

    foreach widget { editorOptionsDir4 } {
	Help $widget "Location of the `remote' (any address with an \"!\" or \"@\" in it) signature to the bottom of outgoing messages." \
    }

    TextBox signatureTextBox2 \
	-height 3 \
	-width 80 \
	-help "This is how your \"~/.elm/remotesignature\" file looked like when you started the current dotfile application. (In case of no such file this textbox isn't active)."

    Line line3    

    CheckBox editorOptionsCheckBox22 \
	-text "Instead, use same file for both local and remote" \
	-default 0

    File-Dir-Browser editorOptionsDir2 \
	-text "Location of both local and remote \".signature\"" \
	-exist 0

    foreach widget { editorOptionsCheckBox22 editorOptionsDir2 } {
	Help $widget "Location of common signature for both local and remote signatue to the bottom of outgoing messages. This eases you for entering same location twice (and it use another variable set too)."
    }

    TextBox signatureTextBox3 \
	-height 3 \
	-width 80 \
	-help "This is how your \"~/.signature\" file looked like when you started the current dotfile application. (In case of no such file this textbox isn't active)."


  ################################ Change #################################
    Change {
	if {$editorOptionsCheckBox33==0} {
		Disable editorOptionsCheckBox22
		Disable editorOptionsDir2
		Disable editorOptionsDir3
		Disable editorOptionsDir4
		Disable editorOptionsHead2
		Disable signatureTextBox1
		Disable signatureTextBox2
		Disable signatureTextBox3
	} else {
		Enable editorOptionsCheckBox22
		Enable editorOptionsDir2
		Enable editorOptionsDir3
		Enable editorOptionsDir4
		Enable editorOptionsHead2
		Enable signatureTextBox1
		Enable signatureTextBox2
		Enable signatureTextBox3
		if {$editorOptionsCheckBox22==0} {
			Enable editorOptionsDir3
			Enable editorOptionsDir4
			Disable editorOptionsDir2
			Enable signatureTextBox1
			Enable signatureTextBox1
			Disable signatureTextBox3
			} {
			Disable editorOptionsDir3
			Disable editorOptionsDir4
			Enable editorOptionsDir2
			Disable signatureTextBox1
			Disable signatureTextBox2
			Enable signatureTextBox3
		}
	}
    }

  ############################## Init / Save ##############################

    Init {
        ### Read default values from system ###
	if {[file exists [glob ~]/.elm/localsignature]} {
		set signatureTextBox1 [exec cat [glob ~]/.elm/localsignature]
        }
	if {[file exists [glob ~]/.elm/remotesignature]} {
		set signatureTextBox2 [exec cat [glob ~]/.elm/remotesignature]
        }
	if {[file exists [glob ~]/.signature]} {
		set signatureTextBox3 [exec cat [glob ~]/.signature]
        }
    }

    Save {
	print "\n# Dashes above signatures? (News 2.11 compatibility and convention)"
	if {$signatureCheckBox1==0} {
		print "sigdashes = OFF"
	} else {
		print "###sigdashes = ON"		
	}

	if {$editorOptionsCheckBox22==0} {
		print "\n# local \".signature\" file to append to appropriate messages"
		if {$editorOptionsDir3=="./" || $editorOptionsDir3==""} {
			print "###localsignature = "
		} else {
			print "localsignature = $editorOptionsDir3"
		}
		print "\n# remote \".signature\" file to append to appropriate messages"
		if {$editorOptionsDir4=="./" || $editorOptionsDir4==""} {
			print "###remotesignature = "
		} else {
			print "remotesignature = $editorOptionsDir4"
		}
	} else {
		if {$editorOptionsDir2!="./" && $editorOptionsDir2!=""} {
			print "\n# both remote and local \".signature\" file to append to appropriate messages"
			print "signature = $editorOptionsDir2"
		}
	}
	
    }
}



