+#!/usr/bin/wish
+# Tell newlisp embedding to exit on window close
-# Report dimensions
-#puts [winfo vrootwidth .]
-#puts [winfo vrootheight .]
+bind . <Destroy> {puts {newLISP: (exit)}}
-wm title . {Hourglass sitetool}
-#wm geometry . 600x400
+proc loadsite {} {
+ set f [open hourglass.conf]
+ set data [read $f]
+ close $f
+ global site
+ foreach line [split $data \n] {
+ if [regexp {(\S[^ =]*)\s*=\s*(.*)} $line all key value] {
+ set site($key) [string trim $value]
+ }
+ }
+}
-## Tell embedding newlisp to (exit)
-bind . <Destroy> {puts {newLISP: (exit)}}
+loadsite
-set count 3
+proc savesite {} {
+ set f [open hourglass.conf w]
+ puts saving
+ global site
+ foreach key [lsort [array names site]] {
+ if {$key != ""} {
+ set v [string trimright $site($key)]
+ puts "$key = >>>$v<<<"
+ puts $f "$key = $v"
+ }
+ }
+ close $f
+}
proc tooltipOn {w name} {
if {![winfo exist .balloon]} {
}
}
+proc leaving {w} {
+ set i [string first value $w]
+ set k [string replace $w $i [expr $i + 4] name]
+ set key [$k cget -text]
+ set value [$w get 1.0 end]
+ global site
+ set site($key) $value
+}
+
+#
+set count 0
+
proc setting {name defval} {
global count;
+ global site;
incr count;
+ if {[array names site $name] != ""} {
+ set defval "$site($name)"
+ } else {
+ set site($name) $defval
+ }
set wname .fr.settings.name$count ;
set wvalue .fr.settings.value$count ;
set weq .fr.settings.eq$count ;
label $weq -text { };
text $wvalue -height 1 -wrap none -padx 4 -font sanserif -width 30;
$wvalue insert end "$defval";
+ bind $wvalue <Leave> [list leaving $wvalue]
grid $wname -row $count -column 0;
grid $weq -row $count -column 1;
grid $wvalue -row $count -column 2;
bind $wname <Leave> {tooltipOff}
}
+wm title . {Hourglass sitetool}
+
frame .fr
frame .fr.settings
grid columnconfigure .fr.settings 0 -weight 1 -uniform A;
setting {wui.port} {1070}
setting {wui.passwd} {htpasswd}
-button .fr.exit -text "exit" -command {exit}
pack .fr.settings
-pack .fr.exit -pady 4
+
+frame .fr.buttons
+
+button .fr.buttons.save -text save -command {savesite}
+button .fr.buttons.exit -text "done" -command {exit}
+
+grid .fr.buttons.save -column 0 -row 0
+grid .fr.buttons.exit -column 1 -row 0
+pack .fr.buttons
+
grid .fr -column 0 -row 0 -sticky w -padx {10 4} -pady {12 0}