From 2e55fdfd3d83eeeba7f2c92e4ce9e8045bf9b08d Mon Sep 17 00:00:00 2001 From: yggverse Date: Fri, 31 Jan 2025 00:46:23 +0200 Subject: [PATCH] fix global actions update on tab init --- src/app/browser/window/tab.rs | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/src/app/browser/window/tab.rs b/src/app/browser/window/tab.rs index d0928177..01a67bdd 100644 --- a/src/app/browser/window/tab.rs +++ b/src/app/browser/window/tab.rs @@ -164,18 +164,26 @@ impl Tab { item.page.navigation.grab_focus(); } - // Register dynamically created tab components in the HashMap index + // Relate with GTK `TabPage` with app `Item` self.index .borrow_mut() .insert(item.tab_page.clone(), item.clone()); // Setup - // * important to call these actions after index! self.tab_view.set_page_pinned(&item.tab_page, is_pinned); if is_selected { self.tab_view.set_selected_page(&item.tab_page); } + // Forcefully update global actions on HashMap index build complete + // * `selected_page_notify` runs this action also, just before Item init @TODO + update_actions( + &self.tab_view, + self.tab_view.selected_page().as_ref(), + &self.index, + &self.window_action, + ); + item } @@ -333,12 +341,12 @@ impl Tab { false, )); + // Relate with GTK `TabPage` with app `Item` self.index .borrow_mut() .insert(item.tab_page.clone(), item.clone()); - // Restore `Self` - // * important to call these actions after index! + // Setup self.tab_view .set_page_pinned(&item.tab_page, item_record.is_pinned); @@ -346,6 +354,15 @@ impl Tab { self.tab_view.set_selected_page(&item.tab_page); } + // Forcefully update global actions on HashMap index build complete + // * `selected_page_notify` runs this action also, just before Item init @TODO + update_actions( + &self.tab_view, + self.tab_view.selected_page().as_ref(), + &self.index, + &self.window_action, + ); + // Restore children components item.page.restore(transaction, item_record.id)?; } @@ -437,7 +454,7 @@ fn update_actions( window_action.change_state(Some(tab_view.page_position(tab_page))); return; - } + } // @TODO `connect_selected_page_notify` panics on unwrap } // Reset to defaults window_action.home.simple_action.set_enabled(false);