summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Userland/Applications/ThemeEditor/PreviewWidget.cpp15
-rw-r--r--Userland/Applications/ThemeEditor/PreviewWidget.h2
-rw-r--r--Userland/Applications/ThemeEditor/main.cpp22
3 files changed, 18 insertions, 21 deletions
diff --git a/Userland/Applications/ThemeEditor/PreviewWidget.cpp b/Userland/Applications/ThemeEditor/PreviewWidget.cpp
index 0947ffc5e7..423f348896 100644
--- a/Userland/Applications/ThemeEditor/PreviewWidget.cpp
+++ b/Userland/Applications/ThemeEditor/PreviewWidget.cpp
@@ -142,16 +142,16 @@ void PreviewWidget::set_preview_palette(const Gfx::Palette& palette)
update();
}
-void PreviewWidget::set_theme_from_file(String const& path, int fd)
+void PreviewWidget::set_theme_from_file(Core::File& file)
{
- auto file = Core::ConfigFile::open(path, fd);
- auto theme = Gfx::load_system_theme(file);
+ auto config_file = Core::ConfigFile::open(file.filename(), file.leak_fd());
+ auto theme = Gfx::load_system_theme(config_file);
VERIFY(theme.is_valid());
m_preview_palette = Gfx::Palette(Gfx::PaletteImpl::create_with_anonymous_buffer(theme));
set_preview_palette(m_preview_palette);
if (on_theme_load_from_file)
- on_theme_load_from_file(path);
+ on_theme_load_from_file(file.filename());
}
void PreviewWidget::set_color_filter(OwnPtr<Gfx::ColorBlindnessFilter> color_filter)
@@ -264,11 +264,10 @@ void PreviewWidget::drop_event(GUI::DropEvent& event)
return;
}
- auto result = FileSystemAccessClient::Client::the().request_file(window()->window_id(), urls.first().path(), Core::OpenMode::ReadOnly);
- if (result.error != 0)
+ auto response = FileSystemAccessClient::Client::the().try_request_file(window(), urls.first().path(), Core::OpenMode::ReadOnly);
+ if (response.is_error())
return;
-
- set_theme_from_file(urls.first().path(), *result.fd);
+ set_theme_from_file(*response.value());
}
}
diff --git a/Userland/Applications/ThemeEditor/PreviewWidget.h b/Userland/Applications/ThemeEditor/PreviewWidget.h
index 7f952b3503..af822916e5 100644
--- a/Userland/Applications/ThemeEditor/PreviewWidget.h
+++ b/Userland/Applications/ThemeEditor/PreviewWidget.h
@@ -25,7 +25,7 @@ public:
const Gfx::Palette& preview_palette() const { return m_preview_palette; }
void set_preview_palette(const Gfx::Palette&);
- void set_theme_from_file(String const& path, int fd);
+ void set_theme_from_file(Core::File&);
void set_color_filter(OwnPtr<Gfx::ColorBlindnessFilter>);
diff --git a/Userland/Applications/ThemeEditor/main.cpp b/Userland/Applications/ThemeEditor/main.cpp
index 19df0a644c..6c5e9de3ab 100644
--- a/Userland/Applications/ThemeEditor/main.cpp
+++ b/Userland/Applications/ThemeEditor/main.cpp
@@ -351,14 +351,13 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
path_input.set_text(preview_widget.preview_palette().path(selected_path_role));
};
- auto save_to_result = [&](FileSystemAccessClient::Result const& result) {
- if (result.error != 0)
+ auto save_to_result = [&](auto const& response) {
+ if (response.is_error())
return;
- path = result.chosen_file;
update_window_title();
-
- auto theme = Core::ConfigFile::open(*result.chosen_file, *result.fd);
+ auto file = response.value();
+ auto theme = Core::ConfigFile::open(file->filename(), file->leak_fd());
for (auto role : color_roles) {
theme->write_entry("Colors", to_string(role), preview_widget.preview_palette().color(role).to_string());
}
@@ -379,23 +378,22 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
};
TRY(file_menu->try_add_action(GUI::CommonActions::make_open_action([&](auto&) {
- auto result = FileSystemAccessClient::Client::the().open_file(window->window_id(), "Select theme file", "/res/themes");
- if (result.error != 0)
+ auto response = FileSystemAccessClient::Client::the().try_open_file(window, "Select theme file", "/res/themes");
+ if (response.is_error())
return;
-
- preview_widget.set_theme_from_file(*result.chosen_file, *result.fd);
+ preview_widget.set_theme_from_file(*response.value());
})));
TRY(file_menu->try_add_action(GUI::CommonActions::make_save_action([&](auto&) {
if (path.has_value()) {
- save_to_result(FileSystemAccessClient::Client::the().request_file(window->window_id(), *path, Core::OpenMode::WriteOnly | Core::OpenMode::Truncate));
+ save_to_result(FileSystemAccessClient::Client::the().try_request_file(window, *path, Core::OpenMode::WriteOnly | Core::OpenMode::Truncate));
} else {
- save_to_result(FileSystemAccessClient::Client::the().save_file(window->window_id(), "Theme", "ini"));
+ save_to_result(FileSystemAccessClient::Client::the().try_save_file(window, "Theme", "ini"));
}
})));
TRY(file_menu->try_add_action(GUI::CommonActions::make_save_as_action([&](auto&) {
- save_to_result(FileSystemAccessClient::Client::the().save_file(window->window_id(), "Theme", "ini"));
+ save_to_result(FileSystemAccessClient::Client::the().try_save_file(window, "Theme", "ini"));
})));
TRY(file_menu->try_add_separator());