@matheusbsbs / matheus-bagliano / commits / da5239dcab
Fork 0

git-gui: Use native tk_messageBox for errors.

Rather than drawing our own toplevel for error messages we really should just use the the native tk_messageBox command to display any error messages. Major benefits for doing so are: - automatically centers over main window; - less code required on our part in git-gui; - includes a nifty error icon on most systems; - better fits the look-and-feel of the operating system. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Shawn O. Pearce committed Nov 11, 2006 at 19:03 UTC da5239dcab0e8f899a4e6bfb34b574f6286b9dbb
1 file changed +25 -31
git-gui
+25 -31
@@ -7,6 +7,9 @@ exec wish "$0" -- "$@"
7 # and distributed under the terms of the GNU General Public Licence,
8 # either version 2, or (at your option) any later version.
9
10 +set appname [lindex [file split $argv0] end]
11 +set gitdir {}
12 +
13 ######################################################################
14 ##
15 ## config
@@ -59,16 +62,30 @@ proc save_my_config {} {
62 }
63 }
64
65 +proc error_popup {msg} {
66 + global gitdir appname
67 +
68 + set title $appname
69 + if {$gitdir != {}} {
70 + append title { (}
71 + append title [lindex \
72 + [file split [file normalize [file dirname $gitdir]]] \
73 + end]
74 + append title {)}
75 + }
76 + tk_messageBox -parent . \
77 + -icon error \
78 + -type ok \
79 + -title "$title: error" \
80 + -message $msg
81 +}
82 +
83 ######################################################################
84 ##
85 ## repository setup
86
66 -set appname [lindex [file split $argv0] end]
67 -set gitdir {}
68 -set GIT_COMMITTER_IDENT {}
69 -
87 if {[catch {set cdup [exec git rev-parse --show-cdup]} err]} {
71 - show_msg {} . "Cannot find the git directory: $err"
88 + error_popup "Cannot find the git directory:\n$err"
89 exit 1
90 }
91 if {$cdup != ""} {
@@ -77,7 +94,7 @@ if {$cdup != ""} {
94 unset cdup
95
96 if {[catch {set gitdir [exec git rev-parse --git-dir]} err]} {
80 - show_msg {} . "Cannot find the git directory: $err"
97 + error_popup "Cannot find the git directory:\n$err"
98 exit 1
99 }
100
@@ -1204,31 +1221,6 @@ unset filemask i
1221 ##
1222 ## util
1223
1207 -proc error_popup {msg} {
1208 - set w .error
1209 - toplevel $w
1210 - wm transient $w .
1211 - show_msg $w $w $msg
1212 -}
1213 -
1214 -proc show_msg {w top msg} {
1215 - global gitdir appname font_ui
1216 -
1217 - message $w.m -text $msg -justify left -aspect 400
1218 - pack $w.m -side top -fill x -padx 5 -pady 10
1219 - button $w.ok -text OK \
1220 - -width 15 \
1221 - -font $font_ui \
1222 - -command "destroy $top"
1223 - pack $w.ok -side bottom
1224 - bind $top <Visibility> "grab $top; focus $top"
1225 - bind $top <Key-Return> "destroy $top"
1226 - wm title $w "$appname ([lindex [file split \
1227 - [file normalize [file dirname $gitdir]]] \
1228 - end]): error"
1229 - tkwait window $top
1230 -}
1231 -
1224 proc hook_failed_popup {hook msg} {
1225 global gitdir font_ui font_diff appname
1226
@@ -1482,6 +1474,8 @@ proc do_include_all {} {
1474 }
1475 }
1476
1477 +set GIT_COMMITTER_IDENT {}
1478 +
1479 proc do_signoff {} {
1480 global ui_comm GIT_COMMITTER_IDENT
1481