mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-03-31 08:35:28 +00:00
reset notice banner on page update
This commit is contained in:
parent
f7b653f36a
commit
c8607e151a
4 changed files with 24 additions and 14 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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<Content>,
|
||||
pub input: Rc<Input>,
|
||||
pub navigation: Rc<Navigation>,
|
||||
pub notice: Banner,
|
||||
pub notice: Rc<Notice>,
|
||||
pub search: Rc<Search>,
|
||||
// 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 {
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue