mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-24 10:12:25 -05:00
a17fbd98e7
Currently the two available input types are: - GMessageBox::InputType::OK (default) - GMessageBox::InputType::OKCancel Based on your choice, GMessageBox::exec() will return ExecOK or ExecCancel.
49 lines
1.2 KiB
C++
49 lines
1.2 KiB
C++
#include <LibGUI/GApplication.h>
|
|
#include <LibGUI/GBoxLayout.h>
|
|
#include <LibGUI/GButton.h>
|
|
#include <LibGUI/GDesktop.h>
|
|
#include <LibGUI/GLabel.h>
|
|
#include <LibGUI/GMessageBox.h>
|
|
#include <LibGUI/GWindow.h>
|
|
#include <stdio.h>
|
|
#include <sys/utsname.h>
|
|
|
|
static int run_shutdown_dialog(int argc, char** argv);
|
|
|
|
int main(int argc, char** argv)
|
|
{
|
|
if (argc != 2) {
|
|
printf("usage: SystemDialog <type>\n");
|
|
return 0;
|
|
}
|
|
|
|
if (String(argv[1]) == "--shutdown")
|
|
return run_shutdown_dialog(argc, argv);
|
|
|
|
fprintf(stderr, "Unknown argument: %s\n", argv[1]);
|
|
return 1;
|
|
}
|
|
|
|
int run_shutdown_dialog(int argc, char** argv)
|
|
{
|
|
GApplication app(argc, argv);
|
|
|
|
{
|
|
GMessageBox box("Shut down Serenity?", "Confirm Shutdown", GMessageBox::Type::Warning, GMessageBox::InputType::OKCancel);
|
|
auto result = box.exec();
|
|
|
|
if (result == GMessageBox::ExecOK) {
|
|
dbg() << "OK";
|
|
int rc = execl("/bin/shutdown", "/bin/shutdown", "-n", nullptr);
|
|
if (rc < 0) {
|
|
perror("execl");
|
|
return 1;
|
|
}
|
|
} else {
|
|
dbg() << "Cancel";
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
return app.exec();
|
|
}
|