1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-23 18:35:07 +00:00

LibGUI: Allow adding previously constructed menus to Menubar

This commit is contained in:
thankyouverycool 2022-09-26 08:42:36 -04:00 committed by Andreas Kling
parent 9cf93528f5
commit c88d77361c
4 changed files with 18 additions and 0 deletions

View file

@ -1272,6 +1272,16 @@ Gfx::Bitmap* Window::back_bitmap()
return m_back_store ? &m_back_store->bitmap() : nullptr;
}
ErrorOr<void> Window::try_add_menu(NonnullRefPtr<Menu> menu)
{
TRY(m_menubar->try_add_menu({}, move(menu)));
if (m_window_id) {
menu->realize_menu_if_needed();
ConnectionToWindowServer::the().async_add_menu(m_window_id, menu->menu_id());
}
return {};
}
ErrorOr<NonnullRefPtr<Menu>> Window::try_add_menu(String name)
{
auto menu = TRY(m_menubar->try_add_menu({}, move(name)));