2020-02-16 19:28:08 +01:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-02-16 19:28:08 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <LibCore/ArgsParser.h>
|
|
|
|
|
#include <LibGUI/Application.h>
|
|
|
|
|
#include <LibGUI/Notification.h>
|
2020-03-29 19:04:05 +02:00
|
|
|
#include <LibGfx/Bitmap.h>
|
2022-01-30 11:53:20 +01:00
|
|
|
#include <LibMain/Main.h>
|
2020-02-16 19:28:08 +01:00
|
|
|
|
2022-01-30 11:53:20 +01:00
|
|
|
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
2020-02-16 19:28:08 +01:00
|
|
|
{
|
2022-01-30 11:53:20 +01:00
|
|
|
auto app = TRY(GUI::Application::try_create(arguments));
|
2020-02-16 19:28:08 +01:00
|
|
|
|
|
|
|
|
Core::ArgsParser args_parser;
|
2022-04-01 20:58:27 +03:00
|
|
|
char const* title = nullptr;
|
|
|
|
|
char const* message = nullptr;
|
|
|
|
|
char const* icon_path = nullptr;
|
2020-02-16 19:28:08 +01:00
|
|
|
args_parser.add_positional_argument(title, "Title of the notification", "title");
|
|
|
|
|
args_parser.add_positional_argument(message, "Message to display in the notification", "message");
|
2020-03-26 20:38:28 +01:00
|
|
|
args_parser.add_positional_argument(icon_path, "Path of icon to display in the notification", "icon-path", Core::ArgsParser::Required::No);
|
2022-01-30 11:53:20 +01:00
|
|
|
args_parser.parse(arguments);
|
2020-02-16 19:28:08 +01:00
|
|
|
|
2022-01-30 11:53:20 +01:00
|
|
|
auto notification = TRY(GUI::Notification::try_create());
|
2020-02-16 19:28:08 +01:00
|
|
|
notification->set_text(message);
|
|
|
|
|
notification->set_title(title);
|
2021-12-25 16:35:47 +01:00
|
|
|
if (icon_path) {
|
2022-01-30 11:53:20 +01:00
|
|
|
notification->set_icon(TRY(Gfx::Bitmap::try_load_from_file(icon_path)));
|
2021-12-25 16:35:47 +01:00
|
|
|
}
|
2020-02-16 19:28:08 +01:00
|
|
|
notification->show();
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|