1 # git-gui desktop icon creators
2 # Copyright (C) 2006, 2007 Shawn Pearce
4 proc do_windows_shortcut
{} {
7 set fn
[tk_getSaveFile \
9 -title "[appname] ([reponame]): Create Desktop Icon" \
10 -initialfile "Git [reponame].bat"]
12 if {[file extension
$fn] ne
{.bat
}} {
17 puts $fd "@ECHO Entering [reponame]"
18 puts $fd "@ECHO Starting git-gui... please wait..."
19 puts $fd "@SET PATH=[file normalize [gitexec]];%PATH%"
20 puts $fd "@SET GIT_DIR=[file normalize [gitdir]]"
21 puts -nonewline $fd "@\"[info nameofexecutable]\""
22 puts $fd " \"[file normalize $argv0]\""
25 error_popup
"Cannot write script:\n\n$err"
30 proc do_cygwin_shortcut
{} {
34 set desktop
[exec cygpath
\
42 set fn
[tk_getSaveFile \
44 -title "[appname] ([reponame]): Create Desktop Icon" \
45 -initialdir $desktop \
46 -initialfile "Git [reponame].bat"]
48 if {[file extension
$fn] ne
{.bat
}} {
53 set sh
[exec cygpath
\
57 set me
[exec cygpath
\
61 set gd
[exec cygpath
\
65 set gw
[exec cygpath
\
68 [file dirname
[gitdir
]]]
69 regsub -all '
$me "'\\''" me
70 regsub -all '
$gd "'\\''" gd
71 puts $fd "@ECHO Entering $gw"
72 puts $fd "@ECHO Starting git-gui... please wait..."
73 puts -nonewline $fd "@\"$sh\" --login -c \""
74 puts -nonewline $fd "GIT_DIR='$gd'"
75 puts -nonewline $fd " '$me'"
79 error_popup
"Cannot write script:\n\n$err"
84 proc do_macosx_app
{} {
87 set fn
[tk_getSaveFile \
89 -title "[appname] ([reponame]): Create Desktop Icon" \
90 -initialdir [file join $env(HOME
) Desktop
] \
91 -initialfile "Git [reponame].app"]
94 set Contents
[file join $fn Contents
]
95 set MacOS
[file join $Contents MacOS
]
96 set exe
[file join $MacOS git-gui
]
100 set fd
[open [file join $Contents Info.plist
] w
]
101 puts $fd {<?xml version
="1.0" encoding="UTF-8"?
>
102 <!DOCTYPE plist PUBLIC
"-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
103 <plist version
="1.0">
105 <key
>CFBundleDevelopmentRegion
</key
>
106 <string>English
</string>
107 <key
>CFBundleExecutable
</key
>
108 <string>git-gui
</string>
109 <key
>CFBundleIdentifier
</key
>
110 <string>org.spearce.git-gui
</string>
111 <key
>CFBundleInfoDictionaryVersion
</key
>
113 <key
>CFBundlePackageType
</key
>
114 <string>APPL
</string>
115 <key
>CFBundleSignature
</key
>
116 <string>????
</string>
117 <key
>CFBundleVersion
</key
>
119 <key
>NSPrincipalClass
</key
>
120 <string>NSApplication
</string>
126 set gd
[file normalize
[gitdir
]]
127 set ep
[file normalize
[gitexec
]]
128 regsub -all '
$gd "'\\''" gd
129 regsub -all '
$ep "'\\''" ep
131 foreach name
[array names env
] {
132 if {[string match GIT_
* $name]} {
133 regsub -all '
$env($name) "'\\''" v
134 puts $fd "export $name='$v'"
137 puts $fd "export PATH='$ep':\$PATH"
138 puts $fd "export GIT_DIR='$gd'"
139 puts $fd "exec [file normalize $argv0]"
142 file attributes
$exe -permissions u
+x
,g
+x
,o
+x
144 error_popup
"Cannot write icon:\n\n$err"