From 570d63b601e5362ce73e850ae68fc3266bbd41e5 Mon Sep 17 00:00:00 2001 From: David Lindbom Date: Sun, 9 Jan 2022 20:25:38 +0100 Subject: [PATCH] FlappyBug: Add link to help pages in menu --- Userland/Games/FlappyBug/CMakeLists.txt | 2 +- Userland/Games/FlappyBug/main.cpp | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Userland/Games/FlappyBug/CMakeLists.txt b/Userland/Games/FlappyBug/CMakeLists.txt index 596bb07fd1..05031cc29a 100644 --- a/Userland/Games/FlappyBug/CMakeLists.txt +++ b/Userland/Games/FlappyBug/CMakeLists.txt @@ -10,4 +10,4 @@ set(SOURCES ) serenity_app(FlappyBug ICON app-flappybug) -target_link_libraries(FlappyBug LibGUI LibConfig LibMain) +target_link_libraries(FlappyBug LibGUI LibConfig LibMain LibDesktop) diff --git a/Userland/Games/FlappyBug/main.cpp b/Userland/Games/FlappyBug/main.cpp index fc6aac43e8..4bda06ce93 100644 --- a/Userland/Games/FlappyBug/main.cpp +++ b/Userland/Games/FlappyBug/main.cpp @@ -5,8 +5,10 @@ */ #include "Game.h" +#include #include #include +#include #include #include #include @@ -23,9 +25,13 @@ ErrorOr serenity_main(Main::Arguments arguments) Config::pledge_domains("FlappyBug"); + TRY(Desktop::Launcher::add_allowed_handler_with_only_specific_urls("/bin/Help", { URL::create_with_file_protocol("/usr/share/man/man6/FlappyBug.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)); u32 high_score = Config::read_i32("FlappyBug", "Game", "HighScore", 0); @@ -55,6 +61,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/FlappyBug.md"), "/bin/Help"); + }))); TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action("Flappy Bug", app_icon, window))); window->show();