Browse Source

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>
maint
Shawn O. Pearce 18 years ago
parent
commit
9f4119eb76
  1. 19
      git-gui.sh

19
git-gui.sh

@ -2432,20 +2432,19 @@ proc popup_diff_menu {ctxm x y X Y} {
set ::cursorX $x set ::cursorX $x
set ::cursorY $y set ::cursorY $y
if {$::ui_index eq $::current_diff_side} { if {$::ui_index eq $::current_diff_side} {
$ctxm entryconf $::ui_diff_applyhunk \ set s normal
-state normal \ set l "Unstage Hunk From Commit"
-label {Unstage Hunk From Commit} } else {
} elseif {$current_diff_path eq {} if {$current_diff_path eq {}
|| ![info exists file_states($current_diff_path)] || ![info exists file_states($current_diff_path)]
|| {_O} eq [lindex $file_states($current_diff_path) 0]} { || {_O} eq [lindex $file_states($current_diff_path) 0]} {
$ctxm entryconf $::ui_diff_applyhunk \ set s disabled
-state disabled \
-label {Stage Hunk For Commit}
} else { } else {
$ctxm entryconf $::ui_diff_applyhunk \ set s normal
-state normal \ }
-label {Stage Hunk For Commit} set l "Stage Hunk For Commit"
} }
$ctxm entryconf $::ui_diff_applyhunk -state $s -label $l
tk_popup $ctxm $X $Y tk_popup $ctxm $X $Y
} }
bind_button3 $ui_diff [list popup_diff_menu $ctxm %x %y %X %Y] bind_button3 $ui_diff [list popup_diff_menu $ctxm %x %y %X %Y]

Loading…
Cancel
Save