Load menus from packages

This commit is contained in:
Matt Colyer
2013-10-04 13:39:35 -07:00
parent 141c4f48bf
commit 7b7c9abdeb
2 changed files with 4 additions and 3 deletions

View File

@@ -92,6 +92,7 @@ class AtomPackage extends Package
activateResources: ->
keymap.add(keymapPath, map) for [keymapPath, map] in @keymaps
atom.contextMenu.add(menuPath, map['context-menu']) for [menuPath, map] in @menus
atom.menu.add(map.menu) for [menuPath, map] in @menus when map.menu
syntax.addGrammar(grammar) for grammar in @grammars
for [scopedPropertiesPath, selector, properties] in @scopedProperties
syntax.addProperties(scopedPropertiesPath, selector, properties)

View File

@@ -24,8 +24,8 @@ class MenuManager
# https://github.com/atom/atom-shell/blob/master/docs/api/browser/menu.md
#
# Returns nothing.
add: (item) ->
@merge(@template, item)
add: (items) ->
@merge(@template, item) for item in items
# Public: Refreshes the currently visible menu.
update: ->
@@ -36,7 +36,7 @@ class MenuManager
menuPaths = fsUtils.listSync(atom.config.bundledMenusDirPath, ['cson', 'json'])
for menuPath in menuPaths
data = CSON.readFileSync(menuPath)
@add(item) for item in data.menu
@add(data.menu)
# Private: Merges an item in a menu aware way such that new items are always
# appended to the bottom.