/* * Copyright (c) 2020, Andreas Kling * Copyright (c) 2021, Jakob-Niklas See * Copyright (c) 2021-2022, Sam Atkins * Copyright (c) 2021, Antonio Di Stefano * Copyright (c) 2022, Filiph Sandström * * SPDX-License-Identifier: BSD-2-Clause */ #include "MainWidget.h" #include "PreviewWidget.h" #include #include #include #include #include #include #include #include #include #include ErrorOr serenity_main(Main::Arguments arguments) { TRY(Core::System::pledge("stdio recvfd sendfd thread rpath cpath wpath unix")); auto app = TRY(GUI::Application::try_create(arguments)); char const* file_to_edit = nullptr; Core::ArgsParser parser; parser.add_positional_argument(file_to_edit, "Theme file to edit", "file", Core::ArgsParser::Required::No); parser.parse(arguments); Optional path = {}; if (file_to_edit) { path = Core::File::absolute_path(file_to_edit); if (Core::File::exists(*path)) { dbgln("unveil for: {}", *path); if (unveil(path->characters(), "r") < 0) { perror("unveil"); return 1; } } } TRY(Core::System::pledge("stdio recvfd sendfd thread rpath unix")); TRY(Core::System::unveil("/tmp/portal/filesystemaccess", "rw")); TRY(Core::System::unveil("/res", "r")); TRY(Core::System::unveil(nullptr, nullptr)); auto app_icon = GUI::Icon::default_icon("app-theme-editor"sv); auto window = GUI::Window::construct(); auto main_widget = TRY(window->try_set_main_widget()); if (path.has_value()) main_widget->load_from_file(TRY(Core::File::open(*path, Core::OpenMode::ReadOnly))); TRY(main_widget->initialize_menubar(window)); main_widget->update_title(); window->on_close_request = [&]() -> GUI::Window::CloseRequestDecision { return main_widget->request_close(); }; window->resize(820, 520); window->set_resizable(false); window->show(); window->set_icon(app_icon.bitmap_for_size(16)); return app->exec(); }