Merge pull request #991 from atom/menu-improvements

Improve menus for discoverablity
This commit is contained in:
Matt Colyer
2013-10-18 13:04:37 -07:00
7 changed files with 65 additions and 29 deletions

View File

@@ -7,12 +7,11 @@
{ label: "Install update", command: 'application:install-update', visible: false }
{ type: 'separator' }
{ label: 'Preferences...', command: 'application:show-settings' }
{ type: 'separator' }
{ label: 'Hide Atom', command: 'application:hide' }
{ label: 'Hide Others', command: 'application:hide-other-applications' }
{ label: 'Show All', command: 'application:unhide-all-applications' }
{ type: 'separator' }
{ label: 'Run Atom Specs', command: 'application:run-all-specs' }
{ type: 'separator' }
{ label: 'Quit', command: 'application:quit' }
]
}
@@ -21,10 +20,15 @@
submenu: [
{ label: 'New Window', command: 'application:new-window' }
{ label: 'New File', command: 'application:new-file' }
{ type: 'separator' }
{ label: 'Open...', command: 'application:open' }
{ label: 'Open In Dev Mode...', command: 'application:open-dev' }
{ label: 'Reopen Last Item', command: 'pane:reopen-closed-item' }
{ type: 'separator' }
{ label: 'Save', command: 'core:save' }
{ label: 'Save As...', command: 'core:save-as' }
{ label: 'Save All', command: 'window:save-all' }
{ type: 'separator' }
{ label: 'Close Buffer', command: 'core:close' }
{ label: 'Close All Buffers', command: 'pane:close' }
{ label: 'Close Window', command: 'window:close' }
]
}
@@ -37,8 +41,10 @@
{ type: 'separator' }
{ label: 'Cut', command: 'core:cut' }
{ label: 'Copy', command: 'core:copy' }
{ label: 'Copy Path', command: 'editor:copy-path' }
{ label: 'Paste', command: 'core:paste' }
{ label: 'Select All', command: 'core:select-all' }
{ type: 'separator' }
]
}
@@ -47,7 +53,17 @@
submenu: [
{ label: 'Reload', command: 'window:reload' }
{ label: 'Toggle Full Screen', command: 'window:toggle-full-screen' }
{ label: 'Toggle Developer Tools', command: 'window:toggle-dev-tools' }
{
label: 'Developer'
submenu: [
{ label: 'Open In Dev Mode...', command: 'application:open-dev' }
{ label: 'Run Atom Specs', command: 'application:run-all-specs' }
{ label: 'Run Package Specs', command: 'window:run-package-specs' }
{ label: 'Toggle Developer Tools', command: 'window:toggle-dev-tools' }
]
}
{ type: 'separator' }
{ label: 'Toggle Soft Wrap', command: 'editor:toggle-soft-wrap' }
]
}
@@ -60,4 +76,13 @@
{ label: 'Bring All to Front', command: 'application:bring-all-windows-to-front' }
]
}
{
label: 'Help'
submenu: [
{ label: 'Documentation', command: 'application:open-documentation' }
{ label: 'Report an Issue', command: 'application:report-issue' }
{ type: 'separator' }
]
}
]

View File

