Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/git-gui/lib/shortcut.tcl # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / git-gui / lib / shortcut.tcl` 154 lines ยท 4161 bytes Raw Blame History 1 # git-gui desktop icon creators 2 # Copyright (C) 2006, 2007 Shawn Pearce 3 4 proc do_windows_shortcut {} { 5 global _gitworktree 6 7 set desktop [safe_exec [list cygpath -mD]] 8 set link_file "Git [reponame].lnk" 9 set link_path [file normalize [file join $desktop $link_file]] 10 11 # on Windows, tk_getSaveFile dereferences .lnk files, so no simple 12 # filename chooser is available. Use the default or quit. 13 if {[file exists $link_path]} { 14 set answer [tk_messageBox \ 15 -type yesno \ 16 -title [mc "%s (%s): Create Desktop Icon" [appname] [reponame]] \ 17 -default yes \ 18 -message [mc "Replace existing shortcut: %s?" $link_file]] 19 if {$answer == no} { 20 return 21 } 22 } 23 24 # Use git-gui.exe if found, fall back to wish + launcher 25 set link_arguments {} 26 set link_target [safe_exec [list cygpath -m /cmd/git-gui.exe]] 27 if {![file executable $link_target]} { 28 set link_target [_which git-gui] 29 } 30 if {![file executable $link_target]} { 31 set link_target [file normalize [info nameofexecutable]] 32 set link_arguments [file normalize $::argv0] 33 } 34 set cmdLine [list $link_target $link_arguments] 35 if {[catch { 36 win32_create_lnk $link_path $cmdLine \ 37 [file normalize $_gitworktree] 38 } err]} { 39 error_popup [strcat [mc "Cannot write shortcut:"] "\n\n$err"] 40 } 41 } 42 43 proc do_cygwin_shortcut {} { 44 global argv0 _gitworktree oguilib 45 46 if {[catch { 47 set desktop [safe_exec [list cygpath \ 48 --desktop]] 49 }]} { 50 set desktop . 51 } 52 set fn [tk_getSaveFile \ 53 -parent . \ 54 -title [mc "%s (%s): Create Desktop Icon" [appname] [reponame]] \ 55 -initialdir $desktop \ 56 -initialfile "Git [reponame].lnk"] 57 if {$fn != {}} { 58 if {[file extension $fn] ne {.lnk}} { 59 set fn ${fn}.lnk 60 } 61 if {[catch { 62 set repodir [file normalize $_gitworktree] 63 set shargs {-c \ 64 "CHERE_INVOKING=1 \ 65 source /etc/profile; \ 66 git gui"} 67 safe_exec [list /bin/mkshortcut.exe \ 68 --arguments $shargs \ 69 --desc "git-gui on $repodir" \ 70 --icon $oguilib/git-gui.ico \ 71 --name $fn \ 72 --show min \ 73 --workingdir $repodir \ 74 /bin/sh.exe] 75 } err]} { 76 error_popup [strcat [mc "Cannot write shortcut:"] "\n\n$err"] 77 } 78 } 79 } 80 81 proc do_macosx_app {} { 82 global argv0 env 83 84 set fn [tk_getSaveFile \ 85 -parent . \ 86 -title [mc "%s (%s): Create Desktop Icon" [appname] [reponame]] \ 87 -initialdir [file join $env(HOME) Desktop] \ 88 -initialfile "Git [reponame].app"] 89 if {$fn != {}} { 90 if {[file extension $fn] ne {.app}} { 91 set fn ${fn}.app 92 } 93 if {[catch { 94 set Contents [file join $fn Contents] 95 set MacOS [file join $Contents MacOS] 96 set exe [file join $MacOS git-gui] 97 98 file mkdir $MacOS 99 100 set fd [safe_open_file [file join $Contents Info.plist] w] 101 puts $fd { 102 103 104 105 CFBundleDevelopmentRegion 106 English 107 CFBundleExecutable 108 git-gui 109 CFBundleIdentifier 110 org.spearce.git-gui 111 CFBundleInfoDictionaryVersion 112 6.0 113 CFBundlePackageType 114 APPL 115 CFBundleSignature 116 ???? 117 CFBundleVersion 118 1.0 119 NSPrincipalClass 120 NSApplication 121 122 } 123 close $fd 124 125 set fd [safe_open_file $exe w] 126 puts $fd "#!/bin/sh" 127 foreach name [lsort [array names env]] { 128 set value $env($name) 129 switch -- $name { 130 GIT_DIR { set value [file normalize [gitdir]] } 131 } 132 133 switch -glob -- $name { 134 SSH_* - 135 GIT_* { 136 puts $fd "if test \"z\$$name\" = z; then" 137 puts $fd " export $name=[sq $value]" 138 puts $fd "fi &&" 139 } 140 } 141 } 142 puts $fd "export PATH=[sq [file dirname $::_git]]:\$PATH &&" 143 puts $fd "cd [sq [file normalize [pwd]]] &&" 144 puts $fd "exec \\" 145 puts $fd " [sq [info nameofexecutable]] \\" 146 puts $fd " [sq [file normalize $argv0]]" 147 close $fd 148 149 file attributes $exe -permissions u+x,g+x,o+x 150 } err]} { 151 error_popup [strcat [mc "Cannot write icon:"] "\n\n$err"] 152 } 153 } 154 }