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}} {
16 set ge [file normalize [file dirname $::_git]]
18 puts $fd "@ECHO Entering [reponame]"
19 puts $fd "@ECHO Starting git-gui... please wait..."
20 puts $fd "@SET PATH=$ge;%PATH%"
21 puts $fd "@SET GIT_DIR=[file normalize [gitdir]]"
22 puts -nonewline $fd "@\"[info nameofexecutable]\""
23 puts $fd " \"[file normalize $argv0]\""
26 error_popup "Cannot write script:\n\n$err"
31 proc do_cygwin_shortcut {} {
35 set desktop [exec cygpath \
43 set fn [tk_getSaveFile \
45 -title "[appname] ([reponame]): Create Desktop Icon" \
46 -initialdir $desktop \
47 -initialfile "Git [reponame].bat"]
49 if {[file extension $fn] ne {.bat}} {
54 set sh [exec cygpath \
58 set me [exec cygpath \
62 set gd [exec cygpath \
66 puts $fd "@ECHO Entering [reponame]"
67 puts $fd "@ECHO Starting git-gui... please wait..."
68 puts -nonewline $fd "@\"$sh\" --login -c \""
69 puts -nonewline $fd "GIT_DIR=[sq $gd]"
70 puts -nonewline $fd " [sq $me]"
74 error_popup "Cannot write script:\n\n$err"
79 proc do_macosx_app {} {
82 set fn [tk_getSaveFile \
84 -title "[appname] ([reponame]): Create Desktop Icon" \
85 -initialdir [file join $env(HOME) Desktop] \
86 -initialfile "Git [reponame].app"]
88 if {[file extension $fn] ne {.app}} {
92 set Contents [file join $fn Contents]
93 set MacOS [file join $Contents MacOS]
94 set exe [file join $MacOS git-gui]
98 set fd [open [file join $Contents Info.plist] w]
99 puts $fd {<?xml version="1.0" encoding="UTF-8"?>
100 <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
101 <plist version="1.0">
103 <key>CFBundleDevelopmentRegion</key>
104 <string>English</string>
105 <key>CFBundleExecutable</key>
106 <string>git-gui</string>
107 <key>CFBundleIdentifier</key>
108 <string>org.spearce.git-gui</string>
109 <key>CFBundleInfoDictionaryVersion</key>
111 <key>CFBundlePackageType</key>
112 <string>APPL</string>
113 <key>CFBundleSignature</key>
114 <string>????</string>
115 <key>CFBundleVersion</key>
117 <key>NSPrincipalClass</key>
118 <string>NSApplication</string>
125 foreach name [lsort [array names env]] {
126 set value $env($name)
128 GIT_DIR { set value [file normalize [gitdir]] }
131 switch -glob -- $name {
134 puts $fd "if test \"z\$$name\" = z; then"
135 puts $fd " export $name=[sq $value]"
140 puts $fd "export PATH=[sq [file dirname $::_git]]:\$PATH &&"
141 puts $fd "cd [sq [file normalize [pwd]]] &&"
143 puts $fd " [sq [info nameofexecutable]] \\"
144 puts $fd " [sq [file normalize $argv0]]"
147 file attributes $exe -permissions u+x,g+x,o+x
149 error_popup "Cannot write icon:\n\n$err"