LibGUI: Remove Menubar::try_add_menu()

And fall back to the infallible add_menu().
This commit is contained in:
Andreas Kling 2023-08-14 10:22:49 +02:00
parent 94cd272ac0
commit 5300896095
Notes: sideshowbarker 2024-07-17 20:58:35 +09:00
4 changed files with 8 additions and 17 deletions

View file

@ -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());

View file

@ -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);

View file

@ -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&)>);

View file

@ -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());