@matheusbsbs / matheus-bagliano / commits / 84a76f18f0
Fork 0

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 <angavrilov@gmail.com> Signed-off-by: Paul Mackerras <paulus@samba.org>

Alexander Gavrilov committed Nov 2, 2008 at 21:59 UTC 84a76f18f0313832ccc9c2f0171ace3da64ffa4f
1 file changed +28 -18
gitk
+28 -18
@@ -1751,19 +1751,19 @@ proc show_error {w top msg} {
1751 tkwait window $top
1752 }
1753
1754 -proc error_popup msg {
1754 +proc error_popup {msg {owner .}} {
1755 set w .error
1756 toplevel $w
1757 - wm transient $w .
1757 + wm transient $w $owner
1758 show_error $w $w $msg
1759 }
1760
1761 -proc confirm_popup msg {
1761 +proc confirm_popup {msg {owner .}} {
1762 global confirm_ok
1763 set confirm_ok 0
1764 set w .confirm
1765 toplevel $w
1766 - wm transient $w .
1766 + wm transient $w $owner
1767 message $w.m -text $msg -justify center -aspect 400
1768 pack $w.m -side top -fill x -padx 20 -pady 20
1769 button $w.ok -text [mc OK] -command "set confirm_ok 1; destroy $w"
@@ -2546,6 +2546,7 @@ proc about {} {
2546 }
2547 toplevel $w
2548 wm title $w [mc "About gitk"]
2549 + wm transient $w .
2550 message $w.m -text [mc "
2551 Gitk - a commit viewer for git
2552
@@ -2574,6 +2575,7 @@ proc keys {} {
2575 }
2576 toplevel $w
2577 wm title $w [mc "Gitk key bindings"]
2578 + wm transient $w .
2579 message $w.m -text "
2580 [mc "Gitk key bindings:"]
2581
@@ -3503,6 +3505,7 @@ proc vieweditor {top n title} {
3505
3506 toplevel $top
3507 wm title $top $title
3508 + wm transient $top .
3509 label $top.nl -text [mc "Name"]
3510 entry $top.name -width 20 -textvariable newviewname($n)
3511 grid $top.nl $top.name -sticky w -pady 5
@@ -3572,9 +3575,7 @@ proc newviewok {top n} {
3575 if {[catch {
3576 set newargs [shellsplit $newviewargs($n)]
3577 } 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
3579 return
3580 }
3581 set files {}
@@ -7770,6 +7771,7 @@ proc mkpatch {} {
7771 set patchtop $top
7772 catch {destroy $top}
7773 toplevel $top
7774 + wm transient $top .
7775 label $top.title -text [mc "Generate patch"]
7776 grid $top.title - -pady 10
7777 label $top.from -text [mc "From:"]
@@ -7836,7 +7838,7 @@ proc mkpatchgo {} {
7838 set cmd [lrange $cmd 1 end]
7839 lappend cmd >$fname &
7840 if {[catch {eval exec $cmd} err]} {
7839 - error_popup "[mc "Error creating patch:"] $err"
7841 + error_popup "[mc "Error creating patch:"] $err" $patchtop
7842 }
7843 catch {destroy $patchtop}
7844 unset patchtop
@@ -7856,6 +7858,7 @@ proc mktag {} {
7858 set mktagtop $top
7859 catch {destroy $top}
7860 toplevel $top
7861 + wm transient $top .
7862 label $top.title -text [mc "Create tag"]
7863 grid $top.title - -pady 10
7864 label $top.id -text [mc "ID:"]
@@ -7888,18 +7891,18 @@ proc domktag {} {
7891 set id [$mktagtop.sha1 get]
7892 set tag [$mktagtop.tag get]
7893 if {$tag == {}} {
7891 - error_popup [mc "No tag name specified"]
7892 - return
7894 + error_popup [mc "No tag name specified"] $mktagtop
7895 + return 0
7896 }
7897 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
7900 }
7901 if {[catch {
7902 exec git tag $tag $id
7903 } err]} {
7901 - error_popup "[mc "Error creating tag:"] $err"
7902 - return
7904 + error_popup "[mc "Error creating tag:"] $err" $mktagtop
7905 + return 0
7906 }
7907
7908 set tagids($tag) $id
@@ -7908,6 +7911,7 @@ proc domktag {} {
7911 addedtag $id
7912 dispneartags 0
7913 run refill_reflist
7914 + return 1
7915 }
7916
7917 proc redrawtags {id} {
@@ -7946,7 +7950,7 @@ proc mktagcan {} {
7950 }
7951
7952 proc mktaggo {} {
7949 - domktag
7953 + if {![domktag]} return
7954 mktagcan
7955 }
7956
@@ -7957,6 +7961,7 @@ proc writecommit {} {
7961 set wrcomtop $top
7962 catch {destroy $top}
7963 toplevel $top
7964 + wm transient $top .
7965 label $top.title -text [mc "Write commit to file"]
7966 grid $top.title - -pady 10
7967 label $top.id -text [mc "ID:"]
@@ -7994,7 +7999,7 @@ proc wrcomgo {} {
7999 set cmd "echo $id | [$wrcomtop.cmd get]"
8000 set fname [$wrcomtop.fname get]
8001 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
8003 }
8004 catch {destroy $wrcomtop}
8005 unset wrcomtop
@@ -8013,6 +8018,7 @@ proc mkbranch {} {
8018 set top .makebranch
8019 catch {destroy $top}
8020 toplevel $top
8021 + wm transient $top .
8022 label $top.title -text [mc "Create new branch"]
8023 grid $top.title - -pady 10
8024 label $top.id -text [mc "ID:"]
@@ -8044,12 +8050,12 @@ proc mkbrgo {top} {
8050 set cmdargs {}
8051 set old_id {}
8052 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
8054 return
8055 }
8056 if {[info exists headids($name)]} {
8057 if {![confirm_popup [mc \
8052 - "Branch '%s' already exists. Overwrite?" $name]]} {
8058 + "Branch '%s' already exists. Overwrite?" $name] $top]} {
8059 return
8060 }
8061 set old_id $headids($name)
@@ -8310,6 +8316,7 @@ proc showrefs {} {
8316 }
8317 toplevel $top
8318 wm title $top [mc "Tags and heads: %s" [file tail [pwd]]]
8319 + wm transient $top .
8320 text $top.list -background $bgcolor -foreground $fgcolor \
8321 -selectbackground $selectbgcolor -font mainfont \
8322 -xscrollcommand "$top.xsb set" -yscrollcommand "$top.ysb set" \
@@ -9637,6 +9644,7 @@ proc mkfontdisp {font top which} {
9644
9645 proc choosefont {font which} {
9646 global fontparam fontlist fonttop fontattr
9647 + global prefstop
9648
9649 set fontparam(which) $which
9650 set fontparam(font) $font
@@ -9650,6 +9658,7 @@ proc choosefont {font which} {
9658 font create sample
9659 eval font config sample [font actual $font]
9660 toplevel $top
9661 + wm transient $top $prefstop
9662 wm title $top [mc "Gitk font chooser"]
9663 label $top.l -textvariable fontparam(which)
9664 pack $top.l -side top
@@ -9766,6 +9775,7 @@ proc doprefs {} {
9775 }
9776 toplevel $top
9777 wm title $top [mc "Gitk preferences"]
9778 + wm transient $top .
9779 label $top.ldisp -text [mc "Commit list display options"]
9780 grid $top.ldisp - -sticky w -pady 10
9781 label $top.spacer -text " "