Skip to content

Commit 84a76f1

Browse files
angavrilovpaulusmack
authored andcommitted
gitk: Make gitk dialog windows transient
Transient windows are always kept above their parent, and don't occupy any space in the taskbar, which is useful for dialogs. Also, when transient is used, it is important to bind windows to the correct parent. This commit adds transient annotations to all dialogs, ensures usage of the correct parent for error and confirmation popups, and, as a side job, makes gitk preserve the create tag dialog window in case of errors. Signed-off-by: Alexander Gavrilov <[email protected]> Signed-off-by: Paul Mackerras <[email protected]>
1 parent 76f1594 commit 84a76f1

File tree

1 file changed

+28
-18
lines changed

1 file changed

+28
-18
lines changed

gitk

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1751,19 +1751,19 @@ proc show_error {w top msg} {
17511751
tkwait window $top
17521752
}
17531753

1754-
proc error_popup msg {
1754+
proc error_popup {msg {owner .}} {
17551755
set w .error
17561756
toplevel $w
1757-
wm transient $w .
1757+
wm transient $w $owner
17581758
show_error $w $w $msg
17591759
}
17601760

1761-
proc confirm_popup msg {
1761+
proc confirm_popup {msg {owner .}} {
17621762
global confirm_ok
17631763
set confirm_ok 0
17641764
set w .confirm
17651765
toplevel $w
1766-
wm transient $w .
1766+
wm transient $w $owner
17671767
message $w.m -text $msg -justify center -aspect 400
17681768
pack $w.m -side top -fill x -padx 20 -pady 20
17691769
button $w.ok -text [mc OK] -command "set confirm_ok 1; destroy $w"
@@ -2546,6 +2546,7 @@ proc about {} {
25462546
}
25472547
toplevel $w
25482548
wm title $w [mc "About gitk"]
2549+
wm transient $w .
25492550
message $w.m -text [mc "
25502551
Gitk - a commit viewer for git
25512552
@@ -2574,6 +2575,7 @@ proc keys {} {
25742575
}
25752576
toplevel $w
25762577
wm title $w [mc "Gitk key bindings"]
2578+
wm transient $w .
25772579
message $w.m -text "
25782580
[mc "Gitk key bindings:"]
25792581
@@ -3503,6 +3505,7 @@ proc vieweditor {top n title} {
35033505

35043506
toplevel $top
35053507
wm title $top $title
3508+
wm transient $top .
35063509
label $top.nl -text [mc "Name"]
35073510
entry $top.name -width 20 -textvariable newviewname($n)
35083511
grid $top.nl $top.name -sticky w -pady 5
@@ -3572,9 +3575,7 @@ proc newviewok {top n} {
35723575
if {[catch {
35733576
set newargs [shellsplit $newviewargs($n)]
35743577
} err]} {
3575-
error_popup "[mc "Error in commit selection arguments:"] $err"
3576-
wm raise $top
3577-
focus $top
3578+
error_popup "[mc "Error in commit selection arguments:"] $err" $top
35783579
return
35793580
}
35803581
set files {}
@@ -7770,6 +7771,7 @@ proc mkpatch {} {
77707771
set patchtop $top
77717772
catch {destroy $top}
77727773
toplevel $top
7774+
wm transient $top .
77737775
label $top.title -text [mc "Generate patch"]
77747776
grid $top.title - -pady 10
77757777
label $top.from -text [mc "From:"]
@@ -7836,7 +7838,7 @@ proc mkpatchgo {} {
78367838
set cmd [lrange $cmd 1 end]
78377839
lappend cmd >$fname &
78387840
if {[catch {eval exec $cmd} err]} {
7839-
error_popup "[mc "Error creating patch:"] $err"
7841+
error_popup "[mc "Error creating patch:"] $err" $patchtop
78407842
}
78417843
catch {destroy $patchtop}
78427844
unset patchtop
@@ -7856,6 +7858,7 @@ proc mktag {} {
78567858
set mktagtop $top
78577859
catch {destroy $top}
78587860
toplevel $top
7861+
wm transient $top .
78597862
label $top.title -text [mc "Create tag"]
78607863
grid $top.title - -pady 10
78617864
label $top.id -text [mc "ID:"]
@@ -7888,18 +7891,18 @@ proc domktag {} {
78887891
set id [$mktagtop.sha1 get]
78897892
set tag [$mktagtop.tag get]
78907893
if {$tag == {}} {
7891-
error_popup [mc "No tag name specified"]
7892-
return
7894+
error_popup [mc "No tag name specified"] $mktagtop
7895+
return 0
78937896
}
78947897
if {[info exists tagids($tag)]} {
7895-
error_popup [mc "Tag \"%s\" already exists" $tag]
7896-
return
7898+
error_popup [mc "Tag \"%s\" already exists" $tag] $mktagtop
7899+
return 0
78977900
}
78987901
if {[catch {
78997902
exec git tag $tag $id
79007903
} err]} {
7901-
error_popup "[mc "Error creating tag:"] $err"
7902-
return
7904+
error_popup "[mc "Error creating tag:"] $err" $mktagtop
7905+
return 0
79037906
}
79047907

79057908
set tagids($tag) $id
@@ -7908,6 +7911,7 @@ proc domktag {} {
79087911
addedtag $id
79097912
dispneartags 0
79107913
run refill_reflist
7914+
return 1
79117915
}
79127916

79137917
proc redrawtags {id} {
@@ -7946,7 +7950,7 @@ proc mktagcan {} {
79467950
}
79477951

79487952
proc mktaggo {} {
7949-
domktag
7953+
if {![domktag]} return
79507954
mktagcan
79517955
}
79527956

@@ -7957,6 +7961,7 @@ proc writecommit {} {
79577961
set wrcomtop $top
79587962
catch {destroy $top}
79597963
toplevel $top
7964+
wm transient $top .
79607965
label $top.title -text [mc "Write commit to file"]
79617966
grid $top.title - -pady 10
79627967
label $top.id -text [mc "ID:"]
@@ -7994,7 +7999,7 @@ proc wrcomgo {} {
79947999
set cmd "echo $id | [$wrcomtop.cmd get]"
79958000
set fname [$wrcomtop.fname get]
79968001
if {[catch {exec sh -c $cmd >$fname &} err]} {
7997-
error_popup "[mc "Error writing commit:"] $err"
8002+
error_popup "[mc "Error writing commit:"] $err" $wrcomtop
79988003
}
79998004
catch {destroy $wrcomtop}
80008005
unset wrcomtop
@@ -8013,6 +8018,7 @@ proc mkbranch {} {
80138018
set top .makebranch
80148019
catch {destroy $top}
80158020
toplevel $top
8021+
wm transient $top .
80168022
label $top.title -text [mc "Create new branch"]
80178023
grid $top.title - -pady 10
80188024
label $top.id -text [mc "ID:"]
@@ -8044,12 +8050,12 @@ proc mkbrgo {top} {
80448050
set cmdargs {}
80458051
set old_id {}
80468052
if {$name eq {}} {
8047-
error_popup [mc "Please specify a name for the new branch"]
8053+
error_popup [mc "Please specify a name for the new branch"] $top
80488054
return
80498055
}
80508056
if {[info exists headids($name)]} {
80518057
if {![confirm_popup [mc \
8052-
"Branch '%s' already exists. Overwrite?" $name]]} {
8058+
"Branch '%s' already exists. Overwrite?" $name] $top]} {
80538059
return
80548060
}
80558061
set old_id $headids($name)
@@ -8310,6 +8316,7 @@ proc showrefs {} {
83108316
}
83118317
toplevel $top
83128318
wm title $top [mc "Tags and heads: %s" [file tail [pwd]]]
8319+
wm transient $top .
83138320
text $top.list -background $bgcolor -foreground $fgcolor \
83148321
-selectbackground $selectbgcolor -font mainfont \
83158322
-xscrollcommand "$top.xsb set" -yscrollcommand "$top.ysb set" \
@@ -9637,6 +9644,7 @@ proc mkfontdisp {font top which} {
96379644

96389645
proc choosefont {font which} {
96399646
global fontparam fontlist fonttop fontattr
9647+
global prefstop
96409648

96419649
set fontparam(which) $which
96429650
set fontparam(font) $font
@@ -9650,6 +9658,7 @@ proc choosefont {font which} {
96509658
font create sample
96519659
eval font config sample [font actual $font]
96529660
toplevel $top
9661+
wm transient $top $prefstop
96539662
wm title $top [mc "Gitk font chooser"]
96549663
label $top.l -textvariable fontparam(which)
96559664
pack $top.l -side top
@@ -9766,6 +9775,7 @@ proc doprefs {} {
97669775
}
97679776
toplevel $top
97689777
wm title $top [mc "Gitk preferences"]
9778+
wm transient $top .
97699779
label $top.ldisp -text [mc "Commit list display options"]
97709780
grid $top.ldisp - -sticky w -pady 10
97719781
label $top.spacer -text " "

0 commit comments

Comments
 (0)