mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-01-15 17:20:08 +00:00
update window actions on menu setup, fix #5
This commit is contained in:
parent
dc83042301
commit
9f7a8882cc
@ -43,13 +43,36 @@ impl Tab {
|
|||||||
let widget = Rc::new(Widget::new(&menu.main));
|
let widget = Rc::new(Widget::new(&menu.main));
|
||||||
|
|
||||||
// Init events
|
// Init events
|
||||||
|
|
||||||
widget.tab_view.connect_setup_menu({
|
widget.tab_view.connect_setup_menu({
|
||||||
let action = action.1.clone();
|
let action = action.1.clone();
|
||||||
|
let index = index.clone();
|
||||||
|
let widget = widget.clone();
|
||||||
move |tab_view, tab_page| {
|
move |tab_view, tab_page| {
|
||||||
// Set new state for page selected on menu open
|
let state = match tab_page {
|
||||||
// * this action return default state (`None`) on menu close
|
// on menu open
|
||||||
let state = tab_page.map(|this| tab_view.page_position(this));
|
Some(this) => {
|
||||||
|
let position = tab_view.page_position(this);
|
||||||
|
if let Some(page) = widget.page(Some(position)) {
|
||||||
|
if let Some(id) = page.keyword() {
|
||||||
|
if let Some(item) = index.borrow().get(&id) {
|
||||||
|
item.page.update(); // update window actions for tab activated
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Some(position)
|
||||||
|
}
|
||||||
|
// on menu close
|
||||||
|
None => {
|
||||||
|
if let Some(page) = widget.page(None) {
|
||||||
|
if let Some(id) = page.keyword() {
|
||||||
|
if let Some(item) = index.borrow().get(&id) {
|
||||||
|
item.page.update(); // update window actions for current tab
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// Update actions with new state value
|
// Update actions with new state value
|
||||||
action.bookmark.change_state(state);
|
action.bookmark.change_state(state);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user