+ bind . <Destroy> {savestuff %W}
+ bind . <Button-1> "click %W"
+ bind $fstring <Key-Return> dofind
+}
+
+# when we make a key binding for the toplevel, make sure
+# it doesn't get triggered when that key is pressed in the
+# find string entry widget.
+proc bindkey {ev script} {
+ global fstring
+ bind . $ev $script
+ set escript [bind Entry $ev]
+ if {$escript == {}} {
+ set escript [bind Entry <Key>]
+ }
+ bind $fstring $ev "$escript; break"
+}
+
+# set the focus back to the toplevel for any click outside
+# the find string entry widget
+proc click {w} {
+ global fstring
+ if {$w != $fstring} {
+ focus .
+ }
+}
+
+proc savestuff {w} {
+ global canv canv2 canv3 ctext cflist mainfont textfont
+ global stuffsaved
+ if {$stuffsaved} return
+ if {![winfo viewable .]} return
+ catch {
+ set f [open "~/.gitk-new" w]
+ puts $f "set mainfont {$mainfont}"
+ puts $f "set textfont {$textfont}"
+ puts $f "set geometry(width) [winfo width .ctop]"
+ puts $f "set geometry(height) [winfo height .ctop]"
+ puts $f "set geometry(canv1) [expr [winfo width $canv]-2]"
+ puts $f "set geometry(canv2) [expr [winfo width $canv2]-2]"
+ puts $f "set geometry(canv3) [expr [winfo width $canv3]-2]"
+ puts $f "set geometry(canvh) [expr [winfo height $canv]-2]"
+ set wid [expr {([winfo width $ctext] - 8) \
+ / [font measure $textfont "0"]}]
+ puts $f "set geometry(ctextw) $wid"
+ set wid [expr {([winfo width $cflist] - 11) \
+ / [font measure [$cflist cget -font] "0"]}]
+ puts $f "set geometry(cflistw) $wid"
+ close $f
+ file rename -force "~/.gitk-new" "~/.gitk"
+ }
+ set stuffsaved 1