mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-02 17:45:28 +00:00
update actions enabled status on tab menu request
This commit is contained in:
parent
90759f6aea
commit
5883593c39
1 changed files with 37 additions and 31 deletions
|
|
@ -54,29 +54,33 @@ impl Tab {
|
||||||
widget.tab_view.connect_setup_menu({
|
widget.tab_view.connect_setup_menu({
|
||||||
let action = window_action.clone();
|
let action = window_action.clone();
|
||||||
let index = index.clone();
|
let index = index.clone();
|
||||||
let widget = widget.clone();
|
|
||||||
move |tab_view, tab_page| {
|
move |tab_view, tab_page| {
|
||||||
let state = match tab_page {
|
// Update actions on open popover request (`tab_page` == `Some`)
|
||||||
// on menu open
|
// * it's no handle for popover close event (`tab_page` == `None`)
|
||||||
Some(tab_page) => {
|
// as it will be updated on the next init for new tab selected
|
||||||
if let Some(item) = index.borrow().get(tab_page) {
|
tab_page.map(|tab_page| {
|
||||||
item.page.update(); // update window actions using page of tab activated
|
index.borrow().get(tab_page).map(|item| {
|
||||||
}
|
// Update actions status
|
||||||
|
action
|
||||||
|
.history_back
|
||||||
|
.simple_action
|
||||||
|
.set_enabled(item.action.history.back.is_enabled());
|
||||||
|
action
|
||||||
|
.history_forward
|
||||||
|
.simple_action
|
||||||
|
.set_enabled(item.action.history.forward.is_enabled());
|
||||||
|
action
|
||||||
|
.home
|
||||||
|
.simple_action
|
||||||
|
.set_enabled(item.action.home.is_enabled());
|
||||||
|
action
|
||||||
|
.reload
|
||||||
|
.simple_action
|
||||||
|
.set_enabled(item.action.reload.is_enabled());
|
||||||
|
|
||||||
Some(tab_view.page_position(tab_page)) // activated tab
|
// Update actions target
|
||||||
}
|
let state = Some(tab_view.page_position(tab_page));
|
||||||
// on menu close
|
|
||||||
None => {
|
|
||||||
if let Some(tab_page) = widget.page(None) {
|
|
||||||
if let Some(item) = index.borrow().get(&tab_page) {
|
|
||||||
item.page.update(); // update window actions using page of current tab
|
|
||||||
}
|
|
||||||
}
|
|
||||||
None // current tab
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Update actions with new state value
|
|
||||||
action.bookmark.change_state(state);
|
action.bookmark.change_state(state);
|
||||||
action.close_all.change_state(state);
|
action.close_all.change_state(state);
|
||||||
action.close.change_state(state);
|
action.close.change_state(state);
|
||||||
|
|
@ -88,6 +92,8 @@ impl Tab {
|
||||||
action.reload.change_state(state);
|
action.reload.change_state(state);
|
||||||
action.save_as.change_state(state);
|
action.save_as.change_state(state);
|
||||||
action.source.change_state(state);
|
action.source.change_state(state);
|
||||||
|
})
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue