From 48f01c66e2d31fd0d19476ccdcfc28ce23f212ef Mon Sep 17 00:00:00 2001 From: Ben Ogle Date: Wed, 11 Sep 2013 11:31:56 -0700 Subject: [PATCH] Change Theme load verbiage to activate This is to be more consistent with packages. --- spec/theme-manager-spec.coffee | 4 ++-- spec/theme-spec.coffee | 1 - src/theme-manager.coffee | 20 ++++++++++---------- src/theme.coffee | 7 ++++--- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/spec/theme-manager-spec.coffee b/spec/theme-manager-spec.coffee index 83733cdc9..0ffea53a0 100644 --- a/spec/theme-manager-spec.coffee +++ b/spec/theme-manager-spec.coffee @@ -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']) diff --git a/spec/theme-spec.coffee b/spec/theme-spec.coffee index d9f67d4f4..d77cf80c4 100644 --- a/spec/theme-spec.coffee +++ b/spec/theme-spec.coffee @@ -56,7 +56,6 @@ describe "Theme", -> beforeEach -> themePath = project.resolve('themes/theme-with-package-file') theme = new Theme(themePath) - theme.load() afterEach -> theme.deactivate() diff --git a/src/theme-manager.coffee b/src/theme-manager.coffee index 43eb12bc2..3a54d95ca 100644 --- a/src/theme-manager.coffee +++ b/src/theme-manager.coffee @@ -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 = [] diff --git a/src/theme.coffee b/src/theme.coffee index 6c79c786a..df3e6ca88 100644 --- a/src/theme.coffee +++ b/src/theme.coffee @@ -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