Skip to content
This repository was archived by the owner on Mar 3, 2023. It is now read-only.

🏁 Show/hide Atom shell context menu from settings - #8780

Closed
BrainCrumbz wants to merge 16 commits into
atom:masterfrom
BrainCrumbz:win-context-menu-option-squash
Closed

BrainCrumbz wants to merge 16 commits into
atom:masterfrom
BrainCrumbz:win-context-menu-option-squash

Conversation

@BrainCrumbz

Copy link
Copy Markdown
Contributor

Features

This PR aims at addressing some issues (see e.g. #5901 ) about Atom integration in Windows shell context menu (i.e., the right click menu in Explorer). In particular, with those changes:

  1. user will be able to disable Atom commands in context menu by acting on Atom settings, without resorting to manually editing the registry. Of course s/he can also enable it back again
  2. when Atom is updated, again user will not have to re-edit the registry (nor settings) because Atom will "remember" that items were disabled and keep them like that.

Implementation

  1. Windows Registry operations needed to be invoked by more than one place, so they have been extracted from squirrel-update.coffee and moved to a new WinRegistry module in win-registry.coffee.
  2. Because registry operations need ChildProcess.spawn functionalities, those have been extract from squirrel-update.coffee as well and moved to a new Spawner in spawner.coffee.
  3. A new checkbox <-> boolean setting has been added to the core settings pane in config-schema.coffee.
  4. The new setting is monitored by a dedicated module, WinContextMenuSettings in win-context-menu-settings.coffee. When setting changes, that is responsible for updating the registry by invoking WinRegistry
  5. atom.coffee creates an instance of that monitor, and dispose that when it's time to
  6. WinContextMenuSettings monitor got its own specs
  7. Some squirrel-update-spec.coffee specs, related to ignoring errors, where actually a test on spawning functionality, so they have been moved to a new spawner-spec.coffee
  8. Specs for the shell context menu integration upon update found place in squirrel-update-spec.coffee
  9. In squirrel-update-spec.coffee then there was a repetition on how to invoke a callback, and that has been factored

@winstliu

Copy link
Copy Markdown
Contributor

Travis is reporting some lint errors (https://travis-ci.org/atom/atom/jobs/80203864#L287-L290) - it would be great if you could fix those so that the build can continue.

@BrainCrumbz

Copy link
Copy Markdown
Contributor Author

Thanks for notifying that, we'll have a look at it!

@BrainCrumbz

Copy link
Copy Markdown
Contributor Author

@mnquintana @paulcbetts some people mentioned that after an Atom update, the context menu would be there again, even if they manually removed by editing the registry.

Looking at code, even the one from our PR, it seems that nothing will change on that side:

    when '--squirrel-updated'
      updateShortcuts ->
        # installContextMenu will run anyway!
        WinRegistry.installContextMenu -> 
          addCommandsToPath ->
            app.quit()

the context menu will be installed again no matter what's configured in settings. Should this behaviour change as well, and take into account current settings?

Comment thread src/browser/squirrel-update.coffee Outdated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@mnquintana @paulcbetts some people mentioned that after an Atom update, the context menu would be there again, even if they manually removed by editing the registry.

Looking at code, even in this PR it seems that nothing will change on that side: the context menu will be installed again no matter what's configured in settings. Should this behaviour change as well, and take into account current settings?

@Zireael07

Copy link
Copy Markdown

IMHO context menu after an update should respect current/existing settings.

@BrainCrumbz

Copy link
Copy Markdown
Contributor Author

Hello all. Does this PR still require-changes?

@winstliu

Copy link
Copy Markdown
Contributor

/cc @kevinsawicki for review

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think atom.config is available in the browser process where this code runs. Did this work for you? I would have guessed this line would throw have thrown an error.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It worked during tests. We don't yet have a Windows machine at hand, so we did not actually run the build script (or whatever is needed) on Windows.
BTW, why did nobody mention this until now? 😬

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Tests run inside the render process where globals like this one are available. In the main browser process though where this will run, atom.config is not available.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Is there a way to "inject" or include or whatever the atom.config in the main browser process? I mean, is there something preventing the access to configuration from within the browser process?

If this cannot be done, or cannot be done easily, at least I'd go for removing the second feature described (update does not add context menu if it was disabled), keeping the first one (allow to show/hide context menu from settings) and review this PR

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hello all. Any thoughts on this roadblock? TA

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If this cannot be done, or cannot be done easily

Loading and accessing atom.config from the browser process cannot be done easily at this time. src/config.coffee would need to be adjusted to work in the browser process where packages (and other things) are unavailable.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ok, got that. You know what, maybe we don't necessarily need the atom.config to detect if user had disabled Atom context menu, at least as long as accessing that module is not easy.
During update, so in browser process, we already access the Windows Registry to read/write keys.
We could just define a way to detect - by reading the registry - whether the context menu is enabled or not. A new method would be added to WinRegistry to this purpose. Then, during update, SquirrellUpdate would acces such method, instead of atom.config.
What do you think about that?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hello there. Any thoughts on this? Does it make sense to remove access atom.config and implement it this way?

@kevinsawicki

Copy link
Copy Markdown
Contributor

This pull request is pretty large and there is no description currently provided. Would you mind writing up a bit about what this changes in detail? Thanks.

@BrainCrumbz

Copy link
Copy Markdown
Contributor Author

Added some information. Please do let me know if more is needed, there are things not clear or what else. Cheers

@BrainCrumbz

Copy link
Copy Markdown
Contributor Author

Could anyone tell if this PR is still of interest for project owners? So that we can invest some more time in updating code and fix build fails. Otherwise we can happily close it.

@kevinsawicki

Copy link
Copy Markdown
Contributor

Could anyone tell if this PR is still of interest for project owners?

Yeah, it would be nice to have this as an option.

It looks like the build is failing legitimately because the the windows context menu file added in this pull request is using the atom global before it has defined.

The config should be passed into win-context-menu-settings instead of relied on as a global.

>> ReferenceError: atom is not defined
>>     at new WinContextMenuSettings (/Users/travis/build/atom/atom/src/win-context-menu-settings.coffee:9:22)
>>     at new AtomEnvironment (/Users/travis/build/atom/atom/src/atom-environment.coffee:166:27)
>>     at buildAtomEnvironment (/Users/travis/build/atom/atom/src/initialize-test-window.coffee:56:42)
>>     at module.exports (/Users/travis/build/atom/atom/spec/jasmine-test-runner.coffee:21:17)
>>     at Object.<anonymous> (/Users/travis/build/atom/atom/src/initialize-test-window.coffee:59:13)
>>     at Object.<anonymous> (/Users/travis/build/atom/atom/src/initialize-test-window.coffee:2:1)

@BrainCrumbz

Copy link
Copy Markdown
Contributor Author

Thanks for feedback. Yes I'm on that already. Now we've just being struggling for the last hours both on Windows 10 and Mac OS X to land on a successful build :-\

On Windows we incurred in a number of issues, among which the dreaded common.gypi not found, then npm install hanging on .lock files, then others as well.

On Mac OS X, we usually had much more luck when building as well as running tests. Now we also have problems with apm test. I don't have that machine running now, so I can't remember exactly the error but, after googling, again it seems something related more to node/npm/gyp environment than atom itself.

If we call it a day on those issues, we will probably resort to just force push the updated PR and hope for the best, i.e. either Travis or someone will be so nice to try build it.

@BrainCrumbz

Copy link
Copy Markdown
Contributor Author

Sorry for late update: in the past weeks we tried without luck to get a working build on Windows, or at least passing tests on Mac. None of them was possible, sadly. Quite some time has been spent in those days, in order to overcome issues that seemed more related to other players (e.g. npm on windows and long paths, etc.) than to Atom itself. But still, it was not possible to get feedback from tests before submitting PR again.
So, at least in these days, we're basically at rest on this PR. I guess we'll give it another try in the near future, e.g. after an update on node environment.

@Zireael07

Copy link
Copy Markdown

What's the news?

@BrainCrumbz

Copy link
Copy Markdown
Contributor Author

Last time tried, still had problems with build environment (e.g. npm downloading & installing modules), so no chance to even get to the actual merging issues.

@damieng damieng added the windows Issues that occur on Windows but not on other platforms. label Mar 10, 2016
@BrainCrumbz

Copy link
Copy Markdown
Contributor Author

We decided to split this PR (and eventually close it) in a refactoring part (please see #11639) and then in a coming part strictly dedicated to this feature improvement.

@damieng

damieng commented May 4, 2016

Copy link
Copy Markdown
Contributor

Going to close this one - the core part is in on the other PR which is now merged. We should discuss the shell integration settings for Windows - I have a few ideas.

@damieng damieng closed this May 4, 2016
@BrainCrumbz

BrainCrumbz commented May 4, 2016 •

Copy link
Copy Markdown
Contributor Author

Is there already an open issue where to discuss about shell integration settings for Windows? A couple of points from this PR could be useful to talk about, like having a checkbox in preferences and like checking context menu enabled state while re-installing.

EDIT
well, thinking about it, we opened an issue just for that purpose: #5901

@BrainCrumbz
BrainCrumbz deleted the win-context-menu-option-squash branch May 4, 2016 22:53
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

requires-changes windows Issues that occur on Windows but not on other platforms.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants