git-gui: Create Windows shortcut icons for git-gui.
If we are running on Windows we now offer a 'Create Desktop Icon' menu item under the Project menu. This pops up a save dialog box letting the user create a .bat file on their desktop (or somewhere else). The .bat script will startup Cygwin with a login shell then launch git-gui in the current working directory. This is very useful for Windows users who have little to no desire to start a command window just to run a git-gui session. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Shawn O. Pearce committed
Nov 15, 2006 at 22:35 UTC
4aca740b3915b35d7fa1707be79b268b0cc94123
1 file changed
+55
git-gui
+55
@@ -2002,6 +2002,54 @@ proc do_save_config {w} {
2002
destroy $w
2003
}
2004
2005
+proc do_windows_shortcut {} {
2006
+ global gitdir appname argv0
2007
+
2008
+ set reponame [lindex [file split \
2009
+ [file normalize [file dirname $gitdir]]] \
2010
+ end]
2011
+
2012
+ if {[catch {
2013
+ set desktop [exec cygpath \
2014
+ --windows \
2015
+ --absolute \
2016
+ --long-name \
2017
+ --desktop]
2018
+ }]} {
2019
+ set desktop .
2020
+ }
2021
+ set fn [tk_getSaveFile \
2022
+ -parent . \
2023
+ -title "$appname ($reponame): Create Desktop Icon" \
2024
+ -initialdir $desktop \
2025
+ -initialfile "Git $reponame.bat"]
2026
+ if {$fn != {}} {
2027
+ if {[catch {
2028
+ set fd [open $fn w]
2029
+ set sh [exec cygpath \
2030
+ --windows \
2031
+ --absolute \
2032
+ --long-name \
2033
+ /bin/sh]
2034
+ set me [exec cygpath \
2035
+ --unix \
2036
+ --absolute \
2037
+ $argv0]
2038
+ set gd [exec cygpath \
2039
+ --unix \
2040
+ --absolute \
2041
+ $gitdir]
2042
+ puts -nonewline $fd "\"$sh\" --login -c \""
2043
+ puts -nonewline $fd "GIT_DIR=\\\"$gd\\\""
2044
+ puts -nonewline $fd " \\\"$me\\\""
2045
+ puts $fd "&\""
2046
+ close $fd
2047
+ } err]} {
2048
+ error_popup "Cannot write script:\n\n$err"
2049
+ }
2050
+ }
2051
+}
2052
+
2053
proc toggle_or_diff {w x y} {
2054
global file_lists ui_index ui_other
2055
global last_clicked selected_paths
@@ -2168,6 +2216,13 @@ if {!$single_commit} {
2216
.mbar.project add command -label {Repack Database} \
2217
-command do_repack \
2218
-font font_ui
2219
+
2220
+ if {$tcl_platform(platform) eq {windows}} {
2221
+ .mbar.project add command \
2222
+ -label {Create Desktop Icon} \
2223
+ -command do_windows_shortcut \
2224
+ -font font_ui
2225
+ }
2226
}
2227
.mbar.project add command -label Quit \
2228
-command do_quit \