Skip to content

Commit

Permalink
Support Tortoise Git icon set in Visual Studio 2012
Browse files Browse the repository at this point in the history
  • Loading branch information
sharwell committed Feb 12, 2013
1 parent ed84ecc commit 3d9eac0
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 9 deletions.
46 changes: 39 additions & 7 deletions SccGlyphsHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ internal static class SccGlyphsHelper

// Our custom image list
private static ImageList _customSccGlyphsImageList;
private static bool? _usingVisualStudio2010Icons;

// Indexes of icons in our custom image list
private enum CustomSccGlyphs2010
Expand All @@ -36,7 +37,7 @@ public static VsStateIcon Tracked
{
get
{
if (GitSccOptions.IsVisualStudio2010 && GitSccOptions.Current.UseTGitIconSet)
if (UsingTortoiseGitIcons)
return (VsStateIcon)(_customSccGlyphBaseIndex + (uint)CustomSccGlyphs2010.Tracked);

return VsStateIcon.STATEICON_CHECKEDIN;
Expand All @@ -47,7 +48,7 @@ public static VsStateIcon Modified
{
get
{
if (GitSccOptions.IsVisualStudio2010 && GitSccOptions.Current.UseTGitIconSet)
if (UsingTortoiseGitIcons)
return (VsStateIcon)(_customSccGlyphBaseIndex + (uint)CustomSccGlyphs2010.Modified);

return VsStateIcon.STATEICON_CHECKEDOUT;
Expand All @@ -58,7 +59,7 @@ public static VsStateIcon New
{
get
{
if (GitSccOptions.IsVisualStudio2010)
if (UsingVisualStudio2010Icons)
return (VsStateIcon)(_customSccGlyphBaseIndex + (uint)CustomSccGlyphs2010.Untracked);

return (VsStateIcon)(_customSccGlyphBaseIndex + (uint)CustomSccGlyphs2012.New);
Expand All @@ -77,7 +78,7 @@ public static VsStateIcon Staged
{
get
{
if (GitSccOptions.IsVisualStudio2010)
if (UsingVisualStudio2010Icons)
return (VsStateIcon)(_customSccGlyphBaseIndex + (uint)CustomSccGlyphs2010.Staged);

return (VsStateIcon)(_customSccGlyphBaseIndex + (uint)CustomSccGlyphs2012.Staged);
Expand All @@ -104,7 +105,7 @@ public static VsStateIcon Conflict
{
get
{
if (GitSccOptions.IsVisualStudio2010)
if (UsingVisualStudio2010Icons)
return VsStateIcon.STATEICON_DISABLED;

return (VsStateIcon)(_customSccGlyphBaseIndex + (uint)CustomSccGlyphs2012.Conflicted);
Expand All @@ -115,7 +116,7 @@ public static VsStateIcon Merged
{
get
{
if (GitSccOptions.IsVisualStudio2010)
if (UsingVisualStudio2010Icons)
return Modified;

return (VsStateIcon)(_customSccGlyphBaseIndex + (uint)CustomSccGlyphs2012.Merged);
Expand All @@ -130,6 +131,37 @@ public static VsStateIcon Default
}
}

private static bool UsingVisualStudio2010Icons
{
get
{
if (!_usingVisualStudio2010Icons.HasValue)
{
if (GitSccOptions.IsVisualStudio2010)
_usingVisualStudio2010Icons = true;
else
_usingVisualStudio2010Icons = GitSccOptions.Current.UseTGitIconSet;
}

return _usingVisualStudio2010Icons.Value;
}
}

private static bool UsingTortoiseGitIcons
{
get
{
if (!UsingVisualStudio2010Icons)
return false;

// only reason to use the 2010 icons in 2012 is if we are using tortoise icons
if (GitSccOptions.IsVisualStudio2012)
return true;

return GitSccOptions.Current.UseTGitIconSet;
}
}

public static uint GetCustomGlyphList(uint baseIndex)
{
// If this is the first time we got called, construct the image list, remember the index, etc
Expand All @@ -151,7 +183,7 @@ public static uint GetCustomGlyphList(uint baseIndex)

// Add the custom scc glyphs we support to the list
// NOTE: VS2005 and VS2008 are limited to 4 custom scc glyphs (let's hope this will change in future versions)
Image sccGlyphs = GitSccOptions.IsVisualStudio2010 ? Resources.SccGlyphs : Resources.SccGlyphs2012;
Image sccGlyphs = UsingVisualStudio2010Icons ? Resources.SccGlyphs : Resources.SccGlyphs2012;
_customSccGlyphsImageList.Images.AddStrip(sccGlyphs);
}

Expand Down
6 changes: 4 additions & 2 deletions SccProviderOptionsControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -357,12 +357,14 @@ private void SccProviderOptionsControl_Load(object sender, EventArgs e)
this.checkBox1.Checked = GitSccOptions.Current.NotExpandGitExtensions;
this.checkBox2.Checked = GitSccOptions.Current.NotExpandTortoiseGit;
this.checkBox3.Checked = GitSccOptions.Current.UseTGitIconSet;
this.checkBox3.Enabled = GitSccOptions.IsVisualStudio2010;
this.checkBox4.Checked = GitSccOptions.Current.DisableAutoRefresh;
this.checkBox5.Checked = GitSccOptions.Current.DisableAutoLoad;
this.checkBox6.Checked = GitSccOptions.Current.NotUseUTF8FileNames;
this.chkDisableDiffMargin.Checked = GitSccOptions.Current.DisableDiffMargin;
this.useVsDiffChk.Checked = GitSccOptions.Current.UseVsDiff;

if (GitSccOptions.IsVisualStudio2012)
checkBox3.Text += " (requires restart)";
}

private void button1_Click(object sender, EventArgs e)
Expand Down Expand Up @@ -403,7 +405,7 @@ internal void Save()
GitSccOptions.Current.TortoiseGitPath = this.textBox4.Text;
GitSccOptions.Current.NotExpandGitExtensions = this.checkBox1.Checked;
GitSccOptions.Current.NotExpandTortoiseGit = this.checkBox2.Checked;
GitSccOptions.Current.UseTGitIconSet = GitSccOptions.IsVisualStudio2010 && this.checkBox3.Checked;
GitSccOptions.Current.UseTGitIconSet = this.checkBox3.Checked;
GitSccOptions.Current.DisableAutoRefresh = this.checkBox4.Checked;
GitSccOptions.Current.DisableAutoLoad = this.checkBox5.Checked;
GitSccOptions.Current.NotUseUTF8FileNames = this.checkBox6.Checked;
Expand Down

0 comments on commit 3d9eac0

Please sign in to comment.