From f19a849f39582973eec95d1eca2051ad22af47f6 Mon Sep 17 00:00:00 2001 From: David Lindbom Date: Sun, 9 Jan 2022 20:23:51 +0100 Subject: [PATCH] Breakout: Add link to help pages in menu --- Userland/Games/Breakout/CMakeLists.txt | 2 +- Userland/Games/Breakout/main.cpp | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Userland/Games/Breakout/CMakeLists.txt b/Userland/Games/Breakout/CMakeLists.txt index 3fad09eb26..8fb1a5ed6e 100644 --- a/Userland/Games/Breakout/CMakeLists.txt +++ b/Userland/Games/Breakout/CMakeLists.txt @@ -11,4 +11,4 @@ set(SOURCES ) serenity_app(Breakout ICON app-breakout) -target_link_libraries(Breakout LibGUI LibMain) +target_link_libraries(Breakout LibGUI LibMain LibDesktop) diff --git a/Userland/Games/Breakout/main.cpp b/Userland/Games/Breakout/main.cpp index aa7389ba03..53a30852d9 100644 --- a/Userland/Games/Breakout/main.cpp +++ b/Userland/Games/Breakout/main.cpp @@ -5,7 +5,9 @@ */ #include "Game.h" +#include #include +#include #include #include #include @@ -20,9 +22,13 @@ ErrorOr serenity_main(Main::Arguments arguments) auto app = TRY(GUI::Application::try_create(arguments)); + TRY(Desktop::Launcher::add_allowed_handler_with_only_specific_urls("/bin/Help", { URL::create_with_file_protocol("/usr/share/man/man6/Breakout.md") })); + TRY(Desktop::Launcher::seal_allowlist()); + TRY(Core::System::pledge("stdio recvfd sendfd rpath")); TRY(Core::System::unveil("/res", "r")); + TRY(Core::System::unveil("/tmp/portal/launch", "rw")); TRY(Core::System::unveil(nullptr, nullptr)); auto window = TRY(GUI::Window::try_create()); @@ -47,6 +53,9 @@ ErrorOr serenity_main(Main::Arguments arguments) }))); auto help_menu = TRY(window->try_add_menu("&Help")); + TRY(help_menu->try_add_action(GUI::CommonActions::make_help_action([](auto&) { + Desktop::Launcher::open(URL::create_with_file_protocol("/usr/share/man/man6/Breakout.md"), "/bin/Help"); + }))); TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action("Breakout", app_icon, window))); window->show();