From a493ed1f95d0355a95eb9e106ccf17dc188c67c3 Mon Sep 17 00:00:00 2001 From: yggverse Date: Tue, 27 Aug 2024 17:03:22 +0300 Subject: [PATCH] implement tabLabel pointer getter --- src/app/browser/main/tab.cpp | 52 ++++++++++++++++++++---------------- src/app/browser/main/tab.hpp | 7 ++++- 2 files changed, 35 insertions(+), 24 deletions(-) diff --git a/src/app/browser/main/tab.cpp b/src/app/browser/main/tab.cpp index 514f566f..082c4acb 100644 --- a/src/app/browser/main/tab.cpp +++ b/src/app/browser/main/tab.cpp @@ -29,13 +29,13 @@ Tab::~Tab() = default; Glib::ustring Tab::get_page_title( const int & PAGE_NUMBER ) { - return get_tab_page_ptr(PAGE_NUMBER)->get_title(); + return get_tabPage_ptr(PAGE_NUMBER)->get_title(); }; Glib::ustring Tab::get_page_subtitle( const int & PAGE_NUMBER ) { - return get_tab_page_ptr(PAGE_NUMBER)->get_subtitle(); + return get_tabPage_ptr(PAGE_NUMBER)->get_subtitle(); }; // Actions @@ -101,29 +101,11 @@ void Tab::close_all() void Tab::refresh( const int & PAGE_NUMBER ) { - auto pageWidget = get_nth_page( + auto tabPage = get_tabPage_ptr( 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( + get_tabLabel_ptr(PAGE_NUMBER)->set_label( tabPage->get_title() ); @@ -148,7 +130,31 @@ void Tab::update( } // @TODO // Private helpers -tab::Page * Tab::get_tab_page_ptr( +tab::Label * Tab::get_tabLabel_ptr( + const 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!"); + } + + return (tab::Label *) labelWidget; +} + +tab::Page * Tab::get_tabPage_ptr( const int & PAGE_NUMBER ) { auto pageWidget = get_nth_page( diff --git a/src/app/browser/main/tab.hpp b/src/app/browser/main/tab.hpp index cbf942e8..1f963dd1 100644 --- a/src/app/browser/main/tab.hpp +++ b/src/app/browser/main/tab.hpp @@ -9,6 +9,7 @@ namespace app::browser::main { namespace tab { + class Label; class Page; } @@ -17,7 +18,11 @@ namespace app::browser::main const bool REORDERABLE = true; const bool SCROLLABLE = true; - tab::Page * get_tab_page_ptr( + tab::Label * get_tabLabel_ptr( + const int & PAGE_NUMBER + ); + + tab::Page * get_tabPage_ptr( const int & PAGE_NUMBER );