lib / shortcut.tclon commit git-gui: Skip nicknames when selecting author initials (88dce86)
   1# git-gui desktop icon creators
   2# Copyright (C) 2006, 2007 Shawn Pearce
   3
   4proc do_windows_shortcut {} {
   5        global argv0
   6
   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
  14                }
  15                if {[catch {
  16                                set fd [open $fn w]
  17                                puts $fd "@ECHO Entering [reponame]"
  18                                puts $fd "@ECHO Starting git-gui... please wait..."
  19                                puts $fd "@SET PATH=[file normalize [gitexec]];%PATH%"
  20                                puts $fd "@SET GIT_DIR=[file normalize [gitdir]]"
  21                                puts -nonewline $fd "@\"[info nameofexecutable]\""
  22                                puts $fd " \"[file normalize $argv0]\""
  23                                close $fd
  24                        } err]} {
  25                        error_popup "Cannot write script:\n\n$err"
  26                }
  27        }
  28}
  29
  30proc do_cygwin_shortcut {} {
  31        global argv0
  32
  33        if {[catch {
  34                set desktop [exec cygpath \
  35                        --windows \
  36                        --absolute \
  37                        --long-name \
  38                        --desktop]
  39                }]} {
  40                        set desktop .
  41        }
  42        set fn [tk_getSaveFile \
  43                -parent . \
  44                -title "[appname] ([reponame]): Create Desktop Icon" \
  45                -initialdir $desktop \
  46                -initialfile "Git [reponame].bat"]
  47        if {$fn != {}} {
  48                if {[file extension $fn] ne {.bat}} {
  49                        set fn ${fn}.bat
  50                }
  51                if {[catch {
  52                                set fd [open $fn w]
  53                                set sh [exec cygpath \
  54                                        --windows \
  55                                        --absolute \
  56                                        /bin/sh]
  57                                set me [exec cygpath \
  58                                        --unix \
  59                                        --absolute \
  60                                        $argv0]
  61                                set gd [exec cygpath \
  62                                        --unix \
  63                                        --absolute \
  64                                        [gitdir]]
  65                                set gw [exec cygpath \
  66                                        --windows \
  67                                        --absolute \
  68                                        [file dirname [gitdir]]]
  69                                regsub -all ' $me "'\\''" me
  70                                regsub -all ' $gd "'\\''" gd
  71                                puts $fd "@ECHO Entering $gw"
  72                                puts $fd "@ECHO Starting git-gui... please wait..."
  73                                puts -nonewline $fd "@\"$sh\" --login -c \""
  74                                puts -nonewline $fd "GIT_DIR='$gd'"
  75                                puts -nonewline $fd " '$me'"
  76                                puts $fd "&\""
  77                                close $fd
  78                        } err]} {
  79                        error_popup "Cannot write script:\n\n$err"
  80                }
  81        }
  82}
  83
  84proc do_macosx_app {} {
  85        global argv0 env
  86
  87        set fn [tk_getSaveFile \
  88                -parent . \
  89                -title "[appname] ([reponame]): Create Desktop Icon" \
  90                -initialdir [file join $env(HOME) Desktop] \
  91                -initialfile "Git [reponame].app"]
  92        if {$fn != {}} {
  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 [open [file join $Contents Info.plist] w]
 101                                puts $fd {<?xml version="1.0" encoding="UTF-8"?>
 102<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 103<plist version="1.0">
 104<dict>
 105        <key>CFBundleDevelopmentRegion</key>
 106        <string>English</string>
 107        <key>CFBundleExecutable</key>
 108        <string>git-gui</string>
 109        <key>CFBundleIdentifier</key>
 110        <string>org.spearce.git-gui</string>
 111        <key>CFBundleInfoDictionaryVersion</key>
 112        <string>6.0</string>
 113        <key>CFBundlePackageType</key>
 114        <string>APPL</string>
 115        <key>CFBundleSignature</key>
 116        <string>????</string>
 117        <key>CFBundleVersion</key>
 118        <string>1.0</string>
 119        <key>NSPrincipalClass</key>
 120        <string>NSApplication</string>
 121</dict>
 122</plist>}
 123                                close $fd
 124
 125                                set fd [open $exe w]
 126                                set gd [file normalize [gitdir]]
 127                                set ep [file normalize [gitexec]]
 128                                regsub -all ' $gd "'\\''" gd
 129                                regsub -all ' $ep "'\\''" ep
 130                                puts $fd "#!/bin/sh"
 131                                foreach name [array names env] {
 132                                        if {[string match GIT_* $name]} {
 133                                                regsub -all ' $env($name) "'\\''" v
 134                                                puts $fd "export $name='$v'"
 135                                        }
 136                                }
 137                                puts $fd "export PATH='$ep':\$PATH"
 138                                puts $fd "export GIT_DIR='$gd'"
 139                                puts $fd "exec [file normalize $argv0]"
 140                                close $fd
 141
 142                                file attributes $exe -permissions u+x,g+x,o+x
 143                        } err]} {
 144                        error_popup "Cannot write icon:\n\n$err"
 145                }
 146        }
 147}