#! /bin/sh
# the next line restarts using wish \
exec wish84 "$0" "$@"

# interface generated by SpecTcl version 1.2 from /export/home/suhler/tkphone/pref.ui
#   root     is the parent window for this user interface

proc pref_ui {root args} {

	# this treats "." as a special case

	if {$root == "."} {
	    set base ""
	} else {
	    set base $root
	}
    
	frame $base.frame#2

	frame $base.advanced \
		-borderwidth 2 \
		-relief groove

	frame $base.frame#4

	frame $base.frame#9

	frame $base.ring_frame \
		-borderwidth 2 \
		-relief ridge

	frame $base.filter_frame \
		-relief ridge

	frame $base.frame#7

	frame $base.frame#8 \
		-borderwidth 2 \
		-relief ridge

	label $base.label#6 \
		-text Settings

	label $base.label#1 \
		-anchor e \
		-text {IAX server}

	entry $base.entry#1 \
		-cursor {} \
		-textvariable input_server

	label $base.label#2 \
		-anchor e \
		-text {auth name}

	entry $base.entry#2 \
		-textvariable input_user \
		-width 8

	label $base.label#3 \
		-anchor e \
		-text {auth password }

	entry $base.entry#3 \
		-show * \
		-textvariable input_pass \
		-width 8

	label $base.label#4 \
		-anchor e \
		-text {phone extension}

	entry $base.entry#4 \
		-textvariable input_ext \
		-width 5

	label $base.label#7 \
		-text {preferred codec}

	radiobutton $base.radiobutton#1 \
		-text gsm \
		-value gsm \
		-variable input_preferred_codec

	radiobutton $base.radiobutton#2 \
		-text ulaw \
		-value ulaw \
		-variable input_preferred_codec

	radiobutton $base.radiobutton#3 \
		-text speex \
		-value speex \
		-variable input_preferred_codec

	label $base.label#14 \
		-text {audio devices}

	label $base.label#15 \
		-text in

	spinbox $base.in_device_list \
		-command " select_device in \[$base.in_device_list get\]" \
		-textvariable in_device
	catch {
		$base.in_device_list configure \
			-font -*-Helvetica-Medium-R-Normal-*-*-120-*-*-*-*-*-*
	}

	label $base.label#16 \
		-text out

	spinbox $base.out_device_list \
		-command "select_device out \[$base.out_device_list get\]" \
		-textvariable out_device

	checkbutton $base.checkbutton#6 \
		-command "if {\$advanced_options} {grid $base.advanced} {grid remove $base.advanced}" \
		-text {advanced
options} \
		-variable advanced_options

	checkbutton $base.flag_deecho \
		-text de-echo \
		-variable filter_2

	checkbutton $base.checkbutton#8 \
		-command {if {$filter_3} {set filter_1 1}} \
		-text {mixer agc} \
		-variable filter_3

	checkbutton $base.flag_agc \
		-command {if {!$filter_1} {set filter_3 0}} \
		-text {soft agc} \
		-variable filter_1

	checkbutton $base.flag_denoise \
		-text de-noise \
		-variable filter_0

	checkbutton $base.ring \
		-command "if {\$input_audio_ring} {grid $base.ring_frame -in $base.advanced} {grid remove $base.ring_frame}" \
		-text {audio
ring} \
		-variable input_audio_ring

	label $base.label#11 \
		-text {ring time (s)}

	scale $base.scale#4 \
		-from 0.1 \
		-label on \
		-length 50 \
		-orient horizontal \
		-resolution 0.1 \
		-to 4.0 \
		-variable input_ring_on

	scale $base.scale#5 \
		-from 0.1 \
		-label off \
		-length 50 \
		-orient horizontal \
		-resolution 0.1 \
		-to 4.0 \
		-variable input_ring_off

	scale $base.scale#6 \
		-from 10.0 \
		-label {vol %} \
		-orient horizontal \
		-variable input_ring_volume

	scale $base.scale#1 \
		-borderwidth 1 \
		-label {mute vol %} \
		-length 75 \
		-orient horizontal \
		-relief ridge \
		-sliderlength 20 \
		-to 25.0 \
		-variable input_mute_play_level

	scale $base.scale#3 \
		-borderwidth 1 \
		-label {kbd rpt ms} \
		-length 75 \
		-orient horizontal \
		-relief ridge \
		-resolution 50.0 \
		-sliderlength 20 \
		-to 250.0 \
		-variable input_repeat_time

	scale $base.scale#2 \
		-borderwidth 1 \
		-label {delay ms} \
		-length 75 \
		-orient horizontal \
		-relief ridge \
		-resolution 10.0 \
		-sliderlength 20 \
		-to 50.0 \
		-variable input_audio_min_latency

	label $base.label#12 \
		-text shortcut

	button $base.button#6 \
		-command {set input_shortcut_modifier [lindex $Meta [expr {([lsearch $Meta $input_shortcut_modifier]+1) % [llength $Meta]}]]} \
		-padx 1 \
		-pady 1 \
		-text +

	label $base.label#13 \
		-text Control \
		-textvariable input_shortcut_modifier

	button $base.button#4 \
		-command pref_ok \
		-text ok

	button $base.button#5 \
		-command pref_cancel \
		-text cancel


	# Add contents to menus

	# Geometry management

	grid $base.frame#2 -in $root	-row 6 -column 2  \
		-sticky w
	grid $base.advanced -in $root	-row 8 -column 2  \
		-sticky ew
	grid $base.frame#4 -in $root	-row 9 -column 1  \
		-columnspan 2 \
		-sticky s
	grid $base.frame#9 -in $root	-row 7 -column 2  \
		-sticky new
	grid $base.ring_frame -in $base.advanced	-row 2 -column 2  \
		-sticky ew
	grid $base.filter_frame -in $base.advanced	-row 1 -column 1  \
		-columnspan 2 \
		-sticky w
	grid $base.frame#7 -in $base.advanced	-row 3 -column 1  \
		-columnspan 2 \
		-sticky ew
	grid $base.frame#8 -in $base.advanced	-row 4 -column 2  \
		-sticky w
	grid $base.label#6 -in $root	-row 1 -column 1  \
		-columnspan 2
	grid $base.label#1 -in $root	-row 2 -column 1  \
		-sticky ew
	grid $base.entry#1 -in $root	-row 2 -column 2  \
		-sticky w
	grid $base.label#2 -in $root	-row 3 -column 1  \
		-sticky ew
	grid $base.entry#2 -in $root	-row 3 -column 2  \
		-sticky w
	grid $base.label#3 -in $root	-row 4 -column 1  \
		-sticky ew
	grid $base.entry#3 -in $root	-row 4 -column 2  \
		-sticky w
	grid $base.label#4 -in $root	-row 5 -column 1  \
		-sticky ew
	grid $base.entry#4 -in $root	-row 5 -column 2  \
		-sticky w
	grid $base.label#7 -in $root	-row 6 -column 1  \
		-sticky e
	grid $base.radiobutton#1 -in $base.frame#2	-row 1 -column 1 
	grid $base.radiobutton#2 -in $base.frame#2	-row 1 -column 2 
	grid $base.radiobutton#3 -in $base.frame#2	-row 1 -column 3  \
		-sticky w
	grid $base.label#14 -in $root	-row 7 -column 1  \
		-sticky e
	grid $base.label#15 -in $base.frame#9	-row 1 -column 1 
	grid $base.in_device_list -in $base.frame#9	-row 1 -column 2  \
		-sticky ew
	grid $base.label#16 -in $base.frame#9	-row 2 -column 1 
	grid $base.out_device_list -in $base.frame#9	-row 2 -column 2  \
		-sticky ew
	grid $base.checkbutton#6 -in $root	-row 8 -column 1  \
		-sticky ne
	grid $base.flag_deecho -in $base.filter_frame	-row 1 -column 1  \
		-sticky w
	grid $base.checkbutton#8 -in $base.filter_frame	-row 1 -column 2  \
		-sticky w
	grid $base.flag_agc -in $base.filter_frame	-row 2 -column 1  \
		-sticky w
	grid $base.flag_denoise -in $base.filter_frame	-row 2 -column 2  \
		-sticky w
	grid $base.ring -in $base.advanced	-row 2 -column 1  \
		-sticky w
	grid $base.label#11 -in $base.ring_frame	-row 1 -column 1  \
		-columnspan 2
	grid $base.scale#4 -in $base.ring_frame	-row 2 -column 1  \
		-sticky ew
	grid $base.scale#5 -in $base.ring_frame	-row 2 -column 2  \
		-sticky ew
	grid $base.scale#6 -in $base.ring_frame	-row 3 -column 1  \
		-columnspan 2 \
		-sticky ew
	grid $base.scale#1 -in $base.frame#7	-row 1 -column 1  \
		-sticky ew
	grid $base.scale#3 -in $base.frame#7	-row 1 -column 2  \
		-sticky ew
	grid $base.scale#2 -in $base.frame#7	-row 1 -column 3  \
		-sticky ew
	grid $base.label#12 -in $base.advanced	-row 4 -column 1 
	grid $base.button#6 -in $base.frame#8	-row 1 -column 1 
	grid $base.label#13 -in $base.frame#8	-row 1 -column 2  \
		-sticky w
	grid $base.button#4 -in $base.frame#4	-row 1 -column 1 
	grid $base.button#5 -in $base.frame#4	-row 1 -column 2 

	# Resize behavior management

	grid rowconfigure $base.frame#2 1 -weight 0 -minsize 2 -pad 0
	grid columnconfigure $base.frame#2 1 -weight 0 -minsize 30 -pad 0
	grid columnconfigure $base.frame#2 2 -weight 0 -minsize 30 -pad 0
	grid columnconfigure $base.frame#2 3 -weight 0 -minsize 30 -pad 0

	grid rowconfigure $base.filter_frame 1 -weight 0 -minsize 19 -pad 0
	grid rowconfigure $base.filter_frame 2 -weight 0 -minsize 10 -pad 0
	grid columnconfigure $base.filter_frame 1 -weight 0 -minsize 30 -pad 0
	grid columnconfigure $base.filter_frame 2 -weight 0 -minsize 30 -pad 0

	grid rowconfigure $base.frame#7 1 -weight 0 -minsize 30 -pad 0
	grid columnconfigure $base.frame#7 1 -weight 1 -minsize 30 -pad 0
	grid columnconfigure $base.frame#7 2 -weight 1 -minsize 30 -pad 0
	grid columnconfigure $base.frame#7 3 -weight 1 -minsize 30 -pad 0

	grid rowconfigure $base.advanced 1 -weight 0 -minsize 8 -pad 0
	grid rowconfigure $base.advanced 2 -weight 0 -minsize 2 -pad 0
	grid rowconfigure $base.advanced 3 -weight 0 -minsize 30 -pad 0
	grid rowconfigure $base.advanced 4 -weight 0 -minsize 2 -pad 0
	grid columnconfigure $base.advanced 1 -weight 0 -minsize 2 -pad 0
	grid columnconfigure $base.advanced 2 -weight 1 -minsize 30 -pad 0

	grid rowconfigure $root 1 -weight 0 -minsize 5 -pad 0
	grid rowconfigure $root 2 -weight 0 -minsize 2 -pad 0
	grid rowconfigure $root 3 -weight 0 -minsize 2 -pad 0
	grid rowconfigure $root 4 -weight 0 -minsize 2 -pad 0
	grid rowconfigure $root 5 -weight 0 -minsize 2 -pad 0
	grid rowconfigure $root 6 -weight 0 -minsize 2 -pad 0
	grid rowconfigure $root 7 -weight 0 -minsize 2 -pad 0
	grid rowconfigure $root 8 -weight 0 -minsize 2 -pad 0
	grid rowconfigure $root 9 -weight 1 -minsize 2 -pad 0
	grid columnconfigure $root 1 -weight 0 -minsize 30 -pad 0
	grid columnconfigure $root 2 -weight 1 -minsize 30 -pad 0

	grid rowconfigure $base.frame#8 1 -weight 0 -minsize 18 -pad 0
	grid columnconfigure $base.frame#8 1 -weight 0 -minsize 2 -pad 0
	grid columnconfigure $base.frame#8 2 -weight 1 -minsize 30 -pad 0

	grid rowconfigure $base.frame#4 1 -weight 0 -minsize 30 -pad 0
	grid columnconfigure $base.frame#4 1 -weight 0 -minsize 30 -pad 0
	grid columnconfigure $base.frame#4 2 -weight 0 -minsize 30 -pad 0

	grid rowconfigure $base.frame#9 1 -weight 0 -minsize 2 -pad 0
	grid rowconfigure $base.frame#9 2 -weight 0 -minsize 15 -pad 0
	grid columnconfigure $base.frame#9 1 -weight 0 -minsize 30 -pad 0
	grid columnconfigure $base.frame#9 2 -weight 1 -minsize 30 -pad 0

	grid rowconfigure $base.ring_frame 1 -weight 0 -minsize 6 -pad 0
	grid rowconfigure $base.ring_frame 2 -weight 0 -minsize 30 -pad 0
	grid rowconfigure $base.ring_frame 3 -weight 0 -minsize 30 -pad 0
	grid columnconfigure $base.ring_frame 1 -weight 1 -minsize 30 -pad 0
	grid columnconfigure $base.ring_frame 2 -weight 1 -minsize 30 -pad 0
# additional interface code
set ::advanced_options 0
grid remove $base.advanced
if {!$::input_audio_ring} {grid remove $base.ring_frame}

set ::Meta "Control Shift Meta"


# end additional interface code

}


# Allow interface to be run "stand-alone" for testing

catch {
    if [info exists embed_args] {
	# we are running in the plugin
	pref_ui .
    } else {
	# we are running in stand-alone mode
	if {$argv0 == [info script]} {
	    wm title . "Testing pref_ui"
	    pref_ui .
	}
    }
}
