LibGUI: Add 'remove_all_actions' method to 'Menu'

This commit is contained in:
Marco Cutecchia 2022-02-14 14:06:57 +01:00 committed by Andreas Kling
parent 8ede1a6a6f
commit dbfe385879
2 changed files with 9 additions and 0 deletions

View file

@ -64,6 +64,14 @@ void Menu::add_action(NonnullRefPtr<Action> action)
MUST(try_add_action(move(action)));
}
void Menu::remove_all_actions()
{
for (auto& item : m_items) {
WindowServerConnection::the().async_remove_menu_item(m_menu_id, item.identifier());
}
m_items.clear();
}
ErrorOr<NonnullRefPtr<Menu>> Menu::try_add_submenu(String name)
{
// NOTE: We grow the vector first, to get allocation failure handled immediately.

View file

@ -39,6 +39,7 @@ public:
void add_action(NonnullRefPtr<Action>);
void add_separator();
Menu& add_submenu(String name);
void remove_all_actions();
void popup(const Gfx::IntPoint& screen_position, const RefPtr<Action>& default_action = nullptr);
void dismiss();