2019-02-09 09:22:04 +01:00
|
|
|
#include <LibGUI/GWindow.h>
|
|
|
|
|
#include <LibGUI/GWidget.h>
|
2019-02-10 11:07:13 +01:00
|
|
|
#include <LibGUI/GBoxLayout.h>
|
2019-02-11 14:56:23 +01:00
|
|
|
#include <LibGUI/GApplication.h>
|
2019-02-10 11:07:13 +01:00
|
|
|
#include <LibGUI/GStatusBar.h>
|
2019-02-09 09:22:04 +01:00
|
|
|
#include <unistd.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include "DirectoryView.h"
|
|
|
|
|
|
|
|
|
|
static GWindow* make_window();
|
|
|
|
|
|
2019-02-11 14:56:23 +01:00
|
|
|
int main(int argc, char** argv)
|
2019-02-09 09:22:04 +01:00
|
|
|
{
|
2019-02-11 14:56:23 +01:00
|
|
|
GApplication app(argc, argv);
|
2019-02-09 09:22:04 +01:00
|
|
|
|
|
|
|
|
auto* window = make_window();
|
|
|
|
|
window->set_should_exit_app_on_close(true);
|
|
|
|
|
window->show();
|
|
|
|
|
|
2019-02-11 14:56:23 +01:00
|
|
|
return app.exec();
|
2019-02-09 09:22:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
2019-02-10 11:07:13 +01:00
|
|
|
widget->set_layout(make<GBoxLayout>(Orientation::Vertical));
|
|
|
|
|
|
2019-02-09 09:22:04 +01:00
|
|
|
auto* directory_view = new DirectoryView(widget);
|
2019-02-10 11:07:13 +01:00
|
|
|
|
|
|
|
|
auto* statusbar = new GStatusBar(widget);
|
|
|
|
|
statusbar->set_text("Welcome!");
|
2019-02-09 09:22:04 +01:00
|
|
|
|
|
|
|
|
directory_view->on_path_change = [window] (const String& new_path) {
|
|
|
|
|
window->set_title(String::format("FileManager: %s", new_path.characters()));
|
|
|
|
|
};
|
|
|
|
|
|
2019-02-10 11:07:13 +01:00
|
|
|
directory_view->on_status_message = [statusbar] (String message) {
|
|
|
|
|
statusbar->set_text(move(message));
|
|
|
|
|
};
|
|
|
|
|
|
2019-02-09 09:22:04 +01:00
|
|
|
directory_view->open("/");
|
|
|
|
|
|
|
|
|
|
return window;
|
|
|
|
|
}
|
|
|
|
|
|