WinGit: clean up a few temporary files after installing
[msysgit.git] / share / WinGit / install.tcl
blob6eefeb26ffef601198f5be42d2d05cad7ad7e965
1 #!/bin/sh
2 # Tcl ignores the next line -*- tcl -*- \
3 exec wish "$0" -- "$@"
5 # Copyright (C) 2007 Johannes E. Schindelin. All rights reserved.
6 # This program is free software; it may be used, copied, modified
7 # and distributed under the terms of the GNU General Public Licence,
8 # either version 2, or (at your option) any later version.
10 proc installGit {} {
11 global currentDirectory answer env
13 toplevel .listbox
14 text .listbox.list -yscrollcommand ".listbox.scroll set"
15 scrollbar .listbox.scroll -command ".listbox.list yview"
16 pack .listbox.scroll -side right -fill y
17 pack .listbox.list -expand yes -fill both
18 raise .listbox
20 set list [open "$currentDirectory/fileList-builtins.txt" r]
21 while {[gets $list line] >= 0} {
22 .listbox.list insert end "copying builtin: $line\n"
23 .listbox.list yview moveto 1
24 update
25 file copy -force $currentDirectory/bin/git.exe \
26 $currentDirectory/$line
28 close $list
30 #destroy .listbox
32 # Create shortcuts
34 set destinations [list]
35 set answer [tk_dialog .question "Desktop Icon" \
36 "Would you like to add a Git icon to the Desktop?" \
37 question 0 Yes No]
38 if {$answer == 0} {
39 lappend destinations $env(USERPROFILE)/Desktop
42 set answer [tk_dialog .question "Quick Launch" \
43 "Would you like to add a Quick Launch icon?" \
44 question 0 Yes No]
45 if {$answer == 0} {
46 set appdata [regsub -all "\\\\" $env(APPDATA) "/"]
47 lappend destinations \
48 "$appdata/Microsoft/Internet Explorer/Quick Launch"
50 toplevel .question
51 wm title .question "Start Menu item"
52 label .question.label -text \
53 "Would you like to add a start menu item?"
54 frame .question.name
55 label .question.name.name -text "Name:"
56 global startMenuName
57 set startMenuName "Git"
58 entry .question.name.entry -textvariable startMenuName
59 pack .question.name.name .question.name.entry \
60 -fill x -expand true -side left
61 frame .question.buttons
62 set answer -1
63 button .question.buttons.yes -text Yes -default active \
64 -command {
65 set answer 1
66 destroy .question
68 bind .question <KeyPress> {
69 if {[string equal %K "Return"]} {
70 set answer 1
71 destroy .question
73 if {[string equal %K "Escape"]} {
74 set answer 0
75 destroy .question
78 button .question.buttons.no -text No -command {
79 set answer 0
80 destroy .question
82 pack .question.buttons.yes .question.buttons.no \
83 -fill x -expand true -side left
84 pack .question.label .question.name .question.buttons \
85 -fill y -expand true
86 focus -force .question
87 tkwait window .question
88 if {$answer == 1} {
89 package require registry 1.0
90 set key "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows"
91 set key "$key\\CurrentVersion\\Explorer\\Shell Folders"
92 set programs [registry get $key "Programs"]
93 file mkdir $programs/$startMenuName
94 lappend destinations $programs/$startMenuName
97 # TODO: add git-gui
98 # TODO: incorporate git-cheetah
100 foreach location $destinations {
101 exec bin/create-shortcut.exe --work-dir $currentDirectory \
102 --icon-file $currentDirectory/git.ico \
103 --arguments "--login -i" \
104 --description "Git for MSys" \
105 $currentDirectory/bin/sh.exe $location/Git.lnk
108 file delete $currentDirectory/fileList.txt
109 file delete $currentDirectory/fileList-builtins.txt
110 file delete $currentDirectory/git.ico
112 tk_dialog .info "WinGit installed" \
113 "WinGit was successfully installed" info 0 OK
115 destroy .
116 exit
119 set currentDirectory [lindex $argv 0]
121 wm withdraw .
122 installGit