From 1e773256bf321201f36fe39035dadeb48e3a62c4 Mon Sep 17 00:00:00 2001 From: David Lindbom Date: Sun, 9 Jan 2022 20:32:44 +0100 Subject: [PATCH] Snake: Add link to help pages in menu --- Userland/Games/Snake/CMakeLists.txt | 2 +- Userland/Games/Snake/main.cpp | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Userland/Games/Snake/CMakeLists.txt b/Userland/Games/Snake/CMakeLists.txt index ae7f8332ba..dbd3b05be9 100644 --- a/Userland/Games/Snake/CMakeLists.txt +++ b/Userland/Games/Snake/CMakeLists.txt @@ -10,4 +10,4 @@ set(SOURCES ) serenity_app(Snake ICON app-snake) -target_link_libraries(Snake LibGUI LibConfig LibMain) +target_link_libraries(Snake LibGUI LibConfig LibMain LibDesktop) diff --git a/Userland/Games/Snake/main.cpp b/Userland/Games/Snake/main.cpp index e2881c60aa..f833a14e53 100644 --- a/Userland/Games/Snake/main.cpp +++ b/Userland/Games/Snake/main.cpp @@ -5,8 +5,10 @@ */ #include "SnakeGame.h" +#include #include #include +#include #include #include #include @@ -26,9 +28,13 @@ ErrorOr serenity_main(Main::Arguments arguments) Config::pledge_domains("Snake"); + TRY(Desktop::Launcher::add_allowed_handler_with_only_specific_urls("/bin/Help", { URL::create_with_file_protocol("/usr/share/man/man6/Snake.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 app_icon = TRY(GUI::Icon::try_create_default_icon("app-snake")); @@ -52,6 +58,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/Snake.md"), "/bin/Help"); + }))); TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action("Snake", app_icon, window))); window->show();