mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-29 14:14:45 +03:00
LibGUI: Make GUI::Application a Core::Object
Having this on the stack makes whole-program teardown iffy. Turning it into a Core::Object allows anyone who needs it to extends its lifetime.
This commit is contained in:
parent
0d577ab781
commit
1dd1595043
Notes:
sideshowbarker
2024-07-19 05:11:31 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/1dd15950439
@ -37,7 +37,7 @@ int main(int argc, char** argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
GUI::Application app(argc, argv);
|
||||
auto app = GUI::Application::construct(argc, argv);
|
||||
|
||||
if (pledge("stdio shared_buffer accept rpath", nullptr) < 0) {
|
||||
perror("pledge");
|
||||
@ -52,5 +52,5 @@ int main(int argc, char** argv)
|
||||
unveil(nullptr, nullptr);
|
||||
|
||||
GUI::AboutDialog::show("SerenityOS", nullptr, nullptr, Gfx::Bitmap::load_from_file("/res/icons/16x16/ladybug.png"));
|
||||
return app.exec();
|
||||
return app->exec();
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ int main(int argc, char** argv)
|
||||
args_parser.add_positional_argument(specified_url, "URL to open", "url", Core::ArgsParser::Required::No);
|
||||
args_parser.parse(argc, argv);
|
||||
|
||||
GUI::Application app(argc, argv);
|
||||
auto app = GUI::Application::construct(argc, argv);
|
||||
|
||||
// Connect to the ProtocolServer immediately so we can drop the "unix" pledge.
|
||||
Web::ResourceLoader::the();
|
||||
@ -175,7 +175,7 @@ int main(int argc, char** argv)
|
||||
tab_widget.remove_tab(tab);
|
||||
tab_widget.set_bar_visible(!window->is_fullscreen() && tab_widget.children().size() > 1);
|
||||
if (tab_widget.children().is_empty())
|
||||
app.quit();
|
||||
app->quit();
|
||||
});
|
||||
};
|
||||
|
||||
@ -220,5 +220,5 @@ int main(int argc, char** argv)
|
||||
create_new_tab(first_url, true);
|
||||
window->show();
|
||||
|
||||
return app.exec();
|
||||
return app->exec();
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ int main(int argc, char** argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
GUI::Application app(argc, argv);
|
||||
auto app = GUI::Application::construct(argc, argv);
|
||||
|
||||
if (pledge("stdio shared_buffer rpath accept", nullptr) < 0) {
|
||||
perror("pledge");
|
||||
@ -78,7 +78,7 @@ int main(int argc, char** argv)
|
||||
GUI::AboutDialog::show("Calculator", Gfx::Bitmap::load_from_file("/res/icons/16x16/app-calculator.png"), window);
|
||||
}));
|
||||
|
||||
app.set_menubar(move(menubar));
|
||||
app->set_menubar(move(menubar));
|
||||
|
||||
return app.exec();
|
||||
return app->exec();
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ int main(int argc, char** argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
GUI::Application app(argc, argv);
|
||||
auto app = GUI::Application::construct(argc, argv);
|
||||
|
||||
if (pledge("stdio shared_buffer rpath accept", nullptr) < 0) {
|
||||
perror("pledge");
|
||||
@ -78,7 +78,7 @@ int main(int argc, char** argv)
|
||||
return;
|
||||
}));
|
||||
|
||||
app.set_menubar(move(menubar));
|
||||
app->set_menubar(move(menubar));
|
||||
|
||||
app.exec();
|
||||
app->exec();
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ int main(int argc, char** argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
GUI::Application app(argc, argv);
|
||||
auto app = GUI::Application::construct(argc, argv);
|
||||
|
||||
if (pledge("stdio thread shared_buffer rpath accept cpath wpath", nullptr) < 0) {
|
||||
perror("pledge");
|
||||
@ -64,7 +64,7 @@ int main(int argc, char** argv)
|
||||
|
||||
auto& app_menu = menubar->add_menu("Display settings");
|
||||
app_menu.add_action(GUI::CommonActions::make_quit_action([&](const GUI::Action&) {
|
||||
app.quit();
|
||||
app->quit();
|
||||
}));
|
||||
|
||||
auto& help_menu = menubar->add_menu("Help");
|
||||
@ -72,7 +72,7 @@ int main(int argc, char** argv)
|
||||
GUI::AboutDialog::show("Display settings", Gfx::Bitmap::load_from_file("/res/icons/32x32/app-display-settings.png"), window);
|
||||
}));
|
||||
|
||||
app.set_menubar(move(menubar));
|
||||
app->set_menubar(move(menubar));
|
||||
window->show();
|
||||
return app.exec();
|
||||
return app->exec();
|
||||
}
|
||||
|
@ -85,14 +85,14 @@ int main(int argc, char** argv)
|
||||
|
||||
RefPtr<Core::ConfigFile> config = Core::ConfigFile::get_for_app("FileManager");
|
||||
|
||||
GUI::Application app(argc, argv);
|
||||
auto app = GUI::Application::construct(argc, argv);
|
||||
|
||||
if (pledge("stdio thread shared_buffer accept cpath rpath wpath fattr proc exec unix", nullptr) < 0) {
|
||||
perror("pledge");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (app.args().contains_slow("--desktop") || app.args().contains_slow("-d"))
|
||||
if (app->args().contains_slow("--desktop") || app->args().contains_slow("-d"))
|
||||
return run_in_desktop_mode(move(config), Core::StandardPaths::desktop_directory());
|
||||
|
||||
// our initial location is defined as, in order of precedence:
|
||||
|
@ -45,7 +45,7 @@ int main(int argc, char** argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
GUI::Application app(argc, argv);
|
||||
auto app = GUI::Application::construct(argc, argv);
|
||||
|
||||
if (pledge("stdio shared_buffer rpath accept cpath wpath", nullptr) < 0) {
|
||||
perror("pledge");
|
||||
@ -96,9 +96,9 @@ int main(int argc, char** argv)
|
||||
GUI::AboutDialog::show("Font Editor", app_icon.bitmap_for_size(32), window);
|
||||
}));
|
||||
|
||||
app.set_menubar(move(menubar));
|
||||
app->set_menubar(move(menubar));
|
||||
|
||||
window->show();
|
||||
|
||||
return app.exec();
|
||||
return app->exec();
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ int main(int argc, char* argv[])
|
||||
return 1;
|
||||
}
|
||||
|
||||
GUI::Application app(argc, argv);
|
||||
auto app = GUI::Application::construct(argc, argv);
|
||||
|
||||
if (pledge("stdio shared_buffer accept rpath", nullptr) < 0) {
|
||||
perror("pledge");
|
||||
@ -201,12 +201,12 @@ int main(int argc, char* argv[])
|
||||
go_menu.add_action(*go_back_action);
|
||||
go_menu.add_action(*go_forward_action);
|
||||
|
||||
app.set_menubar(move(menubar));
|
||||
app->set_menubar(move(menubar));
|
||||
|
||||
window->set_focused_widget(&tree_view);
|
||||
window->show();
|
||||
|
||||
window->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/book.png"));
|
||||
|
||||
return app.exec();
|
||||
return app->exec();
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ int main(int argc, char** argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
GUI::Application app(argc, argv);
|
||||
auto app = GUI::Application::construct(argc, argv);
|
||||
|
||||
if (pledge("stdio shared_buffer accept rpath cpath wpath thread", nullptr) < 0) {
|
||||
perror("pledge");
|
||||
@ -60,5 +60,5 @@ int main(int argc, char** argv)
|
||||
if (argc >= 2)
|
||||
hex_editor_widget.open_file(argv[1]);
|
||||
|
||||
return app.exec();
|
||||
return app->exec();
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ int main(int argc, char** argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
GUI::Application app(argc, argv);
|
||||
auto app = GUI::Application::construct(argc, argv);
|
||||
|
||||
if (pledge("stdio inet dns unix shared_buffer rpath wpath cpath", nullptr) < 0) {
|
||||
perror("pledge");
|
||||
@ -50,8 +50,8 @@ int main(int argc, char** argv)
|
||||
}
|
||||
|
||||
URL url = "";
|
||||
if (app.args().size() >= 1) {
|
||||
url = URL::create_with_url_or_path(app.args()[0]);
|
||||
if (app->args().size() >= 1) {
|
||||
url = URL::create_with_url_or_path(app->args()[0]);
|
||||
|
||||
if (url.protocol().to_lowercase() == "ircs") {
|
||||
fprintf(stderr, "Secure IRC over SSL/TLS (ircs) is not supported\n");
|
||||
@ -74,5 +74,5 @@ int main(int argc, char** argv)
|
||||
|
||||
auto app_window = IRCAppWindow::construct(url.host(), url.port());
|
||||
app_window->show();
|
||||
return app.exec();
|
||||
return app->exec();
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ int main(int argc, char** argv)
|
||||
args_parser.add_positional_argument(path, "Keyboard character mapping file.", "file", Core::ArgsParser::Required::No);
|
||||
args_parser.parse(argc, argv);
|
||||
|
||||
GUI::Application app(argc, argv);
|
||||
auto app = GUI::Application::construct(argc, argv);
|
||||
|
||||
auto app_icon = GUI::Icon::default_icon("app-keyboard-mapper");
|
||||
|
||||
@ -87,7 +87,7 @@ int main(int argc, char** argv)
|
||||
|
||||
auto quit_action = GUI::CommonActions::make_quit_action(
|
||||
[&](auto&) {
|
||||
app.quit();
|
||||
app->quit();
|
||||
});
|
||||
|
||||
auto about_action = GUI::Action::create("About",
|
||||
@ -108,7 +108,7 @@ int main(int argc, char** argv)
|
||||
auto& help_menu = menubar->add_menu("Help");
|
||||
help_menu.add_action(about_action);
|
||||
|
||||
app.set_menubar(move(menubar));
|
||||
app->set_menubar(move(menubar));
|
||||
|
||||
return app.exec();
|
||||
return app->exec();
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ int main(int argc, char** argv)
|
||||
}
|
||||
|
||||
// If there is no command line parameter go for GUI.
|
||||
GUI::Application app(argc, argv);
|
||||
auto app = GUI::Application::construct(argc, argv);
|
||||
|
||||
if (pledge("stdio rpath accept shared_buffer proc exec", nullptr) < 0) {
|
||||
perror("pledge");
|
||||
@ -131,7 +131,7 @@ int main(int argc, char** argv)
|
||||
exit(1);
|
||||
}
|
||||
if (quit)
|
||||
app.quit();
|
||||
app->quit();
|
||||
};
|
||||
|
||||
auto& bottom_widget = root_widget.add<GUI::Widget>();
|
||||
@ -161,12 +161,12 @@ int main(int argc, char** argv)
|
||||
cancel_button.set_size_policy(Orientation::Horizontal, GUI::SizePolicy::Fixed);
|
||||
cancel_button.set_preferred_size(60, 22);
|
||||
cancel_button.on_click = [&](auto) {
|
||||
app.quit();
|
||||
app->quit();
|
||||
};
|
||||
|
||||
auto quit_action = GUI::CommonActions::make_quit_action(
|
||||
[&](auto&) {
|
||||
app.quit();
|
||||
app->quit();
|
||||
});
|
||||
|
||||
auto about_action = GUI::Action::create("About",
|
||||
@ -182,9 +182,9 @@ int main(int argc, char** argv)
|
||||
auto& help_menu = menubar->add_menu("Help");
|
||||
help_menu.add_action(about_action);
|
||||
|
||||
app.set_menubar(move(menubar));
|
||||
app->set_menubar(move(menubar));
|
||||
|
||||
window->show();
|
||||
|
||||
return app.exec();
|
||||
return app->exec();
|
||||
}
|
||||
|
@ -44,7 +44,7 @@
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
GUI::Application app(argc, argv);
|
||||
auto app = GUI::Application::construct(argc, argv);
|
||||
|
||||
auto audio_client = Audio::ClientConnection::construct();
|
||||
audio_client->handshake();
|
||||
@ -120,7 +120,7 @@ int main(int argc, char** argv)
|
||||
auto& edit_menu = menubar->add_menu("Edit");
|
||||
main_widget.add_actions(edit_menu);
|
||||
|
||||
app.set_menubar(move(menubar));
|
||||
app->set_menubar(move(menubar));
|
||||
|
||||
return app.exec();
|
||||
return app->exec();
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ int main(int argc, char** argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
GUI::Application app(argc, argv);
|
||||
auto app = GUI::Application::construct(argc, argv);
|
||||
|
||||
if (pledge("stdio thread shared_buffer accept rpath wpath cpath", nullptr) < 0) {
|
||||
perror("pledge");
|
||||
@ -196,7 +196,7 @@ int main(int argc, char** argv)
|
||||
GUI::AboutDialog::show("PixelPaint", app_icon.bitmap_for_size(32), window);
|
||||
}));
|
||||
|
||||
app.set_menubar(move(menubar));
|
||||
app->set_menubar(move(menubar));
|
||||
|
||||
image_editor.on_active_layer_change = [&](auto* layer) {
|
||||
layer_list_widget.set_selected_layer(layer);
|
||||
@ -227,5 +227,5 @@ int main(int argc, char** argv)
|
||||
image_editor.set_image(image);
|
||||
image_editor.set_active_layer(bg_layer);
|
||||
|
||||
return app.exec();
|
||||
return app->exec();
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ int main(int argc, char** argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
GUI::Application app(argc, argv);
|
||||
auto app = GUI::Application::construct(argc, argv);
|
||||
|
||||
if (pledge("stdio shared_buffer accept cpath rpath wpath proc exec thread", nullptr) < 0) {
|
||||
perror("pledge");
|
||||
@ -166,7 +166,7 @@ int main(int argc, char** argv)
|
||||
|
||||
auto quit_action = GUI::CommonActions::make_quit_action(
|
||||
[&](auto&) {
|
||||
app.quit();
|
||||
app->quit();
|
||||
});
|
||||
|
||||
auto rotate_left_action = GUI::Action::create("Rotate Left", { Mod_None, Key_L },
|
||||
@ -290,7 +290,7 @@ int main(int argc, char** argv)
|
||||
auto& help_menu = menubar->add_menu("Help");
|
||||
help_menu.add_action(about_action);
|
||||
|
||||
app.set_menubar(move(menubar));
|
||||
app->set_menubar(move(menubar));
|
||||
|
||||
if (path != nullptr) {
|
||||
widget.load_from_file(path);
|
||||
@ -298,5 +298,5 @@ int main(int argc, char** argv)
|
||||
|
||||
window->show();
|
||||
|
||||
return app.exec();
|
||||
return app->exec();
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ int main(int argc, char** argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
GUI::Application app(argc, argv);
|
||||
auto app = GUI::Application::construct(argc, argv);
|
||||
|
||||
if (pledge("stdio shared_buffer accept rpath unix", nullptr) < 0) {
|
||||
perror("pledge");
|
||||
@ -87,7 +87,7 @@ int main(int argc, char** argv)
|
||||
app_menu.add_action(move(hide_scope));
|
||||
app_menu.add_separator();
|
||||
app_menu.add_action(GUI::CommonActions::make_quit_action([&](auto&) {
|
||||
app.quit();
|
||||
app->quit();
|
||||
}));
|
||||
|
||||
auto& help_menu = menubar->add_menu("Help");
|
||||
@ -95,8 +95,8 @@ int main(int argc, char** argv)
|
||||
GUI::AboutDialog::show("SoundPlayer", Gfx::Bitmap::load_from_file("/res/icons/32x32/app-sound-player.png"), window);
|
||||
}));
|
||||
|
||||
app.set_menubar(move(menubar));
|
||||
app->set_menubar(move(menubar));
|
||||
|
||||
window->show();
|
||||
return app.exec();
|
||||
return app->exec();
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ int main(int argc, char** argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
GUI::Application app(argc, argv);
|
||||
auto app = GUI::Application::construct(argc, argv);
|
||||
|
||||
if (pledge("stdio proc shared_buffer accept rpath exec", nullptr) < 0) {
|
||||
perror("pledge");
|
||||
@ -269,7 +269,7 @@ int main(int argc, char** argv)
|
||||
GUI::AboutDialog::show("System Monitor", Gfx::Bitmap::load_from_file("/res/icons/32x32/app-system-monitor.png"), window);
|
||||
}));
|
||||
|
||||
app.set_menubar(move(menubar));
|
||||
app->set_menubar(move(menubar));
|
||||
|
||||
auto& process_tab_unused_widget = process_container_splitter.add<UnavailableProcessWidget>("No process selected");
|
||||
process_tab_unused_widget.set_visible(true);
|
||||
@ -302,7 +302,7 @@ int main(int argc, char** argv)
|
||||
|
||||
window->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-system-monitor.png"));
|
||||
|
||||
return app.exec();
|
||||
return app->exec();
|
||||
}
|
||||
|
||||
class ProgressBarPaintingDelegate final : public GUI::TableCellPaintingDelegate {
|
||||
|
@ -209,7 +209,7 @@ int main(int argc, char** argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
GUI::Application app(argc, argv);
|
||||
auto app = GUI::Application::construct(argc, argv);
|
||||
|
||||
if (pledge("stdio tty rpath accept cpath wpath shared_buffer proc exec unix", nullptr) < 0) {
|
||||
perror("pledge");
|
||||
@ -251,7 +251,7 @@ int main(int argc, char** argv)
|
||||
|
||||
auto& terminal = window->set_main_widget<TerminalWidget>(ptm_fd, true, config);
|
||||
terminal.on_command_exit = [&] {
|
||||
app.quit(0);
|
||||
app->quit(0);
|
||||
};
|
||||
terminal.on_title_change = [&](auto& title) {
|
||||
window->set_title(title);
|
||||
@ -321,7 +321,7 @@ int main(int argc, char** argv)
|
||||
GUI::AboutDialog::show("Terminal", Gfx::Bitmap::load_from_file("/res/icons/32x32/app-terminal.png"), window);
|
||||
}));
|
||||
|
||||
app.set_menubar(move(menubar));
|
||||
app->set_menubar(move(menubar));
|
||||
|
||||
if (unveil("/res", "r") < 0) {
|
||||
perror("unveil");
|
||||
@ -346,5 +346,5 @@ int main(int argc, char** argv)
|
||||
unveil(nullptr, nullptr);
|
||||
|
||||
config->sync();
|
||||
return app.exec();
|
||||
return app->exec();
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ int main(int argc, char** argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
GUI::Application app(argc, argv);
|
||||
auto app = GUI::Application::construct(argc, argv);
|
||||
|
||||
if (pledge("stdio thread rpath accept cpath wpath shared_buffer unix", nullptr) < 0) {
|
||||
perror("pledge");
|
||||
@ -62,5 +62,5 @@ int main(int argc, char** argv)
|
||||
window->show();
|
||||
window->set_icon(Gfx::Bitmap::load_from_file("/res/icons/TextEditor16.png"));
|
||||
|
||||
return app.exec();
|
||||
return app->exec();
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ int main(int argc, char** argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
GUI::Application app(argc, argv);
|
||||
auto app = GUI::Application::construct(argc, argv);
|
||||
|
||||
if (pledge("stdio shared_buffer rpath", nullptr) < 0) {
|
||||
perror("pledge");
|
||||
@ -257,5 +257,5 @@ int main(int argc, char** argv)
|
||||
}
|
||||
|
||||
window->show();
|
||||
return app.exec();
|
||||
return app->exec();
|
||||
}
|
||||
|
@ -190,7 +190,7 @@ void Cube::timer_event(Core::TimerEvent&)
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
GUI::Application app(argc, argv);
|
||||
auto app = GUI::Application::construct(argc, argv);
|
||||
|
||||
auto window = GUI::Window::construct();
|
||||
window->set_double_buffering_enabled(true);
|
||||
@ -209,5 +209,5 @@ int main(int argc, char** argv)
|
||||
window->show();
|
||||
window->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-cube.png"));
|
||||
|
||||
return app.exec();
|
||||
return app->exec();
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ int main(int argc, char* argv[])
|
||||
return 1;
|
||||
}
|
||||
|
||||
GUI::Application app(argc, argv);
|
||||
auto app = GUI::Application::construct(argc, argv);
|
||||
|
||||
if (pledge("stdio shared_buffer accept rpath cpath wpath thread", nullptr) < 0) {
|
||||
perror("pledge");
|
||||
@ -58,5 +58,5 @@ int main(int argc, char* argv[])
|
||||
window->show();
|
||||
eyes.track_cursor_globally();
|
||||
|
||||
return app.exec();
|
||||
return app->exec();
|
||||
}
|
||||
|
@ -222,7 +222,7 @@ void Fire::mouseup_event(GUI::MouseEvent& event)
|
||||
*/
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
GUI::Application app(argc, argv);
|
||||
auto app = GUI::Application::construct(argc, argv);
|
||||
|
||||
auto window = GUI::Window::construct();
|
||||
window->set_double_buffering_enabled(false);
|
||||
@ -241,5 +241,5 @@ int main(int argc, char** argv)
|
||||
window->show();
|
||||
window->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-fire.png"));
|
||||
|
||||
return app.exec();
|
||||
return app->exec();
|
||||
}
|
||||
|
@ -33,7 +33,7 @@
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
GUI::Application app(argc, argv);
|
||||
auto app = GUI::Application::construct(argc, argv);
|
||||
|
||||
auto window = GUI::Window::construct();
|
||||
window->set_rect(100, 100, 240, 160);
|
||||
@ -53,10 +53,10 @@ int main(int argc, char** argv)
|
||||
button.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||
button.set_preferred_size(0, 20);
|
||||
button.on_click = [&](auto) {
|
||||
app.quit();
|
||||
app->quit();
|
||||
};
|
||||
|
||||
window->show();
|
||||
|
||||
return app.exec();
|
||||
return app->exec();
|
||||
}
|
||||
|
@ -196,7 +196,7 @@ void Canvas::draw()
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
GUI::Application app(argc, argv);
|
||||
auto app = GUI::Application::construct(argc, argv);
|
||||
|
||||
auto window = GUI::Window::construct();
|
||||
window->set_double_buffering_enabled(true);
|
||||
@ -206,5 +206,5 @@ int main(int argc, char** argv)
|
||||
window->set_main_widget<Canvas>();
|
||||
window->show();
|
||||
|
||||
return app.exec();
|
||||
return app->exec();
|
||||
}
|
||||
|
@ -171,7 +171,7 @@ private:
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
GUI::Application app(argc, argv);
|
||||
auto app = GUI::Application::construct(argc, argv);
|
||||
auto window = GUI::Window::construct();
|
||||
window->set_title("Mouse button demo");
|
||||
window->resize(160, 155);
|
||||
@ -181,15 +181,15 @@ int main(int argc, char** argv)
|
||||
|
||||
auto menubar = GUI::MenuBar::construct();
|
||||
auto& app_menu = menubar->add_menu("Mouse Demo");
|
||||
app_menu.add_action(GUI::CommonActions::make_quit_action([&](auto&) { app.quit(); }));
|
||||
app_menu.add_action(GUI::CommonActions::make_quit_action([&](auto&) { app->quit(); }));
|
||||
|
||||
auto& help_menu = menubar->add_menu("Help");
|
||||
help_menu.add_action(GUI::Action::create("About", [&](auto&) {
|
||||
GUI::AboutDialog::show("Mouse Demo", Gfx::Bitmap::load_from_file("/res/icons/32x32/app-mouse.png"), window);
|
||||
}));
|
||||
|
||||
app.set_menubar(move(menubar));
|
||||
app->set_menubar(move(menubar));
|
||||
window->set_resizable(false);
|
||||
window->show();
|
||||
return app.exec();
|
||||
return app->exec();
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ void Screensaver::draw()
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
GUI::Application app(argc, argv);
|
||||
auto app = GUI::Application::construct(argc, argv);
|
||||
|
||||
auto window = GUI::Window::construct();
|
||||
window->set_double_buffering_enabled(true);
|
||||
@ -148,5 +148,5 @@ int main(int argc, char** argv)
|
||||
window->show();
|
||||
window->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-screensaver.png"));
|
||||
|
||||
return app.exec();
|
||||
return app->exec();
|
||||
}
|
||||
|
@ -32,7 +32,7 @@
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
GUI::Application app(argc, argv);
|
||||
auto app = GUI::Application::construct(argc, argv);
|
||||
auto window = GUI::Window::construct();
|
||||
auto& view = window->set_main_widget<WebContentView>();
|
||||
window->set_title("WebContentView");
|
||||
@ -41,5 +41,5 @@ int main(int argc, char** argv)
|
||||
|
||||
view.load("file:///res/html/misc/welcome.html");
|
||||
|
||||
return app.exec();
|
||||
return app->exec();
|
||||
}
|
||||
|
@ -46,7 +46,7 @@
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
GUI::Application app(argc, argv);
|
||||
auto app = GUI::Application::construct(argc, argv);
|
||||
|
||||
auto window = GUI::Window::construct();
|
||||
window->set_rect(100, 100, 433, 487);
|
||||
@ -245,5 +245,5 @@ int main(int argc, char** argv)
|
||||
|
||||
window->show();
|
||||
|
||||
return app.exec();
|
||||
return app->exec();
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ int main(int argc, char** argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
GUI::Application app(argc, argv);
|
||||
auto app = GUI::Application::construct(argc, argv);
|
||||
|
||||
if (pledge("stdio tty accept rpath cpath wpath shared_buffer proc exec fattr thread", nullptr) < 0) {
|
||||
perror("pledge");
|
||||
@ -525,7 +525,7 @@ int main(int argc, char** argv)
|
||||
app_menu.add_action(save_action);
|
||||
app_menu.add_separator();
|
||||
app_menu.add_action(GUI::CommonActions::make_quit_action([&](auto&) {
|
||||
app.quit();
|
||||
app->quit();
|
||||
}));
|
||||
|
||||
auto& project_menu = menubar->add_menu("Project");
|
||||
@ -664,7 +664,7 @@ int main(int argc, char** argv)
|
||||
GUI::AboutDialog::show("HackStudio", Gfx::Bitmap::load_from_file("/res/icons/32x32/app-hack-studio.png"), g_window);
|
||||
}));
|
||||
|
||||
app.set_menubar(move(menubar));
|
||||
app->set_menubar(move(menubar));
|
||||
|
||||
g_window->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-hack-studio.png"));
|
||||
|
||||
@ -691,7 +691,7 @@ int main(int argc, char** argv)
|
||||
open_file(g_project->default_file());
|
||||
|
||||
update_actions();
|
||||
return app.exec();
|
||||
return app->exec();
|
||||
}
|
||||
|
||||
void build(TerminalWrapper& wrapper)
|
||||
|
@ -71,7 +71,7 @@ int main(int argc, char** argv)
|
||||
|
||||
pid_t pid = pid_opt.value();
|
||||
|
||||
GUI::Application app(argc, argv);
|
||||
auto app = GUI::Application::construct(argc, argv);
|
||||
|
||||
auto window = GUI::Window::construct();
|
||||
window->set_title("Inspector");
|
||||
@ -114,5 +114,5 @@ int main(int argc, char** argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
return app.exec();
|
||||
return app->exec();
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ int main(int argc, char** argv)
|
||||
args_parser.add_option(pid, "PID to profile", "pid", 'p', "PID");
|
||||
args_parser.parse(argc, argv, false);
|
||||
|
||||
GUI::Application app(argc, argv);
|
||||
auto app = GUI::Application::construct(argc, argv);
|
||||
|
||||
const char* path = nullptr;
|
||||
if (argc != 2) {
|
||||
@ -101,7 +101,7 @@ int main(int argc, char** argv)
|
||||
|
||||
auto menubar = GUI::MenuBar::construct();
|
||||
auto& app_menu = menubar->add_menu("Profiler");
|
||||
app_menu.add_action(GUI::CommonActions::make_quit_action([&](auto&) { app.quit(); }));
|
||||
app_menu.add_action(GUI::CommonActions::make_quit_action([&](auto&) { app->quit(); }));
|
||||
|
||||
auto& view_menu = menubar->add_menu("View");
|
||||
auto invert_action = GUI::Action::create_checkable("Invert tree", { Mod_Ctrl, Key_I }, [&](auto& action) {
|
||||
@ -118,10 +118,10 @@ int main(int argc, char** argv)
|
||||
percent_action->set_checked(false);
|
||||
view_menu.add_action(percent_action);
|
||||
|
||||
app.set_menubar(move(menubar));
|
||||
app->set_menubar(move(menubar));
|
||||
|
||||
window->show();
|
||||
return app.exec();
|
||||
return app->exec();
|
||||
}
|
||||
|
||||
bool prompt_to_stop_profiling()
|
||||
|
@ -47,7 +47,7 @@ static RefPtr<GUI::Window> make_toolbox_window();
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
GUI::Application app(argc, argv);
|
||||
auto app = GUI::Application::construct(argc, argv);
|
||||
|
||||
auto propbox = VBPropertiesWindow::construct();
|
||||
|
||||
@ -83,7 +83,7 @@ int main(int argc, char** argv)
|
||||
GUI::AboutDialog::show("Visual Builder", Gfx::Bitmap::load_from_file("/res/icons/32x32/app-visual-builder.png"), window);
|
||||
}));
|
||||
|
||||
app.set_menubar(move(menubar));
|
||||
app->set_menubar(move(menubar));
|
||||
|
||||
auto toolbox = make_toolbox_window();
|
||||
toolbox->show();
|
||||
@ -94,7 +94,7 @@ int main(int argc, char** argv)
|
||||
form1->load_from_file(argv[1]);
|
||||
}
|
||||
|
||||
return app.exec();
|
||||
return app->exec();
|
||||
}
|
||||
|
||||
RefPtr<GUI::Window> make_toolbox_window()
|
||||
|
@ -45,7 +45,7 @@ int main(int argc, char** argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
GUI::Application app(argc, argv);
|
||||
auto app = GUI::Application::construct(argc, argv);
|
||||
|
||||
if (pledge("stdio rpath accept wpath cpath shared_buffer", nullptr) < 0) {
|
||||
perror("pledge");
|
||||
@ -127,11 +127,11 @@ int main(int argc, char** argv)
|
||||
GUI::AboutDialog::show("Minesweeper", Gfx::Bitmap::load_from_file("/res/icons/32x32/app-minesweeper.png"), window);
|
||||
}));
|
||||
|
||||
app.set_menubar(move(menubar));
|
||||
app->set_menubar(move(menubar));
|
||||
|
||||
window->show();
|
||||
|
||||
window->set_icon(Gfx::Bitmap::load_from_file("/res/icons/minesweeper/mine.png"));
|
||||
|
||||
return app.exec();
|
||||
return app->exec();
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ int main(int argc, char** argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
GUI::Application app(argc, argv);
|
||||
auto app = GUI::Application::construct(argc, argv);
|
||||
|
||||
if (pledge("stdio rpath wpath cpath shared_buffer accept", nullptr) < 0) {
|
||||
perror("pledge");
|
||||
@ -73,11 +73,11 @@ int main(int argc, char** argv)
|
||||
GUI::AboutDialog::show("Snake", Gfx::Bitmap::load_from_file("/res/icons/32x32/app-snake.png"), window);
|
||||
}));
|
||||
|
||||
app.set_menubar(move(menubar));
|
||||
app->set_menubar(move(menubar));
|
||||
|
||||
window->show();
|
||||
|
||||
window->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-snake.png"));
|
||||
|
||||
return app.exec();
|
||||
return app->exec();
|
||||
}
|
||||
|
@ -35,7 +35,7 @@
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
GUI::Application app(argc, argv);
|
||||
auto app = GUI::Application::construct(argc, argv);
|
||||
|
||||
if (pledge("stdio rpath shared_buffer", nullptr) < 0) {
|
||||
perror("pledge");
|
||||
@ -56,18 +56,18 @@ int main(int argc, char** argv)
|
||||
|
||||
app_menu.add_action(GUI::Action::create("Restart game", [&](auto&) { widget->setup(); }));
|
||||
app_menu.add_separator();
|
||||
app_menu.add_action(GUI::CommonActions::make_quit_action([&](auto&) { app.quit(); }));
|
||||
app_menu.add_action(GUI::CommonActions::make_quit_action([&](auto&) { app->quit(); }));
|
||||
|
||||
auto& help_menu = menubar->add_menu("Help");
|
||||
help_menu.add_action(GUI::Action::create("About", [&](auto&) {
|
||||
GUI::AboutDialog::show("Solitaire", Gfx::Bitmap::load_from_file("/res/icons/32x32/app-solitaire.png"), window);
|
||||
}));
|
||||
|
||||
app.set_menubar(move(menubar));
|
||||
app->set_menubar(move(menubar));
|
||||
window->set_main_widget(widget);
|
||||
window->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-solitaire.png"));
|
||||
window->show();
|
||||
widget->setup();
|
||||
|
||||
return app.exec();
|
||||
return app->exec();
|
||||
}
|
||||
|
@ -49,8 +49,6 @@ Application& Application::the()
|
||||
|
||||
Application::Application(int argc, char** argv)
|
||||
{
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
ASSERT(!s_the);
|
||||
s_the = this;
|
||||
m_event_loop = make<Core::EventLoop>();
|
||||
|
@ -29,17 +29,19 @@
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/OwnPtr.h>
|
||||
#include <AK/String.h>
|
||||
#include <LibCore/Forward.h>
|
||||
#include <LibCore/Object.h>
|
||||
#include <LibGUI/Forward.h>
|
||||
#include <LibGUI/Shortcut.h>
|
||||
#include <LibGfx/Forward.h>
|
||||
|
||||
namespace GUI {
|
||||
|
||||
class Application {
|
||||
class Application : public Core::Object {
|
||||
C_OBJECT(Application);
|
||||
|
||||
public:
|
||||
static Application& the();
|
||||
Application(int argc, char** argv);
|
||||
|
||||
~Application();
|
||||
|
||||
int exec();
|
||||
@ -71,6 +73,8 @@ public:
|
||||
bool focus_debugging_enabled() const { return m_focus_debugging_enabled; }
|
||||
|
||||
private:
|
||||
Application(int argc, char** argv);
|
||||
|
||||
OwnPtr<Core::EventLoop> m_event_loop;
|
||||
RefPtr<MenuBar> m_menubar;
|
||||
RefPtr<Gfx::PaletteImpl> m_palette;
|
||||
|
@ -81,7 +81,7 @@ int main(int argc, char** argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
GUI::Application app(argc, argv);
|
||||
auto app = GUI::Application::construct(argc, argv);
|
||||
|
||||
if (pledge("stdio shared_buffer accept rpath unix", nullptr) < 0) {
|
||||
perror("pledge");
|
||||
@ -109,5 +109,5 @@ int main(int argc, char** argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
return app.exec();
|
||||
return app->exec();
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ int main(int argc, char* argv[])
|
||||
return 1;
|
||||
}
|
||||
|
||||
GUI::Application app(argc, argv);
|
||||
auto app = GUI::Application::construct(argc, argv);
|
||||
|
||||
if (pledge("stdio shared_buffer accept rpath", nullptr) < 0) {
|
||||
perror("pledge");
|
||||
@ -85,5 +85,5 @@ int main(int argc, char* argv[])
|
||||
applet_window->resize(16, 16);
|
||||
applet_window->show();
|
||||
|
||||
return app.exec();
|
||||
return app->exec();
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ int main(int argc, char** argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
GUI::Application app(argc, argv);
|
||||
auto app = GUI::Application::construct(argc, argv);
|
||||
|
||||
if (pledge("stdio shared_buffer accept rpath exec proc", nullptr) < 0) {
|
||||
perror("pledge");
|
||||
@ -137,5 +137,5 @@ int main(int argc, char** argv)
|
||||
|
||||
unveil(nullptr, nullptr);
|
||||
|
||||
return app.exec();
|
||||
return app->exec();
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ int main(int argc, char** argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
GUI::Application app(argc, argv);
|
||||
auto app = GUI::Application::construct(argc, argv);
|
||||
|
||||
if (pledge("stdio shared_buffer accept proc exec rpath", nullptr) < 0) {
|
||||
perror("pledge");
|
||||
@ -235,5 +235,5 @@ int main(int argc, char** argv)
|
||||
|
||||
unveil(nullptr, nullptr);
|
||||
|
||||
return app.exec();
|
||||
return app->exec();
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ int main(int argc, char** argv)
|
||||
|
||||
unveil(nullptr, nullptr);
|
||||
|
||||
GUI::Application app(argc, argv);
|
||||
auto app = GUI::Application::construct(argc, argv);
|
||||
|
||||
auto window = GUI::Window::construct();
|
||||
window->set_title("UserName");
|
||||
@ -101,5 +101,5 @@ int main(int argc, char** argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
return app.exec();
|
||||
return app->exec();
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ int main(int argc, char** argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
GUI::Application app(argc, argv);
|
||||
auto app = GUI::Application::construct(argc, argv);
|
||||
auto server = Core::LocalServer::construct();
|
||||
|
||||
bool ok = server->take_over_from_system_server();
|
||||
@ -67,5 +67,5 @@ int main(int argc, char** argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
return app.exec();
|
||||
return app->exec();
|
||||
}
|
||||
|
@ -65,8 +65,8 @@ static NonnullRefPtr<GUI::Menu> build_system_menu();
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
GUI::Application app(argc, argv);
|
||||
app.set_quit_when_last_window_deleted(false);
|
||||
auto app = GUI::Application::construct(argc, argv);
|
||||
app->set_quit_when_last_window_deleted(false);
|
||||
|
||||
auto menu = build_system_menu();
|
||||
menu->realize_menu_if_needed();
|
||||
@ -95,7 +95,7 @@ int main(int argc, char** argv)
|
||||
|
||||
unveil(nullptr, nullptr);
|
||||
|
||||
return app.exec();
|
||||
return app->exec();
|
||||
}
|
||||
|
||||
NonnullRefPtr<GUI::Menu> build_system_menu()
|
||||
|
@ -37,7 +37,7 @@ int main(int argc, char** argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
GUI::Application app(argc, argv);
|
||||
auto app = GUI::Application::construct(argc, argv);
|
||||
|
||||
signal(SIGCHLD, [](int signo) {
|
||||
(void)signo;
|
||||
@ -52,5 +52,5 @@ int main(int argc, char** argv)
|
||||
TaskbarWindow window;
|
||||
window.show();
|
||||
|
||||
return app.exec();
|
||||
return app->exec();
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ Options parse_options(int argc, char* argv[])
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
GUI::Application app(argc, argv);
|
||||
auto app = GUI::Application::construct(argc, argv);
|
||||
|
||||
Options options = parse_options(argc, argv);
|
||||
|
||||
|
@ -37,7 +37,7 @@
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
GUI::Application app(argc, argv);
|
||||
auto app = GUI::Application::construct(argc, argv);
|
||||
|
||||
auto f = Core::File::construct();
|
||||
bool success;
|
||||
@ -67,7 +67,7 @@ int main(int argc, char** argv)
|
||||
|
||||
auto& app_menu = menubar->add_menu("HTML");
|
||||
app_menu.add_action(GUI::CommonActions::make_quit_action([&](auto&) {
|
||||
app.quit();
|
||||
app->quit();
|
||||
}));
|
||||
|
||||
auto& help_menu = menubar->add_menu("Help");
|
||||
@ -75,9 +75,9 @@ int main(int argc, char** argv)
|
||||
GUI::AboutDialog::show("HTML", Gfx::Bitmap::load_from_file("/res/icons/32x32/filetype-html.png"), window);
|
||||
}));
|
||||
|
||||
app.set_menubar(move(menubar));
|
||||
app->set_menubar(move(menubar));
|
||||
|
||||
window->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-html.png"));
|
||||
|
||||
return app.exec();
|
||||
return app->exec();
|
||||
}
|
||||
|
@ -32,7 +32,7 @@
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
GUI::Application app(argc, argv);
|
||||
auto app = GUI::Application::construct(argc, argv);
|
||||
|
||||
Core::ArgsParser args_parser;
|
||||
const char* title = nullptr;
|
||||
|
@ -85,7 +85,7 @@ int main(int argc, char** argv)
|
||||
args_parser.add_positional_argument(name, "Wallpaper to set", "name", Core::ArgsParser::Required::No);
|
||||
args_parser.parse(argc, argv);
|
||||
|
||||
GUI::Application app(argc, argv);
|
||||
auto app = GUI::Application::construct(argc, argv);
|
||||
|
||||
if (show_all)
|
||||
return handle_show_all();
|
||||
|
@ -41,7 +41,7 @@ int main(int argc, char* argv[])
|
||||
args_parser.add_option(no_newline, "Do not append a newline", "no-newline", 'n');
|
||||
args_parser.parse(argc, argv);
|
||||
|
||||
GUI::Application app(argc, argv);
|
||||
auto app = GUI::Application::construct(argc, argv);
|
||||
|
||||
auto& clipboard = GUI::Clipboard::the();
|
||||
auto data_and_type = clipboard.data_and_type();
|
||||
|
Loading…
Reference in New Issue
Block a user