Pull load settings out of the focused window

This commit is contained in:
Ben Ogle
2014-12-19 10:37:36 -08:00
parent 0db1971825
commit 20504fc7a8
3 changed files with 14 additions and 10 deletions

View File

@@ -140,14 +140,18 @@ class AtomApplication
# Registers basic application commands, non-idempotent.
handleEvents: ->
getLoadSettings = =>
devMode: @focusedWindow()?.devMode
safeMode: @focusedWindow()?.safeMode
@on 'application:run-all-specs', -> @runSpecs(exitWhenDone: false, resourcePath: global.devResourcePath, safeMode: @focusedWindow()?.safeMode)
@on 'application:run-benchmarks', -> @runBenchmarks()
@on 'application:quit', -> app.quit()
@on 'application:new-window', -> @openPath(windowDimensions: @focusedWindow()?.getDimensions())
@on 'application:new-window', -> @openPath(_.extend(windowDimensions: @focusedWindow()?.getDimensions(), getLoadSettings()))
@on 'application:new-file', -> (@focusedWindow() ? this).openPath()
@on 'application:open', (loadSettings) -> @promptForPath(_.extend(type: 'all', loadSettings))
@on 'application:open-file', (loadSettings) -> @promptForPath(_.extend(type: 'file', loadSettings))
@on 'application:open-folder', (loadSettings) -> @promptForPath(_.extend(type: 'folder', loadSettings))
@on 'application:open', -> @promptForPath(_.extend(type: 'all', getLoadSettings()))
@on 'application:open-file', -> @promptForPath(_.extend(type: 'file', getLoadSettings()))
@on 'application:open-folder', -> @promptForPath(_.extend(type: 'folder', getLoadSettings()))
@on 'application:open-dev', -> @promptForPath(devMode: true)
@on 'application:open-safe', -> @promptForPath(safeMode: true)
@on 'application:inspect', ({x,y, atomWindow}) ->
@@ -227,8 +231,8 @@ class AtomApplication
ipc.on 'run-package-specs', (event, specDirectory) =>
@runSpecs({resourcePath: global.devResourcePath, specDirectory: specDirectory, exitWhenDone: false})
ipc.on 'command', (event, command, options) =>
@emit(command, options)
ipc.on 'command', (event, command) =>
@emit(command)
ipc.on 'window-command', (event, command, args...) ->
win = BrowserWindow.fromWebContents(event.sender)

View File

@@ -18,7 +18,7 @@ class AtomWindow
isSpec: null
constructor: (settings={}) ->
{@resourcePath, pathToOpen, initialLine, initialColumn, @isSpec, @exitWhenDone, @safeMode} = settings
{@resourcePath, pathToOpen, initialLine, initialColumn, @isSpec, @exitWhenDone, @safeMode, @devMode} = settings
# Normalize to make sure drive letter case is consistent on Windows
@resourcePath = path.normalize(@resourcePath) if @resourcePath

View File

@@ -131,9 +131,9 @@ atom.commands.add 'atom-workspace',
'application:unhide-all-applications': -> ipc.send('command', 'application:unhide-all-applications')
'application:new-window': -> ipc.send('command', 'application:new-window')
'application:new-file': -> ipc.send('command', 'application:new-file')
'application:open': -> ipc.send('command', 'application:open', devMode: atom.inDevMode(), safeMode: atom.inSafeMode())
'application:open-file': -> ipc.send('command', 'application:open-file', devMode: atom.inDevMode(), safeMode: atom.inSafeMode())
'application:open-folder': -> ipc.send('command', 'application:open-folder', devMode: atom.inDevMode(), safeMode: atom.inSafeMode())
'application:open': -> ipc.send('command', 'application:open')
'application:open-file': -> ipc.send('command', 'application:open-file')
'application:open-folder': -> ipc.send('command', 'application:open-folder')
'application:open-dev': -> ipc.send('command', 'application:open-dev')
'application:open-safe': -> ipc.send('command', 'application:open-safe')
'application:minimize': -> ipc.send('command', 'application:minimize')