1
0
mirror of https://github.com/SerenityOS/serenity synced 2024-07-09 10:40:45 +00:00

Welcome: Move tips.txt to /usr/share/Welcome because it's system wide

This commit is contained in:
Bastiaan van der Plaat 2024-01-29 19:18:19 +01:00 committed by Jelle Raaijmakers
parent 813c66403d
commit f4d5ff9ed9
3 changed files with 7 additions and 4 deletions

View File

@ -19,6 +19,9 @@
#include <LibGfx/Palette.h>
namespace Welcome {
static String tips_file_path = "/usr/share/Welcome/tips.txt"_string;
ErrorOr<NonnullRefPtr<WelcomeWidget>> WelcomeWidget::create()
{
auto welcome_widget = TRY(WelcomeWidget::try_create());
@ -79,8 +82,7 @@ ErrorOr<void> WelcomeWidget::create_widgets()
};
if (auto result = open_and_parse_tips_file(); result.is_error()) {
auto path = TRY(String::formatted("{}/tips.txt", Core::StandardPaths::documents_directory()));
auto error = TRY(String::formatted("Opening \"{}\" failed: {}", path, result.error()));
auto error = TRY(String::formatted("Opening \"{}\" failed: {}", tips_file_path, result.error()));
m_tip_label->set_text(error);
warnln(error);
}
@ -92,8 +94,7 @@ ErrorOr<void> WelcomeWidget::create_widgets()
ErrorOr<void> WelcomeWidget::open_and_parse_tips_file()
{
auto path = TRY(String::formatted("{}/tips.txt", Core::StandardPaths::documents_directory()));
auto file = TRY(Core::File::open(path, Core::File::OpenMode::Read));
auto file = TRY(Core::File::open(tips_file_path, Core::File::OpenMode::Read));
auto buffered_file = TRY(Core::InputBufferedFile::create(move(file)));
Array<u8, PAGE_SIZE> buffer;
@ -128,4 +129,5 @@ void WelcomeWidget::paint_event(GUI::PaintEvent& event)
rect.set_x(rect.x() + static_cast<int>(ceilf(m_banner_font->bold_variant().width("Serenity"sv))));
painter.draw_text(rect, "OS"sv, m_banner_font->bold_variant(), Gfx::TextAlignment::CenterLeft, palette().tray_text());
}
}

View File

@ -23,6 +23,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
TRY(Core::System::unveil("/tmp/session/%sid/portal/filesystemaccess", "rw"));
TRY(Core::System::unveil("/res", "r"));
TRY(Core::System::unveil("/home", "r"));
TRY(Core::System::unveil("/usr/share/Welcome", "r"));
TRY(Core::System::unveil("/bin/Help", "x"));
TRY(Core::System::unveil(nullptr, nullptr));
auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-welcome"sv));