mirror of
https://github.com/atom/atom.git
synced 2026-01-27 15:58:00 -05:00
Move package related data to Atom from RootView
This commit is contained in:
@@ -13,6 +13,25 @@ _.extend atom,
|
||||
loadedThemes: []
|
||||
pendingBrowserProcessCallbacks: {}
|
||||
loadedPackages: []
|
||||
activatedAtomPackages: []
|
||||
atomPackageStates: {}
|
||||
|
||||
activateAtomPackage: (pack) ->
|
||||
@activatedAtomPackages.push(pack)
|
||||
pack.packageMain.activate(@atomPackageStates[pack.name])
|
||||
|
||||
deactivateAtomPackages: ->
|
||||
pack.packageMain.deactivate?() for pack in @activatedAtomPackages
|
||||
@activatedAtomPackages = []
|
||||
|
||||
serializeAtomPackages: ->
|
||||
packageStates = {}
|
||||
for pack in @activatedAtomPackages
|
||||
try
|
||||
packageStates[pack.name] = pack.packageMain.serialize?()
|
||||
catch e
|
||||
console?.error("Exception serializing '#{pack.name}' package's module\n", e.stack)
|
||||
packageStates
|
||||
|
||||
loadPackage: (name, options) ->
|
||||
packagePath = _.find @getPackagePaths(), (packagePath) -> fs.base(packagePath) == name
|
||||
|
||||
@@ -29,18 +29,18 @@ class RootView extends View
|
||||
else
|
||||
projectOrPathToOpen = projectPath # This will migrate people over to the new project serialization scheme. It should be removed eventually.
|
||||
|
||||
rootView = new RootView(projectOrPathToOpen , packageStates: packageStates, suppressOpen: true)
|
||||
atom.atomPackageStates = packageStates ? {}
|
||||
|
||||
rootView = new RootView(projectOrPathToOpen , suppressOpen: true)
|
||||
rootView.setRootPane(rootView.deserializeView(panesViewState)) if panesViewState
|
||||
rootView
|
||||
|
||||
packages: null
|
||||
packageStates: null
|
||||
title: null
|
||||
pathToOpenIsFile: false
|
||||
|
||||
initialize: (projectOrPathToOpen, { @packageStates, suppressOpen } = {}) ->
|
||||
initialize: (projectOrPathToOpen, { suppressOpen } = {}) ->
|
||||
window.rootView = this
|
||||
@packageStates ?= {}
|
||||
@packages = []
|
||||
@viewClasses = {
|
||||
"Pane": Pane,
|
||||
@@ -263,18 +263,10 @@ class RootView extends View
|
||||
@project.eachBuffer(callback)
|
||||
|
||||
activatePackage: (pack) ->
|
||||
@packages.push(pack)
|
||||
pack.packageMain.activate(@packageStates[pack.name])
|
||||
atom.activateAtomPackage(pack)
|
||||
|
||||
deactivatePackages: ->
|
||||
pack.packageMain.deactivate?() for pack in @packages
|
||||
@packages = []
|
||||
atom.deactivateAtomPackages()
|
||||
|
||||
serializePackages: ->
|
||||
packageStates = {}
|
||||
for pack in @packages
|
||||
try
|
||||
packageStates[pack.name] = pack.packageMain.serialize?()
|
||||
catch e
|
||||
console?.error("Exception serializing '#{name}' package's module\n", e.stack)
|
||||
packageStates
|
||||
atom.serializeAtomPackages()
|
||||
|
||||
@@ -37,8 +37,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.getRootViewStateForPath(pathToOpen)
|
||||
RootView.deserialize(rootViewState)
|
||||
if pathState = atom.getRootViewStateForPath(pathToOpen)
|
||||
RootView.deserialize(pathState)
|
||||
else
|
||||
new RootView(pathToOpen)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user