From 579ebfa03767bc24fc75280bfea85cfe85d8b28d Mon Sep 17 00:00:00 2001 From: yggverse Date: Wed, 14 Aug 2024 07:56:34 +0300 Subject: [PATCH] draft tab actions --- src/app/browser/main/tab.cpp | 36 ++++++++++++++++++++++++++++--- src/app/browser/main/tab.hpp | 22 ++++++++++--------- src/app/browser/main/tab/data.cpp | 22 ++++++++++++++++++- src/app/browser/main/tab/data.hpp | 6 ++++++ 4 files changed, 72 insertions(+), 14 deletions(-) diff --git a/src/app/browser/main/tab.cpp b/src/app/browser/main/tab.cpp index d3f73ecb..2f59c8fd 100644 --- a/src/app/browser/main/tab.cpp +++ b/src/app/browser/main/tab.cpp @@ -6,21 +6,30 @@ using namespace app::browser::main; Tab::Tab() { + // Init widget set_scrollable( true ); + + // Init events + signal_switch_page().connect( + sigc::mem_fun( + * this, + & Tab::on_switch + ) + ); } Tab::~Tab() = default; +// Actions void Tab::append( const char * request, bool open, bool focus ) { - label = new tab::Label(); - - data = new tab::Data(); + auto label = new tab::Label(); + auto data = new tab::Data(); append_page( * data, @@ -67,4 +76,25 @@ void Tab::close_all() -1 // last ); } +} + +void Tab::update( + int number +) { + auto page = get_nth_page( + number + ); + + page->activate_action( + "tab.update" + ); + +} // @TODO + +// Events +void Tab::on_switch( + Gtk::Widget * page, + guint page_num +) { + // @TODO update header } \ No newline at end of file diff --git a/src/app/browser/main/tab.hpp b/src/app/browser/main/tab.hpp index ae40d03c..d5e038f2 100644 --- a/src/app/browser/main/tab.hpp +++ b/src/app/browser/main/tab.hpp @@ -2,22 +2,22 @@ #define APP_BROWSER_MAIN_TAB_HPP #include +#include #include +#include namespace app::browser::main { - namespace tab - { - class Data; - class Label; - } - class Tab : public Gtk::Notebook { - public: + private: + + void on_switch( + Gtk::Widget * page, + guint page_num + ); - tab::Data * data; - tab::Label * label; + public: Tab(); @@ -37,7 +37,9 @@ namespace app::browser::main void close_right(); void close_all(); - void update(); + void update( + int number + ); }; } diff --git a/src/app/browser/main/tab/data.cpp b/src/app/browser/main/tab/data.cpp index 92dd6c25..eb4184b0 100644 --- a/src/app/browser/main/tab/data.cpp +++ b/src/app/browser/main/tab/data.cpp @@ -10,12 +10,32 @@ Data::Data() Gtk::Orientation::VERTICAL ); - // Init elements + // Init children components navbar = new data::Navbar(); append( * navbar ); + + // Init actions group + action_group = Gio::SimpleActionGroup::create(); + + // Define actions + action_group->add_action( + "update", + sigc::mem_fun( + * this, + & Data::update + ) + ); + + insert_action_group( + "tab", + action_group + ); } Data::~Data() = default; + +void Data::update() +{} // @TODO diff --git a/src/app/browser/main/tab/data.hpp b/src/app/browser/main/tab/data.hpp index c8a06e3f..4726e317 100644 --- a/src/app/browser/main/tab/data.hpp +++ b/src/app/browser/main/tab/data.hpp @@ -2,6 +2,8 @@ #define APP_BROWSER_MAIN_TAB_DATA_HPP #include +#include +#include namespace app::browser::main::tab { @@ -14,6 +16,8 @@ namespace app::browser::main::tab { private: + Glib::RefPtr action_group; + data::Navbar * navbar; public: @@ -21,6 +25,8 @@ namespace app::browser::main::tab Data(); ~Data(); + + void update(); }; }