mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-01-15 17:20:08 +00:00
fix active page reset
This commit is contained in:
parent
b443d1c58e
commit
710093b161
@ -52,7 +52,7 @@ impl App {
|
|||||||
let action_page_home = Action::new("win", false, None);
|
let action_page_home = Action::new("win", false, None);
|
||||||
let action_page_history_back = Action::new("win", false, None);
|
let action_page_history_back = Action::new("win", false, None);
|
||||||
let action_page_history_forward = Action::new("win", false, None);
|
let action_page_history_forward = Action::new("win", false, None);
|
||||||
let action_page_reload = Action::new_stateful("win", true, None, &0.to_variant()); // @TODO
|
let action_page_reload = Action::new_stateful("win", true, None, &(-1).to_variant());
|
||||||
let action_page_pin = Action::new("win", true, None);
|
let action_page_pin = Action::new("win", true, None);
|
||||||
|
|
||||||
// Init GTK
|
// Init GTK
|
||||||
|
@ -27,6 +27,9 @@ impl Action {
|
|||||||
Self { group, simple }
|
Self { group, simple }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Stateful constructors useful for actions that require custom values
|
||||||
|
/// but could not receive it directly with action argument
|
||||||
|
/// e.g. [MenuModel](https://docs.gtk.org/gio/class.MenuModel.html)
|
||||||
pub fn new_stateful(
|
pub fn new_stateful(
|
||||||
group: &str,
|
group: &str,
|
||||||
is_enabled: bool,
|
is_enabled: bool,
|
||||||
|
@ -181,7 +181,11 @@ impl Browser {
|
|||||||
.get::<i32>()
|
.get::<i32>()
|
||||||
.expect("Parameter does not match `i32`");
|
.expect("Parameter does not match `i32`");
|
||||||
|
|
||||||
window.tab_page_navigation_reload(page_position);
|
if page_position > -1 {
|
||||||
|
window.tab_page_navigation_reload(Some(page_position));
|
||||||
|
} else {
|
||||||
|
window.tab_page_navigation_reload(None);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -92,7 +92,8 @@ impl Window {
|
|||||||
self.tab.page_navigation_history_forward();
|
self.tab.page_navigation_history_forward();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn tab_page_navigation_reload(&self, page_position: i32) {
|
/// Reload page at `i32` position or selected page on `None` given
|
||||||
|
pub fn tab_page_navigation_reload(&self, page_position: Option<i32>) {
|
||||||
self.tab.page_navigation_reload(page_position);
|
self.tab.page_navigation_reload(page_position);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,23 +72,21 @@ impl Tab {
|
|||||||
// Menu opened:
|
// Menu opened:
|
||||||
// setup actions to operate with page selected only
|
// setup actions to operate with page selected only
|
||||||
Some(this) => {
|
Some(this) => {
|
||||||
let position = tab_view.page_position(this).to_variant();
|
// Set state
|
||||||
|
let state = tab_view.page_position(this).to_variant();
|
||||||
|
|
||||||
action_page_reload.change_state(&position);
|
// Update related actions
|
||||||
|
action_page_reload.change_state(&state);
|
||||||
}
|
}
|
||||||
// Menu closed:
|
// Menu closed:
|
||||||
// return actions to default values
|
// return actions to default values
|
||||||
None => match tab_view.selected_page() {
|
None => {
|
||||||
Some(selected) => {
|
// Set state
|
||||||
// Get position of page selected
|
let state = &(-1).to_variant();
|
||||||
let position = tab_view.page_position(&selected).to_variant();
|
|
||||||
|
|
||||||
// Update related actions
|
// Update related actions
|
||||||
action_page_reload.change_state(&position);
|
action_page_reload.change_state(&state);
|
||||||
}
|
}
|
||||||
// No selected page found, disable related actions
|
|
||||||
None => action_page_reload.set_enabled(false),
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -242,10 +240,22 @@ impl Tab {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn page_navigation_reload(&self, page_position: i32) {
|
/// Reload page at `i32` position or selected page on `None` given
|
||||||
if let Some(id) = self.widget.gobject().nth_page(page_position).keyword() {
|
pub fn page_navigation_reload(&self, page_position: Option<i32>) {
|
||||||
if let Some(item) = self.index.borrow().get(&id) {
|
match page_position {
|
||||||
item.page_navigation_reload();
|
Some(value) => {
|
||||||
|
if let Some(id) = self.widget.gobject().nth_page(value).keyword() {
|
||||||
|
if let Some(item) = self.index.borrow().get(&id) {
|
||||||
|
item.page_navigation_reload();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None => {
|
||||||
|
if let Some(id) = self.widget.current_page_keyword() {
|
||||||
|
if let Some(item) = self.index.borrow().get(&id) {
|
||||||
|
item.page_navigation_reload();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user