win: Newly created window should also be aware of application menu.

This commit is contained in:
Cheng Zhao 2013-10-05 21:05:59 +08:00
parent caaab22841
commit a182de20a4
5 changed files with 17 additions and 3 deletions

View file

@ -15,6 +15,9 @@ app.getBrowserWindows = ->
app.setApplicationMenu = (menu) ->
require('menu').setApplicationMenu menu
app.getApplicationMenu = ->
require('menu').getApplicationMenu()
app.commandLine =
appendSwitch: bindings.appendSwitch,
appendArgument: bindings.appendArgument

View file

@ -5,6 +5,12 @@ v8Util = process.atomBinding 'v8_util'
BrowserWindow = process.atomBinding('window').BrowserWindow
BrowserWindow::__proto__ = EventEmitter.prototype
BrowserWindow::_init = ->
# Simulate the application menu on platforms other than OS X.
if process.platform isnt 'darwin'
menu = app.getApplicationMenu()
@setMenu menu if menu?
BrowserWindow::toggleDevTools = ->
opened = v8Util.getHiddenValue this, 'devtoolsOpened'
if opened

View file

@ -55,6 +55,8 @@ Menu.setApplicationMenu = (menu) ->
windows = app.getBrowserWindows()
w.setMenu menu for w in windows
Menu.getApplicationMenu = -> applicationMenu
Menu.sendActionToFirstResponder = bindings.sendActionToFirstResponder
Menu.buildFromTemplate = (template) ->