All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <junkio@cox.net>
To: git@vger.kernel.org
Cc: Mark Levedahl <mdl123@verizon.net>
Subject: [PATCH] Make gitk save and restore the user set window position.
Date: Tue, 06 Feb 2007 19:21:05 -0800	[thread overview]
Message-ID: <7v3b5ifyam.fsf@assigned-by-dhcp.cox.net> (raw)

From: Mark Levedahl <mdl123@verizon.net>
Date: Mon, 05 Feb 2007 22:59:50 -0500

gitk was saving widget sizes and positions when the main window was
destroyed, which is after all child widgets are destroyed. Tk resizes
container widgets as children are destroyed, so the saved main window
information was not as the user left the window. This patch causes the
info to be saved before the first child widget is destroyed. Also,
use wm geometry rather than winfo geometry (both work on Windows, on
Linux they give different answers and the former is correct).

Signed-off-by: Mark Levedahl <mdl123@verizon.net>
---
 * Somehow this did not appeared on the list, so I am forwarding.

   After seeing what this patch has to do, I feel dirty, but
   that is not Mark's fault -- rather it is Tk's.

   I am tempted to suggest adding an explicit "Save window
   configuration" action on the menubar and forget about
   resurrecting the window configuration immediately before the
   end of the last session.

 gitk |   20 ++++++++++++++++++--
 1 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/gitk b/gitk
index 8132812..beec6a9 100755
--- a/gitk
+++ b/gitk
@@ -725,7 +725,7 @@ proc makewindow {} {
     bind . <Control-KP_Add> {incrfont 1}
     bind . <Control-minus> {incrfont -1}
     bind . <Control-KP_Subtract> {incrfont -1}
-    bind . <Destroy> {savestuff %W}
+    bindalldestroy .
     bind . <Button-1> "click %W"
     bind $fstring <Key-Return> dofind
     bind $sha1entry <Key-Return> gotocommit
@@ -759,6 +759,22 @@ proc makewindow {} {
 	-command rmbranch
 }
 
+# The main window resizes itself while the windows are being destroyed,
+# we want to save the size before it is resized so we write out when the
+# first widget with no children is destroyed.  We don't know which this
+# will be, so we bind all child widgets (savestuff will save only once,
+# the remaining calls are ignored).
+proc bindalldestroy {w} {
+    set children [winfo children $w]
+    if {"$children" == ""} {
+        bind $w <Destroy> {savestuff %W}
+    } else {
+        foreach child $children {
+            bindalldestroy $child
+        }
+    }
+}
+
 # mouse-2 makes all windows scan vertically, but only the one
 # the cursor is in scans horizontally
 proc canvscan {op w x y} {
@@ -829,7 +845,7 @@ proc savestuff {w} {
 	puts $f [list set colors $colors]
 	puts $f [list set diffcolors $diffcolors]
 
-        puts $f "set geometry(main) [winfo geometry .]"
+	puts $f "set geometry(main) [wm geometry .]"
 	puts $f "set geometry(topwidth) [winfo width .tf]"
 	puts $f "set geometry(topheight) [winfo height .tf]"
 	puts $f "set geometry(canv) [expr {[winfo width $canv]-0}]"
-- 
1.5.0.rc3.24.g0c5e

             reply	other threads:[~2007-02-07  3:21 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-07  3:21 Junio C Hamano [this message]
2007-02-07  5:40 ` [PATCH] Make gitk save and restore the user set window position Shawn O. Pearce
2007-02-08  0:30   ` Mark Levedahl
2007-02-08  5:43 Brett Schwarz
2007-02-08 16:55 ` Mark Levedahl
2007-02-11 14:27 Mark Levedahl
2007-02-11 14:27 ` Mark Levedahl
2007-02-11 21:49 ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7v3b5ifyam.fsf@assigned-by-dhcp.cox.net \
    --to=junkio@cox.net \
    --cc=git@vger.kernel.org \
    --cc=mdl123@verizon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.