diff options
-rw-r--r-- | Applications/FileManager/DirectoryTableView.cpp | 5 | ||||
-rw-r--r-- | Applications/FileManager/DirectoryTableView.h | 2 | ||||
-rw-r--r-- | Applications/FileManager/Makefile | 2 | ||||
-rw-r--r-- | Applications/FileManager/main.cpp | 19 | ||||
-rw-r--r-- | LibGUI/GDialog.cpp | 7 | ||||
-rw-r--r-- | LibGUI/GMessageBox.cpp | 2 | ||||
-rw-r--r-- | LibGUI/GWindow.h | 3 |
7 files changed, 32 insertions, 8 deletions
diff --git a/Applications/FileManager/DirectoryTableView.cpp b/Applications/FileManager/DirectoryTableView.cpp index 938f9ebf76..bd43d47988 100644 --- a/Applications/FileManager/DirectoryTableView.cpp +++ b/Applications/FileManager/DirectoryTableView.cpp @@ -42,3 +42,8 @@ void DirectoryTableView::open_parent_directory() { model().open(String::format("%s/..", model().path().characters())); } + +void DirectoryTableView::refresh() +{ + model().update(); +} diff --git a/Applications/FileManager/DirectoryTableView.h b/Applications/FileManager/DirectoryTableView.h index b7567e718a..dac693e799 100644 --- a/Applications/FileManager/DirectoryTableView.h +++ b/Applications/FileManager/DirectoryTableView.h @@ -13,6 +13,8 @@ public: String path() const { return model().path(); } void open_parent_directory(); + void refresh(); + Function<void(const String&)> on_path_change; Function<void(String)> on_status_message; diff --git a/Applications/FileManager/Makefile b/Applications/FileManager/Makefile index ae9cbe0f0f..305da08c0e 100644 --- a/Applications/FileManager/Makefile +++ b/Applications/FileManager/Makefile @@ -9,7 +9,7 @@ STANDARD_FLAGS = -std=c++17 WARNING_FLAGS = -Wextra -Wall -Wundef -Wcast-qual -Wwrite-strings -Wimplicit-fallthrough FLAVOR_FLAGS = -fno-exceptions -fno-rtti OPTIMIZATION_FLAGS = -Os -INCLUDE_FLAGS = -I../.. -I. -I../../LibC +INCLUDE_FLAGS = -I../.. -I../../Servers -I. -I../../LibC DEFINES = -DSERENITY -DSANITIZE_PTRS -DUSERLAND diff --git a/Applications/FileManager/main.cpp b/Applications/FileManager/main.cpp index 0c4bd56dd6..f94fbbcd30 100644 --- a/Applications/FileManager/main.cpp +++ b/Applications/FileManager/main.cpp @@ -8,6 +8,8 @@ #include <LibGUI/GMenuBar.h> #include <LibGUI/GAction.h> #include <LibGUI/GLabel.h> +#include <LibGUI/GInputBox.h> +#include <LibGUI/GMessageBox.h> #include <unistd.h> #include <signal.h> #include <stdio.h> @@ -56,8 +58,21 @@ int main(int argc, char** argv) directory_table_view->open_parent_directory(); }); - auto mkdir_action = GAction::create("New directory...", GraphicsBitmap::load_from_file(GraphicsBitmap::Format::RGBA32, "/res/icons/16x16/mkdir.rgb", { 16, 16 }), [] (const GAction&) { - dbgprintf("'New directory' action activated!\n"); + auto mkdir_action = GAction::create("New directory...", GraphicsBitmap::load_from_file(GraphicsBitmap::Format::RGBA32, "/res/icons/16x16/mkdir.rgb", { 16, 16 }), [&] (const GAction&) { + GInputBox input_box("Enter name:", "New directory", window); + if (input_box.exec() == GInputBox::ExecOK && !input_box.text_value().is_empty()) { + auto new_dir_path = String::format("%s/%s", + directory_table_view->path().characters(), + input_box.text_value().characters() + ); + int rc = mkdir(new_dir_path.characters(), 0777); + if (rc < 0) { + GMessageBox message_box(String::format("mkdir() failed: %s", strerror(errno)), "Error", window); + message_box.exec(); + } else { + directory_table_view->refresh(); + } + } }); auto copy_action = GAction::create("Copy", GraphicsBitmap::load_from_file(GraphicsBitmap::Format::RGBA32, "/res/icons/copyfile16.rgb", { 16, 16 }), [] (const GAction&) { diff --git a/LibGUI/GDialog.cpp b/LibGUI/GDialog.cpp index d6a925bfb2..3832d2b32c 100644 --- a/LibGUI/GDialog.cpp +++ b/LibGUI/GDialog.cpp @@ -25,14 +25,15 @@ int GDialog::exec() show(); auto result = m_event_loop->exec(); m_event_loop = nullptr; - dbgprintf("event loop returned with result %d\n", result); + dbgprintf("%s: event loop returned with result %d\n", class_name(), result); return result; } void GDialog::done(int result) { - ASSERT(m_event_loop); + if (!m_event_loop) + return; m_result = result; - dbgprintf("quit event loop with result %d\n", result); + dbgprintf("%s: quit event loop with result %d\n", class_name(), result); m_event_loop->quit(result); } diff --git a/LibGUI/GMessageBox.cpp b/LibGUI/GMessageBox.cpp index 8f97cca5bd..057cd6a28a 100644 --- a/LibGUI/GMessageBox.cpp +++ b/LibGUI/GMessageBox.cpp @@ -39,7 +39,7 @@ void GMessageBox::build() button->set_preferred_size({ 100, 16 }); button->set_caption("OK"); button->on_click = [this] (auto&) { - dbgprintf("OK button clicked\n"); + dbgprintf("GMessageBox: OK button clicked\n"); done(0); }; } diff --git a/LibGUI/GWindow.h b/LibGUI/GWindow.h index 1f899e1acb..720de5b408 100644 --- a/LibGUI/GWindow.h +++ b/LibGUI/GWindow.h @@ -80,8 +80,9 @@ public: Size base_size() const { return m_base_size; } void set_base_size(const Size& size) { m_base_size = size; } -private: virtual const char* class_name() const override { return "GWindow"; } + +private: virtual bool is_window() const override final { return true; } Retained<GraphicsBitmap> create_backing_bitmap(const Size&); |