1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-20 00:15:08 +00:00
serenity/Applications/FileManager/main.cpp
Andreas Kling 2def3d8d3f LibGUI: Start adding an automatic widget layout system.
My needs are really quite simple, so I'm just going to add what I need
as I go along. The first thing I needed was a simple box layout with
widgets being able to say whether they prefer fixed or fill for both
their vertical and horizontal sizes.

I also made a simple GStatusBar so FileManager can show how many bytes
worth of files are in the current directory.
2019-02-10 11:07:13 +01:00

51 lines
1.2 KiB
C++

#include <LibGUI/GWindow.h>
#include <LibGUI/GWidget.h>
#include <LibGUI/GBoxLayout.h>
#include <LibGUI/GEventLoop.h>
#include <LibGUI/GStatusBar.h>
#include <unistd.h>
#include <stdio.h>
#include "DirectoryView.h"
static GWindow* make_window();
int main(int, char**)
{
GEventLoop loop;
auto* window = make_window();
window->set_should_exit_app_on_close(true);
window->show();
return loop.exec();
}
GWindow* make_window()
{
auto* window = new GWindow;
window->set_title("FileManager");
window->set_rect(20, 200, 240, 300);
auto* widget = new GWidget;
window->set_main_widget(widget);
widget->set_layout(make<GBoxLayout>(Orientation::Vertical));
auto* directory_view = new DirectoryView(widget);
auto* statusbar = new GStatusBar(widget);
statusbar->set_text("Welcome!");
directory_view->on_path_change = [window] (const String& new_path) {
window->set_title(String::format("FileManager: %s", new_path.characters()));
};
directory_view->on_status_message = [statusbar] (String message) {
statusbar->set_text(move(message));
};
directory_view->open("/");
return window;
}