git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] git-gui: offer a list of recent repositories on startup
@ 2007-10-07 21:28 Steffen Prohaska
  2007-10-07 23:30 ` Shawn O. Pearce
  0 siblings, 1 reply; 10+ messages in thread
From: Steffen Prohaska @ 2007-10-07 21:28 UTC (permalink / raw)
  To: spearce; +Cc: git, msysgit, Steffen Prohaska

If git-gui is started outside a work tree the repository
chooser will offer a list of recently opend repositories.
Clicking on an entry directly opens the repository.

The list of recently opened repositories is stored in the
config as gui.recentrepos. If the list grows beyond 10
entries it will be truncated.

Note, only repositories that are opened through the
repository chooser will get added to the recent list.
Repositories opened from the shell will not yet be added.

Signed-off-by: Steffen Prohaska <prohaska@zib.de>
---
 git-gui/lib/choose_repository.tcl |   47 +++++++++++++++++++++++++++++++++++++
 1 files changed, 47 insertions(+), 0 deletions(-)


The commit is also available on branch
steffen/git-gui-openrecent in 4msysgit.


Shawn,
I'd suggest to reduce the number of clicks needed to open or
clone an existing directory that is not in the list of
recent repositories. First choosing from the radiobuttons
and then clicking next is one click to much. There are no
options to combine. Choosing from the list should
immediately trigger the action.

We could either put 'Create/Clone/Open New Repository' into
the Repository menu and only present the recent repository
list. Or we could offer push buttons for the other actions.

	Steffen


diff --git a/git-gui/lib/choose_repository.tcl b/git-gui/lib/choose_repository.tcl
index 16bf67c..bfc8780 100644
--- a/git-gui/lib/choose_repository.tcl
+++ b/git-gui/lib/choose_repository.tcl
@@ -116,9 +116,26 @@ constructor pick {} {
 		-text [mc "Open Existing Repository"] \
 		-variable @action \
 		-value open
+	label $w_body.space
+	label $w_body.recentlabel \
+		-anchor w \
+		-text "Select Recent Repository:"
+	listbox $w_body.recentlist \
+		-relief flat \
+		-width 50 \
+		-height 10 \
+		-exportselection false \
+		-selectmode select
+	foreach p [_get_recentrepos] {
+		$w_body.recentlist insert end $p
+	}
+	bind $w_body.recentlist <<ListboxSelect>> [cb _open_recent]
 	pack $w_body.new -anchor w -fill x
 	pack $w_body.clone -anchor w -fill x
 	pack $w_body.open -anchor w -fill x
+	pack $w_body.space -anchor w -fill x
+	pack $w_body.recentlabel -anchor w -fill x
+	pack $w_body.recentlist -anchor w -fill x
 	pack $w_body -fill x -padx 10 -pady 10
 
 	frame $w.buttons
@@ -171,6 +188,34 @@ method _invoke_next {} {
 	}
 }
 
+proc _get_recentrepos {} {
+	set recent [list]
+	foreach p [get_config gui.recentrepos] {
+		if {[file isdirectory [file join $p .git]]} {
+			lappend recent $p
+		}
+	}
+	return [lsort $recent]
+}
+
+proc _append_recentrepos {path} {
+	set recent [get_config gui.recentrepos]
+	if {[lsearch $recent $path] < 0} {
+		lappend recent $path
+	}
+	if {[llength $recent] > 10} {
+		set recent [lrange $recent 1 end]
+	}
+	regsub -all "\[{}\]" $recent {"} recent
+	git config --global gui.recentrepos $recent
+}
+
+method _open_recent {} {
+	set id [$w_body.recentlist curselection]
+	set local_path [$w_body.recentlist get $id]
+	_do_open2 $this
+}
+
 method _next {} {
 	destroy $w_body
 	_do_$action $this
@@ -893,6 +938,8 @@ method _do_open2 {} {
 		return
 	}
 
+	_append_recentrepos $local_path
+
 	set ::_gitdir .git
 	set ::_prefix {}
 	set done 1
-- 
1.5.3.mingw.1.110.gef4c8

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2007-10-10 15:44 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-07 21:28 [PATCH] git-gui: offer a list of recent repositories on startup Steffen Prohaska
2007-10-07 23:30 ` Shawn O. Pearce
2007-10-08 14:16   ` Steffen Prohaska
2007-10-09 11:43     ` [msysGit] " Johannes Schindelin
2007-10-09 12:42       ` Steffen Prohaska
2007-10-10  4:40         ` Shawn O. Pearce
2007-10-10 15:43           ` Johannes Schindelin
2007-10-10  7:30     ` Shawn O. Pearce
2007-10-10  8:13       ` [msysGit] " Steffen Prohaska
2007-10-10  8:19         ` Shawn O. Pearce

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).