mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 03:37:45 +00:00
LibFSAC+Userland: Pass options for FSAC::open_file() using a struct
It was rather inconvenient having to specify all arguments if you wanted to modify only the last one.
This commit is contained in:
parent
5c07aeb78e
commit
27011cf55d
10 changed files with 34 additions and 16 deletions
|
@ -63,10 +63,10 @@ Result Client::request_file(GUI::Window* parent_window, DeprecatedString const&
|
|||
return handle_promise(id);
|
||||
}
|
||||
|
||||
Result Client::open_file(GUI::Window* parent_window, DeprecatedString const& window_title, StringView path, Core::File::OpenMode requested_access, Optional<Vector<GUI::FileTypeFilter>> const& allowed_file_types)
|
||||
Result Client::open_file(GUI::Window* parent_window, OpenFileOptions const& options)
|
||||
{
|
||||
auto const id = get_new_id();
|
||||
m_promises.set(id, RequestData { { Core::Promise<Result>::construct() }, parent_window, requested_access });
|
||||
m_promises.set(id, RequestData { { Core::Promise<Result>::construct() }, parent_window, options.requested_access });
|
||||
|
||||
auto parent_window_server_client_id = GUI::ConnectionToWindowServer::the().expose_client_id();
|
||||
auto child_window_server_client_id = expose_window_server_client_id();
|
||||
|
@ -78,7 +78,7 @@ Result Client::open_file(GUI::Window* parent_window, DeprecatedString const& win
|
|||
GUI::ConnectionToWindowServer::the().remove_window_stealing_for_client(child_window_server_client_id, parent_window_id);
|
||||
});
|
||||
|
||||
async_prompt_open_file(id, parent_window_server_client_id, parent_window_id, window_title, path, requested_access, allowed_file_types);
|
||||
async_prompt_open_file(id, parent_window_server_client_id, parent_window_id, options.window_title, options.path, options.requested_access, options.allowed_file_types);
|
||||
|
||||
return handle_promise(id);
|
||||
}
|
||||
|
|
|
@ -48,6 +48,13 @@ private:
|
|||
|
||||
using Result = ErrorOr<File>;
|
||||
|
||||
struct OpenFileOptions {
|
||||
StringView window_title = {};
|
||||
DeprecatedString path = Core::StandardPaths::home_directory();
|
||||
Core::File::OpenMode requested_access = Core::File::OpenMode::Read;
|
||||
Optional<Vector<GUI::FileTypeFilter>> allowed_file_types = {};
|
||||
};
|
||||
|
||||
class Client final
|
||||
: public IPC::ConnectionToServer<FileSystemAccessClientEndpoint, FileSystemAccessServerEndpoint>
|
||||
, public FileSystemAccessClientEndpoint {
|
||||
|
@ -56,7 +63,7 @@ class Client final
|
|||
public:
|
||||
Result request_file_read_only_approved(GUI::Window* parent_window, DeprecatedString const& path);
|
||||
Result request_file(GUI::Window* parent_window, DeprecatedString const& path, Core::File::OpenMode requested_access);
|
||||
Result open_file(GUI::Window* parent_window, DeprecatedString const& window_title = {}, StringView path = Core::StandardPaths::home_directory(), Core::File::OpenMode requested_access = Core::File::OpenMode::Read, Optional<Vector<GUI::FileTypeFilter>> const& = {});
|
||||
Result open_file(GUI::Window* parent_window, OpenFileOptions const& = {});
|
||||
Result save_file(GUI::Window* parent_window, DeprecatedString const& name, DeprecatedString const ext, Core::File::OpenMode requested_access = Core::File::OpenMode::Write | Core::File::OpenMode::Truncate);
|
||||
|
||||
void set_silence_errors(u32 flags) { m_silenced_errors = flags; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue