From 8e891facbef4b0196e51fe2065602175f28508c3 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Wed, 18 Jul 2007 01:39:27 -0400 Subject: [PATCH] git-gui: Allow users to browse any branch, not just the current one We now allow users to pick which commit they want to browse through our revision picking mega-widget. This opens up in a dialog first, and then opens a tree browser for that selected commit. It is a very simple approach and requires minimal code changes. I also clarified the language a bit in the Repository menu, to show that these actions will access files. Just in case a user is not quite sure what specific action they are looking for, but they know they want some sort of file thing. Signed-off-by: Shawn O. Pearce --- git-gui.sh | 7 +++++-- lib/browser.tcl | 53 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 2 deletions(-) diff --git a/git-gui.sh b/git-gui.sh index 267d60621..ac04bc0b2 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -1670,9 +1670,12 @@ if {[is_enabled transport]} { menu .mbar.repository .mbar.repository add command \ - -label {Browse Current Branch} \ + -label {Browse Current Branch's Files} \ -command {browser::new $current_branch} -trace add variable current_branch write ".mbar.repository entryconf [.mbar.repository index last] -label \"Browse \$current_branch\" ;#" +trace add variable current_branch write ".mbar.repository entryconf [.mbar.repository index last] -label \"Browse \$current_branch's Files\" ;#" +.mbar.repository add command \ + -label {Browse Branch Files...} \ + -command browser_open::dialog .mbar.repository add separator .mbar.repository add command \ diff --git a/lib/browser.tcl b/lib/browser.tcl index e8802d001..b684c6714 100644 --- a/lib/browser.tcl +++ b/lib/browser.tcl @@ -243,3 +243,56 @@ method _read {fd} { } } + +class browser_open { + +field w ; # widget path +field w_rev ; # mega-widget to pick the initial revision + +constructor dialog {} { + make_toplevel top w + wm title $top "[appname] ([reponame]): Browse Branch Files" + if {$top ne {.}} { + wm geometry $top "+[winfo rootx .]+[winfo rooty .]" + } + + label $w.header \ + -text {Browse Branch Files} \ + -font font_uibold + pack $w.header -side top -fill x + + frame $w.buttons + button $w.buttons.browse -text Browse \ + -default active \ + -command [cb _open] + pack $w.buttons.browse -side right + button $w.buttons.cancel -text {Cancel} \ + -command [list destroy $w] + pack $w.buttons.cancel -side right -padx 5 + pack $w.buttons -side bottom -fill x -pady 10 -padx 10 + + set w_rev [::choose_rev::new $w.rev {Revision}] + $w_rev bind_listbox [cb _open] + pack $w.rev -anchor nw -fill both -expand 1 -pady 5 -padx 5 + + bind $w [cb _visible] + bind $w [list destroy $w] + bind $w [cb _open]\;break + tkwait window $w +} + +method _open {} { + if {[catch {$w_rev commit_or_die} err]} { + return + } + set name [$w_rev get] + destroy $w + browser::new $name +} + +method _visible {} { + grab $w + $w_rev focus_filter +} + +} -- 2.26.2