From fbfb8039b074678e86218babd24cab64a14f4011 Mon Sep 17 00:00:00 2001 From: yggverse Date: Tue, 20 Aug 2024 16:32:20 +0300 Subject: [PATCH] add get_label_text, use lambda function on switch_page, rename page_number variables --- src/app/browser/main/tab.cpp | 49 +++++++++++++++++++++++------------- src/app/browser/main/tab.hpp | 11 ++++---- 2 files changed, 37 insertions(+), 23 deletions(-) diff --git a/src/app/browser/main/tab.cpp b/src/app/browser/main/tab.cpp index efbeab63..429b8c16 100644 --- a/src/app/browser/main/tab.cpp +++ b/src/app/browser/main/tab.cpp @@ -15,9 +15,9 @@ Tab::Tab() signal_switch_page().connect( [this](Gtk::Widget * page, guint page_num) { - on_switch( - page, - page_num + // Refresh window elements, e.g. tab label to header bar + activate_action( + "win.refresh" ); } ); @@ -25,6 +25,26 @@ Tab::Tab() Tab::~Tab() = default; +// Getters +Glib::ustring Tab::get_label_text( + int page_number +) { + auto page = get_nth_page( + page_number + ); + + if (page != nullptr) + { + return get_tab_label_text( + * get_nth_page( + page_number + ) + ); + } + + return ""; // @TODO +}; + // Actions void Tab::append( const char * request, @@ -92,22 +112,17 @@ void Tab::close_all() } void Tab::update( - int number + int page_number ) { auto page = get_nth_page( - number - ); - - page->activate_action( - "page.update" + page_number ); -} // @TODO + if (page != nullptr) + { + page->activate_action( + "page.update" + ); + } -// Events -void Tab::on_switch( - Gtk::Widget * page, - guint page_num -) { - // @TODO update header text -} \ No newline at end of file +} // @TODO \ No newline at end of file diff --git a/src/app/browser/main/tab.hpp b/src/app/browser/main/tab.hpp index a05aa9fb..cf13b4f0 100644 --- a/src/app/browser/main/tab.hpp +++ b/src/app/browser/main/tab.hpp @@ -2,24 +2,23 @@ #define APP_BROWSER_MAIN_TAB_HPP #include -#include +#include #include namespace app::browser::main { class Tab : public Gtk::Notebook { - void on_switch( - Gtk::Widget * page, - guint page_num - ); - public: Tab(); ~Tab(); + Glib::ustring get_label_text( + int page_number + ); + void append( const char * request, bool open,