From 5d09f4abce0510d79a5b8e47c743b4aff9a20f4e Mon Sep 17 00:00:00 2001 From: thankyouverycool <66646555+thankyouverycool@users.noreply.github.com> Date: Mon, 18 Oct 2021 07:48:26 -0400 Subject: [PATCH] Welcome: Save startup preference to user's SystemServer session Off by default. --- Userland/Applications/Welcome/WelcomeWidget.cpp | 9 +++++++++ Userland/Applications/Welcome/WelcomeWidget.h | 1 + Userland/Applications/Welcome/WelcomeWindow.gml | 4 ++-- Userland/Applications/Welcome/main.cpp | 3 +++ 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Userland/Applications/Welcome/WelcomeWidget.cpp b/Userland/Applications/Welcome/WelcomeWidget.cpp index 39442953bd..439cfc0543 100644 --- a/Userland/Applications/Welcome/WelcomeWidget.cpp +++ b/Userland/Applications/Welcome/WelcomeWidget.cpp @@ -7,10 +7,12 @@ #include "WelcomeWidget.h" #include #include +#include #include #include #include #include +#include #include #include #include @@ -66,6 +68,13 @@ WelcomeWidget::WelcomeWidget() GUI::Application::the()->quit(); }; + auto exec_path = Config::read_string("SystemServer", "Welcome", "Executable", {}); + m_startup_checkbox = *find_descendant_of_type_named("startup_checkbox"); + m_startup_checkbox->set_checked(!exec_path.is_empty()); + m_startup_checkbox->on_checked = [](bool is_checked) { + Config::write_string("SystemServer", "Welcome", "Executable", is_checked ? "/bin/Welcome" : ""); + }; + open_and_parse_readme_file(); open_and_parse_tips_file(); set_random_tip(); diff --git a/Userland/Applications/Welcome/WelcomeWidget.h b/Userland/Applications/Welcome/WelcomeWidget.h index c8d490a1f0..a0853b0d18 100644 --- a/Userland/Applications/Welcome/WelcomeWidget.h +++ b/Userland/Applications/Welcome/WelcomeWidget.h @@ -29,6 +29,7 @@ private: RefPtr m_help_button; RefPtr m_new_button; RefPtr m_tip_label; + RefPtr m_startup_checkbox; RefPtr m_web_view; size_t m_initial_tip_index { 0 }; diff --git a/Userland/Applications/Welcome/WelcomeWindow.gml b/Userland/Applications/Welcome/WelcomeWindow.gml index bf3ef46c71..77b7394aa5 100644 --- a/Userland/Applications/Welcome/WelcomeWindow.gml +++ b/Userland/Applications/Welcome/WelcomeWindow.gml @@ -104,8 +104,8 @@ @GUI::CheckBox{ name: "startup_checkbox" - text: "Show this Welcome Screen next time SerenityOS starts" - fixed_width: 315 + text: "Show Welcome the next time SerenityOS starts" + autosize: true } @GUI::Widget diff --git a/Userland/Applications/Welcome/main.cpp b/Userland/Applications/Welcome/main.cpp index d939153008..86419ff85c 100644 --- a/Userland/Applications/Welcome/main.cpp +++ b/Userland/Applications/Welcome/main.cpp @@ -5,6 +5,7 @@ */ #include "WelcomeWidget.h" +#include #include #include #include @@ -19,6 +20,8 @@ int main(int argc, char** argv) auto app = GUI::Application::construct(argc, argv); + Config::pledge_domains("SystemServer"); + if (unveil("/res", "r") < 0) { perror("unveil"); return 1;