]> git.ipfire.org Git - thirdparty/git.git/blame - git-gui/lib/shortcut.tcl
Merge branch 'es/add-doc-list-short-form-of-all-in-synopsis'
[thirdparty/git.git] / git-gui / lib / shortcut.tcl
CommitLineData
f522c9b5
SP
1# git-gui desktop icon creators
2# Copyright (C) 2006, 2007 Shawn Pearce
3
4proc 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
29proc do_cygwin_shortcut {} {
b85c5a4e 30 global argv0 _gitworktree oguilib
f522c9b5
SP
31
32 if {[catch {
33 set desktop [exec cygpath \
f522c9b5
SP
34 --desktop]
35 }]} {
36 set desktop .
37 }
38 set fn [tk_getSaveFile \
39 -parent . \
a3d97afa 40 -title [mc "%s (%s): Create Desktop Icon" [appname] [reponame]] \
f522c9b5 41 -initialdir $desktop \
51a41ac4 42 -initialfile "Git [reponame].lnk"]
f522c9b5 43 if {$fn != {}} {
51a41ac4
SP
44 if {[file extension $fn] ne {.lnk}} {
45 set fn ${fn}.lnk
47282d46 46 }
f522c9b5 47 if {[catch {
b85c5a4e
ML
48 set repodir [file normalize $_gitworktree]
49 set shargs {-c \
50 "CHERE_INVOKING=1 \
51 source /etc/profile; \
52 git gui"}
53 exec /bin/mkshortcut.exe \
54 --arguments $shargs \
55 --desc "git-gui on $repodir" \
56 --icon $oguilib/git-gui.ico \
57 --name $fn \
58 --show min \
59 --workingdir $repodir \
60 /bin/sh.exe
f522c9b5 61 } err]} {
51a41ac4 62 error_popup [strcat [mc "Cannot write shortcut:"] "\n\n$err"]
f522c9b5
SP
63 }
64 }
65}
66
67proc do_macosx_app {} {
68 global argv0 env
69
70 set fn [tk_getSaveFile \
71 -parent . \
a3d97afa 72 -title [mc "%s (%s): Create Desktop Icon" [appname] [reponame]] \
f522c9b5
SP
73 -initialdir [file join $env(HOME) Desktop] \
74 -initialfile "Git [reponame].app"]
75 if {$fn != {}} {
7eafa2f1
SP
76 if {[file extension $fn] ne {.app}} {
77 set fn ${fn}.app
78 }
f522c9b5
SP
79 if {[catch {
80 set Contents [file join $fn Contents]
81 set MacOS [file join $Contents MacOS]
82 set exe [file join $MacOS git-gui]
83
84 file mkdir $MacOS
85
86 set fd [open [file join $Contents Info.plist] w]
87 puts $fd {<?xml version="1.0" encoding="UTF-8"?>
88<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
89<plist version="1.0">
90<dict>
91 <key>CFBundleDevelopmentRegion</key>
92 <string>English</string>
93 <key>CFBundleExecutable</key>
94 <string>git-gui</string>
95 <key>CFBundleIdentifier</key>
96 <string>org.spearce.git-gui</string>
97 <key>CFBundleInfoDictionaryVersion</key>
98 <string>6.0</string>
99 <key>CFBundlePackageType</key>
100 <string>APPL</string>
101 <key>CFBundleSignature</key>
102 <string>????</string>
103 <key>CFBundleVersion</key>
104 <string>1.0</string>
105 <key>NSPrincipalClass</key>
106 <string>NSApplication</string>
107</dict>
108</plist>}
109 close $fd
110
111 set fd [open $exe w]
f522c9b5 112 puts $fd "#!/bin/sh"
7eafa2f1
SP
113 foreach name [lsort [array names env]] {
114 set value $env($name)
115 switch -- $name {
116 GIT_DIR { set value [file normalize [gitdir]] }
117 }
118
119 switch -glob -- $name {
120 SSH_* -
121 GIT_* {
122 puts $fd "if test \"z\$$name\" = z; then"
123 puts $fd " export $name=[sq $value]"
124 puts $fd "fi &&"
125 }
f522c9b5
SP
126 }
127 }
7eafa2f1
SP
128 puts $fd "export PATH=[sq [file dirname $::_git]]:\$PATH &&"
129 puts $fd "cd [sq [file normalize [pwd]]] &&"
130 puts $fd "exec \\"
131 puts $fd " [sq [info nameofexecutable]] \\"
132 puts $fd " [sq [file normalize $argv0]]"
f522c9b5
SP
133 close $fd
134
135 file attributes $exe -permissions u+x,g+x,o+x
136 } err]} {
31bb1d1b 137 error_popup [strcat [mc "Cannot write icon:"] "\n\n$err"]
f522c9b5
SP
138 }
139 }
140}