mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-24 10:22:05 -05:00
LibGUI: Add 'remove_all_actions' method to 'Menu'
This commit is contained in:
parent
8ede1a6a6f
commit
dbfe385879
2 changed files with 9 additions and 0 deletions
|
@ -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.
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Add table
Reference in a new issue