From bb343d5f590059079dc9a77268b586f4d6f47439 Mon Sep 17 00:00:00 2001 From: yggverse Date: Tue, 27 Aug 2024 13:50:29 +0300 Subject: [PATCH] implement tab refresh method --- src/app/browser/main/tab.cpp | 38 +++++++++++++++++++++++++++++++++++- src/app/browser/main/tab.hpp | 4 ++++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/src/app/browser/main/tab.cpp b/src/app/browser/main/tab.cpp index 92eed8e3..5cdcb528 100644 --- a/src/app/browser/main/tab.cpp +++ b/src/app/browser/main/tab.cpp @@ -15,6 +15,10 @@ Tab::Tab() signal_switch_page().connect( [this](Gtk::Widget * pageWidget, guint page_number) { + refresh( + page_number + ); + // Refresh window elements, e.g. tab label to header bar activate_action( "win.refresh" @@ -111,4 +115,36 @@ void Tab::update( ); } -} // @TODO \ No newline at end of file +} // @TODO + +void Tab::refresh( + int page_number +) { + auto pageWidget = get_nth_page( + page_number + ); + + if (pageWidget == nullptr) + { + throw _("Tab page not found!"); + } + + auto labelWidget = get_tab_label( + * pageWidget + ); + + if (labelWidget == nullptr) + { + throw _("Tab label not found!"); + } + + auto tabPage = (tab::Page *) pageWidget; + + auto tabLabel = (tab::Label *) labelWidget; + + tabLabel->set_label( + tabPage->get_title() + ); + + // @TODO delegate refresh action to child level widgets (on available) +} \ No newline at end of file diff --git a/src/app/browser/main/tab.hpp b/src/app/browser/main/tab.hpp index ec708d58..6f751fef 100644 --- a/src/app/browser/main/tab.hpp +++ b/src/app/browser/main/tab.hpp @@ -35,6 +35,10 @@ namespace app::browser::main void close_right(); void close_all(); + void refresh( + int page_number + ); + void update( int page_number );