Now storing a window's state based on its rootDirectory (instead of on windowNumber)

This commit is contained in:
Corey Johnson
2012-08-29 10:59:45 -07:00
parent 073164c584
commit 6f99b61dd3
7 changed files with 30 additions and 19 deletions

View File

@@ -2,5 +2,20 @@ fs = require('fs')
atom.configDirPath = fs.absolute("~/.atom")
atom.configFilePath = fs.join(atom.configDirPath, "atom.coffee")
atom.open = (args...) -> @sendMessageToBrowserProcess('open', args)
atom.newWindow = (args...) -> @sendMessageToBrowserProcess('newWindow', args)
atom.open = (args...) ->
@sendMessageToBrowserProcess('open', args)
atom.newWindow = (args...) ->
@sendMessageToBrowserProcess('newWindow', args)
atom.getRootViewStateForPath = (path) ->
if json = localStorage[path]
JSON.parse(json)
atom.setRootViewStateForPath = (path, state) ->
return unless path
if state?
localStorage[path] = JSON.stringify(state)
else
delete localStorage[path]

View File

@@ -94,7 +94,7 @@ class RootView extends View
delete @extensions[extension.name]
deactivate: ->
# atom.rootViewStates[$windowNumber] = JSON.stringify(@serialize()) # TODO: Reinstate
atom.setRootViewStateForPath(@project.getPath(), @serialize())
@deactivateExtension(extension) for name, extension of @extensions
@remove()

View File

@@ -25,14 +25,12 @@ windowAdditions =
@shutdown()
false
$(window).focus()
# atom.windowOpened this # TODO: Reinstate this!
shutdown: ->
@rootView.deactivate()
$(window).unbind('focus')
$(window).unbind('blur')
$(window).off('before')
# atom.windowClosed this # TODO: Reinstate this!
setUpKeymap: ->
Keymap = require 'keymap'
@@ -47,8 +45,8 @@ windowAdditions =
# Note: RootView assigns itself on window on initialization so that
# window.rootView is available when loading user configuration
attachRootView: (pathToOpen) ->
if rootViewState = atom.rootViewStates?[$windowNumber]
RootView.deserialize(JSON.parse(rootViewState))
if rootViewState = atom.getRootViewStateForPath(pathToOpen)
RootView.deserialize(rootViewState)
else
new RootView(pathToOpen)
@rootView.open() unless pathToOpen