mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-01-30 13:04:13 +00:00
move history to page open action, fix request activate action
This commit is contained in:
parent
da46928dfd
commit
78b7dd960b
@ -70,6 +70,7 @@ impl Page {
|
|||||||
action_page_history_back.clone(),
|
action_page_history_back.clone(),
|
||||||
action_page_history_forward.clone(),
|
action_page_history_forward.clone(),
|
||||||
action_page_reload.clone(),
|
action_page_reload.clone(),
|
||||||
|
action_page_open.clone(),
|
||||||
action_update.clone(),
|
action_update.clone(),
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -89,15 +90,25 @@ impl Page {
|
|||||||
action_page_open.connect_activate({
|
action_page_open.connect_activate({
|
||||||
let navigation = navigation.clone();
|
let navigation = navigation.clone();
|
||||||
let action_page_reload = action_page_reload.clone();
|
let action_page_reload = action_page_reload.clone();
|
||||||
move |_, request| {
|
move |_, parameter| {
|
||||||
// Update request
|
// Get request value from action parameter
|
||||||
navigation.set_request_text(
|
let request = parameter
|
||||||
request
|
|
||||||
.expect("Parameter required for this action")
|
.expect("Parameter required for this action")
|
||||||
.get::<String>()
|
.get::<String>()
|
||||||
.expect("Parameter does not match `String`")
|
.expect("Parameter does not match `String`");
|
||||||
.as_str(),
|
|
||||||
);
|
// Update navigation entry
|
||||||
|
navigation.set_request_text(&request);
|
||||||
|
|
||||||
|
// Add history record
|
||||||
|
match navigation.history_current() {
|
||||||
|
Some(current) => {
|
||||||
|
if current != request {
|
||||||
|
navigation.history_add(request.into());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None => navigation.history_add(request.into()),
|
||||||
|
}
|
||||||
|
|
||||||
// Reload page
|
// Reload page
|
||||||
action_page_reload.activate(None);
|
action_page_reload.activate(None);
|
||||||
@ -188,18 +199,6 @@ impl Page {
|
|||||||
// Return value from redirection holder
|
// Return value from redirection holder
|
||||||
redirect.request()
|
redirect.request()
|
||||||
} else {
|
} else {
|
||||||
// Add history record
|
|
||||||
let value = self.navigation.request_text();
|
|
||||||
|
|
||||||
match self.navigation.history_current() {
|
|
||||||
Some(current) => {
|
|
||||||
if current != value {
|
|
||||||
self.navigation.history_add(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
None => self.navigation.history_add(value),
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reset redirect counter as request value taken from user input
|
// Reset redirect counter as request value taken from user input
|
||||||
self.meta.unset_redirect_count();
|
self.meta.unset_redirect_count();
|
||||||
|
|
||||||
|
@ -34,13 +34,14 @@ impl Navigation {
|
|||||||
action_page_history_back: SimpleAction,
|
action_page_history_back: SimpleAction,
|
||||||
action_page_history_forward: SimpleAction,
|
action_page_history_forward: SimpleAction,
|
||||||
action_page_reload: SimpleAction,
|
action_page_reload: SimpleAction,
|
||||||
|
action_page_open: SimpleAction,
|
||||||
action_update: SimpleAction,
|
action_update: SimpleAction,
|
||||||
) -> Arc<Self> {
|
) -> Arc<Self> {
|
||||||
// Init components
|
// Init components
|
||||||
let home = Home::new_arc(action_page_home);
|
let home = Home::new_arc(action_page_home);
|
||||||
let history = History::new_arc(action_page_history_back, action_page_history_forward);
|
let history = History::new_arc(action_page_history_back, action_page_history_forward);
|
||||||
let reload = Reload::new_arc(action_page_reload.clone());
|
let reload = Reload::new_arc(action_page_reload.clone());
|
||||||
let request = Request::new_arc(action_update.clone(), action_page_reload.clone());
|
let request = Request::new_arc(action_update.clone(), action_page_open.clone());
|
||||||
let bookmark = Bookmark::new_arc();
|
let bookmark = Bookmark::new_arc();
|
||||||
|
|
||||||
// Init widget
|
// Init widget
|
||||||
|
@ -29,10 +29,7 @@ pub struct Widget {
|
|||||||
|
|
||||||
impl Widget {
|
impl Widget {
|
||||||
// Construct
|
// Construct
|
||||||
pub fn new_arc(
|
pub fn new_arc(action_update: SimpleAction, action_page_open: SimpleAction) -> Arc<Self> {
|
||||||
action_update: SimpleAction,
|
|
||||||
action_page_reload: SimpleAction, // @TODO local `action_page_open`?
|
|
||||||
) -> Arc<Self> {
|
|
||||||
// Init animated progress bar state
|
// Init animated progress bar state
|
||||||
let progress = Arc::new(Progress {
|
let progress = Arc::new(Progress {
|
||||||
fraction: RefCell::new(0.0),
|
fraction: RefCell::new(0.0),
|
||||||
@ -50,8 +47,8 @@ impl Widget {
|
|||||||
action_update.activate(Some(&"".to_variant())); // @TODO
|
action_update.activate(Some(&"".to_variant())); // @TODO
|
||||||
});
|
});
|
||||||
|
|
||||||
gobject.connect_activate(move |_| {
|
gobject.connect_activate(move |this| {
|
||||||
action_page_reload.activate(None);
|
action_page_open.activate(Some(&this.text().to_variant()));
|
||||||
});
|
});
|
||||||
|
|
||||||
gobject.connect_state_flags_changed({
|
gobject.connect_state_flags_changed({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user