]>
Commit | Line | Data |
---|---|---|
f522c9b5 SP |
1 | # git-gui desktop icon creators |
2 | # Copyright (C) 2006, 2007 Shawn Pearce | |
3 | ||
4 | proc do_windows_shortcut {} { | |
3748b03d | 5 | global _gitworktree |
f522c9b5 SP |
6 | set fn [tk_getSaveFile \ |
7 | -parent . \ | |
a3d97afa | 8 | -title [mc "%s (%s): Create Desktop Icon" [appname] [reponame]] \ |
51a41ac4 | 9 | -initialfile "Git [reponame].lnk"] |
f522c9b5 | 10 | if {$fn != {}} { |
51a41ac4 SP |
11 | if {[file extension $fn] ne {.lnk}} { |
12 | set fn ${fn}.lnk | |
47282d46 | 13 | } |
f110c469 PT |
14 | # Use git-gui.exe if available (ie: git-for-windows) |
15 | set cmdLine [auto_execok git-gui.exe] | |
16 | if {$cmdLine eq {}} { | |
17 | set cmdLine [list [info nameofexecutable] \ | |
18 | [file normalize $::argv0]] | |
19 | } | |
f522c9b5 | 20 | if {[catch { |
f110c469 | 21 | win32_create_lnk $fn $cmdLine \ |
a197b1e8 | 22 | [file normalize $_gitworktree] |
f522c9b5 | 23 | } err]} { |
51a41ac4 | 24 | error_popup [strcat [mc "Cannot write shortcut:"] "\n\n$err"] |
f522c9b5 SP |
25 | } |
26 | } | |
27 | } | |
28 | ||
29 | proc do_cygwin_shortcut {} { | |
3748b03d | 30 | global argv0 _gitworktree |
f522c9b5 SP |
31 | |
32 | if {[catch { | |
33 | set desktop [exec cygpath \ | |
34 | --windows \ | |
35 | --absolute \ | |
36 | --long-name \ | |
37 | --desktop] | |
38 | }]} { | |
39 | set desktop . | |
40 | } | |
41 | set fn [tk_getSaveFile \ | |
42 | -parent . \ | |
a3d97afa | 43 | -title [mc "%s (%s): Create Desktop Icon" [appname] [reponame]] \ |
f522c9b5 | 44 | -initialdir $desktop \ |
51a41ac4 | 45 | -initialfile "Git [reponame].lnk"] |
f522c9b5 | 46 | if {$fn != {}} { |
51a41ac4 SP |
47 | if {[file extension $fn] ne {.lnk}} { |
48 | set fn ${fn}.lnk | |
47282d46 | 49 | } |
f522c9b5 | 50 | if {[catch { |
f522c9b5 SP |
51 | set sh [exec cygpath \ |
52 | --windows \ | |
53 | --absolute \ | |
6a5955fa | 54 | /bin/sh.exe] |
f522c9b5 SP |
55 | set me [exec cygpath \ |
56 | --unix \ | |
57 | --absolute \ | |
58 | $argv0] | |
51a41ac4 SP |
59 | win32_create_lnk $fn [list \ |
60 | $sh -c \ | |
880fa117 | 61 | "CHERE_INVOKING=1 source /etc/profile;[sq $me] &" \ |
51a41ac4 | 62 | ] \ |
a197b1e8 | 63 | [file normalize $_gitworktree] |
f522c9b5 | 64 | } err]} { |
51a41ac4 | 65 | error_popup [strcat [mc "Cannot write shortcut:"] "\n\n$err"] |
f522c9b5 SP |
66 | } |
67 | } | |
68 | } | |
69 | ||
70 | proc do_macosx_app {} { | |
71 | global argv0 env | |
72 | ||
73 | set fn [tk_getSaveFile \ | |
74 | -parent . \ | |
a3d97afa | 75 | -title [mc "%s (%s): Create Desktop Icon" [appname] [reponame]] \ |
f522c9b5 SP |
76 | -initialdir [file join $env(HOME) Desktop] \ |
77 | -initialfile "Git [reponame].app"] | |
78 | if {$fn != {}} { | |
7eafa2f1 SP |
79 | if {[file extension $fn] ne {.app}} { |
80 | set fn ${fn}.app | |
81 | } | |
f522c9b5 SP |
82 | if {[catch { |
83 | set Contents [file join $fn Contents] | |
84 | set MacOS [file join $Contents MacOS] | |
85 | set exe [file join $MacOS git-gui] | |
86 | ||
87 | file mkdir $MacOS | |
88 | ||
89 | set fd [open [file join $Contents Info.plist] w] | |
90 | puts $fd {<?xml version="1.0" encoding="UTF-8"?> | |
91 | <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
92 | <plist version="1.0"> | |
93 | <dict> | |
94 | <key>CFBundleDevelopmentRegion</key> | |
95 | <string>English</string> | |
96 | <key>CFBundleExecutable</key> | |
97 | <string>git-gui</string> | |
98 | <key>CFBundleIdentifier</key> | |
99 | <string>org.spearce.git-gui</string> | |
100 | <key>CFBundleInfoDictionaryVersion</key> | |
101 | <string>6.0</string> | |
102 | <key>CFBundlePackageType</key> | |
103 | <string>APPL</string> | |
104 | <key>CFBundleSignature</key> | |
105 | <string>????</string> | |
106 | <key>CFBundleVersion</key> | |
107 | <string>1.0</string> | |
108 | <key>NSPrincipalClass</key> | |
109 | <string>NSApplication</string> | |
110 | </dict> | |
111 | </plist>} | |
112 | close $fd | |
113 | ||
114 | set fd [open $exe w] | |
f522c9b5 | 115 | puts $fd "#!/bin/sh" |
7eafa2f1 SP |
116 | foreach name [lsort [array names env]] { |
117 | set value $env($name) | |
118 | switch -- $name { | |
119 | GIT_DIR { set value [file normalize [gitdir]] } | |
120 | } | |
121 | ||
122 | switch -glob -- $name { | |
123 | SSH_* - | |
124 | GIT_* { | |
125 | puts $fd "if test \"z\$$name\" = z; then" | |
126 | puts $fd " export $name=[sq $value]" | |
127 | puts $fd "fi &&" | |
128 | } | |
f522c9b5 SP |
129 | } |
130 | } | |
7eafa2f1 SP |
131 | puts $fd "export PATH=[sq [file dirname $::_git]]:\$PATH &&" |
132 | puts $fd "cd [sq [file normalize [pwd]]] &&" | |
133 | puts $fd "exec \\" | |
134 | puts $fd " [sq [info nameofexecutable]] \\" | |
135 | puts $fd " [sq [file normalize $argv0]]" | |
f522c9b5 SP |
136 | close $fd |
137 | ||
138 | file attributes $exe -permissions u+x,g+x,o+x | |
139 | } err]} { | |
31bb1d1b | 140 | error_popup [strcat [mc "Cannot write icon:"] "\n\n$err"] |
f522c9b5 SP |
141 | } |
142 | } | |
143 | } |