mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Build MenuManager in Atom environment constructor
This commit is contained in:
@@ -5,7 +5,11 @@ describe "MenuManager", ->
|
||||
menu = null
|
||||
|
||||
beforeEach ->
|
||||
menu = new MenuManager(resourcePath: atom.getLoadSettings().resourcePath)
|
||||
menu = new MenuManager(
|
||||
resourcePath: atom.getLoadSettings().resourcePath
|
||||
keymapManager: atom.keymaps
|
||||
packageManager: atom.packages
|
||||
)
|
||||
|
||||
describe "::add(items)", ->
|
||||
it "can add new menus that can be removed with the returned disposable", ->
|
||||
|
||||
@@ -192,6 +192,9 @@ class Atom extends Model
|
||||
styleManager: @styles, notificationManager: @notifications, viewRegistry: @views
|
||||
})
|
||||
|
||||
MenuManager = require './menu-manager'
|
||||
@menu = new MenuManager({resourcePath, keymapManager: @keymaps, packageManager: @packages})
|
||||
|
||||
ContextMenuManager = require './context-menu-manager'
|
||||
@contextMenu = new ContextMenuManager({resourcePath, devMode, keymapManager: @keymaps})
|
||||
|
||||
@@ -233,7 +236,6 @@ class Atom extends Model
|
||||
|
||||
Clipboard = require './clipboard'
|
||||
GrammarRegistry = require './grammar-registry'
|
||||
MenuManager = require './menu-manager'
|
||||
{devMode, safeMode, resourcePath} = @getLoadSettings()
|
||||
configDirPath = @getConfigDirPath()
|
||||
|
||||
@@ -250,7 +252,6 @@ class Atom extends Model
|
||||
|
||||
@registerViewProviders()
|
||||
document.head.appendChild(new StylesElement)
|
||||
@menu = new MenuManager({resourcePath})
|
||||
@clipboard = new Clipboard()
|
||||
@grammars = @deserializers.deserialize(@state.grammars ? @state.syntax) ? new GrammarRegistry()
|
||||
@disposables.add @packages.onDidActivateInitialPackages => @watchThemes()
|
||||
|
||||
@@ -59,12 +59,12 @@ platformMenu = require('../package.json')?._atomMenu?.menu
|
||||
# See {::add} for more info about adding menu's directly.
|
||||
module.exports =
|
||||
class MenuManager
|
||||
constructor: ({@resourcePath}) ->
|
||||
constructor: ({@resourcePath, @keymapManager, @packageManager}) ->
|
||||
@pendingUpdateOperation = null
|
||||
@template = []
|
||||
atom.keymaps.onDidLoadBundledKeymaps => @loadPlatformItems()
|
||||
atom.keymaps.onDidReloadKeymap => @update()
|
||||
atom.packages.onDidActivateInitialPackages => @sortPackagesMenu()
|
||||
@keymapManager.onDidLoadBundledKeymaps => @loadPlatformItems()
|
||||
@keymapManager.onDidReloadKeymap => @update()
|
||||
@packageManager.onDidActivateInitialPackages => @sortPackagesMenu()
|
||||
|
||||
# Public: Adds the given items to the application menu.
|
||||
#
|
||||
@@ -143,7 +143,7 @@ class MenuManager
|
||||
includedBindings = []
|
||||
unsetKeystrokes = new Set
|
||||
|
||||
for binding in atom.keymaps.getKeyBindings() when @includeSelector(binding.selector)
|
||||
for binding in @keymapManager.getKeyBindings() when @includeSelector(binding.selector)
|
||||
includedBindings.push(binding)
|
||||
if binding.command is 'unset!'
|
||||
unsetKeystrokes.add(binding.keystrokes)
|
||||
|
||||
Reference in New Issue
Block a user