Browse Source

add custom failure icons support

master
yggverse 1 month ago
parent
commit
ae1d3531bf
  1. 29
      src/app/browser/window/tab/item/page.rs
  2. 9
      src/app/browser/window/tab/item/page/content.rs
  3. 10
      src/app/browser/window/tab/item/page/content/status.rs

29
src/app/browser/window/tab/item/page.rs

@ -189,8 +189,11 @@ impl Page {
let description = gformat!("Protocol `{scheme}` not supported"); let description = gformat!("Protocol `{scheme}` not supported");
// Update widget // Update widget
self.content self.content.set_status_failure(
.set_status_failure(Some(title.as_str()), Some(description.as_str())); Some(title.as_str()),
Some(description.as_str()),
None,
);
// Update meta // Update meta
self.meta.replace(Meta { self.meta.replace(Meta {
@ -523,7 +526,8 @@ impl Page {
// Update widget // Update widget
content.set_status_failure( content.set_status_failure(
Some(title.as_str()), Some(title.as_str()),
Some(description.as_str()) Some(description.as_str()),
None
); );
// Update meta // Update meta
@ -593,7 +597,8 @@ impl Page {
// Update widget // Update widget
content.set_status_failure( content.set_status_failure(
Some(title.as_str()), Some(title.as_str()),
Some(description.as_str()) Some(description.as_str()),
None
); );
// Update meta // Update meta
@ -622,7 +627,8 @@ impl Page {
// Update widget // Update widget
content.set_status_failure( content.set_status_failure(
Some(title.as_str()), Some(title.as_str()),
Some(description.as_str()) Some(description.as_str()),
None
); );
// Update meta // Update meta
@ -660,6 +666,7 @@ impl Page {
content.set_status_failure( content.set_status_failure(
Some(title.as_str()), Some(title.as_str()),
Some(description.as_str()), Some(description.as_str()),
None
); );
// Update meta // Update meta
@ -695,7 +702,8 @@ impl Page {
None => { None => {
content.set_status_failure( content.set_status_failure(
Some(&"Oops"), Some(&"Oops"),
Some(&"Could not parse redirect meta") Some(&"Could not parse redirect meta"),
None
); );
}, },
} }
@ -758,7 +766,8 @@ impl Page {
// Update widget // Update widget
content.set_status_failure( content.set_status_failure(
Some(title.as_str()), Some(title.as_str()),
Some(description.as_str()) Some(description.as_str()),
None
); );
// Update meta // Update meta
@ -783,7 +792,8 @@ impl Page {
// Update widget // Update widget
content.set_status_failure( content.set_status_failure(
Some(title.as_str()), Some(title.as_str()),
Some(description.as_str()) Some(description.as_str()),
None
); );
// Update meta // Update meta
@ -808,7 +818,8 @@ impl Page {
// Update widget // Update widget
content.set_status_failure( content.set_status_failure(
Some(title.as_str()), Some(title.as_str()),
Some(description.as_str()) Some(description.as_str()),
None
); );
// Update meta // Update meta

9
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 /// Set new `content::Status` component for `Self` with new `status::Failure` preset
/// ///
/// * action removes previous children component from `Self` /// * 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(); self.clean();
let status = Status::new_failure(title, description); let status = Status::new_failure(title, description, icon_name);
self.gobject.append(status.gobject()); self.gobject.append(status.gobject());
status status
} }

10
src/app/browser/window/tab/item/page/content/status.rs

@ -17,9 +17,15 @@ impl Status {
/// Create new failure preset /// Create new failure preset
/// ///
/// Useful as placeholder widget for error handlers /// 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 { Self {
gobject: Failure::new(title, description, None).gobject().clone(), gobject: Failure::new(title, description, icon_name)
.gobject()
.clone(),
} }
} }

Loading…
Cancel
Save