From ae1d3531bf23cb9da862cc0cd6cfed129898348c Mon Sep 17 00:00:00 2001 From: yggverse Date: Thu, 31 Oct 2024 22:40:48 +0200 Subject: [PATCH] add custom failure icons support --- src/app/browser/window/tab/item/page.rs | 29 +++++++++++++------ .../browser/window/tab/item/page/content.rs | 9 ++++-- .../window/tab/item/page/content/status.rs | 10 +++++-- 3 files changed, 35 insertions(+), 13 deletions(-) diff --git a/src/app/browser/window/tab/item/page.rs b/src/app/browser/window/tab/item/page.rs index 7c7bbf7e..a772cafc 100644 --- a/src/app/browser/window/tab/item/page.rs +++ b/src/app/browser/window/tab/item/page.rs @@ -189,8 +189,11 @@ impl Page { let description = gformat!("Protocol `{scheme}` not supported"); // Update widget - self.content - .set_status_failure(Some(title.as_str()), Some(description.as_str())); + self.content.set_status_failure( + Some(title.as_str()), + Some(description.as_str()), + None, + ); // Update meta self.meta.replace(Meta { @@ -523,7 +526,8 @@ impl Page { // Update widget content.set_status_failure( Some(title.as_str()), - Some(description.as_str()) + Some(description.as_str()), + None ); // Update meta @@ -593,7 +597,8 @@ impl Page { // Update widget content.set_status_failure( Some(title.as_str()), - Some(description.as_str()) + Some(description.as_str()), + None ); // Update meta @@ -622,7 +627,8 @@ impl Page { // Update widget content.set_status_failure( Some(title.as_str()), - Some(description.as_str()) + Some(description.as_str()), + None ); // Update meta @@ -660,6 +666,7 @@ impl Page { content.set_status_failure( Some(title.as_str()), Some(description.as_str()), + None ); // Update meta @@ -695,7 +702,8 @@ impl Page { None => { content.set_status_failure( Some(&"Oops"), - Some(&"Could not parse redirect meta") + Some(&"Could not parse redirect meta"), + None ); }, } @@ -758,7 +766,8 @@ impl Page { // Update widget content.set_status_failure( Some(title.as_str()), - Some(description.as_str()) + Some(description.as_str()), + None ); // Update meta @@ -783,7 +792,8 @@ impl Page { // Update widget content.set_status_failure( Some(title.as_str()), - Some(description.as_str()) + Some(description.as_str()), + None ); // Update meta @@ -808,7 +818,8 @@ impl Page { // Update widget content.set_status_failure( Some(title.as_str()), - Some(description.as_str()) + Some(description.as_str()), + None ); // Update meta diff --git a/src/app/browser/window/tab/item/page/content.rs b/src/app/browser/window/tab/item/page/content.rs index adad4ff9..0feb6921 100644 --- a/src/app/browser/window/tab/item/page/content.rs +++ b/src/app/browser/window/tab/item/page/content.rs @@ -50,9 +50,14 @@ impl Content { /// Set new `content::Status` component for `Self` with new `status::Failure` preset /// /// * action removes previous children component from `Self` - pub fn set_status_failure(&self, title: Option<&str>, description: Option<&str>) -> Status { + pub fn set_status_failure( + &self, + title: Option<&str>, + description: Option<&str>, + icon_name: Option<&str>, + ) -> Status { self.clean(); - let status = Status::new_failure(title, description); + let status = Status::new_failure(title, description, icon_name); self.gobject.append(status.gobject()); status } diff --git a/src/app/browser/window/tab/item/page/content/status.rs b/src/app/browser/window/tab/item/page/content/status.rs index 5317f6de..4e7cfe38 100644 --- a/src/app/browser/window/tab/item/page/content/status.rs +++ b/src/app/browser/window/tab/item/page/content/status.rs @@ -17,9 +17,15 @@ impl Status { /// Create new failure preset /// /// Useful as placeholder widget for error handlers - pub fn new_failure(title: Option<&str>, description: Option<&str>) -> Self { + pub fn new_failure( + title: Option<&str>, + description: Option<&str>, + icon_name: Option<&str>, + ) -> Self { Self { - gobject: Failure::new(title, description, None).gobject().clone(), + gobject: Failure::new(title, description, icon_name) + .gobject() + .clone(), } }