aboutsummaryrefslogtreecommitdiff
path: root/lib/class.tcl
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2007-06-11 23:52:43 -0400
committerShawn O. Pearce <spearce@spearce.org>2007-06-11 23:52:43 -0400
commit39fa2a983d55b37759b99e67f9f1892879efb775 (patch)
tree1be07eaef87b5c614b4b8559c91ddb62e6342c8a /lib/class.tcl
parentb2f3bb1b66d9422aa5049f994c6e370a18d89759 (diff)
downloadgit-39fa2a983d55b37759b99e67f9f1892879efb775.tar.gz
git-39fa2a983d55b37759b99e67f9f1892879efb775.tar.xz
git-gui: Save geometry before the window layout is damaged
Because Tk does not assure us the order that it will process children in before it destroys the main toplevel we cannot safely save our geometry data during a "bind . <Destroy>" event binding. The geometry may have already changed as a result of a one or more children being removed from the layout. This was pointed out in gitk by Mark Levedahl, and patched over there by commit b6047c5a8166a71e01c6b63ebbb67c6894d95114. So we now also use "wm protocol . WM_DELETE_WINDOW" to detect when the window is closed by the user, and forward that close event to our main do_quit routine. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'lib/class.tcl')
-rw-r--r--lib/class.tcl24
1 files changed, 21 insertions, 3 deletions
diff --git a/lib/class.tcl b/lib/class.tcl
index 72494c1a1..9d298d0dc 100644
--- a/lib/class.tcl
+++ b/lib/class.tcl
@@ -120,10 +120,21 @@ proc delete_this {{t {}}} {
if {[namespace exists $t]} {namespace delete $t}
}
-proc make_toplevel {t w} {
- upvar $t top $w pfx
+proc make_toplevel {t w args} {
+ upvar $t top $w pfx this this
+
+ if {[llength $args] % 2} {
+ error "make_toplevel topvar winvar {options}"
+ }
+ set autodelete 1
+ foreach {name value} $args {
+ switch -exact -- $name {
+ -autodelete {set autodelete $value}
+ default {error "unsupported option $name"}
+ }
+ }
+
if {[winfo ismapped .]} {
- upvar this this
regsub -all {::} $this {__} w
set top .$w
set pfx $top
@@ -132,6 +143,13 @@ proc make_toplevel {t w} {
set top .
set pfx {}
}
+
+ if {$autodelete} {
+ wm protocol $top WM_DELETE_WINDOW "
+ [list delete_this $this]
+ [list destroy $top]
+ "
+ }
}