From 387decbb0112cdb14887a6c56e5a2a81cdc2545a Mon Sep 17 00:00:00 2001 From: Strawby Date: Wed, 1 Nov 2023 19:39:48 +0100 Subject: [PATCH] Spider: Add Manual link to the help-context-menu --- Userland/Games/Spider/CMakeLists.txt | 2 +- Userland/Games/Spider/main.cpp | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Userland/Games/Spider/CMakeLists.txt b/Userland/Games/Spider/CMakeLists.txt index 94b2e08175..7d899b6418 100644 --- a/Userland/Games/Spider/CMakeLists.txt +++ b/Userland/Games/Spider/CMakeLists.txt @@ -16,4 +16,4 @@ set(GENERATED_SOURCES ) serenity_app(Spider ICON app-spider) -target_link_libraries(Spider PRIVATE LibCards LibGUI LibGfx LibCore LibConfig LibMain) +target_link_libraries(Spider PRIVATE LibCards LibGUI LibGfx LibCore LibDesktop LibConfig LibMain) diff --git a/Userland/Games/Spider/main.cpp b/Userland/Games/Spider/main.cpp index 9d3274c7f9..1ad7caeab2 100644 --- a/Userland/Games/Spider/main.cpp +++ b/Userland/Games/Spider/main.cpp @@ -8,10 +8,12 @@ #include "Game.h" #include +#include #include #include #include #include +#include #include #include #include @@ -40,6 +42,11 @@ ErrorOr serenity_main(Main::Arguments arguments) Config::pledge_domains({ "Games", "Spider" }); Config::monitor_domain("Games"); + auto const man_file = "/usr/share/man/man6/Spider.md"; + + TRY(Desktop::Launcher::add_allowed_handler_with_only_specific_urls("/bin/Help", { URL::create_with_file_scheme(man_file) })); + TRY(Desktop::Launcher::seal_allowlist()); + TRY(Core::System::pledge("stdio recvfd sendfd rpath proc exec")); TRY(Core::System::unveil("/res", "r")); @@ -279,6 +286,9 @@ ErrorOr serenity_main(Main::Arguments arguments) auto help_menu = window->add_menu("&Help"_string); help_menu->add_action(GUI::CommonActions::make_command_palette_action(window)); + help_menu->add_action(GUI::CommonActions::make_help_action([&man_file](auto&) { + Desktop::Launcher::open(URL::create_with_file_scheme(man_file), "/bin/Help"); + })); help_menu->add_action(GUI::CommonActions::make_about_action("Spider"_string, app_icon, window)); window->set_resizable(false);