mirror of
https://github.com/atom/atom.git
synced 2026-01-22 13:28:01 -05:00
Change Theme load verbiage to activate
This is to be more consistent with packages.
This commit is contained in:
@@ -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'])
|
||||
|
||||
|
||||
@@ -56,7 +56,6 @@ describe "Theme", ->
|
||||
beforeEach ->
|
||||
themePath = project.resolve('themes/theme-with-package-file')
|
||||
theme = new Theme(themePath)
|
||||
theme.load()
|
||||
|
||||
afterEach ->
|
||||
theme.deactivate()
|
||||
|
||||
@@ -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 = []
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user