Merge branch 'dr/ru' into pu
[gitweb.git] / lib / error.tcl
index 45800d54932bf1367cff81db040d1a14b87a9ab5..8968a57f33e37584e3589f03918db2cb89db24e9 100644 (file)
@@ -2,7 +2,11 @@
 # Copyright (C) 2006, 2007 Shawn Pearce
 
 proc _error_parent {} {
-       return [grab current .]
+       set p [grab current .]
+       if {$p eq {}} {
+               return .
+       }
+       return $p
 }
 
 proc error_popup {msg} {
@@ -13,7 +17,7 @@ proc error_popup {msg} {
        set cmd [list tk_messageBox \
                -icon error \
                -type ok \
-               -title [append "$title: " [mc "error"]] \
+               -title [mc "%s: error" $title] \
                -message $msg]
        if {[winfo ismapped [_error_parent]]} {
                lappend cmd -parent [_error_parent]
@@ -29,7 +33,7 @@ proc warn_popup {msg} {
        set cmd [list tk_messageBox \
                -icon warning \
                -type ok \
-               -title [append "$title: " [mc "warning"]] \
+               -title [mc "%s: warning" $title] \
                -message $msg]
        if {[winfo ismapped [_error_parent]]} {
                lappend cmd -parent [_error_parent]
@@ -43,7 +47,7 @@ proc info_popup {msg} {
                append title " ([reponame])"
        }
        tk_messageBox \
-               -parent $parent \
+               -parent [_error_parent] \
                -icon info \
                -type ok \
                -title $title \
@@ -67,24 +71,28 @@ proc ask_popup {msg} {
 }
 
 proc hook_failed_popup {hook msg {is_fatal 1}} {
+       global use_ttk NS
        set w .hookfail
-       toplevel $w
+       Dialog $w
+       wm withdraw $w
 
-       frame $w.m
-       label $w.m.l1 -text "$hook hook failed:" \
+       ${NS}::frame $w.m
+       ${NS}::label $w.m.l1 -text [mc "%s hook failed:" $hook] \
                -anchor w \
                -justify left \
                -font font_uibold
        text $w.m.t \
-               -background white -borderwidth 1 \
+               -background white \
+               -foreground black \
+               -borderwidth 1 \
                -relief sunken \
                -width 80 -height 10 \
                -font font_diff \
                -yscrollcommand [list $w.m.sby set]
-       scrollbar $w.m.sby -command [list $w.m.t yview]
+       ${NS}::scrollbar $w.m.sby -command [list $w.m.t yview]
        pack $w.m.l1 -side top -fill x
        if {$is_fatal} {
-               label $w.m.l2 \
+               ${NS}::label $w.m.l2 \
                        -text [mc "You must correct the above errors before committing."] \
                        -anchor w \
                        -justify left \
@@ -98,13 +106,14 @@ proc hook_failed_popup {hook msg {is_fatal 1}} {
        $w.m.t insert 1.0 $msg
        $w.m.t conf -state disabled
 
-       button $w.ok -text OK \
+       ${NS}::button $w.ok -text OK \
                -width 15 \
                -command "destroy $w"
        pack $w.ok -side bottom -anchor e -pady 10 -padx 10
 
        bind $w <Visibility> "grab $w; focus $w"
        bind $w <Key-Return> "destroy $w"
-       wm title $w [strcat "[appname] ([reponame]): " [mc "error"]]
+       wm title $w [mc "%s (%s): error" [appname] [reponame]]
+       wm deiconify $w
        tkwait window $w
 }