WinGit: Install Git for All Users
[git/jnareb-git.git] / share / WinGit / install.tcl
blob87cc2e0eeec2c75bcc56467606e45ebe25144126
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 # center it
53 set maxsize [wm maxsize .question]
54 set question_width 320
55 set question_height 80
56 set question_x [expr ([lindex $maxsize 0] - $question_width) / 2]
57 set question_y [expr ([lindex $maxsize 1] - $question_height) / 2]
58 wm geometry .question [format "%dx%d+%d+%d" \
59 $question_width $question_height $question_x $question_y]
60 label .question.label -text \
61 "Would you like to add a start menu item?"
62 frame .question.name
63 label .question.name.name -text "Name:"
64 global startMenuName
65 set startMenuName "Git"
66 entry .question.name.entry -textvariable startMenuName
67 pack .question.name.name .question.name.entry \
68 -fill x -expand true -side left
69 frame .question.buttons
70 set answer -1
71 button .question.buttons.yes -text Yes -default active \
72 -command {
73 set answer 1
74 destroy .question
76 bind .question <KeyPress> {
77 if {[string equal %K "Return"]} {
78 set answer 1
79 destroy .question
81 if {[string equal %K "Escape"]} {
82 set answer 0
83 destroy .question
86 button .question.buttons.no -text No -command {
87 set answer 0
88 destroy .question
90 pack .question.buttons.yes .question.buttons.no \
91 -fill x -expand true -side left
92 pack .question.label .question.name .question.buttons \
93 -fill y -expand true
94 focus -force .question
95 tkwait window .question
96 if {$answer == 1} {
97 package require registry 1.0
98 set key "HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows"
99 set key "$key\\CurrentVersion\\Explorer\\Shell Folders"
100 set programs [registry get $key "Common Programs"]
101 file mkdir $programs/$startMenuName
102 lappend destinations $programs/$startMenuName
105 # TODO: add git-gui
106 # TODO: incorporate git-cheetah
108 foreach location $destinations {
109 exec bin/create-shortcut.exe --work-dir $currentDirectory \
110 --icon-file $currentDirectory/etc/git.ico \
111 --arguments "--login -i" \
112 $currentDirectory/bin/sh.exe $location/Git\ Shell.lnk
115 file delete $currentDirectory/fileList.txt
116 file delete $currentDirectory/fileList-builtins.txt
118 tk_dialog .info "WinGit installed" \
119 "WinGit was successfully installed" info 0 OK
121 destroy .
122 exit
125 set currentDirectory [lindex $argv 0]
127 wm withdraw .
128 installGit