win: Newly created window should also be aware of application menu.
This commit is contained in:
parent
caaab22841
commit
a182de20a4
5 changed files with 17 additions and 3 deletions
|
@ -101,6 +101,9 @@ v8::Handle<v8::Value> Window::New(const v8::Arguments &args) {
|
||||||
|
|
||||||
new Window(args.This(), static_cast<base::DictionaryValue*>(options.get()));
|
new Window(args.This(), static_cast<base::DictionaryValue*>(options.get()));
|
||||||
|
|
||||||
|
// Give js code a chance to do initialization.
|
||||||
|
node::MakeCallback(args.This(), "_init", 0, NULL);
|
||||||
|
|
||||||
return args.This();
|
return args.This();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,9 @@ app.getBrowserWindows = ->
|
||||||
app.setApplicationMenu = (menu) ->
|
app.setApplicationMenu = (menu) ->
|
||||||
require('menu').setApplicationMenu menu
|
require('menu').setApplicationMenu menu
|
||||||
|
|
||||||
|
app.getApplicationMenu = ->
|
||||||
|
require('menu').getApplicationMenu()
|
||||||
|
|
||||||
app.commandLine =
|
app.commandLine =
|
||||||
appendSwitch: bindings.appendSwitch,
|
appendSwitch: bindings.appendSwitch,
|
||||||
appendArgument: bindings.appendArgument
|
appendArgument: bindings.appendArgument
|
||||||
|
|
|
@ -5,6 +5,12 @@ v8Util = process.atomBinding 'v8_util'
|
||||||
BrowserWindow = process.atomBinding('window').BrowserWindow
|
BrowserWindow = process.atomBinding('window').BrowserWindow
|
||||||
BrowserWindow::__proto__ = EventEmitter.prototype
|
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 = ->
|
BrowserWindow::toggleDevTools = ->
|
||||||
opened = v8Util.getHiddenValue this, 'devtoolsOpened'
|
opened = v8Util.getHiddenValue this, 'devtoolsOpened'
|
||||||
if opened
|
if opened
|
||||||
|
|
|
@ -55,6 +55,8 @@ Menu.setApplicationMenu = (menu) ->
|
||||||
windows = app.getBrowserWindows()
|
windows = app.getBrowserWindows()
|
||||||
w.setMenu menu for w in windows
|
w.setMenu menu for w in windows
|
||||||
|
|
||||||
|
Menu.getApplicationMenu = -> applicationMenu
|
||||||
|
|
||||||
Menu.sendActionToFirstResponder = bindings.sendActionToFirstResponder
|
Menu.sendActionToFirstResponder = bindings.sendActionToFirstResponder
|
||||||
|
|
||||||
Menu.buildFromTemplate = (template) ->
|
Menu.buildFromTemplate = (template) ->
|
||||||
|
|
|
@ -76,6 +76,9 @@ app.on('finish-launching', function() {
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
var menu = Menu.buildFromTemplate(template);
|
||||||
|
app.setApplicationMenu(menu);
|
||||||
|
|
||||||
// Test if using protocol module would crash.
|
// Test if using protocol module would crash.
|
||||||
require('protocol').registerProtocol('test-if-crashes', function() {});
|
require('protocol').registerProtocol('test-if-crashes', function() {});
|
||||||
|
|
||||||
|
@ -86,7 +89,4 @@ app.on('finish-launching', function() {
|
||||||
height: 600
|
height: 600
|
||||||
});
|
});
|
||||||
window.loadUrl('file://' + __dirname + '/index.html');
|
window.loadUrl('file://' + __dirname + '/index.html');
|
||||||
|
|
||||||
var menu = Menu.buildFromTemplate(template);
|
|
||||||
app.setApplicationMenu(menu);
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue