From 49c1f5923b2559b9d0f8d344aa2da6580c9b508a Mon Sep 17 00:00:00 2001 From: yggverse Date: Sun, 26 Jan 2025 16:41:59 +0200 Subject: [PATCH] update window actions on tab change --- src/app/browser/window.rs | 1 - src/app/browser/window/tab.rs | 21 ++++++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/app/browser/window.rs b/src/app/browser/window.rs index 130ed4d3..2478815d 100644 --- a/src/app/browser/window.rs +++ b/src/app/browser/window.rs @@ -158,7 +158,6 @@ impl Window { } Err(e) => return Err(e.to_string()), } - Ok(()) } diff --git a/src/app/browser/window/tab.rs b/src/app/browser/window/tab.rs index 14f278b2..8e494f58 100644 --- a/src/app/browser/window/tab.rs +++ b/src/app/browser/window/tab.rs @@ -15,7 +15,7 @@ use super::{Action as WindowAction, BrowserAction, Position}; use crate::Profile; use gtk::{ glib::{DateTime, GString, Propagation}, - prelude::{EditableExt, WidgetExt}, + prelude::{ActionExt, EditableExt, WidgetExt}, }; use sqlite::Transaction; use std::{cell::RefCell, collections::HashMap, rc::Rc}; @@ -123,15 +123,30 @@ impl Tab { }); widget.tab_view.connect_selected_page_notify({ + let window_action = window_action.clone(); let index = index.clone(); move |this| { if let Some(page) = this.selected_page() { if let Some(id) = page.keyword() { 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); } }