From 35fe1b39a2fa4613239a3bd0fb88f4d8412bd4d4 Mon Sep 17 00:00:00 2001 From: Brendan Coles Date: Sun, 3 Jan 2021 12:16:37 +0000 Subject: [PATCH] FontEditor: Add help documentation --- Applications/FontEditor/CMakeLists.txt | 2 +- Applications/FontEditor/main.cpp | 20 +++++++++++++++++++- Base/usr/share/man/man1/FontEditor.md | 19 +++++++++++++++++++ 3 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 Base/usr/share/man/man1/FontEditor.md diff --git a/Applications/FontEditor/CMakeLists.txt b/Applications/FontEditor/CMakeLists.txt index 079b7a521a..569ab9a9bd 100644 --- a/Applications/FontEditor/CMakeLists.txt +++ b/Applications/FontEditor/CMakeLists.txt @@ -8,4 +8,4 @@ set(SOURCES ) serenity_app(FontEditor ICON app-font-editor) -target_link_libraries(FontEditor LibGUI LibGfx) +target_link_libraries(FontEditor LibGUI LibDesktop LibGfx) diff --git a/Applications/FontEditor/main.cpp b/Applications/FontEditor/main.cpp index 873248bd4e..756a0dba06 100644 --- a/Applications/FontEditor/main.cpp +++ b/Applications/FontEditor/main.cpp @@ -25,7 +25,9 @@ */ #include "FontEditor.h" +#include #include +#include #include #include #include @@ -43,13 +45,26 @@ int main(int argc, char** argv) { - if (pledge("stdio shared_buffer thread rpath accept unix cpath wpath fattr", nullptr) < 0) { + if (pledge("stdio shared_buffer thread rpath accept unix cpath wpath fattr unix", nullptr) < 0) { perror("pledge"); return 1; } auto app = GUI::Application::construct(argc, argv); + if (pledge("stdio shared_buffer thread rpath accept cpath wpath unix", nullptr) < 0) { + perror("pledge"); + return 1; + } + + if (!Desktop::Launcher::add_allowed_handler_with_only_specific_urls( + "/bin/Help", + { URL::create_with_file_protocol("/usr/share/man/man1/FontEditor.md") }) + || !Desktop::Launcher::seal_allowlist()) { + warnln("Failed to set up allowed launch URLs"); + return 1; + } + if (pledge("stdio shared_buffer thread rpath accept cpath wpath", nullptr) < 0) { perror("pledge"); return 1; @@ -127,6 +142,9 @@ int main(int argc, char** argv) })); auto& help_menu = menubar->add_menu("Help"); + help_menu.add_action(GUI::CommonActions::make_help_action([](auto&) { + Desktop::Launcher::open(URL::create_with_file_protocol("/usr/share/man/man1/FontEditor.md"), "/bin/Help"); + })); help_menu.add_action(GUI::Action::create("About", [&](const GUI::Action&) { GUI::AboutDialog::show("Font Editor", app_icon.bitmap_for_size(32), window); })); diff --git a/Base/usr/share/man/man1/FontEditor.md b/Base/usr/share/man/man1/FontEditor.md new file mode 100644 index 0000000000..3d4af06eae --- /dev/null +++ b/Base/usr/share/man/man1/FontEditor.md @@ -0,0 +1,19 @@ +## Name + +FontEditor - Serenity font editor + +## Synopsis + +```**sh +$ FontEditor [file] +``` + +## Description + +FontEditor is a font editing application for Serenity. + +## Examples + +```sh +$ FontEditor /res/fonts/CsillaRegular10.font +```