Change Theme load verbiage to activate

This is to be more consistent with packages.
This commit is contained in:
Ben Ogle
2013-09-11 11:31:56 -07:00
parent 28d48f983e
commit 48f01c66e2
4 changed files with 16 additions and 16 deletions

View File

@@ -54,7 +54,7 @@ describe "ThemeManager", ->
describe "when a theme fails to load", ->
it "logs a warning", ->
spyOn(console, 'warn')
themeManager.loadTheme('a-theme-that-will-not-be-found')
themeManager.activateTheme('a-theme-that-will-not-be-found')
expect(console.warn).toHaveBeenCalled()
describe "theme-loaded event", ->
@@ -63,7 +63,7 @@ describe "ThemeManager", ->
themeManager.load()
it "fires when a new theme has been added", ->
themeManager.on 'theme-loaded', loadHandler = jasmine.createSpy()
themeManager.on 'theme-activated', loadHandler = jasmine.createSpy()
config.set('core.themes', ['atom-dark-syntax'])

View File

@@ -56,7 +56,6 @@ describe "Theme", ->
beforeEach ->
themePath = project.resolve('themes/theme-with-package-file')
theme = new Theme(themePath)
theme.load()
afterEach ->
theme.deactivate()

View File

@@ -12,7 +12,7 @@ class ThemeManager
_.extend @prototype, EventEmitter
constructor: ->
@loadedThemes = []
@activeThemes = []
getAvailablePaths: ->
themePaths = []
@@ -23,27 +23,27 @@ class ThemeManager
getAvailableNames: ->
path.basename(themePath).split('.')[0] for themePath in @getAvailablePaths()
getLoadedThemes: ->
_.clone(@loadedThemes)
getActiveThemes: ->
_.clone(@activeThemes)
unload: ->
removeStylesheet(@userStylesheetPath) if @userStylesheetPath?
theme.deactivate() while theme = @loadedThemes.pop()
theme.deactivate() while theme = @activeThemes.pop()
load: ->
config.observe 'core.themes', (themeNames) =>
@unload()
themeNames = [themeNames] unless _.isArray(themeNames)
@loadTheme(themeName) for themeName in themeNames
@activateTheme(themeName) for themeName in themeNames
@loadUserStylesheet()
@trigger('reloaded')
loadTheme: (name) ->
activateTheme: (name) ->
try
theme = new Theme(name)
@loadedThemes.push(theme)
@trigger('theme-loaded', theme)
@activeThemes.push(theme)
@trigger('theme-activated', theme)
catch error
console.warn("Failed to load theme #{name}", error.stack ? error)
@@ -55,8 +55,8 @@ class ThemeManager
null
getImportPaths: ->
if @loadedThemes.length
theme.directoryPath for theme in @loadedThemes when theme.directoryPath
if @activeThemes.length
theme.directoryPath for theme in @activeThemes when theme.directoryPath
else
themeNames = config.get('core.themes')
themes = []

View File

@@ -24,7 +24,7 @@ class Theme
throw new Error("No theme exists named '#{name}'") unless @stylesheetPath
@load()
@activate()
getPath: ->
@stylesheetPath
@@ -35,8 +35,9 @@ class Theme
isFile: ->
path.extname(@stylesheetPath) in ['.css', '.less']
# Loads the stylesheets found in a `package.cson` file.
load: ->
# Loads the stylesheets found in a `package.cson` file. If no package.json
# file, it will load them in alphabetical order.
activate: ->
if @isFile()
@loadStylesheet(@stylesheetPath)
else