PixelPaint: Port to LibMain
This commit is contained in:
parent
55db1811c7
commit
bec7ffaf0a
Notes:
sideshowbarker
2024-07-18 00:50:45 +09:00
Author: https://github.com/pascalpuffke 🔰 Commit: https://github.com/SerenityOS/serenity/commit/bec7ffaf0a2 Pull-request: https://github.com/SerenityOS/serenity/pull/11018
2 changed files with 12 additions and 35 deletions
|
@ -45,4 +45,4 @@ set(SOURCES
|
|||
)
|
||||
|
||||
serenity_app(PixelPaint ICON app-pixel-paint)
|
||||
target_link_libraries(PixelPaint LibImageDecoderClient LibGUI LibGfx LibFileSystemAccessClient LibConfig)
|
||||
target_link_libraries(PixelPaint LibImageDecoderClient LibGUI LibGfx LibFileSystemAccessClient LibConfig LibMain)
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#include "MainWidget.h"
|
||||
#include <LibConfig/Client.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibFileSystemAccessClient/Client.h>
|
||||
#include <LibGUI/Action.h>
|
||||
#include <LibGUI/Application.h>
|
||||
|
@ -17,48 +16,26 @@
|
|||
#include <LibGUI/Statusbar.h>
|
||||
#include <LibGUI/Window.h>
|
||||
#include <LibGfx/Painter.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <LibMain/Main.h>
|
||||
#include <LibSystem/Wrappers.h>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
{
|
||||
if (pledge("stdio thread recvfd sendfd rpath unix wpath cpath", nullptr) < 0) {
|
||||
perror("pledge");
|
||||
return 1;
|
||||
}
|
||||
TRY(System::pledge("stdio thread recvfd sendfd rpath unix wpath cpath", nullptr));
|
||||
|
||||
auto app = GUI::Application::construct(argc, argv);
|
||||
auto app = GUI::Application::construct(arguments.argc, arguments.argv);
|
||||
Config::pledge_domains("PixelPaint");
|
||||
|
||||
const char* image_file = nullptr;
|
||||
Core::ArgsParser args_parser;
|
||||
args_parser.add_positional_argument(image_file, "Image file to open", "path", Core::ArgsParser::Required::No);
|
||||
args_parser.parse(argc, argv);
|
||||
args_parser.parse(arguments.argc, arguments.argv);
|
||||
|
||||
if (unveil("/res", "r") < 0) {
|
||||
perror("unveil");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (unveil("/tmp/portal/clipboard", "rw") < 0) {
|
||||
perror("unveil");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (unveil("/tmp/portal/filesystemaccess", "rw") < 0) {
|
||||
perror("unveil");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (unveil("/tmp/portal/image", "rw") < 0) {
|
||||
perror("unveil");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (unveil(nullptr, nullptr) < 0) {
|
||||
perror("unveil");
|
||||
return 1;
|
||||
}
|
||||
TRY(System::unveil("/res", "r"));
|
||||
TRY(System::unveil("/tmp/portal/clipboard", "rw"));
|
||||
TRY(System::unveil("/tmp/portal/filesystemaccess", "rw"));
|
||||
TRY(System::unveil("/tmp/portal/image", "rw"));
|
||||
TRY(System::unveil(nullptr, nullptr));
|
||||
|
||||
auto app_icon = GUI::Icon::default_icon("app-pixel-paint");
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue