diff --git a/src/app/browser/window/tab/item.rs b/src/app/browser/window/tab/item.rs index 85987fa3..f4ca2a1a 100644 --- a/src/app/browser/window/tab/item.rs +++ b/src/app/browser/window/tab/item.rs @@ -63,7 +63,7 @@ impl Item { )); target_child.append(&page.navigation.g_box); - target_child.append(&page.notice); + target_child.append(&page.notice.banner); target_child.append(&page.content.g_box); target_child.append(&page.search.g_box); target_child.append(&page.input.clamp); diff --git a/src/app/browser/window/tab/item/client.rs b/src/app/browser/window/tab/item/client.rs index 2383f06a..415732ab 100644 --- a/src/app/browser/window/tab/item/client.rs +++ b/src/app/browser/window/tab/item/client.rs @@ -48,8 +48,9 @@ impl Client { .set_enabled(false); // Reset widgets - self.page.search.unset(); self.page.input.unset(); + self.page.notice.unset(); + self.page.search.unset(); self.page.set_title("Loading.."); self.page.set_progress(0.1); diff --git a/src/app/browser/window/tab/item/page.rs b/src/app/browser/window/tab/item/page.rs index a95f5b80..211621b6 100644 --- a/src/app/browser/window/tab/item/page.rs +++ b/src/app/browser/window/tab/item/page.rs @@ -7,7 +7,7 @@ mod notice; mod search; use super::{Action as ItemAction, BrowserAction, Profile, TabAction, WindowAction}; -use adw::{Banner, TabPage}; +use adw::TabPage; use content::Content; use error::Error; use input::Input; @@ -27,7 +27,7 @@ pub struct Page { pub content: Rc, pub input: Rc, pub navigation: Rc, - pub notice: Banner, + pub notice: Rc, pub search: Rc, // System /// Reference to [TabPage](https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/class.TabPage.html) @@ -59,7 +59,7 @@ impl Page { (window_action, tab_action, item_action), )); let input = Rc::new(Input::new()); - let notice = Banner::notice(); + let notice = Rc::new(Notice::new()); // Done Self { diff --git a/src/app/browser/window/tab/item/page/notice.rs b/src/app/browser/window/tab/item/page/notice.rs index 5bef0098..303bc54c 100644 --- a/src/app/browser/window/tab/item/page/notice.rs +++ b/src/app/browser/window/tab/item/page/notice.rs @@ -1,24 +1,33 @@ use adw::Banner; -pub trait Notice { - fn notice() -> Self; - fn show(&self, title: &str); +pub struct Notice { + pub banner: Banner, } -impl Notice for Banner { +impl Notice { // Constructors /// Create new `Self` - fn notice() -> Self { + pub fn new() -> Self { let banner = Banner::builder().button_label("Ok").build(); banner.connect_button_clicked(|this| this.set_revealed(false)); - banner + Self { banner } } // Actions - fn show(&self, title: &str) { - self.set_title(title); - self.set_revealed(true); + pub fn show(&self, title: &str) { + self.banner.set_title(title); + self.banner.set_revealed(true); + } + + pub fn unset(&self) { + self.banner.set_revealed(false); + } +} + +impl Default for Notice { + fn default() -> Self { + Self::new() } }