Merge branch 'py/git-gui-do-quit'
[gitweb.git] / git-gui / git-gui.sh
index 91c00e6489305a56faed6d4e89150709ba7f2aeb..6ec562d5da3cf07afb27f88b10763f1104134baf 100755 (executable)
@@ -3030,8 +3030,23 @@ unset doc_path doc_url
 wm protocol . WM_DELETE_WINDOW do_quit
 bind all <$M1B-Key-q> do_quit
 bind all <$M1B-Key-Q> do_quit
-bind all <$M1B-Key-w> {destroy [winfo toplevel %W]}
-bind all <$M1B-Key-W> {destroy [winfo toplevel %W]}
+
+set m1b_w_script {
+       set toplvl_win [winfo toplevel %W]
+
+       # If we are destroying the main window, we should call do_quit to take
+       # care of cleanup before exiting the program.
+       if {$toplvl_win eq "."} {
+               do_quit
+       } else {
+               destroy $toplvl_win
+       }
+}
+
+bind all <$M1B-Key-w> $m1b_w_script
+bind all <$M1B-Key-W> $m1b_w_script
+
+unset m1b_w_script
 
 set subcommand_args {}
 proc usage {} {
@@ -3867,6 +3882,7 @@ bind .   <$M1B-Key-equal> {show_more_context;break}
 bind .   <$M1B-Key-plus> {show_more_context;break}
 bind .   <$M1B-Key-KP_Add> {show_more_context;break}
 bind .   <$M1B-Key-Return> do_commit
+bind .   <$M1B-Key-KP_Enter> do_commit
 foreach i [list $ui_index $ui_workdir] {
        bind $i <Button-1>       { toggle_or_diff click %W %x %y; break }
        bind $i <$M1B-Button-1>  { add_one_to_selection %W %x %y; break }