1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-10 18:10:56 +09:00

WidgetGallery: Port file picker to use FileSystemAccessClient

Previously we would unveil the home directory of anon to allow showing
anything in the file picker. This patch removes direct access to the
home directory and instead makes WidgetGallery connect to
FileSystemAccessServer to open a file, making the application more user
agnostic and allowing directories outside /home/anon to be shown.
This commit is contained in:
networkException 2022-09-10 13:12:35 +02:00 committed by Sam Atkins
parent 08f465a47d
commit 1346a653e4
Notes: sideshowbarker 2024-07-17 07:18:14 +09:00
3 changed files with 6 additions and 6 deletions

View file

@ -27,4 +27,4 @@ set(SOURCES
)
serenity_app(WidgetGallery ICON app-widget-gallery)
target_link_libraries(WidgetGallery LibGUI LibMain)
target_link_libraries(WidgetGallery LibGUI LibMain LibFileSystemAccessClient)

View file

@ -14,6 +14,7 @@
#include <Demos/WidgetGallery/SlidersTabGML.h>
#include <Demos/WidgetGallery/WindowGML.h>
#include <Demos/WidgetGallery/WizardsTabGML.h>
#include <LibFileSystemAccessClient/Client.h>
#include <LibGUI/Button.h>
#include <LibGUI/ColorInput.h>
#include <LibGUI/FilePicker.h>
@ -107,10 +108,10 @@ GalleryWidget::GalleryWidget()
m_file_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open.png"sv).release_value_but_fixme_should_propagate_errors());
m_file_button->on_click = [&](auto) {
Optional<String> open_path = GUI::FilePicker::get_open_filepath(window());
if (!open_path.has_value())
auto response = FileSystemAccessClient::Client::the().try_open_file(window());
if (response.is_error())
return;
m_text_editor->set_text(open_path.value());
m_text_editor->set_text(response.release_value()->filename());
};
m_input_button = basics_tab->find_descendant_of_type_named<GUI::Button>("input_button");

View file

@ -17,9 +17,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
TRY(Core::System::pledge("stdio recvfd sendfd rpath unix thread"));
auto app = TRY(GUI::Application::try_create(arguments, Core::EventLoop::MakeInspectable::Yes));
TRY(Core::System::pledge("stdio recvfd sendfd rpath thread"));
TRY(Core::System::unveil("/res", "r"));
TRY(Core::System::unveil("/home/anon", "r"));
TRY(Core::System::unveil("/tmp/user/%uid/portal/filesystemaccess", "rw"));
TRY(Core::System::unveil("/etc/FileIconProvider.ini", "r"));
TRY(Core::System::unveil(nullptr, nullptr));
auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-widget-gallery"sv));