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>
raw | patch | inline | side by side (parent: 76f1594 )
+proc error_popup {msg {owner .}} {
-proc confirm_popup msg {
+proc confirm_popup {msg {owner .}} {
global confirm_ok
set confirm_ok 0
set w .confirm
toplevel $w
global confirm_ok
set confirm_ok 0
set w .confirm
toplevel $w
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 "set confirm_ok 1; destroy $w"
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 "set confirm_ok 1; destroy $w"
}
toplevel $w
wm title $w [mc "About gitk"]
}
toplevel $w
wm title $w [mc "About gitk"]
message $w.m -text [mc "
Gitk - a commit viewer for git
message $w.m -text [mc "
Gitk - a commit viewer for git
}
toplevel $w
wm title $w [mc "Gitk key bindings"]
}
toplevel $w
wm title $w [mc "Gitk key bindings"]
message $w.m -text "
[mc "Gitk key bindings:"]
message $w.m -text "
[mc "Gitk key bindings:"]
toplevel $top
wm title $top $title
toplevel $top
wm title $top $title
label $top.nl -text [mc "Name"]
entry $top.name -width 20 -textvariable newviewname($n)
grid $top.nl $top.name -sticky w -pady 5
label $top.nl -text [mc "Name"]
entry $top.name -width 20 -textvariable newviewname($n)
grid $top.nl $top.name -sticky w -pady 5
if {[catch {
set newargs [shellsplit $newviewargs($n)]
} err]} {
if {[catch {
set newargs [shellsplit $newviewargs($n)]
} err]} {
- error_popup "[mc "Error in commit selection arguments:"] $err"
- wm raise $top
- focus $top
+ error_popup "[mc "Error in commit selection arguments:"] $err" $top
set patchtop $top
catch {destroy $top}
toplevel $top
set patchtop $top
catch {destroy $top}
toplevel $top
label $top.title -text [mc "Generate patch"]
grid $top.title - -pady 10
label $top.from -text [mc "From:"]
label $top.title -text [mc "Generate patch"]
grid $top.title - -pady 10
label $top.from -text [mc "From:"]
set cmd [lrange $cmd 1 end]
lappend cmd >$fname &
if {[catch {eval exec $cmd} err]} {
set cmd [lrange $cmd 1 end]
lappend cmd >$fname &
if {[catch {eval exec $cmd} err]} {
- error_popup "[mc "Error creating patch:"] $err"
+ error_popup "[mc "Error creating patch:"] $err" $patchtop
}
catch {destroy $patchtop}
unset patchtop
}
catch {destroy $patchtop}
unset patchtop
set mktagtop $top
catch {destroy $top}
toplevel $top
set mktagtop $top
catch {destroy $top}
toplevel $top
label $top.title -text [mc "Create tag"]
grid $top.title - -pady 10
label $top.id -text [mc "ID:"]
label $top.title -text [mc "Create tag"]
grid $top.title - -pady 10
label $top.id -text [mc "ID:"]
set id [$mktagtop.sha1 get]
set tag [$mktagtop.tag get]
if {$tag == {}} {
set id [$mktagtop.sha1 get]
set tag [$mktagtop.tag get]
if {$tag == {}} {
- error_popup [mc "No tag name specified"]
- return
+ error_popup [mc "No tag name specified"] $mktagtop
+ return 0
}
if {[info exists tagids($tag)]} {
}
if {[info exists tagids($tag)]} {
- error_popup [mc "Tag \"%s\" already exists" $tag]
- return
+ error_popup [mc "Tag \"%s\" already exists" $tag] $mktagtop
+ return 0
}
if {[catch {
exec git tag $tag $id
} err]} {
}
if {[catch {
exec git tag $tag $id
} err]} {
- error_popup "[mc "Error creating tag:"] $err"
- return
+ error_popup "[mc "Error creating tag:"] $err" $mktagtop
+ return 0
addedtag $id
dispneartags 0
run refill_reflist
addedtag $id
dispneartags 0
run refill_reflist
set wrcomtop $top
catch {destroy $top}
toplevel $top
set wrcomtop $top
catch {destroy $top}
toplevel $top
label $top.title -text [mc "Write commit to file"]
grid $top.title - -pady 10
label $top.id -text [mc "ID:"]
label $top.title -text [mc "Write commit to file"]
grid $top.title - -pady 10
label $top.id -text [mc "ID:"]
set cmd "echo $id | [$wrcomtop.cmd get]"
set fname [$wrcomtop.fname get]
if {[catch {exec sh -c $cmd >$fname &} err]} {
set cmd "echo $id | [$wrcomtop.cmd get]"
set fname [$wrcomtop.fname get]
if {[catch {exec sh -c $cmd >$fname &} err]} {
- error_popup "[mc "Error writing commit:"] $err"
+ error_popup "[mc "Error writing commit:"] $err" $wrcomtop
}
catch {destroy $wrcomtop}
unset wrcomtop
}
catch {destroy $wrcomtop}
unset wrcomtop
set top .makebranch
catch {destroy $top}
toplevel $top
set top .makebranch
catch {destroy $top}
toplevel $top
label $top.title -text [mc "Create new branch"]
grid $top.title - -pady 10
label $top.id -text [mc "ID:"]
label $top.title -text [mc "Create new branch"]
grid $top.title - -pady 10
label $top.id -text [mc "ID:"]
set cmdargs {}
set old_id {}
if {$name eq {}} {
set cmdargs {}
set old_id {}
if {$name eq {}} {
- error_popup [mc "Please specify a name for the new branch"]
+ error_popup [mc "Please specify a name for the new branch"] $top
return
}
if {[info exists headids($name)]} {
if {![confirm_popup [mc \
return
}
if {[info exists headids($name)]} {
if {![confirm_popup [mc \
- "Branch '%s' already exists. Overwrite?" $name]]} {
+ "Branch '%s' already exists. Overwrite?" $name] $top ]} {
return
}
set old_id $headids($name)
return
}
set old_id $headids($name)
}
toplevel $top
wm title $top [mc "Tags and heads: %s" [file tail [pwd]]]
}
toplevel $top
wm title $top [mc "Tags and heads: %s" [file tail [pwd]]]
text $top.list -background $bgcolor -foreground $fgcolor \
-selectbackground $selectbgcolor -font mainfont \
-xscrollcommand "$top.xsb set" -yscrollcommand "$top.ysb set" \
text $top.list -background $bgcolor -foreground $fgcolor \
-selectbackground $selectbgcolor -font mainfont \
-xscrollcommand "$top.xsb set" -yscrollcommand "$top.ysb set" \
proc choosefont {font which} {
global fontparam fontlist fonttop fontattr
proc choosefont {font which} {
global fontparam fontlist fonttop fontattr
set fontparam(which) $which
set fontparam(font) $font
set fontparam(which) $which
set fontparam(font) $font
font create sample
eval font config sample [font actual $font]
toplevel $top
font create sample
eval font config sample [font actual $font]
toplevel $top
+ wm transient $top $prefstop
wm title $top [mc "Gitk font chooser"]
label $top.l -textvariable fontparam(which)
pack $top.l -side top
wm title $top [mc "Gitk font chooser"]
label $top.l -textvariable fontparam(which)
pack $top.l -side top
}
toplevel $top
wm title $top [mc "Gitk preferences"]
}
toplevel $top
wm title $top [mc "Gitk preferences"]
label $top.ldisp -text [mc "Commit list display options"]
grid $top.ldisp - -sticky w -pady 10
label $top.spacer -text " "
label $top.ldisp -text [mc "Commit list display options"]
grid $top.ldisp - -sticky w -pady 10
label $top.spacer -text " "