mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 17:15:28 +00:00
update global actions if tab restored is selected
This commit is contained in:
parent
25db274d2e
commit
34aa1fb2f4
1 changed files with 23 additions and 7 deletions
|
|
@ -64,7 +64,7 @@ impl Tab {
|
||||||
// by documentation:
|
// by documentation:
|
||||||
// * `tab_page` == `Some` - popover open
|
// * `tab_page` == `Some` - popover open
|
||||||
// * `tab_page` == `None` - popover closed
|
// * `tab_page` == `None` - popover closed
|
||||||
update_actions(tab_view, tab_page.cloned(), &index, &window_action);
|
update_actions(tab_view, tab_page, &index, &window_action);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -81,7 +81,12 @@ impl Tab {
|
||||||
DateTime::now_local().unwrap().to_unix(),
|
DateTime::now_local().unwrap().to_unix(),
|
||||||
);
|
);
|
||||||
|
|
||||||
update_actions(tab_view, tab_view.selected_page(), &index, &window_action);
|
update_actions(
|
||||||
|
tab_view,
|
||||||
|
tab_view.selected_page().as_ref(),
|
||||||
|
&index,
|
||||||
|
&window_action,
|
||||||
|
);
|
||||||
Propagation::Proceed
|
Propagation::Proceed
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -93,7 +98,12 @@ impl Tab {
|
||||||
if let Some(tab_page) = tab_view.selected_page() {
|
if let Some(tab_page) = tab_view.selected_page() {
|
||||||
tab_page.set_needs_attention(false);
|
tab_page.set_needs_attention(false);
|
||||||
}
|
}
|
||||||
update_actions(tab_view, tab_view.selected_page(), &index, &window_action)
|
update_actions(
|
||||||
|
tab_view,
|
||||||
|
tab_view.selected_page().as_ref(),
|
||||||
|
&index,
|
||||||
|
&window_action,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -156,7 +166,7 @@ impl Tab {
|
||||||
|
|
||||||
update_actions(
|
update_actions(
|
||||||
&self.tab_view,
|
&self.tab_view,
|
||||||
self.tab_view.selected_page(),
|
self.tab_view.selected_page().as_ref(),
|
||||||
&self.index,
|
&self.index,
|
||||||
&self.window_action,
|
&self.window_action,
|
||||||
);
|
);
|
||||||
|
|
@ -329,6 +339,12 @@ impl Tab {
|
||||||
|
|
||||||
if item_record.is_selected {
|
if item_record.is_selected {
|
||||||
self.tab_view.set_selected_page(&item.tab_page);
|
self.tab_view.set_selected_page(&item.tab_page);
|
||||||
|
update_actions(
|
||||||
|
&self.tab_view,
|
||||||
|
Some(&item.tab_page),
|
||||||
|
&self.index,
|
||||||
|
&self.window_action,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restore children components
|
// Restore children components
|
||||||
|
|
@ -398,13 +414,13 @@ pub fn migrate(tx: &Transaction) -> Result<(), String> {
|
||||||
|
|
||||||
fn update_actions(
|
fn update_actions(
|
||||||
tab_view: &TabView,
|
tab_view: &TabView,
|
||||||
tab_page: Option<TabPage>,
|
tab_page: Option<&TabPage>,
|
||||||
index: &Rc<RefCell<HashMap<TabPage, Rc<Item>>>>,
|
index: &Rc<RefCell<HashMap<TabPage, Rc<Item>>>>,
|
||||||
window_action: &Rc<WindowAction>,
|
window_action: &Rc<WindowAction>,
|
||||||
) {
|
) {
|
||||||
match tab_page {
|
match tab_page {
|
||||||
Some(tab_page) => {
|
Some(tab_page) => {
|
||||||
if let Some(item) = index.borrow().get(&tab_page) {
|
if let Some(item) = index.borrow().get(tab_page) {
|
||||||
window_action
|
window_action
|
||||||
.home
|
.home
|
||||||
.simple_action
|
.simple_action
|
||||||
|
|
@ -422,7 +438,7 @@ fn update_actions(
|
||||||
.simple_action
|
.simple_action
|
||||||
.set_enabled(item.action.history.forward.is_enabled());
|
.set_enabled(item.action.history.forward.is_enabled());
|
||||||
|
|
||||||
window_action.change_state(Some(tab_view.page_position(&tab_page)));
|
window_action.change_state(Some(tab_view.page_position(tab_page)));
|
||||||
} // @TODO incorrect index init implementation, tabs refactory wanted
|
} // @TODO incorrect index init implementation, tabs refactory wanted
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue