Comparar commits

...

22 Commits

Autor SHA1 Mensagem Data
Kevin Sawicki a6e59bbbe0 Always return real package paths 2015-01-27 15:35:28 -08:00
Kevin Sawicki d61c015de7 reloadThemes -> reloadStylesheets 2015-01-27 15:17:24 -08:00
Kevin Sawicki 78b4efe1dd Use commit from PR 2015-01-27 15:10:42 -08:00
Kevin Sawicki df79038bcc Revert changes to loadLessStylesheet 2015-01-27 13:29:08 -08:00
Kevin Sawicki 5a1c6bdf4a Remove unused method 2015-01-27 13:26:14 -08:00
Kevin Sawicki ba6abea216 reloadThemes -> reloadStylesheets 2015-01-27 13:22:41 -08:00
Kevin Sawicki 1e740d95ab Load package stylesheets from theme manager 2015-01-27 13:22:08 -08:00
Kevin Sawicki 6f5b296471 Add initial footer support 2015-01-27 12:04:14 -08:00
Kevin Sawicki 9a5be7e70c Parse object settings into colors manually 2015-01-27 09:36:40 -08:00
Kevin Sawicki 4edb856848 Start watching config after activation 2015-01-27 09:36:40 -08:00
Kevin Sawicki 74358f3e79 Add spec for existing value conforming to new schema 2015-01-27 09:36:40 -08:00
Kevin Sawicki 0ecb46504c Unset values that do not conform to schema 2015-01-27 09:36:40 -08:00
Kevin Sawicki 474be40154 Add back hard-code fallback for specs 2015-01-27 09:36:40 -08:00
Kevin Sawicki 06f496cd13 Remove unneeded config listeners 2015-01-27 09:36:40 -08:00
Kevin Sawicki 27835013fe in -> of 2015-01-27 09:36:40 -08:00
Kevin Sawicki fd593e94be 🎨 2015-01-27 09:36:40 -08:00
Kevin Sawicki 6df60cb29e Validate variables in Package 2015-01-27 09:36:39 -08:00
Kevin Sawicki 920ffd91a5 Make activate optional 2015-01-27 09:36:39 -08:00
Kevin Sawicki 7e194541a0 Only inject strings and numbers 2015-01-27 09:36:39 -08:00
Kevin Sawicki ccf0e6168a Inject theme settings as less variables 2015-01-27 09:36:39 -08:00
Kevin Sawicki 8258ec6d45 Use config default as fallback 2015-01-27 09:36:39 -08:00
Kevin Sawicki db2e6dd97c Set theme settings variables from config 2015-01-27 09:36:39 -08:00
8 arquivos alterados com 110 adições e 53 exclusões
+1 -1
Ver Arquivo
@@ -39,7 +39,7 @@
"jasmine-json": "~0.0",
"jasmine-tagged": "^1.1.2",
"jquery": "^2.1.1",
"less-cache": "0.20.0",
"less-cache": "git+https://github.com/atom/less-cache.git#018b1739ae03ee35aae9827d7d7b16d0799c5d42",
"marked": "^0.3",
"mixto": "^1",
"mkdirp": "0.3.5",
@@ -9,5 +9,3 @@ module.exports =
two:
type: 'integer'
default: 2
activate: -> # no-op
+4 -13
Ver Arquivo
@@ -279,8 +279,6 @@ class Atom extends Model
deprecate "The atom.syntax global is deprecated. Use atom.grammars instead."
@grammars
@subscribe @packages.onDidActivateInitialPackages => @watchThemes()
Project = require './project'
TextBuffer = require 'text-buffer'
@deserializers.add(TextBuffer)
@@ -580,7 +578,10 @@ class Atom extends Model
@watchProjectPath()
@packages.activate()
@packages.activate().then =>
maximize = dimensions?.maximized and process.platform isnt 'darwin'
@displayWindow({maximize})
@keymaps.loadUserKeymap()
@requireUserInitScript() unless safeMode
@@ -589,9 +590,6 @@ class Atom extends Model
@setAutoHideMenuBar(newValue)
@setAutoHideMenuBar(true) if @config.get('core.autoHideMenuBar')
maximize = dimensions?.maximized and process.platform isnt 'darwin'
@displayWindow({maximize})
unloadEditorWindow: ->
return if not @project
@@ -720,13 +718,6 @@ class Atom extends Model
loadThemes: ->
@themes.load()
watchThemes: ->
@themes.onDidChangeActiveThemes =>
# Only reload stylesheets from non-theme packages
for pack in @packages.getActivePackages() when pack.getType() isnt 'theme'
pack.reloadStylesheets?()
null
# Notify the browser project of the window's current project path
watchProjectPath: ->
onProjectPathChanged = =>
+4
Ver Arquivo
@@ -30,6 +30,10 @@ class LessCompileCache
setImportPaths: (importPaths=[]) ->
@cache.setImportPaths(importPaths.concat(@lessSearchPaths))
clearFooters: -> @cache.clearFooters()
setFooter: (filePath, footer) -> @cache.setFooter(filePath, footer)
read: (stylesheetPath) ->
@cache.readFileSync(stylesheetPath)
+2 -1
Ver Arquivo
@@ -154,7 +154,7 @@ class PackageManager
#
# Return a {String} folder path or undefined if it could not be resolved.
resolvePackagePath: (name) ->
return name if fs.isDirectorySync(name)
return fs.absolute(name) if fs.isDirectorySync(name)
packagePath = fs.resolve(@packageDirPaths..., name)
return packagePath if fs.isDirectorySync(packagePath)
@@ -376,6 +376,7 @@ class PackageManager
packages = @getLoadedPackagesForTypes(types)
promises = promises.concat(activator.activatePackages(packages))
Q.all(promises).then =>
@initialPackageActivationComplete = true
@emit 'activated'
@emitter.emit 'did-activate-initial-packages'
+21 -7
Ver Arquivo
@@ -9,6 +9,7 @@ EmitterMixin = require('emissary').Emitter
Q = require 'q'
{deprecate} = require 'grim'
Color = require './color'
ModuleCache = require './module-cache'
ScopedProperties = require './scoped-properties'
@@ -123,7 +124,6 @@ class Package
try
@loadKeymaps()
@loadMenus()
@loadStylesheets()
@settingsPromise = @loadSettings()
@requireMainModule() unless @hasActivationCommands()
@@ -155,9 +155,8 @@ class Package
activateNow: ->
try
@activateConfig()
@activateStylesheets()
if @requireMainModule()
@mainModule.activate(atom.packages.getPackageState(@name) ? {})
@mainModule.activate?(atom.packages.getPackageState(@name) ? {})
@mainActivated = true
catch e
console.warn "Failed to activate package named '#{@name}'", e.stack
@@ -185,6 +184,7 @@ class Package
@stylesheetDisposables = new CompositeDisposable
priority = @getStyleSheetPriority()
@loadStylesheets()
for [sourcePath, source] in @stylesheets
if match = path.basename(sourcePath).match(/[^.]*\.([^.]*)\./)
context = match[1]
@@ -236,8 +236,9 @@ class Package
fs.listSync(menusDirPath, ['cson', 'json'])
loadStylesheets: ->
@stylesheets = @getStylesheetPaths().map (stylesheetPath) ->
[stylesheetPath, atom.themes.loadStylesheet(stylesheetPath, true)]
@stylesheets = @getStylesheetPaths().map (stylesheetPath) =>
stylesheet = atom.themes.loadStylesheet(stylesheetPath, {importFallbackVariables: true})
[stylesheetPath, stylesheet]
getStylesheetsPath: ->
if fs.isDirectorySync(path.join(@path, 'stylesheets'))
@@ -257,6 +258,21 @@ class Package
else
fs.listSync(stylesheetDirPath, ['css', 'less'])
getStylesheetFooter: ->
return unless @isTheme()
footer = ''
for key, value of atom.config.get(@name)
if typeof value is 'object' and not (value instanceof Color)
value = Color.parse(value)
value = value?.toRGBAString?() ? value
switch typeof value
when 'string'
footer += "\n@#{key}: #{value};" if value
when 'number'
footer += "\n@#{key}: #{value};" if isFinite(value)
footer
loadGrammarsSync: ->
return if @grammarsLoaded
@@ -352,8 +368,6 @@ class Package
@settingsActivated = false
reloadStylesheets: ->
oldSheets = _.clone(@stylesheets)
@loadStylesheets()
@stylesheetDisposables?.dispose()
@stylesheetDisposables = new CompositeDisposable
@stylesheetsActivated = false
+68 -28
Ver Arquivo
@@ -197,7 +197,7 @@ class ThemeManager
]
themeNames = _.intersection(themeNames, builtInThemeNames)
if themeNames.length is 0
themeNames = ['atom-dark-syntax', 'atom-dark-ui']
themeNames = ['atom-dark-ui', 'atom-dark-syntax']
else if themeNames.length is 1
if _.endsWith(themeNames[0], '-ui')
themeNames.unshift('atom-dark-syntax')
@@ -266,7 +266,7 @@ class ThemeManager
"""
atom.notifications.addError(message, dismissable: true)
userStylesheetContents = @loadStylesheet(userStylesheetPath, true)
userStylesheetContents = @loadStylesheet(userStylesheetPath, importFallbackVariables: true)
@userStyleSheetDisposable = atom.styles.addStyleSheet(userStylesheetContents, sourcePath: userStylesheetPath, priority: 2)
loadBaseStylesheets: ->
@@ -287,16 +287,14 @@ class ThemeManager
else
fs.resolveOnLoadPath(stylesheetPath, ['css', 'less'])
loadStylesheet: (stylesheetPath, importFallbackVariables) ->
loadStylesheet: (stylesheetPath, options) ->
if path.extname(stylesheetPath) is '.less'
@loadLessStylesheet(stylesheetPath, importFallbackVariables)
@loadLessStylesheet(stylesheetPath, options)
else
fs.readFileSync(stylesheetPath, 'utf8')
loadLessStylesheet: (lessStylesheetPath, importFallbackVariables=false) ->
unless @lessCache?
LessCompileCache = require './less-compile-cache'
@lessCache = new LessCompileCache({@resourcePath, importPaths: @getImportPaths()})
loadLessStylesheet: (lessStylesheetPath, {variables, importFallbackVariables}={}) ->
@createLessCache()
try
if importFallbackVariables
@@ -335,26 +333,7 @@ class ThemeManager
# atom.config.observe runs the callback once, then on subsequent changes.
atom.config.observe 'core.themes', =>
@deactivateThemes()
@refreshLessCache() # Update cache for packages in core.themes config
promises = []
for themeName in @getEnabledThemeNames()
if @packageManager.resolvePackagePath(themeName)
promises.push(@packageManager.activatePackage(themeName))
else
console.warn("Failed to activate theme '#{themeName}' because it isn't installed.")
Q.all(promises).then =>
@addActiveThemeClasses()
@refreshLessCache() # Update cache again now that @getActiveThemes() is populated
@loadUserStylesheet()
@reloadBaseStylesheets()
@initialLoadComplete = true
@emit 'reloaded'
@emitter.emit 'did-change-active-themes'
deferred.resolve()
@reloadStylesheets -> deferred.resolve()
deferred.promise
@@ -364,6 +343,44 @@ class ThemeManager
@packageManager.deactivatePackage(pack.name) for pack in @getActiveThemes()
null
reloadPackageStylesheets: ->
for pack in @packageManager.getActivePackages()
pack.reloadStylesheets() if pack.getType() isnt 'theme'
reloadStylesheets: (callback) ->
@deactivateThemes()
@refreshLessCache() # Update cache for packages in core.themes config
@lessCache?.clearFooters()
loadedThemes = []
for themeName in @getEnabledThemeNames()
unless @packageManager.resolvePackagePath(themeName)
console.warn("Failed to activate theme '#{themeName}' because it isn't installed.")
continue
if theme = @packageManager.loadPackage(themeName)
@setFooterForTheme(theme)
loadedThemes.push(theme)
promises = []
for theme in loadedThemes
promises.push(@packageManager.activatePackage(theme.name))
Q.all(promises).then =>
@addActiveThemeClasses()
@refreshLessCache() # Update cache again now that @getActiveThemes() is populated
@loadUserStylesheet()
@reloadBaseStylesheets()
if @packageManager.initialPackageActivationComplete
@reloadPackageStylesheets()
else
@packageManager.onDidActivateInitialPackages => @reloadPackageStylesheets()
@initialLoadComplete = true
@emit 'reloaded'
@emitter.emit 'did-change-active-themes'
callback?()
isInitialLoadComplete: -> @initialLoadComplete
addActiveThemeClasses: ->
@@ -378,9 +395,32 @@ class ThemeManager
workspaceElement.classList.remove("theme-#{pack.name}")
return
createLessCache: ->
unless @lessCache?
LessCompileCache = require './less-compile-cache'
@lessCache = new LessCompileCache({@resourcePath, importPaths: @getImportPaths()})
@lessCache
refreshLessCache: ->
@lessCache?.setImportPaths(@getImportPaths())
setFooterForTheme: (theme) ->
footer = theme.getStylesheetFooter()
return unless footer
stylesheetPaths = []
try
stylesheetPaths = theme.getStylesheetPaths()
try
stylesPath = path.join(theme.path, 'styles')
stylesheetPaths = stylesheetPaths.concat(fs.listSync(stylesPath, ['less']))
for stylesheetPath in stylesheetPaths
@createLessCache().setFooter(stylesheetPath, footer)
return
getImportPaths: ->
activeThemes = @getActiveThemes()
if activeThemes.length > 0
+10 -1
Ver Arquivo
@@ -21,12 +21,21 @@ class ThemePackage extends Package
console.warn "Failed to load theme named '#{@name}'", error.stack ? error
this
watchThemeConfig: ->
@configDisposable = atom.config.onDidChange @name, =>
atom.themes.reloadStylesheets()
activate: ->
return @activationDeferred.promise if @activationDeferred?
@activationDeferred = Q.defer()
@measure 'activateTime', =>
@loadStylesheets()
@activateNow()
@reloadStylesheets()
@watchThemeConfig()
@activationDeferred.promise
deactivate: ->
@configDisposable?.dispose()
super