mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 09:00:22 +00:00
LibGUI: Remove Menubar::try_add_menu()
And fall back to the infallible add_menu().
This commit is contained in:
parent
94cd272ac0
commit
5300896095
Notes:
sideshowbarker
2024-07-17 20:58:35 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/5300896095 Pull-request: https://github.com/SerenityOS/serenity/pull/20571
4 changed files with 8 additions and 17 deletions
|
@ -27,7 +27,7 @@ Example from LibGUI:
|
|||
|
||||
ErrorOr<NonnullRefPtr<Menu>> Window::try_add_menu(String name)
|
||||
{
|
||||
auto menu = TRY(m_menubar->try_add_menu({}, move(name)));
|
||||
auto menu = m_menubar->add_menu({}, move(name));
|
||||
if (m_window_id) {
|
||||
menu->realize_menu_if_needed();
|
||||
ConnectionToWindowServer::the().async_add_menu(m_window_id, menu->menu_id());
|
||||
|
|
|
@ -10,20 +10,12 @@
|
|||
|
||||
namespace GUI {
|
||||
|
||||
ErrorOr<void> Menubar::try_add_menu(Badge<Window>, NonnullRefPtr<Menu> menu)
|
||||
void Menubar::add_menu(Badge<Window>, NonnullRefPtr<Menu> menu)
|
||||
{
|
||||
TRY(m_menus.try_append(menu));
|
||||
return {};
|
||||
m_menus.append(menu);
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<Menu>> Menubar::try_add_menu(Badge<Window>, String name)
|
||||
{
|
||||
auto menu = TRY(try_add<Menu>(move(name)));
|
||||
TRY(m_menus.try_append(menu));
|
||||
return menu;
|
||||
}
|
||||
|
||||
Menu& Menubar::add_menu(Badge<Window>, String name)
|
||||
NonnullRefPtr<Menu> Menubar::add_menu(Badge<Window>, String name)
|
||||
{
|
||||
auto& menu = add<Menu>(move(name));
|
||||
m_menus.append(menu);
|
||||
|
|
|
@ -22,9 +22,8 @@ class Menubar : public Core::EventReceiver {
|
|||
public:
|
||||
virtual ~Menubar() override = default;
|
||||
|
||||
ErrorOr<void> try_add_menu(Badge<Window>, NonnullRefPtr<Menu>);
|
||||
ErrorOr<NonnullRefPtr<Menu>> try_add_menu(Badge<Window>, String name);
|
||||
Menu& add_menu(Badge<Window>, String name);
|
||||
void add_menu(Badge<Window>, NonnullRefPtr<Menu>);
|
||||
[[nodiscard]] NonnullRefPtr<Menu> add_menu(Badge<Window>, String name);
|
||||
|
||||
void for_each_menu(Function<IterationDecision(Menu&)>);
|
||||
|
||||
|
|
|
@ -1320,7 +1320,7 @@ Gfx::Bitmap* Window::back_bitmap()
|
|||
|
||||
ErrorOr<void> Window::try_add_menu(NonnullRefPtr<Menu> menu)
|
||||
{
|
||||
TRY(m_menubar->try_add_menu({}, move(menu)));
|
||||
m_menubar->add_menu({}, move(menu));
|
||||
if (m_window_id) {
|
||||
menu->realize_menu_if_needed();
|
||||
ConnectionToWindowServer::the().async_add_menu(m_window_id, menu->menu_id());
|
||||
|
@ -1330,7 +1330,7 @@ ErrorOr<void> Window::try_add_menu(NonnullRefPtr<Menu> menu)
|
|||
|
||||
ErrorOr<NonnullRefPtr<Menu>> Window::try_add_menu(String name)
|
||||
{
|
||||
auto menu = TRY(m_menubar->try_add_menu({}, move(name)));
|
||||
auto menu = m_menubar->add_menu({}, move(name));
|
||||
if (m_window_id) {
|
||||
menu->realize_menu_if_needed();
|
||||
ConnectionToWindowServer::the().async_add_menu(m_window_id, menu->menu_id());
|
||||
|
|
Loading…
Reference in a new issue