2020-02-16 13:28:08 -05:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
*
|
2021-04-22 04:24:48 -04:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-02-16 13:28:08 -05:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <LibCore/ArgsParser.h>
|
|
|
|
#include <LibGUI/Application.h>
|
|
|
|
#include <LibGUI/Notification.h>
|
2020-03-29 13:04:05 -04:00
|
|
|
#include <LibGfx/Bitmap.h>
|
2022-01-30 05:53:20 -05:00
|
|
|
#include <LibMain/Main.h>
|
2020-02-16 13:28:08 -05:00
|
|
|
|
2022-01-30 05:53:20 -05:00
|
|
|
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
2020-02-16 13:28:08 -05:00
|
|
|
{
|
2023-05-05 00:24:53 -04:00
|
|
|
auto app = TRY(GUI::Application::create(arguments));
|
2020-02-16 13:28:08 -05:00
|
|
|
|
|
|
|
Core::ArgsParser args_parser;
|
2023-08-31 12:50:32 -04:00
|
|
|
String title {};
|
|
|
|
String message {};
|
2022-07-11 16:42:03 -04:00
|
|
|
StringView icon_path {};
|
2024-11-17 09:09:47 -05:00
|
|
|
StringView launch_url {};
|
2020-02-16 13:28:08 -05: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");
|
2024-11-17 09:09:47 -05:00
|
|
|
args_parser.add_option(icon_path, "Path of icon to display in the notification", "icon-path", 'I', "icon_path");
|
|
|
|
args_parser.add_option(launch_url, "Launch URL for the notification", "launch-url", 'L', "launch_url");
|
2022-01-30 05:53:20 -05:00
|
|
|
args_parser.parse(arguments);
|
2020-02-16 13:28:08 -05:00
|
|
|
|
2023-09-18 01:00:51 -04:00
|
|
|
auto notification = GUI::Notification::construct();
|
2020-02-16 13:28:08 -05:00
|
|
|
notification->set_text(message);
|
|
|
|
notification->set_title(title);
|
2022-07-11 16:42:03 -04:00
|
|
|
if (!icon_path.is_empty()) {
|
2023-01-20 14:06:05 -05:00
|
|
|
notification->set_icon(TRY(Gfx::Bitmap::load_from_file(icon_path)));
|
2021-12-25 10:35:47 -05:00
|
|
|
}
|
2024-11-17 09:09:47 -05:00
|
|
|
notification->set_launch_url(launch_url);
|
2020-02-16 13:28:08 -05:00
|
|
|
notification->show();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|