git-gui: Refactor diff pane popup support for future improvements
The current popup_diff_menu procedure is somewhat messy as it has a few duplications of the same logic in each of the different legs of the routine. We can simplify these by setting a few state variables in the different legs. No functional change, just a cleanup to make it easier to implement future functional changes within this block. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Shawn O. Pearce committed
Aug 23, 2007 at 02:39 UTC
9f4119eb7651c7898f385198409be4ca051bc7ef
1 file changed
+11
-12
git-gui.sh
+11
-12
@@ -2432,20 +2432,19 @@ proc popup_diff_menu {ctxm x y X Y} {
2432
set ::cursorX $x
2433
set ::cursorY $y
2434
if {$::ui_index eq $::current_diff_side} {
2435
- $ctxm entryconf $::ui_diff_applyhunk \
2436
- -state normal \
2437
- -label {Unstage Hunk From Commit}
2438
- } elseif {$current_diff_path eq {}
2439
- || ![info exists file_states($current_diff_path)]
2440
- || {_O} eq [lindex $file_states($current_diff_path) 0]} {
2441
- $ctxm entryconf $::ui_diff_applyhunk \
2442
- -state disabled \
2443
- -label {Stage Hunk For Commit}
2435
+ set s normal
2436
+ set l "Unstage Hunk From Commit"
2437
} else {
2445
- $ctxm entryconf $::ui_diff_applyhunk \
2446
- -state normal \
2447
- -label {Stage Hunk For Commit}
2438
+ if {$current_diff_path eq {}
2439
+ || ![info exists file_states($current_diff_path)]
2440
+ || {_O} eq [lindex $file_states($current_diff_path) 0]} {
2441
+ set s disabled
2442
+ } else {
2443
+ set s normal
2444
+ }
2445
+ set l "Stage Hunk For Commit"
2446
}
2447
+ $ctxm entryconf $::ui_diff_applyhunk -state $s -label $l
2448
tk_popup $ctxm $X $Y
2449
}
2450
bind_button3 $ui_diff [list popup_diff_menu $ctxm %x %y %X %Y]