window_->SetOverlayIcon(overlay, description);
}
-void Window::SetMenu(ui::SimpleMenuModel* menu) {
- window_->SetMenu(menu);
+void Window::SetMenu(v8::Isolate* isolate, v8::Local<v8::Value> value) {
+ mate::Handle<Menu> menu;
+ if (value->IsObject() &&
+ mate::V8ToString(value->ToObject()->GetConstructorName()) == "Menu" &&
+ mate::ConvertFromV8(isolate, value, &menu)) {
+ menu_.Reset(isolate, menu.ToV8());
+ window_->SetMenu(menu->model());
+ } else if (value->IsNull()) {
+ menu_.Reset();
+ window_->SetMenu(nullptr);
+ } else {
+ isolate->ThrowException(v8::Exception::TypeError(
+ mate::StringToV8(isolate, "Invalid Menu")));
+ }
}
void Window::SetAutoHideMenuBar(bool auto_hide) {
.SetMethod("capturePage", &Window::CapturePage)
.SetMethod("setProgressBar", &Window::SetProgressBar)
.SetMethod("setOverlayIcon", &Window::SetOverlayIcon)
- .SetMethod("_setMenu", &Window::SetMenu)
+ .SetMethod("setMenu", &Window::SetMenu)
.SetMethod("setAutoHideMenuBar", &Window::SetAutoHideMenuBar)
.SetMethod("isMenuBarAutoHide", &Window::IsMenuBarAutoHide)
.SetMethod("setMenuBarVisibility", &Window::SetMenuBarVisibility)
class Dictionary;
}
-namespace ui {
-class SimpleMenuModel;
-}
-
namespace atom {
class NativeWindow;
void SetProgressBar(double progress);
void SetOverlayIcon(const gfx::Image& overlay,
const std::string& description);
- void SetMenu(ui::SimpleMenuModel* menu);
+ void SetMenu(v8::Isolate* isolate, v8::Local<v8::Value> menu);
void SetAutoHideMenuBar(bool auto_hide);
bool IsMenuBarAutoHide();
void SetMenuBarVisibility(bool visible);
v8::Global<v8::Value> web_contents_;
v8::Global<v8::Value> devtools_web_contents_;
+ v8::Global<v8::Value> menu_;
scoped_ptr<NativeWindow> window_;
@on 'focus', (event) =>
app.emit 'browser-window-focus', event, this
-BrowserWindow::setMenu = (menu) ->
- throw new TypeError('Invalid menu') unless menu is null or menu?.constructor?.name is 'Menu'
-
- @menu = menu # Keep a reference of menu in case of GC.
- @_setMenu menu
-
BrowserWindow.getFocusedWindow = ->
windows = BrowserWindow.getAllWindows()
return window for window in windows when window.isFocused()