This repository has been archived by the owner on Mar 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17.4k
Windows shell integration system settings #12123
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3e826c1
Initial checkpoint not yet tested with settings-view changes
damieng 6a4f675
Revise API to reduce surface area
damieng 81ebb68
Fixes from testing Windows shell integration
damieng 5a8ced3
Fixup Squirrel installer spec tests
damieng 1610bce
Ensure install & upgrade fix up previous shell paths
damieng 23dfa39
Fix up Squirrel specs
damieng 2fb0d68
Blank lines and for x in y syntax from review
damieng File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
Registry = require 'winreg' | ||
Path = require 'path' | ||
|
||
exeName = Path.basename(process.execPath) | ||
appPath = "\"#{process.execPath}\"" | ||
appName = exeName.replace('atom', 'Atom').replace('beta', 'Beta').replace('.exe', '') | ||
|
||
class ShellOption | ||
constructor: (key, parts) -> | ||
@key = key | ||
@parts = parts | ||
|
||
isRegistered: (callback) => | ||
new Registry({hive: 'HKCU', key: "#{@key}\\#{@parts[0].key}"}) | ||
.get @parts[0].name, (err, val) => | ||
callback(not err? and val.value is @parts[0].value) | ||
|
||
register: (callback) => | ||
doneCount = @parts.length | ||
for part in @parts | ||
reg = new Registry({hive: 'HKCU', key: if part.key? then "#{@key}\\#{part.key}" else @key}) | ||
reg.create( -> reg.set part.name, Registry.REG_SZ, part.value, -> callback() if --doneCount is 0) | ||
|
||
deregister: (callback) => | ||
@isRegistered (isRegistered) => | ||
if isRegistered | ||
new Registry({hive: 'HKCU', key: @key}).destroy -> callback null, true | ||
else | ||
callback null, false | ||
|
||
update: (callback) => | ||
new Registry({hive: 'HKCU', key: "#{@key}\\#{@parts[0].key}"}) | ||
.get @parts[0].name, (err, val) => | ||
if err? or not val.value.includes '\\' + exeName | ||
callback(err) | ||
else | ||
@register callback | ||
|
||
exports.appName = appName | ||
|
||
exports.fileHandler = new ShellOption("\\Software\\Classes\\Applications\\#{exeName}", | ||
[{key: 'shell\\open\\command', name: '', value: "#{appPath} \"%1\""}] | ||
) | ||
|
||
contextParts = [ | ||
{key: 'command', name: '', value: "#{appPath} \"%1\""}, | ||
{name: '', value: "Open with #{appName}"}, | ||
{name: 'Icon', value: "#{appPath}"} | ||
] | ||
|
||
exports.fileContextMenu = new ShellOption("\\Software\\Classes\\*\\shell\\#{appName}", contextParts) | ||
|
||
exports.folderContextMenu = new ShellOption("\\Software\\Classes\\Directory\\shell\\#{appName}", contextParts) | ||
|
||
exports.folderBackgroundContextMenu = new ShellOption("\\Software\\Classes\\Directory\\background\\shell\\#{appName}", | ||
JSON.parse(JSON.stringify(contextParts).replace('%1', '%V')) | ||
) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason to use fat arrows for these functions?
nit It is typical to have a blank line between functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fat arrows are required so that the @ operator points to this object not to the window when the callback functions are executed.
I can add spacing.