mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-02 17:45:28 +00:00
remove extra update actions
This commit is contained in:
parent
d0287695ff
commit
b3b2763af1
4 changed files with 21 additions and 47 deletions
|
|
@ -154,25 +154,6 @@ impl Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actions
|
|
||||||
pub fn update(&self) {
|
|
||||||
// Update self actions
|
|
||||||
self.action.home.set_enabled(
|
|
||||||
self.page
|
|
||||||
.navigation
|
|
||||||
.request
|
|
||||||
.home()
|
|
||||||
.is_some_and(|home| home.to_string() != self.page.navigation.request.entry.text()),
|
|
||||||
);
|
|
||||||
|
|
||||||
self.action
|
|
||||||
.reload
|
|
||||||
.set_enabled(!self.page.navigation.request.entry.text().is_empty());
|
|
||||||
|
|
||||||
// Update child components
|
|
||||||
self.page.update();
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn clean(
|
pub fn clean(
|
||||||
&self,
|
&self,
|
||||||
transaction: &Transaction,
|
transaction: &Transaction,
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,6 @@ impl Page {
|
||||||
Ok(result) => Ok(result),
|
Ok(result) => Ok(result),
|
||||||
Err(_) => Err(Error::Bookmark), // @TODO
|
Err(_) => Err(Error::Bookmark), // @TODO
|
||||||
};
|
};
|
||||||
self.update();
|
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -111,12 +110,6 @@ impl Page {
|
||||||
self.search.show()
|
self.search.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Update `Self` witch children components
|
|
||||||
pub fn update(&self) {
|
|
||||||
// Update children components
|
|
||||||
self.navigation.update();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Cleanup session for `Self`
|
/// Cleanup session for `Self`
|
||||||
pub fn clean(
|
pub fn clean(
|
||||||
&self,
|
&self,
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ impl Navigation {
|
||||||
let request = Rc::new(Request::build(item_action, profile));
|
let request = Rc::new(Request::build(item_action, profile));
|
||||||
let reload = Button::reload((window_action, tab_action, item_action), &request);
|
let reload = Button::reload((window_action, tab_action, item_action), &request);
|
||||||
let home = Button::home((window_action, tab_action, item_action), &request);
|
let home = Button::home((window_action, tab_action, item_action), &request);
|
||||||
let bookmark = Button::bookmark(window_action);
|
let bookmark = Button::bookmark(window_action, profile, &request);
|
||||||
|
|
||||||
// init main widget
|
// init main widget
|
||||||
let widget = Rc::new(Widget::build(
|
let widget = Rc::new(Widget::build(
|
||||||
|
|
@ -65,15 +65,6 @@ impl Navigation {
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
|
|
||||||
pub fn update(&self) {
|
|
||||||
// init shared request value
|
|
||||||
let request = self.request.strip_prefix();
|
|
||||||
|
|
||||||
// update children components
|
|
||||||
self.bookmark
|
|
||||||
.update(self.profile.bookmark.get(&request).is_ok());
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn clean(
|
pub fn clean(
|
||||||
&self,
|
&self,
|
||||||
transaction: &Transaction,
|
transaction: &Transaction,
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use super::WindowAction;
|
use super::{Profile, Request, WindowAction};
|
||||||
use gtk::{
|
use gtk::{
|
||||||
prelude::{ActionExt, ButtonExt},
|
prelude::{ActionExt, ButtonExt, EditableExt},
|
||||||
Button,
|
Button,
|
||||||
};
|
};
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
@ -9,24 +9,33 @@ const ICON_YES: &str = "starred-symbolic";
|
||||||
const ICON_NON: &str = "non-starred-symbolic";
|
const ICON_NON: &str = "non-starred-symbolic";
|
||||||
|
|
||||||
pub trait Bookmark {
|
pub trait Bookmark {
|
||||||
fn bookmark(action: &Rc<WindowAction>) -> Self;
|
fn bookmark(action: &Rc<WindowAction>, profile: &Rc<Profile>, request: &Rc<Request>) -> Self;
|
||||||
fn update(&self, has_bookmark: bool);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Bookmark for Button {
|
impl Bookmark for Button {
|
||||||
fn bookmark(action: &Rc<WindowAction>) -> Self {
|
fn bookmark(action: &Rc<WindowAction>, profile: &Rc<Profile>, request: &Rc<Request>) -> Self {
|
||||||
Button::builder()
|
let has_bookmark = profile.bookmark.get(&request.entry.text()).is_ok();
|
||||||
|
|
||||||
|
let button = Button::builder()
|
||||||
.action_name(format!(
|
.action_name(format!(
|
||||||
"{}.{}",
|
"{}.{}",
|
||||||
action.id,
|
action.id,
|
||||||
action.bookmark.simple_action.name()
|
action.bookmark.simple_action.name()
|
||||||
)) // @TODO
|
)) // @TODO
|
||||||
.icon_name(ICON_NON)
|
.icon_name(icon_name(has_bookmark))
|
||||||
.tooltip_text("Bookmark")
|
.tooltip_text("Bookmark")
|
||||||
.build()
|
.build();
|
||||||
|
|
||||||
|
button.connect_clicked(move |this| this.set_icon_name(icon_name(has_bookmark)));
|
||||||
|
|
||||||
|
button
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update(&self, has_bookmark: bool) {
|
fn icon_name(has_bookmark: bool) -> &'static str {
|
||||||
self.set_icon_name(if has_bookmark { ICON_YES } else { ICON_NON });
|
if has_bookmark {
|
||||||
|
ICON_YES
|
||||||
|
} else {
|
||||||
|
ICON_NON
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue