mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:07:47 +00:00
ImageViewer: Port to LibMain :^)
This commit is contained in:
parent
ba4fd8fa15
commit
f526325e24
2 changed files with 8 additions and 10 deletions
|
@ -11,4 +11,4 @@ set(SOURCES
|
||||||
)
|
)
|
||||||
|
|
||||||
serenity_app(ImageViewer ICON filetype-image)
|
serenity_app(ImageViewer ICON filetype-image)
|
||||||
target_link_libraries(ImageViewer LibDesktop LibGUI LibGfx LibImageDecoderClient)
|
target_link_libraries(ImageViewer LibDesktop LibGUI LibGfx LibImageDecoderClient LibMain)
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include "ViewWidget.h"
|
#include "ViewWidget.h"
|
||||||
#include <AK/URL.h>
|
#include <AK/URL.h>
|
||||||
#include <LibCore/ArgsParser.h>
|
#include <LibCore/ArgsParser.h>
|
||||||
|
#include <LibCore/System.h>
|
||||||
#include <LibDesktop/Launcher.h>
|
#include <LibDesktop/Launcher.h>
|
||||||
#include <LibGUI/Action.h>
|
#include <LibGUI/Action.h>
|
||||||
#include <LibGUI/Application.h>
|
#include <LibGUI/Application.h>
|
||||||
|
@ -25,20 +26,17 @@
|
||||||
#include <LibGfx/Bitmap.h>
|
#include <LibGfx/Bitmap.h>
|
||||||
#include <LibGfx/Palette.h>
|
#include <LibGfx/Palette.h>
|
||||||
#include <LibGfx/Rect.h>
|
#include <LibGfx/Rect.h>
|
||||||
|
#include <LibMain/Main.h>
|
||||||
#include <serenity.h>
|
#include <serenity.h>
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
using namespace ImageViewer;
|
using namespace ImageViewer;
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
{
|
{
|
||||||
if (pledge("stdio recvfd sendfd rpath wpath cpath unix thread", nullptr) < 0) {
|
TRY(Core::System::pledge("stdio recvfd sendfd rpath wpath cpath unix thread", nullptr));
|
||||||
perror("pledge");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto app = GUI::Application::construct(argc, argv);
|
auto app = TRY(GUI::Application::try_create(arguments));
|
||||||
|
|
||||||
if (!Desktop::Launcher::add_allowed_handler_with_any_url("/bin/ImageViewer")) {
|
if (!Desktop::Launcher::add_allowed_handler_with_any_url("/bin/ImageViewer")) {
|
||||||
warnln("Failed to set up allowed launch URLs");
|
warnln("Failed to set up allowed launch URLs");
|
||||||
|
@ -61,9 +59,9 @@ int main(int argc, char** argv)
|
||||||
const char* path = nullptr;
|
const char* path = nullptr;
|
||||||
Core::ArgsParser args_parser;
|
Core::ArgsParser args_parser;
|
||||||
args_parser.add_positional_argument(path, "The image file to be displayed.", "file", Core::ArgsParser::Required::No);
|
args_parser.add_positional_argument(path, "The image file to be displayed.", "file", Core::ArgsParser::Required::No);
|
||||||
args_parser.parse(argc, argv);
|
args_parser.parse(arguments);
|
||||||
|
|
||||||
auto window = GUI::Window::construct();
|
auto window = TRY(GUI::Window::try_create());
|
||||||
window->set_double_buffering_enabled(true);
|
window->set_double_buffering_enabled(true);
|
||||||
window->resize(300, 200);
|
window->resize(300, 200);
|
||||||
window->set_icon(app_icon.bitmap_for_size(16));
|
window->set_icon(app_icon.bitmap_for_size(16));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue