]> git.ipfire.org Git - thirdparty/git.git/blame - git-gui/lib/error.tcl
Merge branch 'rs/commit-graph-use-list-count'
[thirdparty/git.git] / git-gui / lib / error.tcl
CommitLineData
f522c9b5
SP
1# git-gui branch (create/delete) support
2# Copyright (C) 2006, 2007 Shawn Pearce
3
aba15f7f 4proc _error_parent {} {
85ec3e77
SP
5 set p [grab current .]
6 if {$p eq {}} {
7 return .
8 }
9 return $p
aba15f7f
SP
10}
11
f522c9b5
SP
12proc error_popup {msg} {
13 set title [appname]
14 if {[reponame] ne {}} {
15 append title " ([reponame])"
16 }
17 set cmd [list tk_messageBox \
18 -icon error \
19 -type ok \
a3d97afa 20 -title [mc "%s: error" $title] \
f522c9b5 21 -message $msg]
aba15f7f
SP
22 if {[winfo ismapped [_error_parent]]} {
23 lappend cmd -parent [_error_parent]
f522c9b5
SP
24 }
25 eval $cmd
26}
27
28proc warn_popup {msg} {
29 set title [appname]
30 if {[reponame] ne {}} {
31 append title " ([reponame])"
32 }
33 set cmd [list tk_messageBox \
34 -icon warning \
35 -type ok \
a3d97afa 36 -title [mc "%s: warning" $title] \
f522c9b5 37 -message $msg]
aba15f7f
SP
38 if {[winfo ismapped [_error_parent]]} {
39 lappend cmd -parent [_error_parent]
f522c9b5
SP
40 }
41 eval $cmd
42}
43
aba15f7f 44proc info_popup {msg} {
f522c9b5
SP
45 set title [appname]
46 if {[reponame] ne {}} {
47 append title " ([reponame])"
48 }
49 tk_messageBox \
094fbbf9 50 -parent [_error_parent] \
f522c9b5
SP
51 -icon info \
52 -type ok \
53 -title $title \
54 -message $msg
55}
56
57proc ask_popup {msg} {
58 set title [appname]
59 if {[reponame] ne {}} {
60 append title " ([reponame])"
61 }
2370164f 62 set cmd [list tk_messageBox \
f522c9b5
SP
63 -icon question \
64 -type yesno \
65 -title $title \
66 -message $msg]
aba15f7f
SP
67 if {[winfo ismapped [_error_parent]]} {
68 lappend cmd -parent [_error_parent]
2370164f
SP
69 }
70 eval $cmd
f522c9b5
SP
71}
72
ed76cb70 73proc hook_failed_popup {hook msg {is_fatal 1}} {
c80d7be5 74 global use_ttk NS
f522c9b5 75 set w .hookfail
c80d7be5
PT
76 Dialog $w
77 wm withdraw $w
f522c9b5 78
c80d7be5 79 ${NS}::frame $w.m
9360fc22 80 ${NS}::label $w.m.l1 -text [mc "%s hook failed:" $hook] \
f522c9b5
SP
81 -anchor w \
82 -justify left \
83 -font font_uibold
84 text $w.m.t \
c382fdd7
PH
85 -background white \
86 -foreground black \
87 -borderwidth 1 \
f522c9b5
SP
88 -relief sunken \
89 -width 80 -height 10 \
90 -font font_diff \
91 -yscrollcommand [list $w.m.sby set]
c80d7be5 92 ${NS}::scrollbar $w.m.sby -command [list $w.m.t yview]
f522c9b5 93 pack $w.m.l1 -side top -fill x
ed76cb70 94 if {$is_fatal} {
c80d7be5 95 ${NS}::label $w.m.l2 \
ed76cb70
SP
96 -text [mc "You must correct the above errors before committing."] \
97 -anchor w \
98 -justify left \
99 -font font_uibold
100 pack $w.m.l2 -side bottom -fill x
101 }
f522c9b5
SP
102 pack $w.m.sby -side right -fill y
103 pack $w.m.t -side left -fill both -expand 1
104 pack $w.m -side top -fill both -expand 1 -padx 5 -pady 10
105
106 $w.m.t insert 1.0 $msg
107 $w.m.t conf -state disabled
108
c80d7be5 109 ${NS}::button $w.ok -text OK \
f522c9b5
SP
110 -width 15 \
111 -command "destroy $w"
112 pack $w.ok -side bottom -anchor e -pady 10 -padx 10
113
114 bind $w <Visibility> "grab $w; focus $w"
115 bind $w <Key-Return> "destroy $w"
eca96368 116 wm title $w [mc "%s (%s): error" [appname] [reponame]]
c80d7be5 117 wm deiconify $w
f522c9b5
SP
118 tkwait window $w
119}