git-gui: Disable native platform text selection in "lists"
[alt-git.git] / lib / shortcut.tcl
blobc36be2f3cd29b4b0426c312536dca6f697593305
1 # git-gui desktop icon creators
2 # Copyright (C) 2006, 2007 Shawn Pearce
4 proc do_windows_shortcut {} {
5 global argv0
7 set fn [tk_getSaveFile \
8 -parent . \
9 -title "[appname] ([reponame]): Create Desktop Icon" \
10 -initialfile "Git [reponame].bat"]
11 if {$fn != {}} {
12 if {[file extension $fn] ne {.bat}} {
13 set fn ${fn}.bat
15 if {[catch {
16 set ge [file normalize [file dirname $::_git]]
17 set fd [open $fn w]
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]\""
24 close $fd
25 } err]} {
26 error_popup "Cannot write script:\n\n$err"
31 proc do_cygwin_shortcut {} {
32 global argv0
34 if {[catch {
35 set desktop [exec cygpath \
36 --windows \
37 --absolute \
38 --long-name \
39 --desktop]
40 }]} {
41 set desktop .
43 set fn [tk_getSaveFile \
44 -parent . \
45 -title "[appname] ([reponame]): Create Desktop Icon" \
46 -initialdir $desktop \
47 -initialfile "Git [reponame].bat"]
48 if {$fn != {}} {
49 if {[file extension $fn] ne {.bat}} {
50 set fn ${fn}.bat
52 if {[catch {
53 set fd [open $fn w]
54 set sh [exec cygpath \
55 --windows \
56 --absolute \
57 /bin/sh.exe]
58 set me [exec cygpath \
59 --unix \
60 --absolute \
61 $argv0]
62 set gd [exec cygpath \
63 --unix \
64 --absolute \
65 [gitdir]]
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]"
71 puts $fd " &\""
72 close $fd
73 } err]} {
74 error_popup "Cannot write script:\n\n$err"
79 proc do_macosx_app {} {
80 global argv0 env
82 set fn [tk_getSaveFile \
83 -parent . \
84 -title "[appname] ([reponame]): Create Desktop Icon" \
85 -initialdir [file join $env(HOME) Desktop] \
86 -initialfile "Git [reponame].app"]
87 if {$fn != {}} {
88 if {[file extension $fn] ne {.app}} {
89 set fn ${fn}.app
91 if {[catch {
92 set Contents [file join $fn Contents]
93 set MacOS [file join $Contents MacOS]
94 set exe [file join $MacOS git-gui]
96 file mkdir $MacOS
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">
102 <dict>
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>
110 <string>6.0</string>
111 <key>CFBundlePackageType</key>
112 <string>APPL</string>
113 <key>CFBundleSignature</key>
114 <string>????</string>
115 <key>CFBundleVersion</key>
116 <string>1.0</string>
117 <key>NSPrincipalClass</key>
118 <string>NSApplication</string>
119 </dict>
120 </plist>}
121 close $fd
123 set fd [open $exe w]
124 puts $fd "#!/bin/sh"
125 foreach name [lsort [array names env]] {
126 set value $env($name)
127 switch -- $name {
128 GIT_DIR { set value [file normalize [gitdir]] }
131 switch -glob -- $name {
132 SSH_* -
133 GIT_* {
134 puts $fd "if test \"z\$$name\" = z; then"
135 puts $fd " export $name=[sq $value]"
136 puts $fd "fi &&"
140 puts $fd "export PATH=[sq [file dirname $::_git]]:\$PATH &&"
141 puts $fd "cd [sq [file normalize [pwd]]] &&"
142 puts $fd "exec \\"
143 puts $fd " [sq [info nameofexecutable]] \\"
144 puts $fd " [sq [file normalize $argv0]]"
145 close $fd
147 file attributes $exe -permissions u+x,g+x,o+x
148 } err]} {
149 error_popup "Cannot write icon:\n\n$err"