Shawn O. Pearce | f522c9b | 2007-05-07 23:35:48 -0400 | [diff] [blame] | 1 | # git-gui desktop icon creators |
| 2 | # Copyright (C) 2006, 2007 Shawn Pearce |
| 3 | |
| 4 | proc do_windows_shortcut {} { |
Giuseppe Bilotta | 3748b03 | 2010-01-23 11:03:38 +0100 | [diff] [blame] | 5 | global _gitworktree |
Shawn O. Pearce | f522c9b | 2007-05-07 23:35:48 -0400 | [diff] [blame] | 6 | set fn [tk_getSaveFile \ |
| 7 | -parent . \ |
Vasco Almeida | a3d97af | 2016-05-08 10:52:57 +0000 | [diff] [blame] | 8 | -title [mc "%s (%s): Create Desktop Icon" [appname] [reponame]] \ |
Shawn O. Pearce | 51a41ac | 2007-10-12 16:11:35 -0400 | [diff] [blame] | 9 | -initialfile "Git [reponame].lnk"] |
Shawn O. Pearce | f522c9b | 2007-05-07 23:35:48 -0400 | [diff] [blame] | 10 | if {$fn != {}} { |
Shawn O. Pearce | 51a41ac | 2007-10-12 16:11:35 -0400 | [diff] [blame] | 11 | if {[file extension $fn] ne {.lnk}} { |
| 12 | set fn ${fn}.lnk |
Shawn O. Pearce | 47282d4 | 2007-07-05 18:39:40 -0400 | [diff] [blame] | 13 | } |
Pat Thoyts | f110c46 | 2016-10-02 22:19:47 +0100 | [diff] [blame] | 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 | } |
Shawn O. Pearce | f522c9b | 2007-05-07 23:35:48 -0400 | [diff] [blame] | 20 | if {[catch { |
Pat Thoyts | f110c46 | 2016-10-02 22:19:47 +0100 | [diff] [blame] | 21 | win32_create_lnk $fn $cmdLine \ |
Heiko Voigt | a197b1e | 2010-02-27 21:45:51 +0100 | [diff] [blame] | 22 | [file normalize $_gitworktree] |
Shawn O. Pearce | f522c9b | 2007-05-07 23:35:48 -0400 | [diff] [blame] | 23 | } err]} { |
Shawn O. Pearce | 51a41ac | 2007-10-12 16:11:35 -0400 | [diff] [blame] | 24 | error_popup [strcat [mc "Cannot write shortcut:"] "\n\n$err"] |
Shawn O. Pearce | f522c9b | 2007-05-07 23:35:48 -0400 | [diff] [blame] | 25 | } |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | proc do_cygwin_shortcut {} { |
Giuseppe Bilotta | 3748b03 | 2010-01-23 11:03:38 +0100 | [diff] [blame] | 30 | global argv0 _gitworktree |
Shawn O. Pearce | f522c9b | 2007-05-07 23:35:48 -0400 | [diff] [blame] | 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 . \ |
Vasco Almeida | a3d97af | 2016-05-08 10:52:57 +0000 | [diff] [blame] | 43 | -title [mc "%s (%s): Create Desktop Icon" [appname] [reponame]] \ |
Shawn O. Pearce | f522c9b | 2007-05-07 23:35:48 -0400 | [diff] [blame] | 44 | -initialdir $desktop \ |
Shawn O. Pearce | 51a41ac | 2007-10-12 16:11:35 -0400 | [diff] [blame] | 45 | -initialfile "Git [reponame].lnk"] |
Shawn O. Pearce | f522c9b | 2007-05-07 23:35:48 -0400 | [diff] [blame] | 46 | if {$fn != {}} { |
Shawn O. Pearce | 51a41ac | 2007-10-12 16:11:35 -0400 | [diff] [blame] | 47 | if {[file extension $fn] ne {.lnk}} { |
| 48 | set fn ${fn}.lnk |
Shawn O. Pearce | 47282d4 | 2007-07-05 18:39:40 -0400 | [diff] [blame] | 49 | } |
Shawn O. Pearce | f522c9b | 2007-05-07 23:35:48 -0400 | [diff] [blame] | 50 | if {[catch { |
Shawn O. Pearce | f522c9b | 2007-05-07 23:35:48 -0400 | [diff] [blame] | 51 | set sh [exec cygpath \ |
| 52 | --windows \ |
| 53 | --absolute \ |
Shawn O. Pearce | 6a5955f | 2007-07-09 11:09:27 -0400 | [diff] [blame] | 54 | /bin/sh.exe] |
Shawn O. Pearce | f522c9b | 2007-05-07 23:35:48 -0400 | [diff] [blame] | 55 | set me [exec cygpath \ |
| 56 | --unix \ |
| 57 | --absolute \ |
| 58 | $argv0] |
Shawn O. Pearce | 51a41ac | 2007-10-12 16:11:35 -0400 | [diff] [blame] | 59 | win32_create_lnk $fn [list \ |
| 60 | $sh -c \ |
Phil Lawrence | 880fa11 | 2009-03-09 17:09:49 -0500 | [diff] [blame] | 61 | "CHERE_INVOKING=1 source /etc/profile;[sq $me] &" \ |
Shawn O. Pearce | 51a41ac | 2007-10-12 16:11:35 -0400 | [diff] [blame] | 62 | ] \ |
Heiko Voigt | a197b1e | 2010-02-27 21:45:51 +0100 | [diff] [blame] | 63 | [file normalize $_gitworktree] |
Shawn O. Pearce | f522c9b | 2007-05-07 23:35:48 -0400 | [diff] [blame] | 64 | } err]} { |
Shawn O. Pearce | 51a41ac | 2007-10-12 16:11:35 -0400 | [diff] [blame] | 65 | error_popup [strcat [mc "Cannot write shortcut:"] "\n\n$err"] |
Shawn O. Pearce | f522c9b | 2007-05-07 23:35:48 -0400 | [diff] [blame] | 66 | } |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | proc do_macosx_app {} { |
| 71 | global argv0 env |
| 72 | |
| 73 | set fn [tk_getSaveFile \ |
| 74 | -parent . \ |
Vasco Almeida | a3d97af | 2016-05-08 10:52:57 +0000 | [diff] [blame] | 75 | -title [mc "%s (%s): Create Desktop Icon" [appname] [reponame]] \ |
Shawn O. Pearce | f522c9b | 2007-05-07 23:35:48 -0400 | [diff] [blame] | 76 | -initialdir [file join $env(HOME) Desktop] \ |
| 77 | -initialfile "Git [reponame].app"] |
| 78 | if {$fn != {}} { |
Shawn O. Pearce | 7eafa2f | 2007-07-09 03:28:41 -0400 | [diff] [blame] | 79 | if {[file extension $fn] ne {.app}} { |
| 80 | set fn ${fn}.app |
| 81 | } |
Shawn O. Pearce | f522c9b | 2007-05-07 23:35:48 -0400 | [diff] [blame] | 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] |
Shawn O. Pearce | f522c9b | 2007-05-07 23:35:48 -0400 | [diff] [blame] | 115 | puts $fd "#!/bin/sh" |
Shawn O. Pearce | 7eafa2f | 2007-07-09 03:28:41 -0400 | [diff] [blame] | 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 | } |
Shawn O. Pearce | f522c9b | 2007-05-07 23:35:48 -0400 | [diff] [blame] | 129 | } |
| 130 | } |
Shawn O. Pearce | 7eafa2f | 2007-07-09 03:28:41 -0400 | [diff] [blame] | 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]]" |
Shawn O. Pearce | f522c9b | 2007-05-07 23:35:48 -0400 | [diff] [blame] | 136 | close $fd |
| 137 | |
| 138 | file attributes $exe -permissions u+x,g+x,o+x |
| 139 | } err]} { |
Shawn O. Pearce | 31bb1d1 | 2007-09-14 01:50:09 -0400 | [diff] [blame] | 140 | error_popup [strcat [mc "Cannot write icon:"] "\n\n$err"] |
Shawn O. Pearce | f522c9b | 2007-05-07 23:35:48 -0400 | [diff] [blame] | 141 | } |
| 142 | } |
| 143 | } |