mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:28:10 +00:00
FileManager: Make the "open parent directory" action actually open ".."
This commit is contained in:
parent
e11c7a5df5
commit
5c0fca0a95
3 changed files with 21 additions and 18 deletions
|
@ -34,3 +34,8 @@ void DirectoryTableView::set_status_message(const String& message)
|
|||
if (on_status_message)
|
||||
on_status_message(message);
|
||||
}
|
||||
|
||||
void DirectoryTableView::open_parent_directory()
|
||||
{
|
||||
model().open("..");
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ public:
|
|||
|
||||
void open(const String& path);
|
||||
String path() const { return model().path(); }
|
||||
void open_parent_directory();
|
||||
|
||||
Function<void(const String&)> on_path_change;
|
||||
Function<void(String)> on_status_message;
|
||||
|
|
|
@ -25,8 +25,20 @@ int main(int argc, char** argv)
|
|||
|
||||
GApplication app(argc, argv);
|
||||
|
||||
auto open_parent_directory_action = GAction::create("Open parent directory", GraphicsBitmap::load_from_file(GraphicsBitmap::Format::RGBA32, "/res/icons/parentdirectory16.rgb", { 16, 16 }), [] (const GAction&) {
|
||||
dbgprintf("'Parent directory' action activated!\n");
|
||||
auto* window = new GWindow;
|
||||
window->set_title("FileManager");
|
||||
window->set_rect(20, 200, 640, 480);
|
||||
window->set_should_exit_app_on_close(true);
|
||||
|
||||
auto* widget = new GWidget;
|
||||
widget->set_layout(make<GBoxLayout>(Orientation::Vertical));
|
||||
|
||||
auto* toolbar = new GToolBar(widget);
|
||||
auto* directory_table_view = new DirectoryTableView(widget);
|
||||
auto* statusbar = new GStatusBar(widget);
|
||||
|
||||
auto open_parent_directory_action = GAction::create("Open parent directory", GraphicsBitmap::load_from_file(GraphicsBitmap::Format::RGBA32, "/res/icons/parentdirectory16.rgb", { 16, 16 }), [directory_table_view] (const GAction&) {
|
||||
directory_table_view->open_parent_directory();
|
||||
});
|
||||
|
||||
auto mkdir_action = GAction::create("New directory...", GraphicsBitmap::load_from_file(GraphicsBitmap::Format::RGBA32, "/res/icons/mkdir16.rgb", { 16, 16 }), [] (const GAction&) {
|
||||
|
@ -65,26 +77,11 @@ int main(int argc, char** argv)
|
|||
|
||||
app.set_menubar(move(menubar));
|
||||
|
||||
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* toolbar = new GToolBar(widget);
|
||||
toolbar->add_action(open_parent_directory_action.copy_ref());
|
||||
toolbar->add_action(mkdir_action.copy_ref());
|
||||
toolbar->add_action(copy_action.copy_ref());
|
||||
toolbar->add_action(delete_action.copy_ref());
|
||||
|
||||
auto* directory_table_view = new DirectoryTableView(widget);
|
||||
|
||||
auto* statusbar = new GStatusBar(widget);
|
||||
statusbar->set_text("Welcome!");
|
||||
|
||||
directory_table_view->on_path_change = [window] (const String& new_path) {
|
||||
window->set_title(String::format("FileManager: %s", new_path.characters()));
|
||||
};
|
||||
|
@ -96,7 +93,7 @@ int main(int argc, char** argv)
|
|||
directory_table_view->open("/");
|
||||
directory_table_view->set_focus(true);
|
||||
|
||||
window->set_should_exit_app_on_close(true);
|
||||
window->set_main_widget(widget);
|
||||
window->show();
|
||||
|
||||
return app.exec();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue