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

Display a friendlier name for "Open With" menus in Windows #225

Merged
merged 12 commits into from
Jul 4, 2024

Conversation

jaimergp
Copy link
Contributor

@jaimergp jaimergp commented Jul 1, 2024

Description

Hoping this fixes the issue reported at #185 (comment)

Checklist - did you ...

  • Add a file to the news directory (using the template) for the next release's release notes?
  • Add / update necessary tests?
  • Add / update outdated documentation?

@conda-bot conda-bot added the cla-signed [bot] added once the contributor has signed the CLA label Jul 1, 2024
@jaimergp
Copy link
Contributor Author

jaimergp commented Jul 1, 2024

pre-commit.ci autofix

@mrclary
Copy link

mrclary commented Jul 1, 2024

I'll give this a try locally.

@mrclary
Copy link

mrclary commented Jul 1, 2024

It did not appear to affect anything. I can see that the registry entry is different
Screenshot 2024-07-01 at 12 28 04 PM

but the associated application is still "Python", and "Spyder (spy6b3d10)" does not appear in any application list to choose from.

Screenshot 2024-07-01 at 12 29 18 PM

@jaimergp
Copy link
Contributor Author

jaimergp commented Jul 2, 2024

Oh, I do see it in the "Details column" there in the background, next to the file size. Maybe that's what they meant with FriendlyTypeName?

@jaimergp
Copy link
Contributor Author

jaimergp commented Jul 2, 2024

I found what VS Code uses for PY files so I'm going to give it a try now with a couple commits. I don't have a Windows VM around right now so it's going to be a blind guess. I appreciate the patience here, thanks!

@jaimergp
Copy link
Contributor Author

jaimergp commented Jul 2, 2024

With the latest push I can successfully display a "pretty name" for the executable (instead of Python). Unfortunately, looks like the icon logic is hardcoded to whatever the executable is shipping, so the only way around that is to create a forwarder shim equipped with the icon that knows how to call the actual program... a bit hacky 😬

@mrclary
Copy link

mrclary commented Jul 2, 2024

Commit 006c579 looks much better 🎉

The "Open with" context menu still shows the Python icon but has the correct name; the "Choose another app" dialog shows the correct name and icon, and the File Explorer shows the correct icon for the file after assignment.

Screenshot 2024-07-02 at 7 50 47 AM Screenshot 2024-07-02 at 7 51 23 AM Screenshot 2024-07-02 at 7 49 42 AM

@jaimergp
Copy link
Contributor Author

jaimergp commented Jul 3, 2024

I think that's the best we can do for now... :/ The "Open With" icon is going to default to the EXE icon, no matter what. I'll mark this as ready so we can start the review.

@jaimergp jaimergp marked this pull request as ready for review July 3, 2024 09:31
@jaimergp jaimergp requested a review from a team as a code owner July 3, 2024 09:31
@jaimergp jaimergp changed the title Set FriendlyTypeName for file type association on Windows Display a friendlier name for "Open With" menus in Windows Jul 3, 2024
Copy link
Contributor

@marcoesters marcoesters left a comment

Choose a reason for hiding this comment

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

LGTM overall, just needs type consistency

@@ -433,7 +439,7 @@ def _cmd_ftype(identifier, command=None, query=False, remove=False) -> Completed
arg = f"{identifier}="
return logged_run(["cmd", "/D", "/C", f"assoc {arg}"], check=True)

def _register_file_extensions(self):
def _register_file_extensions(self) -> bool:
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't always return bool. I'd change return to return False

app_user_model_id=self._app_user_model_id(),
mode=self.menu.mode,
)
return True

def _unregister_file_extensions(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here: return a bool consistently and add a type hint

app_user_model_id=self._app_user_model_id(),
mode=self.menu.mode,
)
return True

def _unregister_url_protocols(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here: return a bool consistently and add a type hint

@jaimergp jaimergp merged commit aed80b6 into conda:main Jul 4, 2024
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed [bot] added once the contributor has signed the CLA
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants