tweak(menus): "Enter" and "Exit" fullscreen instead of "Toggle"

This commit is contained in:
Ben Gotow 2015-09-09 12:08:45 -07:00
parent ffb33f3c93
commit 748c4c899c
2 changed files with 14 additions and 1 deletions

View file

@ -48,7 +48,8 @@
{
label: 'View'
submenu: [
{ label: 'Toggle Full Screen', command: 'window:toggle-full-screen' }
{ label: 'Enter Full Screen', command: 'window:toggle-full-screen' }
{ label: 'Exit Full Screen', command: 'window:toggle-full-screen', visible: false }
]
}
{

View file

@ -36,6 +36,7 @@ class ApplicationMenu
Menu.setApplicationMenu(@menu)
@showUpdateMenuItem(global.application.autoUpdateManager.getState())
@showFullscreenMenuItem(@lastFocusedWindow?.isFullScreen())
# Register a BrowserWindow with this application menu.
addWindow: (window) ->
@ -47,10 +48,14 @@ class ApplicationMenu
@setActiveTemplate(template)
window.on 'focus', focusHandler
window.on 'enter-full-screen', focusHandler
window.on 'leave-full-screen', focusHandler
window.once 'closed', =>
@lastFocusedWindow = null if window is @lastFocusedWindow
@windowTemplates.delete(window)
window.removeListener 'focus', focusHandler
window.removeListener 'enter-full-screen', focusHandler
window.removeListener 'leave-full-screen', focusHandler
@enableWindowSpecificItems(true)
@ -111,6 +116,13 @@ class ApplicationMenu
when 'update-available'
installUpdateItem.visible = true
showFullscreenMenuItem: (fullscreen) ->
enterItem = _.find(@flattenMenuItems(@menu), ({label}) -> label == 'Enter Full Screen')
exitItem = _.find(@flattenMenuItems(@menu), ({label}) -> label == 'Exit Full Screen')
return unless enterItem and exitItem
enterItem.visible = !fullscreen
exitItem.visible = fullscreen
# Default list of menu items.
#
# Returns an Array of menu item Objects.