Store pathToOpen using new atom.set/getWindowState api

When you use `setWindowState`, your data is saved across refreshes.
You can only store state that can be serialized to JSON.
This commit is contained in:
Kevin Sawicki & Nathan Sobo
2013-01-10 18:04:22 -07:00
parent ac3c059246
commit 2fb27bb2dd
6 changed files with 42 additions and 5 deletions

View File

@@ -109,3 +109,16 @@ _.extend atom,
if name is 'reply'
[messageId, callbackIndex] = data.shift()
@pendingBrowserProcessCallbacks[messageId]?[callbackIndex]?(data...)
setWindowState: (keyPath, value) ->
windowState = @getWindowState()
_.setValueForKeyPath(windowState, keyPath, value)
$native.setWindowState(JSON.stringify(windowState))
windowState
getWindowState: (keyPath) ->
windowState = JSON.parse($native.getWindowState())
if keyPath
_.valueForKeyPath(windowState, keyPath)
else
windowState

View File

@@ -47,8 +47,10 @@ windowAdditions =
false
shutdown: ->
@rootView?.deactivate()
@rootView = null
if @rootView
atom.setWindowState('pathToOpen', @rootView.project.getPath())
@rootView.deactivate()
@rootView = null
$(window).unbind('focus')
$(window).unbind('blur')
$(window).off('before')