@@ -50,41 +50,41 @@
"archive-view": "0.11.0",
"autocomplete": "0.10.0",
"autoflow": "0.4.0",
"bookmarks": "0.7.0",
"autoflow": "0.5.0",
"bookmarks": "0.8.0",
"bracket-matcher": "0.7.0",
"collaboration": "0.26.0",
"command-logger": "0.5.0",
"command-logger": "0.6.0",
"command-palette": "0.5.0",
"dev-live-reload": "0.7.0",
"editor-stats": "0.4.0",
"dev-live-reload": "0.8.0",
"editor-stats": "0.5.0",
"exception-reporting": "0.4.0",
"find-and-replace": "0.28.0",
"fuzzy-finder": "0.14.0",
"find-and-replace": "0.29.0",
"fuzzy-finder": "0.15.0",
"gfm": "0.5.0",
"git-diff": "0.11.0",
"gists": "0.4.0",
"github-sign-in": "0.7.0",
"go-to-line": "0.7.0",
"grammar-selector": "0.6.0",
"gists": "0.5.0",
"github-sign-in": "0.8.0",
"go-to-line": "0.8.0",
"grammar-selector": "0.7.0",
"image-view": "0.7.0",
"link": "0.6.0",
"markdown-preview": "0.8.0",
"markdown-preview": "0.9.0",
"metrics": "0.8.0",
"package-generator": "0.12.0",
"release-notes": "0.4.0",
"package-generator": "0.13.0",
"release-notes": "0.6.0",
"settings-view": "0.29.0",
"snippets": "0.9.0",
"snippets": "0.10.0",
"spell-check": "0.7.0",
"status-bar": "0.14.0",
"styleguide": "0.8.0",
"symbols-view": "0.11.0",
"styleguide": "0.9.0",
"symbols-view": "0.12.0",
"tabs": "0.7.0",
"terminal": "0.12.0",
"timecop": "0.5.0",
"to-the-hubs": "0.7.0",
"terminal": "0.13.0",
"timecop": "0.6.0",
"to-the-hubs": "0.8.0",
"toml": "0.3.0",
"tree-view": "0.18.0",
"tree-view": "0.19.0",
"whitespace": "0.7.0",
"wrap-guide": "0.4.0",

View File

@@ -171,6 +171,7 @@ describe "the `atom` global", ->
atom.activatePackage("package-with-menus")
expect(atom.menu.template.length).toBe 2
expect(atom.menu.template[0].label).toBe "Second to Last"
expect(atom.menu.template[1].label).toBe "Last"
expect(atom.contextMenu.definitionsForElement(element)[0].label).toBe "Menu item 1"

View File

@@ -1,3 +1,7 @@
'menu': [
{ 'label': 'Second to Last' }
]
'context-menu':
'.test-1':
'Menu item 3': 'command-3'

View File

@@ -111,6 +111,7 @@ afterEach ->
keymap.bindingSets = bindingSetsToRestore
keymap.bindingSetsByFirstKeystroke = bindingSetsByFirstKeystrokeToRestore
atom.deactivatePackages()
atom.menu.template = []
window.rootView?.remove?()
atom.rootView?.remove?() if atom.rootView isnt window.rootView

View File

@@ -4,11 +4,12 @@ AtomProtocolHandler = require './atom-protocol-handler'
Menu = require 'menu'
autoUpdater = require 'auto-updater'
app = require 'app'
ipc = require 'ipc'
dialog = require 'dialog'
fs = require 'fs'
ipc = require 'ipc'
path = require 'path'
net = require 'net'
shell = require 'shell'
url = require 'url'
{EventEmitter} = require 'events'
_ = require 'underscore-plus'
@@ -136,6 +137,8 @@ class AtomApplication
@on 'application:zoom', -> Menu.sendActionToFirstResponder('zoom:')
@on 'application:bring-all-windows-to-front', -> Menu.sendActionToFirstResponder('arrangeInFront:')
@on 'application:inspect', ({x,y}) -> @focusedWindow().browserWindow.inspectElement(x, y)
@on 'application:open-documentation', -> shell.openExternal('https://github-atom-io.herokuapp.com/docs/latest/?app=true')
@on 'application:report-issue', -> shell.openExternal('https://github.com/atom/atom/issues/new')
@on 'application:show-settings', ->
if @focusedWindow()
@focusedWindow().openPath("atom://config")

View File

@@ -42,10 +42,12 @@ class MenuManager
# Private: Merges an item in a submenu aware way such that new items are always
# appended to the bottom of existing menus where possible.
merge: (menu, item) ->
if item.submenu? and match = _.find(menu, (o) -> o.submenu? and o.label == item.label)
item = _.deepClone(item)
if item.submenu? and match = _.find(menu, (i) -> i.submenu? and i.label == item.label)
@merge(match.submenu, i) for i in item.submenu
else
menu.push(item)
menu.push(item) unless _.find(menu, (i) -> i.label == item.label)
# Private
sendToBrowserProcess: (template, keystrokesByCommand) ->