1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 15:07:45 +00:00

Browser: Convert BookmarksBarWidget to use failable functions

This commit is contained in:
Cameron Youell 2023-04-17 15:57:16 +10:00 committed by Andreas Kling
parent bedb370dec
commit 2df0eeaa20
4 changed files with 58 additions and 57 deletions

View file

@ -32,20 +32,19 @@ public:
InNewWindow
};
Function<void(DeprecatedString const& url, Open)> on_bookmark_click;
Function<void(DeprecatedString const&, DeprecatedString const&)> on_bookmark_hover;
Function<void()> on_bookmark_change;
bool contains_bookmark(DeprecatedString const& url);
bool remove_bookmark(DeprecatedString const& url);
bool add_bookmark(DeprecatedString const& url, DeprecatedString const& title);
enum class PerformEditOn {
NewBookmark,
ExistingBookmark
};
bool edit_bookmark(DeprecatedString const& url, PerformEditOn perform_edit_on = PerformEditOn::ExistingBookmark);
Function<void(DeprecatedString const& url, Open)> on_bookmark_click;
Function<void(DeprecatedString const&, DeprecatedString const&)> on_bookmark_hover;
Function<void()> on_bookmark_change;
bool contains_bookmark(StringView url);
ErrorOr<void> remove_bookmark(StringView url);
ErrorOr<void> add_bookmark(StringView url, StringView title);
ErrorOr<void> edit_bookmark(StringView url, PerformEditOn perform_edit_on = PerformEditOn::ExistingBookmark);
virtual Optional<GUI::UISize> calculated_min_size() const override
{
@ -64,7 +63,7 @@ private:
void update_content_size();
bool update_model(Vector<JsonValue>& values, Function<bool(GUI::JsonArrayModel& model, Vector<JsonValue>&& values)> perform_model_change);
ErrorOr<void> update_model(Vector<JsonValue>& values, Function<ErrorOr<void>(GUI::JsonArrayModel& model, Vector<JsonValue>&& values)> perform_model_change);
RefPtr<GUI::Model> m_model;
RefPtr<GUI::Button> m_additional;