2023-09-11 17:15:26 +00:00
|
|
|
#include <os/File.h>
|
2023-08-15 13:33:44 +00:00
|
|
|
#include <os/Process.h>
|
2023-08-16 14:49:08 +00:00
|
|
|
#include <signal.h>
|
|
|
|
#include <sys/wait.h>
|
2023-08-15 10:56:55 +00:00
|
|
|
#include <ui/App.h>
|
2023-08-15 13:33:44 +00:00
|
|
|
#include <ui/Button.h>
|
2023-08-15 12:42:21 +00:00
|
|
|
#include <ui/Container.h>
|
|
|
|
#include <ui/Image.h>
|
2023-08-15 10:56:55 +00:00
|
|
|
#include <ui/Layout.h>
|
|
|
|
|
2023-09-20 17:45:01 +00:00
|
|
|
static constexpr ui::Color TASKBAR_COLOR = ui::Color::from_rgb(83, 83, 83);
|
|
|
|
|
2023-08-16 14:49:08 +00:00
|
|
|
void sigchld_handler(int)
|
|
|
|
{
|
|
|
|
wait(nullptr);
|
|
|
|
}
|
|
|
|
|
2023-08-15 10:56:55 +00:00
|
|
|
Result<int> luna_main(int argc, char** argv)
|
|
|
|
{
|
|
|
|
ui::App app;
|
|
|
|
TRY(app.init(argc, argv));
|
|
|
|
|
2023-08-16 14:49:08 +00:00
|
|
|
signal(SIGCHLD, sigchld_handler);
|
|
|
|
|
2023-08-15 10:56:55 +00:00
|
|
|
ui::Rect screen = app.screen_rect();
|
|
|
|
|
|
|
|
ui::Rect bar = ui::Rect { ui::Point { 0, screen.height - 50 }, screen.width, 50 };
|
|
|
|
|
2023-09-27 16:14:32 +00:00
|
|
|
auto window = TRY(ui::Window::create(bar, ui::WindowType::System));
|
2023-08-15 10:56:55 +00:00
|
|
|
app.set_main_window(window);
|
2023-09-20 17:45:01 +00:00
|
|
|
window->set_background(TASKBAR_COLOR);
|
2023-08-15 10:56:55 +00:00
|
|
|
|
|
|
|
ui::HorizontalLayout layout(ui::AdjustHeight::Yes, ui::AdjustWidth::No);
|
|
|
|
window->set_main_widget(layout);
|
|
|
|
|
2023-09-16 09:41:51 +00:00
|
|
|
ui::Button term_button({ 0, 0, 50, 50 });
|
|
|
|
layout.add_widget(term_button);
|
|
|
|
|
|
|
|
ui::Container term_container({ 0, 0, 50, 50 }, ui::VerticalAlignment::Center, ui::HorizontalAlignment::Center);
|
|
|
|
term_button.set_widget(term_container);
|
|
|
|
term_button.set_action([] {
|
|
|
|
StringView args[] = { "/usr/bin/terminal" };
|
|
|
|
os::Process::spawn("/usr/bin/terminal", Slice<StringView> { args, 1 }, false);
|
2023-08-15 13:33:44 +00:00
|
|
|
});
|
2023-08-15 12:42:21 +00:00
|
|
|
|
2023-09-16 09:41:51 +00:00
|
|
|
auto term_image = TRY(ui::ImageWidget::load("/usr/share/icons/32x32/app-terminal.tga"));
|
|
|
|
term_container.set_widget(*term_image);
|
2023-09-11 17:15:26 +00:00
|
|
|
|
|
|
|
ui::Button about_button({ 0, 0, 50, 50 });
|
|
|
|
layout.add_widget(about_button);
|
|
|
|
|
|
|
|
ui::Container about_container({ 0, 0, 50, 50 }, ui::VerticalAlignment::Center, ui::HorizontalAlignment::Center);
|
|
|
|
about_button.set_widget(about_container);
|
|
|
|
about_button.set_action([] {
|
|
|
|
StringView args[] = { "/usr/bin/about" };
|
|
|
|
os::Process::spawn("/usr/bin/about", Slice<StringView> { args, 1 }, false);
|
|
|
|
});
|
|
|
|
|
|
|
|
auto about_image = TRY(ui::ImageWidget::load("/usr/share/icons/32x32/app-about.tga"));
|
|
|
|
about_container.set_widget(*about_image);
|
2023-08-15 12:42:21 +00:00
|
|
|
|
2023-08-15 10:56:55 +00:00
|
|
|
window->draw();
|
|
|
|
|
|
|
|
return app.run();
|
|
|
|
}
|