Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/add windows explorer integration in settings #8010

Conversation

NoahLerner
Copy link
Contributor

@NoahLerner NoahLerner commented Apr 18, 2020

Fixes #7982

Proposed changes

  • Add a checkbox in Tools > Settings > ShellExtensions which will toggle on/off Windows Explorer Integration

Screenshots

Before

image

After

image

Test methodology

  • will update...

Test environment(s)

  • GIT 64 bit
  • Windows 10
  • English

✒️ I contribute this code under The Developer Certificate of Origin.

@ghost ghost assigned NoahLerner Apr 18, 2020
@gerhardol gerhardol added the 📜 status: needs cla The author needs to update contributors.txt before reviewing or merging can proceed label Apr 18, 2020
@pmiossec
Copy link
Member

pmiossec commented Apr 18, 2020

I don't know what others think of it but I would have loved to see these checkboxes changed in a 3 state drop-down "Display in context menu" / "Display in a cascaded menu" / "Hidden".

That way everyone could choose which items he wants to display.

And if all are hidden, then that's equivalent to your new option.

Personally, I'm only interested by "Browse" menu item (that I use a lot) and I hide everything else in the cascaded menu to not pollute the contextual menu.

Others, a point of view ?

@gerhardol
Copy link
Member

I would have loved to see these checkboxes changed in a 3 state drop-down "Display in context menu" / "Display in a cascaded menu" / "Hidden".

No strong opinion here, but a checkbox is easier to handle
Let the checkboxes control "Show on main menu" and a new for "Show cascaded menu"?
(Basically the same as the proposal, just naming.)

set => HandleShellIntegration(null, null, value);
}

private static void HandleShellIntegration(object sender = null, EventArgs e = null, bool register = false)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move out to own file, call it something like ShellExtensionManager:

public sealed ShellExtensionManager
{
	/// <summary>
	///  Check whether the shell extensions is registered.
	/// </summary>
	/// <returns>
	///  <see langword="true"/> if the shell extensions is registered; otherwise <see langword="false"/>.
	/// </returns>
	public bool CheckRegistered();

	/// <summary>
	///  Registers the shell extensions. Throws an exception, if registration process failed.
	/// </summary>
	public void Register([NotNull] string extensionLocation);

	/// <summary>
	///  Unregisters the shell extensions. Throws an exception, if registration process failed.
	/// </summary>
	public void Unregister([NotNull] string extensionLocation);
}

NB: don't make it static, to reduce risks of race conditions while testing. The implementation should be stateless (as far as our code is concerned), so there is no issue with creating multiple instances of the class.
We can later replace is with MEF DI.

Furthermore, I don't like the functionality of registering/unregestering being placed in AppSettings. It is not a settings, and it is unrelated to the app.
If there is an error while registering or unregistering the shell extensions there is no way to inform a user.
Please move checks and register/unregister to the settings page, where it belongs.

Comment on lines +288 to +289
const string GitExtensionsShellEx32Name = "GitExtensionsShellEx32.dll";
const string GitExtensionsShellEx64Name = "GitExtensionsShellEx64.dll";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move out to the class scope

Comment on lines +303 to +322
var pi = new ProcessStartInfo
{
FileName = "regsvr32",
Arguments = $"{(!register ? "/u " : "")}" + path.Quote(),
Verb = "RunAs",
UseShellExecute = false,

// TODO confirmation window is not suppressed
CreateNoWindow = true
};

// TODO is IntPtr really the correct way to check architecture here?
if (IntPtr.Size == 8)
{
path = path.Replace(GitExtensionsShellEx32Name, GitExtensionsShellEx64Name);
if (File.Exists(path))
{
pi.Arguments = $"{(!register ? "/u" : "")}" + path.Quote();
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❗ Multiple string allocations for no reason.

@ghost ghost added the 📭 needs: author feedback More info/confirmation awaited from OP; issues typically get closed after 30 days of inactivity label Apr 19, 2020
@RussKie
Copy link
Member

RussKie commented Apr 19, 2020

I don't know what others think of it but I would have loved to see these checkboxes changed in a 3 state drop-down "Display in context menu" / "Display in a cascaded menu" / "Hidden".

Make it a dropdown list 😉

@RussKie RussKie added this to the 4.1 milestone Apr 19, 2020
@mstv mstv added 🖊️ status: cla signed and removed 📜 status: needs cla The author needs to update contributors.txt before reviewing or merging can proceed labels Apr 20, 2020
@ghost ghost added the 💤 status: no recent activity The issue is stale label May 20, 2020
@ghost
Copy link

ghost commented May 20, 2020

This pull request has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 30 days. It will be closed if no further activity occurs.

@RussKie RussKie modified the milestones: 3.5, 3.6 Mar 8, 2021
@ghost ghost removed the 💤 status: no recent activity The issue is stale label Mar 8, 2021
@ghost ghost added the 💤 status: no recent activity The issue is stale label Apr 7, 2021
@ghost
Copy link

ghost commented Apr 7, 2021

This pull request has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 30 days. It will be closed if no further activity occurs.

@GintasS
Copy link
Collaborator

GintasS commented Aug 6, 2021

This is an old PR and should be closed or set to a draft. @gerhardol

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📭 needs: author feedback More info/confirmation awaited from OP; issues typically get closed after 30 days of inactivity 🖊️ status: cla signed status: abandoned
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add "Remove Windows Explorer integration" in Settings Menu
6 participants