diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-01-21 00:31:11 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-01-21 00:31:48 +0100 |
commit | 6c4f1bad0947e6b9f36af37cda61e57fecd68025 (patch) | |
tree | 6b69af8593b77bd9b9c2e8abf41ac7a5d1f939d4 /Userland | |
parent | 3271c115e2f003564cc6801f12aa21cc9cfae89c (diff) | |
download | serenity-6c4f1bad0947e6b9f36af37cda61e57fecd68025.zip |
guitest2: Add a simple launcher so I can easily spawn more Terminals.
Also update GButton coding style.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/guitest2.cpp | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/Userland/guitest2.cpp b/Userland/guitest2.cpp index ecc9b09166..0244d20e86 100644 --- a/Userland/guitest2.cpp +++ b/Userland/guitest2.cpp @@ -11,15 +11,20 @@ #include <LibGUI/GWindow.h> #include <LibGUI/GWidget.h> #include <LibGUI/GLabel.h> +#include <LibGUI/GButton.h> #include <LibGUI/GEventLoop.h> static GWindow* make_font_test_window(); +static GWindow* make_launcher_window(); int main(int argc, char** argv) { GEventLoop loop; - auto* window = make_font_test_window(); - window->show(); + auto* font_test_window = make_font_test_window(); + font_test_window->show(); + + auto* launcher_window = make_launcher_window(); + launcher_window->show(); return loop.exec(); } @@ -51,3 +56,31 @@ GWindow* make_font_test_window() return window; } + +GWindow* make_launcher_window() +{ + auto* window = new GWindow; + window->set_title("Launcher"); + window->set_rect({ 100, 400, 80, 200 }); + + auto* widget = new GWidget; + window->set_main_widget(widget); + widget->setWindowRelativeRect({ 0, 0, 80, 200 }); + + auto* label = new GLabel(widget); + label->setWindowRelativeRect({ 0, 0, 80, 20 }); + label->setText("Apps"); + + auto* button = new GButton(widget); + button->setWindowRelativeRect({ 5, 20, 70, 20 }); + button->set_caption("Terminal"); + + button->on_click = [] (GButton&) { + if (!fork()) { + execve("/bin/Terminal", nullptr, nullptr); + ASSERT_NOT_REACHED(); + } + }; + + return window; +} |