From 273984fc4f26ab92aa8ebf5b033b9cdb56322b71 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Sun, 28 Jan 2007 20:00:36 -0500 Subject: [PATCH] git-gui: Offer quick access to the HTML formatted documentation. Users may want to be able to read Git documentation, even if they are not command line users. There are many important concepts and terms covered within the standard Git documentation which would be useful to even non command line using people. We now try to offer an 'Online Documentation' menu option within the Help menu. First we try to guess to see what browser the user has setup. We default to instaweb.browser, if set, as this is probably accurate for the user's configuration. If not then we try to guess based on the operating system and the available browsers for each. We prefer documentation which is installed parallel to Git's own executables, e.g. `git --exec-path`/../Documentation/index.html, as that is how I typically install the HTML docs. If those are not found then we open the documentation published on kernel.org. Signed-off-by: Shawn O. Pearce --- git-gui.sh | 48 ++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 44 insertions(+), 4 deletions(-) diff --git a/git-gui.sh b/git-gui.sh index be92fa962..c168826ec 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -4401,17 +4401,57 @@ if {[is_MacOSX]} { lappend disable_on_lock \ [list .mbar.tools entryconf [.mbar.tools index last] -state] } +} - # -- Help Menu - # - .mbar add cascade -label Help -menu .mbar.help - menu .mbar.help +# -- Help Menu +# +.mbar add cascade -label Help -menu .mbar.help +menu .mbar.help +if {![is_MacOSX]} { .mbar.help add command -label "About [appname]" \ -command do_about \ -font font_ui } +set browser {} +catch {set browser $repo_config(instaweb.browser)} +set doc_path [file dirname [exec git --exec-path]] +set doc_path [file join $doc_path Documentation index.html] + +if {[is_Windows]} { + set doc_path [exec cygpath --windows $doc_path] +} + +if {$browser eq {}} { + if {[is_MacOSX]} { + set browser open + } elseif {[is_Windows]} { + set program_files [file dirname [exec cygpath --windir]] + set program_files [file join $program_files {Program Files}] + set firefox [file join $program_files {Mozilla Firefox} firefox.exe] + set ie [file join $program_files {Internet Explorer} IEXPLORE.EXE] + if {[file exists $firefox]} { + set browser $firefox + } elseif {[file exists $ie]} { + set browser $ie + } + unset program_files firefox ie + } +} + +if {[file isfile $doc_path]} { + set doc_url "file:$doc_path" +} else { + set doc_url {http://www.kernel.org/pub/software/scm/git/docs/} +} + +if {$browser ne {}} { + .mbar.help add command -label {Online Documentation} \ + -command [list exec $browser $doc_url &] \ + -font font_ui +} +unset browser doc_path doc_url # -- Branch Control # -- 2.30.2