Skip to content

Commit

Permalink
Merge pull request gitextensions#1681 from feinstaub/topic_choose_com…
Browse files Browse the repository at this point in the history
…mit_dlg

FormChooseCommit: double click behaves like OK button instead of opening the CommitInfo dialog
  • Loading branch information
KindDragon committed Mar 3, 2013
2 parents 08df5c3 + e92d189 commit 700bb88
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 17 deletions.
1 change: 1 addition & 0 deletions GitUI/GitUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@
<Compile Include="UserControls\ExListView.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="UserControls\RevisionGridClasses\DoubleClickRevisionEventArgs.cs" />
<Compile Include="UserControls\RevisionGridClasses\DvcsGraph.Graph.cs">
<DependentUpon>DvcsGraph.cs</DependentUpon>
<SubType>Component</SubType>
Expand Down
24 changes: 11 additions & 13 deletions GitUI/HelperDialogs/FormChooseCommit.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 10 additions & 3 deletions GitUI/HelperDialogs/FormChooseCommit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,8 @@ public FormChooseCommit(GitUICommands aCommands, string preselectCommit)

}


public GitCommands.GitRevision SelectedRevision { get; private set; }



protected override void OnLoad(EventArgs e)
{
revisionGrid.Load();
Expand All @@ -55,5 +52,15 @@ private void btnOK_Click(object sender, EventArgs e)
Close();
}
}

private void revisionGrid_DoubleClickRevision(object sender, UserControls.RevisionGridClasses.DoubleClickRevisionEventArgs e)
{
if (e.Revision != null)
{
SelectedRevision = e.Revision;
DialogResult = DialogResult.OK;
Close();
}
}
}
}
22 changes: 21 additions & 1 deletion GitUI/UserControls/RevisionGrid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using GitUI.Script;
using Gravatar;
using ResourceManager.Translation;
using GitUI.UserControls.RevisionGridClasses;

namespace GitUI
{
Expand Down Expand Up @@ -67,6 +68,7 @@ public sealed partial class RevisionGrid : GitModuleControl
private RevisionGridLayout layout;
private int rowHeigth;
public event GitModuleChangedEventHandler GitModuleChanged;
public event EventHandler<DoubleClickRevisionEventArgs> DoubleClickRevision;

public RevisionGrid()
{
Expand Down Expand Up @@ -216,6 +218,15 @@ public bool ShowUncommitedChangesIfPossible
get; set;
}

[Description("Do not open the commit info dialog on double click. This is used if the double click event is handled elseswhere.")]
[Category("Behavior")]
[DefaultValue(false)]
public bool DoubleClickDoesNotOpenCommitInfo
{
get;
set;
}

private IndexWatcher _IndexWatcher;
[Browsable(false)]
public IndexWatcher IndexWatcher
Expand Down Expand Up @@ -1481,7 +1492,16 @@ private void RefreshGravatar(Image image)

private void RevisionsDoubleClick(object sender, EventArgs e)
{
ViewSelectedRevisions();
if (DoubleClickRevision != null)
{
var selectedRevisions = GetSelectedRevisions();
DoubleClickRevision(this, new DoubleClickRevisionEventArgs(selectedRevisions.FirstOrDefault()));
}

if (!DoubleClickDoesNotOpenCommitInfo)
{
ViewSelectedRevisions();
}
}

public void ViewSelectedRevisions()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GitCommands;

namespace GitUI.UserControls.RevisionGridClasses
{
public class DoubleClickRevisionEventArgs : EventArgs
{
GitRevision _revision;

public DoubleClickRevisionEventArgs(GitRevision revision)
{
_revision = revision;
}

public GitRevision Revision { get { return _revision; } }
}
}

0 comments on commit 700bb88

Please sign in to comment.