menu_will_show_.Run();
}
-void Menu::AttachToWindow(Window* window) {
- window->window()->SetMenu(model_.get());
-}
-
void Menu::InsertItemAt(
int index, int command_id, const base::string16& label) {
model_->InsertItemAt(index, command_id, label);
.SetMethod("isItemCheckedAt", &Menu::IsItemCheckedAt)
.SetMethod("isEnabledAt", &Menu::IsEnabledAt)
.SetMethod("isVisibleAt", &Menu::IsVisibleAt)
- .SetMethod("attachToWindow", &Menu::AttachToWindow)
.SetMethod("_popup", &Menu::Popup)
.SetMethod("_popupAt", &Menu::PopupAt);
}
void ExecuteCommand(int command_id, int event_flags) override;
void MenuWillShow(ui::SimpleMenuModel* source) override;
- virtual void AttachToWindow(Window* window);
virtual void Popup(Window* window) = 0;
virtual void PopupAt(Window* window, int x, int y) = 0;
} // namespace atom
+
+namespace mate {
+
+template<>
+struct Converter<ui::SimpleMenuModel*> {
+ static bool FromV8(v8::Isolate* isolate, v8::Local<v8::Value> val,
+ ui::SimpleMenuModel** out) {
+ // null would be tranfered to NULL.
+ if (val->IsNull()) {
+ *out = nullptr;
+ return true;
+ }
+
+ atom::api::Menu* menu;
+ if (!Converter<atom::api::Menu*>::FromV8(isolate, val, &menu))
+ return false;
+ *out = menu->model();
+ return true;
+ }
+};
+
+} // namespace mate
+
#endif // ATOM_BROWSER_API_ATOM_API_MENU_H_
#include "atom/browser/api/atom_api_window.h"
+#include "atom/browser/api/atom_api_menu.h"
#include "atom/browser/api/atom_api_web_contents.h"
#include "atom/browser/browser.h"
#include "atom/browser/native_window.h"
window_->SetOverlayIcon(overlay, description);
}
+void Window::SetMenu(ui::SimpleMenuModel* menu) {
+ window_->SetMenu(menu);
+}
+
void Window::SetAutoHideMenuBar(bool auto_hide) {
window_->SetAutoHideMenuBar(auto_hide);
}
.SetMethod("print", &Window::Print)
.SetMethod("setProgressBar", &Window::SetProgressBar)
.SetMethod("setOverlayIcon", &Window::SetOverlayIcon)
+ .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 SetAutoHideMenuBar(bool auto_hide);
bool IsMenuBarAutoHide();
void SetMenuBarVisibility(bool visible);
wrapWebContents @_getDevToolsWebContents()
BrowserWindow::setMenu = (menu) ->
- if process.platform is 'darwin'
- throw new Error('BrowserWindow.setMenu is not available on OS X')
-
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.
- @menu.attachToWindow this
+ @_setMenu menu
BrowserWindow.getAllWindows = ->
windows = BrowserWindow.windows