From 3a197eea929e9fcb76ef3985c379aeb2456a56e9 Mon Sep 17 00:00:00 2001 From: David Lindbom Date: Sun, 9 Jan 2022 20:31:53 +0100 Subject: [PATCH] Pong: Add link to help pages in menu --- Userland/Games/Pong/CMakeLists.txt | 2 +- Userland/Games/Pong/main.cpp | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Userland/Games/Pong/CMakeLists.txt b/Userland/Games/Pong/CMakeLists.txt index d6f8de6dc1..1787e60133 100644 --- a/Userland/Games/Pong/CMakeLists.txt +++ b/Userland/Games/Pong/CMakeLists.txt @@ -10,4 +10,4 @@ set(SOURCES ) serenity_app(Pong ICON app-pong) -target_link_libraries(Pong LibGUI LibMain) +target_link_libraries(Pong LibGUI LibMain LibDesktop) diff --git a/Userland/Games/Pong/main.cpp b/Userland/Games/Pong/main.cpp index ae58015448..fb3accfc3f 100644 --- a/Userland/Games/Pong/main.cpp +++ b/Userland/Games/Pong/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/Pong.md") })); + TRY(Desktop::Launcher::seal_allowlist()); + TRY(Core::System::pledge("stdio rpath recvfd sendfd")); 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()); @@ -40,6 +46,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/Pong.md"), "/bin/Help"); + }))); TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action("Pong", app_icon, window))); window->show();