From: Alexander Gavrilov <angavrilov@gmail.com>
To: Paul Mackerras <paulus@samba.org>
Cc: git@vger.kernel.org
Subject: Re: [PATCH (GITK) v3 6/6] gitk: Explicitly position popup windows.
Date: Sun, 9 Nov 2008 17:53:30 +0300 [thread overview]
Message-ID: <200811091753.31198.angavrilov@gmail.com> (raw)
In-Reply-To: <18708.11537.229423.296701@cargo.ozlabs.ibm.com>
On Friday 07 November 2008 14:57:05 Paul Mackerras wrote:
> Alexander Gavrilov writes:
>
> > For some reason, on Windows all transient windows are placed
> > in the upper left corner of the screen. Thus, it is necessary
> > to explicitly position the windows relative to their parent.
> > For simplicity this patch uses the function that is used
> > internally by Tk dialogs.
>
> Is there any reason to call tk::PlaceWindow under Linux or MacOS?
> If not I'd rather add an if statement so we only call it on Windows.
I don't know about MacOS, but in Linux it does seem unnecessary, so:
--- >8 ---
Subject: [PATCH] gitk: Explicitly position popup windows.
For some reason, on Windows all transient windows are placed
in the upper left corner of the screen. Thus, it is necessary
to explicitly position the windows relative to their parent.
For simplicity this patch uses the function that is used
internally by Tk dialogs.
Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
---
gitk | 29 +++++++++++++++++++++++++++--
1 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/gitk b/gitk
index 1363d20..d72412c 100755
--- a/gitk
+++ b/gitk
@@ -1739,7 +1739,17 @@ proc removehead {id name} {
unset headids($name)
}
-proc show_error {w top msg} {
+proc center_window {window origin} {
+ # Let platforms with a real window manager
+ # deal with it on their own
+ if {$::tcl_platform(platform) ne {windows}} return
+
+ # Use a handy function from Tk. Note that it
+ # calls 'update' to figure out dimensions.
+ tk::PlaceWindow $window widget $origin
+}
+
+proc show_error {w top msg {owner {}}} {
message $w.m -text $msg -justify center -aspect 400
pack $w.m -side top -fill x -padx 20 -pady 20
button $w.ok -text [mc OK] -command "destroy $top"
@@ -1748,6 +1758,9 @@ proc show_error {w top msg} {
bind $top <Key-Return> "destroy $top"
bind $top <Key-space> "destroy $top"
bind $top <Key-Escape> "destroy $top"
+ if {$owner ne {}} {
+ center_window $top $owner
+ }
tkwait window $top
}
@@ -1755,7 +1768,7 @@ proc error_popup {msg {owner .}} {
set w .error
toplevel $w
wm transient $w $owner
- show_error $w $w $msg
+ show_error $w $w $msg $owner
}
proc confirm_popup {msg {owner .}} {
@@ -1774,6 +1787,7 @@ proc confirm_popup {msg {owner .}} {
bind $w <Key-Return> "set confirm_ok 1; destroy $w"
bind $w <Key-space> "set confirm_ok 1; destroy $w"
bind $w <Key-Escape> "destroy $w"
+ center_window $w $owner
tkwait window $w
return $confirm_ok
}
@@ -2572,6 +2586,7 @@ Use and redistribute under the terms of the GNU General Public License"] \
bind $w <Visibility> "focus $w.ok"
bind $w <Key-Escape> "destroy $w"
bind $w <Key-Return> "destroy $w"
+ center_window $w .
}
proc keys {} {
@@ -2635,6 +2650,7 @@ proc keys {} {
bind $w <Visibility> "focus $w.ok"
bind $w <Key-Escape> "destroy $w"
bind $w <Key-Return> "destroy $w"
+ center_window $w .
}
# Procedures for manipulating the file list window at the
@@ -3687,6 +3703,7 @@ proc vieweditor {top n title} {
grid columnconfigure $top.buts 1 -weight 1 -uniform a
grid columnconfigure $top.buts 2 -weight 1 -uniform a
pack $top.buts -in $top -side top -fill x
+ center_window $top .
focus $top.t
}
@@ -7950,6 +7967,7 @@ proc mkpatch {} {
grid columnconfigure $top.buts 1 -weight 1 -uniform a
grid $top.buts - -pady 10 -sticky ew
focus $top.fname
+ center_window $top .
}
proc mkpatchrev {} {
@@ -8024,6 +8042,7 @@ proc mktag {} {
grid columnconfigure $top.buts 1 -weight 1 -uniform a
grid $top.buts - -pady 10 -sticky ew
focus $top.tag
+ center_window $top .
}
proc domktag {} {
@@ -8131,6 +8150,7 @@ proc writecommit {} {
grid columnconfigure $top.buts 1 -weight 1 -uniform a
grid $top.buts - -pady 10 -sticky ew
focus $top.fname
+ center_window $top .
}
proc wrcomgo {} {
@@ -8181,6 +8201,7 @@ proc mkbranch {} {
grid columnconfigure $top.buts 1 -weight 1 -uniform a
grid $top.buts - -pady 10 -sticky ew
focus $top.name
+ center_window $top .
}
proc mkbrgo {top} {
@@ -8341,6 +8362,7 @@ proc resethead {} {
bind $w <Key-Escape> [list destroy $w]
pack $w.cancel -side right -fill x -padx 20 -pady 20
bind $w <Visibility> "grab $w; focus $w"
+ center_window $w .
tkwait window $w
if {!$confirm_ok} return
if {[catch {set fd [open \
@@ -8526,6 +8548,7 @@ proc showrefs {} {
bind $top.list <ButtonRelease-1> {sel_reflist %W %x %y; break}
set reflist {}
refill_reflist
+ center_window $top .
}
proc sel_reflist {w x y} {
@@ -9878,6 +9901,7 @@ proc choosefont {font which} {
grid columnconfigure $top.buts 1 -weight 1 -uniform a
pack $top.buts -side bottom -fill x
trace add variable fontparam write chg_fontparam
+ center_window $top $prefstop
} else {
raise $top
$top.c itemconf text -text $which
@@ -10060,6 +10084,7 @@ proc doprefs {} {
grid columnconfigure $top.buts 1 -weight 1 -uniform a
grid $top.buts - - -pady 10 -sticky ew
bind $top <Visibility> "focus $top.buts.ok"
+ center_window $top .
}
proc choose_extdiff {} {
--
1.6.0.3.15.gb8d36
next prev parent reply other threads:[~2008-11-09 14:56 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-02 18:59 [PATCH (GITK) v3 0/6] Enhance popup dialogs in gitk Alexander Gavrilov
2008-11-02 18:59 ` [PATCH (GITK) v3 1/6] gitk: Add Return and Escape bindings to dialogs Alexander Gavrilov
2008-11-02 18:59 ` [PATCH (GITK) v3 2/6] gitk: Make gitk dialog windows transient Alexander Gavrilov
2008-11-02 18:59 ` [PATCH (GITK) v3 3/6] gitk: Add accelerators to frequently used menu commands Alexander Gavrilov
2008-11-02 18:59 ` [PATCH (GITK) v3 4/6] gitk: Make cherry-pick call git-citool on conflicts Alexander Gavrilov
2008-11-02 18:59 ` [PATCH (GITK) v3 5/6] gitk: Implement a user-friendly Edit View dialog Alexander Gavrilov
2008-11-02 18:59 ` [PATCH (GITK) v3 6/6] gitk: Explicitly position popup windows Alexander Gavrilov
2008-11-07 11:57 ` Paul Mackerras
2008-11-07 14:39 ` Alex Riesen
2008-11-07 16:37 ` Johannes Sixt
2008-11-09 10:26 ` Alex Riesen
2008-11-09 11:12 ` Paul Mackerras
2008-11-09 14:53 ` Alexander Gavrilov [this message]
2008-11-10 11:47 ` Paul Mackerras
2008-11-10 12:15 ` Alexander Gavrilov
2008-11-11 11:00 ` Alexander Gavrilov
2008-11-07 11:51 ` [PATCH (GITK) v3 4/6] gitk: Make cherry-pick call git-citool on conflicts Paul Mackerras
2008-11-07 11:50 ` [PATCH (GITK) v3 3/6] gitk: Add accelerators to frequently used menu commands Paul Mackerras
2008-11-09 11:21 ` Alexander Gavrilov
2008-11-07 11:41 ` [PATCH (GITK) v3 2/6] gitk: Make gitk dialog windows transient Paul Mackerras
2008-11-07 11:41 ` [PATCH (GITK) v3 1/6] gitk: Add Return and Escape bindings to dialogs Paul Mackerras
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=200811091753.31198.angavrilov@gmail.com \
--to=angavrilov@gmail.com \
--cc=git@vger.kernel.org \
--cc=paulus@samba.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).