* [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
* Re: [PATCH] git-gui: offer a list of recent repositories on startup 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 0 siblings, 1 reply; 10+ messages in thread From: Shawn O. Pearce @ 2007-10-07 23:30 UTC (permalink / raw) To: Steffen Prohaska; +Cc: git, msysgit Steffen Prohaska <prohaska@zib.de> wrote: > 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. I think that all makes a lot of sense. Three comments below about this patch in particular. > 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. I agree entirely. That "Next" button is stupid stupid stupid. What was I smoking that day? :-) I'm concerned about putting them into the Repository menu only as then the main window is competely void and users are sort of wondering what they should do next. I think we should actually do both. Put them into the menu and as push buttons on the window. > + label $w_body.space > + label $w_body.recentlabel \ > + -anchor w \ > + -text "Select Recent Repository:" This string needs to be i18n'd with [mc ...]. > + listbox $w_body.recentlist \ Please make a field in this class called say "w_recentlist" so you can use that field name instead of $w_body.recentlist. This simplifies the code if we ever have to change the actual path that the widget resides at, such as to alter the layout. > +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 > +} Why treat this as a Tcl list in a single value? Why not make it a true multi-value configuration entry in ~/.gitconfig, like how remote.$name.fetch is a multi-value entry? Does Windows allow you to put " in a path name? Because the above regex will make a list of paths that contains " in one of the entries invalid. I think you also want to have this function return back immediately if [lsearch $recent $path] >= 0 as then you don't invoke git-config to perform a no-op change in the configuration file. As you well know forking on Windows is a major cost. We shouldn't run git-config just because the user opened a recent repository. -- Shawn. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] git-gui: offer a list of recent repositories on startup 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-10 7:30 ` Shawn O. Pearce 0 siblings, 2 replies; 10+ messages in thread From: Steffen Prohaska @ 2007-10-08 14:16 UTC (permalink / raw) To: Shawn O. Pearce; +Cc: git, msysgit [-- Attachment #1: Type: text/plain, Size: 4995 bytes --] Shawn, I attached two patches. They should eventually be both squashed into one. You can also cherry pick them from work/setup-preview in 4msysgit. I'm not yet fully convinced of the performance of the second patch. It is far from optimal, although it might be sufficient. If you're satisfied with the current implementation you can squash them into a single commit; or ask me to do that. More comments below, after the summary. commit a483fdd562d6c44d68a998224e0bbb17933b624a Author: Steffen Prohaska <prohaska@zib.de> Date: Mon Oct 8 08:25:47 2007 +0200 git-gui: offer a list of recent repositories on startup 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> commit a9f083e83717eef91ba8842ece4a3ec0824126af Author: Steffen Prohaska <prohaska@zib.de> Date: Mon Oct 8 08:14:34 2007 +0200 git-gui: handle list of recent repos as multi config gui.recentrepo Instead of encoding the list of recently opened repositories in a single config line, this commit uses multiple lines of gui.recentrepo. An advantage is that the solution makes the list explicit on the git config level. This may be easier to understand if the user wants to look at the configuration. A disadvantage (of the current implementation) is that it requires more git config calls to manage the list. This could be optimized. But maybe not required because the list is only updated on opening a new repository, which is already a quite expensive operation. Signed-off-by: Steffen Prohaska <prohaska@zib.de> On Oct 8, 2007, at 1:30 AM, Shawn O. Pearce wrote: > Steffen Prohaska <prohaska@zib.de> wrote: > >> + label $w_body.space >> + label $w_body.recentlabel \ >> + -anchor w \ >> + -text "Select Recent Repository:" > > This string needs to be i18n'd with [mc ...]. changed in first patch. >> + listbox $w_body.recentlist \ > > Please make a field in this class called say "w_recentlist" > so you can use that field name instead of $w_body.recentlist. > This simplifies the code if we ever have to change the actual path > that the widget resides at, such as to alter the layout. changed in first patch. >> +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 >> +} > > Why treat this as a Tcl list in a single value? Why not make it > a true multi-value configuration entry in ~/.gitconfig, like how > remote.$name.fetch is a multi-value entry? Does Windows allow > you to put " in a path name? Because the above regex will make > a list of paths that contains " in one of the entries invalid. I don't think " is allowed. I wasn't able to create a file containing " in its path. Neither from the explorer nor on the command line. > I think you also want to have this function return back immediately > if [lsearch $recent $path] >= 0 as then you don't invoke git-config > to perform a no-op change in the configuration file. As you well > know forking on Windows is a major cost. We shouldn't run git-config > just because the user opened a recent repository. > The second patch actually runs git config several times to first remote all multi-value entries and then create them one by one. This is worse performance than before. This could be avoided by selectively removing only a single entry. 'git config' could be asked to only remove the entry that was removed from the tcl list. But 'git config' only accepts regular expression to do so. I don't know how to escape a simple string to a corresponding regular expression that matches only the string but nothing else. For my problem it would be much easier if 'git config' accepted just a plain string that must be matched exactly and not a regular expression. I see two solutions: 1) Someone explains me how to convert a string to a regular expression matching only the input string. 2) "git config" is modified to accept a simple string as its second argument. Maybe we can use implementation in the second patch for now and wait until "git config" is modified. Note, I'll not start to work on this right away because I want to stay focused on the basic functionality on Windows and, for now, do not care about performance too much. Steffen [-- Attachment #2: 0001-git-gui-offer-a-list-of-recent-repositories-on-star.patch --] [-- Type: application/octet-stream, Size: 3342 bytes --] From a483fdd562d6c44d68a998224e0bbb17933b624a Mon Sep 17 00:00:00 2001 From: Steffen Prohaska <prohaska@zib.de> Date: Mon, 8 Oct 2007 08:25:47 +0200 Subject: [PATCH] git-gui: offer a list of recent repositories on startup 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 | 49 +++++++++++++++++++++++++++++++++++++ 1 files changed, 49 insertions(+), 0 deletions(-) diff --git a/git-gui/lib/choose_repository.tcl b/git-gui/lib/choose_repository.tcl index 16bf67c..4f57572 100644 --- a/git-gui/lib/choose_repository.tcl +++ b/git-gui/lib/choose_repository.tcl @@ -41,6 +41,7 @@ field w_body ; # Widget holding the center content field w_next ; # Next button field o_cons ; # Console object (if active) field w_types ; # List of type buttons in clone +field w_recentlist ; # Listbox containing recent repositories field action new ; # What action are we going to perform? field done 0 ; # Finished picking the repository? @@ -116,9 +117,27 @@ constructor pick {} { -text [mc "Open Existing Repository"] \ -variable @action \ -value open + label $w_body.space + label $w_body.recentlabel \ + -anchor w \ + -text [mc "Select Recent Repository:"] + set w_recentlist $w_body.recentlist + listbox $w_recentlist \ + -relief flat \ + -width 50 \ + -height 10 \ + -exportselection false \ + -selectmode select + foreach p [_get_recentrepos] { + $w_recentlist insert end $p + } + bind $w_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_recentlist -anchor w -fill x pack $w_body -fill x -padx 10 -pady 10 frame $w.buttons @@ -171,6 +190,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_recentlist curselection] + set local_path [$w_recentlist get $id] + _do_open2 $this +} + method _next {} { destroy $w_body _do_$action $this @@ -893,6 +940,8 @@ method _do_open2 {} { return } + _append_recentrepos $local_path + set ::_gitdir .git set ::_prefix {} set done 1 -- 1.5.3.mingw.1.99.gdbfb3 [-- Attachment #3: 0002-git-gui-handle-list-of-recent-repos-as-multi-config.patch --] [-- Type: application/octet-stream, Size: 2535 bytes --] From a9f083e83717eef91ba8842ece4a3ec0824126af Mon Sep 17 00:00:00 2001 From: Steffen Prohaska <prohaska@zib.de> Date: Mon, 8 Oct 2007 08:14:34 +0200 Subject: [PATCH] git-gui: handle list of recent repos as multi config gui.recentrepo Instead of encoding the list of recently opened repositories in a single config line, this commit uses multiple lines of gui.recentrepo. An advantage is that the solution makes the list explicit on the git config level. This may be easier to understand if the user wants to look at the configuration. A disadvantage (of the current implementation) is that it requires more git config calls to manage the list. This could be optimized. But maybe not required because the list is only updated on opening a new repository, which is already a quite expensive operation. Signed-off-by: Steffen Prohaska <prohaska@zib.de> --- git-gui/git-gui.sh | 3 ++- git-gui/lib/choose_repository.tcl | 15 +++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/git-gui/git-gui.sh b/git-gui/git-gui.sh index 3f5927f..8e56294 100755 --- a/git-gui/git-gui.sh +++ b/git-gui/git-gui.sh @@ -206,7 +206,8 @@ proc disable_option {option} { proc is_many_config {name} { switch -glob -- $name { remote.*.fetch - - remote.*.push + remote.*.push - + gui.recentrepo {return 1} * {return 0} diff --git a/git-gui/lib/choose_repository.tcl b/git-gui/lib/choose_repository.tcl index 4f57572..9f6926c 100644 --- a/git-gui/lib/choose_repository.tcl +++ b/git-gui/lib/choose_repository.tcl @@ -192,7 +192,7 @@ method _invoke_next {} { proc _get_recentrepos {} { set recent [list] - foreach p [get_config gui.recentrepos] { + foreach p [get_config gui.recentrepo] { if {[file isdirectory [file join $p .git]]} { lappend recent $p } @@ -201,15 +201,18 @@ proc _get_recentrepos {} { } proc _append_recentrepos {path} { - set recent [get_config gui.recentrepos] - if {[lsearch $recent $path] < 0} { - lappend recent $path + set recent [get_config gui.recentrepo] + if {[lsearch $recent $path] >= 0} { + return } + lappend recent $path if {[llength $recent] > 10} { set recent [lrange $recent 1 end] } - regsub -all "\[{}\]" $recent {"} recent - git config --global gui.recentrepos $recent + git config --global --unset-all gui.recentrepo + foreach p $recent { + git config --global --add gui.recentrepo $p + } } method _open_recent {} { -- 1.5.3.mingw.1.99.gdbfb3 [-- Attachment #4: Type: text/plain, Size: 2 bytes --] ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [msysGit] Re: [PATCH] git-gui: offer a list of recent repositories on startup 2007-10-08 14:16 ` Steffen Prohaska @ 2007-10-09 11:43 ` Johannes Schindelin 2007-10-09 12:42 ` Steffen Prohaska 2007-10-10 7:30 ` Shawn O. Pearce 1 sibling, 1 reply; 10+ messages in thread From: Johannes Schindelin @ 2007-10-09 11:43 UTC (permalink / raw) To: Steffen Prohaska; +Cc: Shawn O. Pearce, git, msysgit Hi, On Mon, 8 Oct 2007, Steffen Prohaska wrote: > commit a483fdd562d6c44d68a998224e0bbb17933b624a > Author: Steffen Prohaska <prohaska@zib.de> > Date: Mon Oct 8 08:25:47 2007 +0200 > > git-gui: offer a list of recent repositories on startup May I suggest not putting this list into ~/.gitconfig, but rather ~/.gitguirc? It is not really a user-specific git configuration... Besides, the call to "git-config --global --unset-all gui.recentrepo" fails, as far as I can tell because there is not yet such an entry. Ciao, Dscho ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [msysGit] Re: [PATCH] git-gui: offer a list of recent repositories on startup 2007-10-09 11:43 ` [msysGit] " Johannes Schindelin @ 2007-10-09 12:42 ` Steffen Prohaska 2007-10-10 4:40 ` Shawn O. Pearce 0 siblings, 1 reply; 10+ messages in thread From: Steffen Prohaska @ 2007-10-09 12:42 UTC (permalink / raw) To: Johannes Schindelin, Shawn O. Pearce; +Cc: Git Mailing List, msysGit On Oct 9, 2007, at 1:43 PM, Johannes Schindelin wrote: > On Mon, 8 Oct 2007, Steffen Prohaska wrote: > >> commit a483fdd562d6c44d68a998224e0bbb17933b624a >> Author: Steffen Prohaska <prohaska@zib.de> >> Date: Mon Oct 8 08:25:47 2007 +0200 >> >> git-gui: offer a list of recent repositories on startup > > May I suggest not putting this list into ~/.gitconfig, but rather > ~/.gitguirc? It is not really a user-specific git configuration... git-gui already stores other options as global variables gui.*. (see git-gui/lib/option.tcl). I just added gui.recentrepo. The list of recent repos should go to wherever git-gui stores its options. Right now this is in ~/.gitconfig, if I understand correctly. Shawn? Steffen ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [msysGit] Re: [PATCH] git-gui: offer a list of recent repositories on startup 2007-10-09 12:42 ` Steffen Prohaska @ 2007-10-10 4:40 ` Shawn O. Pearce 2007-10-10 15:43 ` Johannes Schindelin 0 siblings, 1 reply; 10+ messages in thread From: Shawn O. Pearce @ 2007-10-10 4:40 UTC (permalink / raw) To: Steffen Prohaska; +Cc: Johannes Schindelin, Git Mailing List, msysGit Steffen Prohaska <prohaska@zib.de> wrote: > On Oct 9, 2007, at 1:43 PM, Johannes Schindelin wrote: > >On Mon, 8 Oct 2007, Steffen Prohaska wrote: > > > >>commit a483fdd562d6c44d68a998224e0bbb17933b624a > >>Author: Steffen Prohaska <prohaska@zib.de> > >>Date: Mon Oct 8 08:25:47 2007 +0200 > >> > >> git-gui: offer a list of recent repositories on startup > > > >May I suggest not putting this list into ~/.gitconfig, but rather > >~/.gitguirc? It is not really a user-specific git configuration... > > git-gui already stores other options as global variables gui.*. > (see git-gui/lib/option.tcl). I just added gui.recentrepo. The > list of recent repos should go to wherever git-gui stores its options. > > Right now this is in ~/.gitconfig, if I understand correctly. Shawn? Yes, that's correct. An item on my todo list (see todo branch in git-gui.git) is to move this into a ~/.gitguiconfig or something like that, but I was going to keep it as a git-config style file so git-config can be used to process its contents. Until that task is complete I'd rather keep all of the "gui" options in ~/.gitconfig (global) or .git/config (per-repository). When I split stuff out to git-gui specific files I'll have to migrate the entire "gui" section at once. -- Shawn. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [msysGit] Re: [PATCH] git-gui: offer a list of recent repositories on startup 2007-10-10 4:40 ` Shawn O. Pearce @ 2007-10-10 15:43 ` Johannes Schindelin 0 siblings, 0 replies; 10+ messages in thread From: Johannes Schindelin @ 2007-10-10 15:43 UTC (permalink / raw) To: Shawn O. Pearce; +Cc: Steffen Prohaska, Git Mailing List, msysGit Hi, On Wed, 10 Oct 2007, Shawn O. Pearce wrote: > Steffen Prohaska <prohaska@zib.de> wrote: > > On Oct 9, 2007, at 1:43 PM, Johannes Schindelin wrote: > > >On Mon, 8 Oct 2007, Steffen Prohaska wrote: > > > > > >>commit a483fdd562d6c44d68a998224e0bbb17933b624a > > >>Author: Steffen Prohaska <prohaska@zib.de> > > >>Date: Mon Oct 8 08:25:47 2007 +0200 > > >> > > >> git-gui: offer a list of recent repositories on startup > > > > > >May I suggest not putting this list into ~/.gitconfig, but rather > > >~/.gitguirc? It is not really a user-specific git configuration... > > > > git-gui already stores other options as global variables gui.*. > > (see git-gui/lib/option.tcl). I just added gui.recentrepo. The > > list of recent repos should go to wherever git-gui stores its options. > > > > Right now this is in ~/.gitconfig, if I understand correctly. Shawn? > > Yes, that's correct. > > An item on my todo list (see todo branch in git-gui.git) is to move > this into a ~/.gitguiconfig or something like that, but I was going > to keep it as a git-config style file so git-config can be used to > process its contents. > > Until that task is complete I'd rather keep all of the "gui" options > in ~/.gitconfig (global) or .git/config (per-repository). When I > split stuff out to git-gui specific files I'll have to migrate the > entire "gui" section at once. FWIW I was only concerned about the recent repos, since strictly speaking, they are not options to git-gui... But I do not care deeply. Ciao, Dscho ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] git-gui: offer a list of recent repositories on startup 2007-10-08 14:16 ` Steffen Prohaska 2007-10-09 11:43 ` [msysGit] " Johannes Schindelin @ 2007-10-10 7:30 ` Shawn O. Pearce 2007-10-10 8:13 ` [msysGit] " Steffen Prohaska 1 sibling, 1 reply; 10+ messages in thread From: Shawn O. Pearce @ 2007-10-10 7:30 UTC (permalink / raw) To: Steffen Prohaska; +Cc: git, msysgit Steffen Prohaska <prohaska@zib.de> wrote: > Shawn, > I attached two patches. They should eventually be both squashed into > one. Thanks. I'm applying the patch below over both of yours, and then squashing them all together and keeping you as the author. I did not like how the listbox looked (or worked!) on Mac OS X. Clicking on the item was at first a very non-obvious action, and then when I did do it I was very shocked to see the repository open immediately. My brain knew the action was wired to the selection event (I obviously read the two patches before applying them), but it didn't expect that behavior. Clearly the wrong UI model. The patch below uses a text widget instead and renders each of the repositories as a blue underlined link. Users will generally assume that clicking on such links will take them immediately to that repository (much as it would take them to another webpage if this was a web browser). The "Open Recent Repositories" is not even shown in the UI if there aren't any to offer to the user. Showing them this area just looks silly if they haven't opened or cloned anything yet. We now add freshly created or cloned repositories to the list of recently opened repositories. These are just as fair game for being recently accessed as any others. Perhaps even more so as users may wonder where they cloned that repository to the last time they started git-gui. We always store the absolute path of a repository into the config. This avoids the mess of opening a repository twice using say a relative path entered into the text entry field and then opening it later via a file browser, only to find out you now have the same repository in the recent list twice. I fixed the --unset-all bug and also avoided the --unset-all/--add loop you were using. We convert the value into a "safe" expression and then try to match on it. --- diff --git a/lib/choose_repository.tcl b/lib/choose_repository.tcl index 4deb1ec..bdfdbae 100644 --- a/lib/choose_repository.tcl +++ b/lib/choose_repository.tcl @@ -80,27 +80,35 @@ constructor pick {} { -text [mc "Open Existing Repository"] \ -variable @action \ -value open - label $w_body.space - label $w_body.recentlabel \ - -anchor w \ - -text [mc "Select Recent Repository:"] - set w_recentlist $w_body.recentlist - listbox $w_recentlist \ - -relief flat \ - -width 50 \ - -height 10 \ - -exportselection false \ - -selectmode select - foreach p [_get_recentrepos] { - $w_recentlist insert end $p - } - bind $w_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_recentlist -anchor w -fill x + + set recent [_get_recentrepos] + if {[llength $recent] > 0} { + label $w_body.space + label $w_body.recentlabel \ + -anchor w \ + -text [mc "Open Recent Repository:"] + set w_recentlist $w_body.recentlist + text $w_recentlist \ + -cursor $::cursor_ptr \ + -wrap none \ + -width 50 \ + -height 10 + $w_recentlist tag conf link \ + -foreground blue \ + -underline 1 + foreach p $recent { + $w_recentlist insert end $p link + $w_recentlist insert end "\n" + } + $w_recentlist conf -state disabled + $w_recentlist tag bind link <1> [cb _open_recent %x,%y] + pack $w_body.space -anchor w -fill x + pack $w_body.recentlabel -anchor w -fill x + pack $w_recentlist -anchor w -fill x + } pack $w_body -fill x -padx 10 -pady 10 frame $w.buttons @@ -164,23 +172,26 @@ proc _get_recentrepos {} { } proc _append_recentrepos {path} { + set path [file normalize $path] set recent [get_config gui.recentrepo] if {[lsearch $recent $path] >= 0} { return } + lappend recent $path - if {[llength $recent] > 10} { + git config --global --add gui.recentrepo $path + + while {[llength $recent] > 10} { + set p [lindex $recent 0] set recent [lrange $recent 1 end] - } - git config --global --unset-all gui.recentrepo - foreach p $recent { - git config --global --add gui.recentrepo $p + regsub -all -- {([()\[\]{}\.^$+*?\\])} $p {\\\1} p + git config --global --unset gui.recentrepo "^$p\$" } } -method _open_recent {} { - set id [$w_recentlist curselection] - set local_path [$w_recentlist get $id] +method _open_recent {xy} { + set id [lindex [split [$w_recentlist index @$xy] .] 0] + set local_path [$w_recentlist get $id.0 $id.end] _do_open2 $this } @@ -224,6 +235,7 @@ method _git_init {} { return 0 } + _append_recentrepos [pwd] set ::_gitdir .git set ::_prefix {} return 1 @@ -906,8 +918,7 @@ method _do_open2 {} { return } - _append_recentrepos $local_path - + _append_recentrepos [pwd] set ::_gitdir .git set ::_prefix {} set done 1 -- Shawn. ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [msysGit] Re: [PATCH] git-gui: offer a list of recent repositories on startup 2007-10-10 7:30 ` Shawn O. Pearce @ 2007-10-10 8:13 ` Steffen Prohaska 2007-10-10 8:19 ` Shawn O. Pearce 0 siblings, 1 reply; 10+ messages in thread From: Steffen Prohaska @ 2007-10-10 8:13 UTC (permalink / raw) To: Shawn O. Pearce; +Cc: git, msysgit Shawn, On Oct 10, 2007, at 9:30 AM, Shawn O. Pearce wrote: > > Steffen Prohaska <prohaska@zib.de> wrote: >> Shawn, >> I attached two patches. They should eventually be both squashed into >> one. > > Thanks. I'm applying the patch below over both of yours, and > then squashing them all together and keeping you as the author. > > I did not like how the listbox looked (or worked!) on Mac OS X. > Clicking on the item was at first a very non-obvious action, and > then when I did do it I was very shocked to see the repository open > immediately. My brain knew the action was wired to the selection > event (I obviously read the two patches before applying them), > but it didn't expect that behavior. Clearly the wrong UI model. > > The patch below uses a text widget instead and renders each of > the repositories as a blue underlined link. Users will generally > assume that clicking on such links will take them immediately to > that repository (much as it would take them to another webpage if > this was a web browser) This is similar to what I had in mind, but was lacking tk knowledge to implement it. > The "Open Recent Repositories" is not even shown in the UI if there > aren't any to offer to the user. Showing them this area just looks > silly if they haven't opened or cloned anything yet. > > We now add freshly created or cloned repositories to the list of > recently opened repositories. These are just as fair game for > being recently accessed as any others. Perhaps even more so as > users may wonder where they cloned that repository to the last time > they started git-gui. > > We always store the absolute path of a repository into the config. > This avoids the mess of opening a repository twice using say a > relative path entered into the text entry field and then opening > it later via a file browser, only to find out you now have the same > repository in the recent list twice. > > I fixed the --unset-all bug and also avoided the --unset-all/--add > loop you were using. We convert the value into a "safe" expression > and then try to match on it. That all sound very reasonable to me. I haven't applied your patch but only read through it. Looks good to me. Thanks, Steffen ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [msysGit] Re: [PATCH] git-gui: offer a list of recent repositories on startup 2007-10-10 8:13 ` [msysGit] " Steffen Prohaska @ 2007-10-10 8:19 ` Shawn O. Pearce 0 siblings, 0 replies; 10+ messages in thread From: Shawn O. Pearce @ 2007-10-10 8:19 UTC (permalink / raw) To: Steffen Prohaska; +Cc: git, msysgit Steffen Prohaska <prohaska@zib.de> wrote: > On Oct 10, 2007, at 9:30 AM, Shawn O. Pearce wrote: > > > >The patch below uses a text widget instead and renders each of > >the repositories as a blue underlined link. > > This is similar to what I had in mind, but was lacking tk knowledge > to implement it. Heh. Tk makes some things easy, assuming you know what you are doing. It makes some other things damn near impossible, even if you do know all of Tk and its internals too. Anyway, your patches were a really good start on this and it saved me a lot of time to just tweak what you already had. So I really appreciate you taking the time to work on the first two iterations of this feature. > I haven't applied your patch but only read through it. Looks good > to me. The combined result is now in my `pu` branch on repo.or.cz. Remember that I freely rebase that branch and any topic in it, so I might wind up rebasing this topic before I finally merge it to master. I have given the change some light testing tonight but want to beat on it more and also fix the radio button issue you pointed out before I merge this series of improvements into master. -- Shawn. ^ permalink raw reply [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).