mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 23:37:35 +00:00
LibGUI: Remove Menu::try_add_separator()
And fall back to the infallible add_separator().
This commit is contained in:
parent
b679094529
commit
1525fa3b8f
41 changed files with 132 additions and 142 deletions
|
@ -51,7 +51,7 @@ ErrorOr<void> LinkLabel::create_menus()
|
|||
{
|
||||
m_context_menu = TRY(Menu::try_create());
|
||||
TRY(m_context_menu->try_add_action(*m_open_action));
|
||||
TRY(m_context_menu->try_add_separator());
|
||||
m_context_menu->add_separator();
|
||||
TRY(m_context_menu->try_add_action(*m_copy_action));
|
||||
return {};
|
||||
}
|
||||
|
|
|
@ -127,21 +127,12 @@ Menu& Menu::add_submenu(String name)
|
|||
return menu;
|
||||
}
|
||||
|
||||
ErrorOr<void> Menu::try_add_separator()
|
||||
{
|
||||
// NOTE: We grow the vector first, to get allocation failure handled immediately.
|
||||
TRY(m_items.try_ensure_capacity(m_items.size() + 1));
|
||||
|
||||
auto item = TRY(adopt_nonnull_own_or_enomem(new (nothrow) MenuItem(m_menu_id, MenuItem::Type::Separator)));
|
||||
if (m_menu_id != -1)
|
||||
realize_menu_item(*item, m_items.size());
|
||||
m_items.unchecked_append(move(item));
|
||||
return {};
|
||||
}
|
||||
|
||||
void Menu::add_separator()
|
||||
{
|
||||
MUST(try_add_separator());
|
||||
auto item = make<MenuItem>(m_menu_id, MenuItem::Type::Separator);
|
||||
if (m_menu_id != -1)
|
||||
realize_menu_item(*item, m_items.size());
|
||||
m_items.append(move(item));
|
||||
}
|
||||
|
||||
void Menu::realize_if_needed(RefPtr<Action> const& default_action)
|
||||
|
@ -271,7 +262,7 @@ ErrorOr<void> Menu::add_recent_files_list(Function<void(Action&)> callback)
|
|||
TRY(try_add_action(action));
|
||||
}
|
||||
|
||||
TRY(try_add_separator());
|
||||
add_separator();
|
||||
return {};
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,6 @@ public:
|
|||
Action* action_at(size_t);
|
||||
|
||||
ErrorOr<void> try_add_action(NonnullRefPtr<Action>);
|
||||
ErrorOr<void> try_add_separator();
|
||||
ErrorOr<NonnullRefPtr<Menu>> try_add_submenu(String name);
|
||||
|
||||
void add_action(NonnullRefPtr<Action>);
|
||||
|
|
|
@ -258,7 +258,7 @@ ErrorOr<void> Toolbar::update_overflow_menu()
|
|||
TRY(m_overflow_menu->try_add_action(*item->action));
|
||||
}
|
||||
if (item->action && peek_item->type == Item::Type::Separator)
|
||||
TRY(m_overflow_menu->try_add_separator());
|
||||
m_overflow_menu->add_separator();
|
||||
}
|
||||
|
||||
return {};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue