mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 16:25:06 +00:00
FileSystemAccessServer: Add window title as parameter for opening file
This commit is contained in:
parent
d496eb48e3
commit
95ee7069d5
5 changed files with 8 additions and 8 deletions
|
@ -8,7 +8,6 @@
|
||||||
// clang-format off
|
// clang-format off
|
||||||
#include <LibGUI/WindowServerConnection.h>
|
#include <LibGUI/WindowServerConnection.h>
|
||||||
// clang-format on
|
// clang-format on
|
||||||
#include <LibCore/StandardPaths.h>
|
|
||||||
#include <LibFileSystemAccessClient/Client.h>
|
#include <LibFileSystemAccessClient/Client.h>
|
||||||
#include <LibGUI/Window.h>
|
#include <LibGUI/Window.h>
|
||||||
|
|
||||||
|
@ -40,7 +39,7 @@ Result Client::request_file(i32 parent_window_id, String const& path, Core::Open
|
||||||
return m_promise->await();
|
return m_promise->await();
|
||||||
}
|
}
|
||||||
|
|
||||||
Result Client::open_file(i32 parent_window_id)
|
Result Client::open_file(i32 parent_window_id, String const& window_title, StringView const& path)
|
||||||
{
|
{
|
||||||
m_promise = Core::Promise<Result>::construct();
|
m_promise = Core::Promise<Result>::construct();
|
||||||
auto parent_window_server_client_id = GUI::WindowServerConnection::the().expose_client_id();
|
auto parent_window_server_client_id = GUI::WindowServerConnection::the().expose_client_id();
|
||||||
|
@ -52,7 +51,7 @@ Result Client::open_file(i32 parent_window_id)
|
||||||
GUI::WindowServerConnection::the().async_remove_window_stealing_for_client(child_window_server_client_id, parent_window_id);
|
GUI::WindowServerConnection::the().async_remove_window_stealing_for_client(child_window_server_client_id, parent_window_id);
|
||||||
});
|
});
|
||||||
|
|
||||||
async_prompt_open_file(parent_window_server_client_id, parent_window_id, Core::StandardPaths::home_directory(), Core::OpenMode::ReadOnly);
|
async_prompt_open_file(parent_window_server_client_id, parent_window_id, window_title, path, Core::OpenMode::ReadOnly);
|
||||||
|
|
||||||
return m_promise->await();
|
return m_promise->await();
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include <FileSystemAccessServer/FileSystemAccessServerEndpoint.h>
|
#include <FileSystemAccessServer/FileSystemAccessServerEndpoint.h>
|
||||||
#include <LibCore/File.h>
|
#include <LibCore/File.h>
|
||||||
#include <LibCore/Promise.h>
|
#include <LibCore/Promise.h>
|
||||||
|
#include <LibCore/StandardPaths.h>
|
||||||
#include <LibIPC/ServerConnection.h>
|
#include <LibIPC/ServerConnection.h>
|
||||||
|
|
||||||
namespace FileSystemAccessClient {
|
namespace FileSystemAccessClient {
|
||||||
|
@ -27,7 +28,7 @@ class Client final
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Result request_file(i32 parent_window_id, String const& path, Core::OpenMode mode);
|
Result request_file(i32 parent_window_id, String const& path, Core::OpenMode mode);
|
||||||
Result open_file(i32 parent_window_id);
|
Result open_file(i32 parent_window_id, String const& window_title = {}, StringView const& path = Core::StandardPaths::home_directory());
|
||||||
Result save_file(i32 parent_window_id, String const& name, String const ext);
|
Result save_file(i32 parent_window_id, String const& name, String const ext);
|
||||||
|
|
||||||
static Client& the();
|
static Client& the();
|
||||||
|
|
|
@ -107,14 +107,14 @@ void ClientConnection::request_file(i32 window_server_client_id, i32 parent_wind
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientConnection::prompt_open_file(i32 window_server_client_id, i32 parent_window_id, String const& path_to_view, Core::OpenMode const& requested_access)
|
void ClientConnection::prompt_open_file(i32 window_server_client_id, i32 parent_window_id, String const& window_title, String const& path_to_view, Core::OpenMode const& requested_access)
|
||||||
{
|
{
|
||||||
auto relevant_permissions = requested_access & (Core::OpenMode::ReadOnly | Core::OpenMode::WriteOnly);
|
auto relevant_permissions = requested_access & (Core::OpenMode::ReadOnly | Core::OpenMode::WriteOnly);
|
||||||
VERIFY(relevant_permissions != Core::OpenMode::NotOpen);
|
VERIFY(relevant_permissions != Core::OpenMode::NotOpen);
|
||||||
|
|
||||||
auto main_window = create_dummy_child_window(window_server_client_id, parent_window_id);
|
auto main_window = create_dummy_child_window(window_server_client_id, parent_window_id);
|
||||||
|
|
||||||
auto user_picked_file = GUI::FilePicker::get_open_filepath(main_window, "Select file", path_to_view);
|
auto user_picked_file = GUI::FilePicker::get_open_filepath(main_window, window_title, path_to_view);
|
||||||
|
|
||||||
prompt_helper(user_picked_file, requested_access);
|
prompt_helper(user_picked_file, requested_access);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual void request_file(i32, i32, String const&, Core::OpenMode const&) override;
|
virtual void request_file(i32, i32, String const&, Core::OpenMode const&) override;
|
||||||
virtual void prompt_open_file(i32, i32, String const&, Core::OpenMode const&) override;
|
virtual void prompt_open_file(i32, i32, String const&, String const&, Core::OpenMode const&) override;
|
||||||
virtual void prompt_save_file(i32, i32, String const&, String const&, String const&, Core::OpenMode const&) override;
|
virtual void prompt_save_file(i32, i32, String const&, String const&, String const&, Core::OpenMode const&) override;
|
||||||
|
|
||||||
void prompt_helper(Optional<String> const&, Core::OpenMode const&);
|
void prompt_helper(Optional<String> const&, Core::OpenMode const&);
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
endpoint FileSystemAccessServer
|
endpoint FileSystemAccessServer
|
||||||
{
|
{
|
||||||
request_file(i32 window_server_client_id, i32 window_id, String path, Core::OpenMode requested_access) =|
|
request_file(i32 window_server_client_id, i32 window_id, String path, Core::OpenMode requested_access) =|
|
||||||
prompt_open_file(i32 window_server_client_id, i32 window_id, String path_to_view, Core::OpenMode requested_access) =|
|
prompt_open_file(i32 window_server_client_id, i32 window_id, String window_title, String path_to_view, Core::OpenMode requested_access) =|
|
||||||
prompt_save_file(i32 window_server_client_id, i32 window_id,String title, String ext, String path_to_view, Core::OpenMode requested_access) =|
|
prompt_save_file(i32 window_server_client_id, i32 window_id,String title, String ext, String path_to_view, Core::OpenMode requested_access) =|
|
||||||
|
|
||||||
expose_window_server_client_id() => (i32 client_id)
|
expose_window_server_client_id() => (i32 client_id)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue