update window actions on tab change

This commit is contained in:
yggverse 2025-01-26 16:41:59 +02:00
parent 81cea44302
commit 49c1f5923b
2 changed files with 18 additions and 4 deletions

View file

@ -158,7 +158,6 @@ impl Window {
} }
Err(e) => return Err(e.to_string()), Err(e) => return Err(e.to_string()),
} }
Ok(()) Ok(())
} }

View file

@ -15,7 +15,7 @@ use super::{Action as WindowAction, BrowserAction, Position};
use crate::Profile; use crate::Profile;
use gtk::{ use gtk::{
glib::{DateTime, GString, Propagation}, glib::{DateTime, GString, Propagation},
prelude::{EditableExt, WidgetExt}, prelude::{ActionExt, EditableExt, WidgetExt},
}; };
use sqlite::Transaction; use sqlite::Transaction;
use std::{cell::RefCell, collections::HashMap, rc::Rc}; use std::{cell::RefCell, collections::HashMap, rc::Rc};
@ -123,15 +123,30 @@ impl Tab {
}); });
widget.tab_view.connect_selected_page_notify({ widget.tab_view.connect_selected_page_notify({
let window_action = window_action.clone();
let index = index.clone(); let index = index.clone();
move |this| { move |this| {
if let Some(page) = this.selected_page() { if let Some(page) = this.selected_page() {
if let Some(id) = page.keyword() { if let Some(id) = page.keyword() {
if let Some(item) = index.borrow().get(&id) { if let Some(item) = index.borrow().get(&id) {
item.update(); window_action
.home
.simple_action
.set_enabled(item.action.home.is_enabled());
window_action
.reload
.simple_action
.set_enabled(item.action.reload.is_enabled());
window_action
.history_back
.simple_action
.set_enabled(item.action.history.back.is_enabled());
window_action
.history_forward
.simple_action
.set_enabled(item.action.history.forward.is_enabled());
} }
} }
// Reset attention decorator
page.set_needs_attention(false); page.set_needs_attention(false);
} }
} }