From 18d9d3b4c5858b2de6fc55636bf0ad253d84fe84 Mon Sep 17 00:00:00 2001 From: yggverse Date: Sat, 28 Sep 2024 15:53:13 +0300 Subject: [PATCH] update window on tab page switch --- src/browser/main/tab.rs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/browser/main/tab.rs b/src/browser/main/tab.rs index 0730bfbb..44a66bc6 100644 --- a/src/browser/main/tab.rs +++ b/src/browser/main/tab.rs @@ -7,7 +7,7 @@ use page::Page; use gtk::{ gio::SimpleAction, glib::{uuid_string_random, GString}, - prelude::WidgetExt, + prelude::{ActionExt, WidgetExt}, GestureClick, Notebook, }; @@ -48,13 +48,17 @@ impl Tab { // Actions pub fn activate(&self, tab: Arc) { - self.widget.connect_page_removed({ - move |_, widget, _| { - // Cleanup HashMap index - let id = &widget.widget_name(); - tab.labels.borrow_mut().remove(id); - tab.pages.borrow_mut().remove(id); - } + self.widget.connect_page_removed(move |_, widget, _| { + // Cleanup HashMap index + let id = &widget.widget_name(); + tab.labels.borrow_mut().remove(id); + tab.pages.borrow_mut().remove(id); + }); + + self.widget.connect_switch_page({ + let action_update = self.action_update.clone(); + // Update window header with current page title + move |_, _, _| action_update.activate(None) }); }