mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 09:34:59 +00:00
notify: Port to LibMain
This commit is contained in:
parent
a64b44377d
commit
5d41f993cd
2 changed files with 7 additions and 11 deletions
|
@ -139,7 +139,7 @@ target_link_libraries(mount LibMain)
|
|||
target_link_libraries(nc LibMain)
|
||||
target_link_libraries(netstat LibMain)
|
||||
target_link_libraries(nl LibMain)
|
||||
target_link_libraries(notify LibGUI)
|
||||
target_link_libraries(notify LibGUI LibMain)
|
||||
target_link_libraries(nproc LibMain)
|
||||
target_link_libraries(open LibDesktop)
|
||||
target_link_libraries(pape LibGUI)
|
||||
|
|
|
@ -8,10 +8,11 @@
|
|||
#include <LibGUI/Application.h>
|
||||
#include <LibGUI/Notification.h>
|
||||
#include <LibGfx/Bitmap.h>
|
||||
#include <LibMain/Main.h>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
{
|
||||
auto app = GUI::Application::construct(argc, argv);
|
||||
auto app = TRY(GUI::Application::try_create(arguments));
|
||||
|
||||
Core::ArgsParser args_parser;
|
||||
const char* title = nullptr;
|
||||
|
@ -20,18 +21,13 @@ int main(int argc, char** argv)
|
|||
args_parser.add_positional_argument(title, "Title of the notification", "title");
|
||||
args_parser.add_positional_argument(message, "Message to display in the notification", "message");
|
||||
args_parser.add_positional_argument(icon_path, "Path of icon to display in the notification", "icon-path", Core::ArgsParser::Required::No);
|
||||
args_parser.parse(argc, argv);
|
||||
args_parser.parse(arguments);
|
||||
|
||||
auto notification = GUI::Notification::construct();
|
||||
auto notification = TRY(GUI::Notification::try_create());
|
||||
notification->set_text(message);
|
||||
notification->set_title(title);
|
||||
if (icon_path) {
|
||||
ErrorOr<NonnullRefPtr<Gfx::Bitmap>> icon_or_error = Gfx::Bitmap::try_load_from_file(icon_path);
|
||||
if (icon_or_error.is_error()) {
|
||||
warnln("Failed to load icon: {}", icon_or_error.error());
|
||||
return 1;
|
||||
}
|
||||
notification->set_icon(icon_or_error.release_value());
|
||||
notification->set_icon(TRY(Gfx::Bitmap::try_load_from_file(icon_path)));
|
||||
}
|
||||
notification->show();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue