mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-20 23:48:05 +03:00
Add a theme-added event to the theme manager
This commit is contained in:
parent
d3eec2db05
commit
261d386809
@ -56,3 +56,16 @@ describe "ThemeManager", ->
|
||||
spyOn(console, 'warn')
|
||||
themeManager.loadTheme('a-theme-that-will-not-be-found')
|
||||
expect(console.warn).toHaveBeenCalled()
|
||||
|
||||
describe "theme-loaded event", ->
|
||||
beforeEach ->
|
||||
spyOn(themeManager, 'getUserStylesheetPath').andCallFake -> null
|
||||
themeManager.load()
|
||||
|
||||
it "fires when a new theme has been added", ->
|
||||
themeManager.on 'theme-loaded', loadHandler = jasmine.createSpy()
|
||||
|
||||
config.set('core.themes', ['atom-dark-syntax'])
|
||||
|
||||
expect(loadHandler).toHaveBeenCalled()
|
||||
expect(loadHandler.mostRecentCall.args[0]).toBeInstanceOf Theme
|
||||
|
@ -23,6 +23,9 @@ class ThemeManager
|
||||
getAvailableNames: ->
|
||||
path.basename(themePath).split('.')[0] for themePath in @getAvailablePaths()
|
||||
|
||||
getThemes: ->
|
||||
_.clone(@loadedThemes)
|
||||
|
||||
unload: ->
|
||||
removeStylesheet(@userStylesheetPath) if @userStylesheetPath?
|
||||
theme.deactivate() while theme = @loadedThemes.pop()
|
||||
@ -38,7 +41,9 @@ class ThemeManager
|
||||
|
||||
loadTheme: (name) ->
|
||||
try
|
||||
theme = new Theme(name)
|
||||
@loadedThemes.push(new Theme(name))
|
||||
@trigger('theme-loaded', theme)
|
||||
catch error
|
||||
console.warn("Failed to load theme #{name}", error.stack ? error)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user