@matheusbsbs / matheus-bagliano / commits / 9c1b1b1e45
Fork 0

git-gui: Offer repository management features in menu bar

When we show the repository chooser as the primary toplevel (".") we now offer the major choices not just on the window as hyperlinks but they also now are shown in the Repository menu, including the recent repository list. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Shawn O. Pearce committed Oct 12, 2007 at 01:56 UTC 9c1b1b1e45926e6eed57f5bfbb5c3f69e063e5ab
1 file changed +49 -6
lib/choose_repository.tcl
+49 -6
@@ -30,14 +30,11 @@ constructor pick {} {
30 menu $w.mbar -tearoff 0
31 $top configure -menu $w.mbar
32
33 + set m_repo $w.mbar.repository
34 $w.mbar add cascade \
35 -label [mc Repository] \
35 - -menu $w.mbar.repository
36 - menu $w.mbar.repository
37 - $w.mbar.repository add command \
38 - -label [mc Quit] \
39 - -command exit \
40 - -accelerator $M1T-Q
36 + -menu $m_repo
37 + menu $m_repo
38
39 if {[is_MacOSX]} {
40 $w.mbar add cascade -label [mc Apple] -menu .mbar.apple
@@ -60,6 +57,7 @@ constructor pick {} {
57 } else {
58 wm geometry $top "+[winfo rootx .]+[winfo rooty .]"
59 bind $top <Key-Escape> [list destroy $top]
60 + set m_repo {}
61 }
62
63 pack [git_logo $w.git_logo] -side left -fill y -padx 10 -pady 10
@@ -81,19 +79,44 @@ constructor pick {} {
79 $opts tag bind link_new <1> [cb _next new]
80 $opts insert end [mc "Create New Repository"] link_new
81 $opts insert end "\n"
82 + if {$m_repo ne {}} {
83 + $m_repo add command \
84 + -command [cb _next new] \
85 + -accelerator $M1T-N \
86 + -label [mc "New..."]
87 + }
88
89 $opts tag conf link_clone -foreground blue -underline 1
90 $opts tag bind link_clone <1> [cb _next clone]
91 $opts insert end [mc "Clone Existing Repository"] link_clone
92 $opts insert end "\n"
93 + if {$m_repo ne {}} {
94 + $m_repo add command \
95 + -command [cb _next clone] \
96 + -accelerator $M1T-C \
97 + -label [mc "Clone..."]
98 + }
99
100 $opts tag conf link_open -foreground blue -underline 1
101 $opts tag bind link_open <1> [cb _next open]
102 $opts insert end [mc "Open Existing Repository"] link_open
103 $opts insert end "\n"
104 + if {$m_repo ne {}} {
105 + $m_repo add command \
106 + -command [cb _next open] \
107 + -accelerator $M1T-O \
108 + -label [mc "Open..."]
109 + }
110
111 set sorted_recent [_get_recentrepos]
112 if {[llength $sorted_recent] > 0} {
113 + if {$m_repo ne {}} {
114 + $m_repo add separator
115 + $m_repo add command \
116 + -state disabled \
117 + -label [mc "Recent Repositories"]
118 + }
119 +
120 label $w_body.space
121 label $w_body.recentlabel \
122 -anchor w \
@@ -112,12 +135,19 @@ constructor pick {} {
135 set home "[file normalize $::env(HOME)][file separator]"
136 set hlen [string length $home]
137 foreach p $sorted_recent {
138 + set path $p
139 if {[string equal -length $hlen $home $p]} {
140 set p "~[file separator][string range $p $hlen end]"
141 }
142 regsub -all "\n" $p "\\n" p
143 $w_recentlist insert end $p link
144 $w_recentlist insert end "\n"
145 +
146 + if {$m_repo ne {}} {
147 + $m_repo add command \
148 + -command [cb _open_recent_path $path] \
149 + -label " $p"
150 + }
151 }
152 $w_recentlist conf -state disabled
153 $w_recentlist tag bind link <1> [cb _open_recent %x,%y]
@@ -136,6 +166,14 @@ constructor pick {} {
166 pack $w_quit -side right -padx 5
167 pack $w.buttons -side bottom -fill x -padx 10 -pady 10
168
169 + if {$m_repo ne {}} {
170 + $m_repo add separator
171 + $m_repo add command \
172 + -label [mc Quit] \
173 + -command exit \
174 + -accelerator $M1T-Q
175 + }
176 +
177 bind $top <Return> [cb _invoke_next]
178 bind $top <Visibility> "
179 [cb _center]
@@ -217,6 +255,11 @@ method _open_recent {xy} {
255 _do_open2 $this
256 }
257
258 +method _open_recent_path {p} {
259 + set local_path $p
260 + _do_open2 $this
261 +}
262 +
263 method _next {action} {
264 destroy $w_body
265 if {![winfo exists $w_next]} {