summaryrefslogtreecommitdiff
path: root/Userland/Games/Snake/main.cpp
diff options
context:
space:
mode:
authorDavid Lindbom <hi@davidlindbom.se>2022-01-09 20:32:44 +0100
committerBrian Gianforcaro <b.gianfo@gmail.com>2022-01-13 03:45:17 -0800
commit1e773256bf321201f36fe39035dadeb48e3a62c4 (patch)
treec564f29f193b51852fcde81bb37c29a1463cdd4e /Userland/Games/Snake/main.cpp
parentfff9547d9bcaeab82b979d8d2d8208cb60362073 (diff)
downloadserenity-1e773256bf321201f36fe39035dadeb48e3a62c4.zip
Snake: Add link to help pages in menu
Diffstat (limited to 'Userland/Games/Snake/main.cpp')
-rw-r--r--Userland/Games/Snake/main.cpp9
1 files changed, 9 insertions, 0 deletions
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 <AK/URL.h>
#include <LibConfig/Client.h>
#include <LibCore/System.h>
+#include <LibDesktop/Launcher.h>
#include <LibGUI/Action.h>
#include <LibGUI/Application.h>
#include <LibGUI/BoxLayout.h>
@@ -26,9 +28,13 @@ ErrorOr<int> 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<int> 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();