mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 17:15:28 +00:00
fix global actions update on setup menu
This commit is contained in:
parent
bd2d85120e
commit
9eaf599892
1 changed files with 55 additions and 34 deletions
|
|
@ -57,6 +57,26 @@ impl Tab {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Init events
|
// Init events
|
||||||
|
tab_view.connect_setup_menu({
|
||||||
|
let index = index.clone();
|
||||||
|
let window_action = window_action.clone();
|
||||||
|
move |tab_view, tab_page| {
|
||||||
|
// by documentation:
|
||||||
|
// * `tab_page` == `Some` - popover open
|
||||||
|
// * `tab_page` == `None` - popover closed
|
||||||
|
update_actions(
|
||||||
|
tab_view,
|
||||||
|
match tab_page {
|
||||||
|
Some(this) => Some(this.clone()),
|
||||||
|
None => tab_view.selected_page(),
|
||||||
|
}
|
||||||
|
.as_ref(),
|
||||||
|
&index,
|
||||||
|
&window_action,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
tab_view.connect_close_page({
|
tab_view.connect_close_page({
|
||||||
let index = index.clone();
|
let index = index.clone();
|
||||||
let profile = profile.clone();
|
let profile = profile.clone();
|
||||||
|
|
@ -83,12 +103,16 @@ impl Tab {
|
||||||
let window_action = window_action.clone();
|
let window_action = window_action.clone();
|
||||||
let index = index.clone();
|
let index = index.clone();
|
||||||
move |tab_view| {
|
move |tab_view| {
|
||||||
if let Some(tab_page) = tab_view.selected_page() {
|
|
||||||
tab_page.set_needs_attention(false);
|
|
||||||
}
|
|
||||||
update_actions(
|
update_actions(
|
||||||
tab_view,
|
tab_view,
|
||||||
tab_view.selected_page().as_ref(),
|
match tab_view.selected_page() {
|
||||||
|
Some(this) => {
|
||||||
|
this.set_needs_attention(false);
|
||||||
|
Some(this.clone())
|
||||||
|
}
|
||||||
|
None => None,
|
||||||
|
}
|
||||||
|
.as_ref(),
|
||||||
&index,
|
&index,
|
||||||
&window_action,
|
&window_action,
|
||||||
)
|
)
|
||||||
|
|
@ -392,42 +416,39 @@ fn update_actions(
|
||||||
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 {
|
if let Some(tab_page) = 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
|
.set_enabled(item.action.home.is_enabled());
|
||||||
.set_enabled(item.action.home.is_enabled());
|
window_action
|
||||||
window_action
|
.reload
|
||||||
.reload
|
.simple_action
|
||||||
.simple_action
|
.set_enabled(item.action.reload.is_enabled());
|
||||||
.set_enabled(item.action.reload.is_enabled());
|
window_action
|
||||||
window_action
|
.history_back
|
||||||
.history_back
|
.simple_action
|
||||||
.simple_action
|
.set_enabled(item.action.history.back.is_enabled());
|
||||||
.set_enabled(item.action.history.back.is_enabled());
|
|
||||||
window_action
|
|
||||||
.history_forward
|
|
||||||
.simple_action
|
|
||||||
.set_enabled(item.action.history.forward.is_enabled());
|
|
||||||
|
|
||||||
window_action.change_state(Some(tab_view.page_position(tab_page)));
|
|
||||||
} // @TODO incorrect index init implementation, tabs refactory wanted
|
|
||||||
}
|
|
||||||
None => {
|
|
||||||
// Reset to defaults
|
|
||||||
window_action.home.simple_action.set_enabled(false);
|
|
||||||
window_action.reload.simple_action.set_enabled(false);
|
|
||||||
window_action.history_back.simple_action.set_enabled(false);
|
|
||||||
window_action
|
window_action
|
||||||
.history_forward
|
.history_forward
|
||||||
.simple_action
|
.simple_action
|
||||||
.set_enabled(false);
|
.set_enabled(item.action.history.forward.is_enabled());
|
||||||
|
|
||||||
window_action.change_state(None);
|
window_action.change_state(Some(tab_view.page_position(tab_page)));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Reset to defaults
|
||||||
|
window_action.home.simple_action.set_enabled(false);
|
||||||
|
window_action.reload.simple_action.set_enabled(false);
|
||||||
|
window_action.history_back.simple_action.set_enabled(false);
|
||||||
|
window_action
|
||||||
|
.history_forward
|
||||||
|
.simple_action
|
||||||
|
.set_enabled(false);
|
||||||
|
|
||||||
|
window_action.change_state(None);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create new [TabPage](https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/class.TabPage.html)
|
/// Create new [TabPage](https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/class.TabPage.html)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue