1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 13:47:45 +00:00

LibGUI: Remove Menu::try_add_action()

And fall back to the infallible add_action().
This commit is contained in:
Andreas Kling 2023-08-14 10:14:27 +02:00
parent eec328e2ab
commit f2faf2767f
51 changed files with 758 additions and 769 deletions

View file

@ -205,30 +205,30 @@ ErrorOr<void> MainWidget::initialize_fallibles(GUI::Window& window)
(void)TRY(m_toolbar->try_add_action(*m_go_home_action));
auto file_menu = TRY(window.try_add_menu("&File"_string));
TRY(file_menu->try_add_action(GUI::CommonActions::make_quit_action([](auto&) {
file_menu->add_action(GUI::CommonActions::make_quit_action([](auto&) {
GUI::Application::the()->quit();
})));
}));
auto go_menu = TRY(window.try_add_menu("&Go"_string));
TRY(go_menu->try_add_action(*m_go_back_action));
TRY(go_menu->try_add_action(*m_go_forward_action));
TRY(go_menu->try_add_action(*m_go_home_action));
go_menu->add_action(*m_go_back_action);
go_menu->add_action(*m_go_forward_action);
go_menu->add_action(*m_go_home_action);
auto help_menu = TRY(window.try_add_menu("&Help"_string));
String help_page_path = TRY(TRY(try_make_ref_counted<Manual::PageNode>(Manual::sections[1 - 1], "Applications/Help"_string))->path());
TRY(help_menu->try_add_action(GUI::CommonActions::make_command_palette_action(&window)));
TRY(help_menu->try_add_action(GUI::Action::create("&Contents", { Key_F1 }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-unknown.png"sv)), [this, help_page_path = move(help_page_path)](auto&) {
help_menu->add_action(GUI::CommonActions::make_command_palette_action(&window));
help_menu->add_action(GUI::Action::create("&Contents", { Key_F1 }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-unknown.png"sv)), [this, help_page_path = move(help_page_path)](auto&) {
open_page(help_page_path);
})));
TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action("Help", TRY(GUI::Icon::try_create_default_icon("app-help"sv)), &window)));
}));
help_menu->add_action(GUI::CommonActions::make_about_action("Help", TRY(GUI::Icon::try_create_default_icon("app-help"sv)), &window));
m_context_menu = TRY(GUI::Menu::try_create());
TRY(m_context_menu->try_add_action(*m_go_back_action));
TRY(m_context_menu->try_add_action(*m_go_forward_action));
TRY(m_context_menu->try_add_action(*m_go_home_action));
m_context_menu->add_action(*m_go_back_action);
m_context_menu->add_action(*m_go_forward_action);
m_context_menu->add_action(*m_go_home_action);
m_context_menu->add_separator();
TRY(m_context_menu->try_add_action(*m_copy_action));
TRY(m_context_menu->try_add_action(*m_select_all_action));
m_context_menu->add_action(*m_copy_action);
m_context_menu->add_action(*m_select_all_action);
m_manual_model = TRY(ManualModel::create());
m_browse_view->set_model(*m_manual_model);