From d869b4b3e7b8314479243731c26b27840467ef29 Mon Sep 17 00:00:00 2001 From: yggverse Date: Sun, 8 Sep 2024 04:20:25 +0300 Subject: [PATCH] implement update action dependencies --- src/app/browser.cpp | 7 +++--- src/app/browser/main.cpp | 6 +++-- src/app/browser/main.hpp | 3 ++- src/app/browser/main/tab.cpp | 7 ++++-- src/app/browser/main/tab.hpp | 6 +++-- src/app/browser/main/tab/page.cpp | 6 +++-- src/app/browser/main/tab/page.hpp | 3 ++- src/app/browser/main/tab/page/navigation.cpp | 7 ++++-- src/app/browser/main/tab/page/navigation.hpp | 3 ++- .../main/tab/page/navigation/update.cpp | 23 +++++++++++++++---- .../main/tab/page/navigation/update.hpp | 8 ++++++- 11 files changed, 56 insertions(+), 23 deletions(-) diff --git a/src/app/browser.cpp b/src/app/browser.cpp index 46fa5792..23571e96 100644 --- a/src/app/browser.cpp +++ b/src/app/browser.cpp @@ -84,14 +84,12 @@ Browser::Browser( ); // Tab page navigation actions - add_action( + const auto ACTION__MAIN_TAB_PAGE_NAVIGATION_UPDATE = add_action( "main_tab_page_navigation_update", [this] { browserMain->tab_page_navigation_update(); } - )->set_enabled( - false ); const auto ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_BACK = add_action( @@ -132,7 +130,8 @@ Browser::Browser( ACTION__REFRESH, ACTION__MAIN_TAB_CLOSE, ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_BACK, - ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_FORWARD + ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_FORWARD, + ACTION__MAIN_TAB_PAGE_NAVIGATION_UPDATE ); set_child( diff --git a/src/app/browser/main.cpp b/src/app/browser/main.cpp index ecda54a7..6f55912c 100644 --- a/src/app/browser/main.cpp +++ b/src/app/browser/main.cpp @@ -7,7 +7,8 @@ Main::Main( const Glib::RefPtr & ACTION__REFRESH, const Glib::RefPtr & ACTION__MAIN_TAB_CLOSE, const Glib::RefPtr & ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_BACK, - const Glib::RefPtr & ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_FORWARD + const Glib::RefPtr & ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_FORWARD, + const Glib::RefPtr & ACTION__MAIN_TAB_PAGE_NAVIGATION_UPDATE ) { // Init container set_orientation( @@ -23,7 +24,8 @@ Main::Main( ACTION__REFRESH, ACTION__MAIN_TAB_CLOSE, ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_BACK, - ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_FORWARD + ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_FORWARD, + ACTION__MAIN_TAB_PAGE_NAVIGATION_UPDATE ); append( diff --git a/src/app/browser/main.hpp b/src/app/browser/main.hpp index 04eec670..41c66e57 100644 --- a/src/app/browser/main.hpp +++ b/src/app/browser/main.hpp @@ -29,7 +29,8 @@ namespace app::browser const Glib::RefPtr & ACTION__REFRESH, const Glib::RefPtr & ACTION__MAIN_TAB_CLOSE, const Glib::RefPtr & ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_BACK, - const Glib::RefPtr & ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_FORWARD + const Glib::RefPtr & ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_FORWARD, + const Glib::RefPtr & ACTION__MAIN_TAB_PAGE_NAVIGATION_UPDATE ); // Actions diff --git a/src/app/browser/main/tab.cpp b/src/app/browser/main/tab.cpp index 6a9ec258..982921a0 100644 --- a/src/app/browser/main/tab.cpp +++ b/src/app/browser/main/tab.cpp @@ -8,13 +8,15 @@ Tab::Tab( const Glib::RefPtr & ACTION__REFRESH, const Glib::RefPtr & ACTION__TAB_CLOSE, const Glib::RefPtr & ACTION__TAB_PAGE_NAVIGATION_HISTORY_BACK, - const Glib::RefPtr & ACTION__TAB_PAGE_NAVIGATION_HISTORY_FORWARD + const Glib::RefPtr & ACTION__TAB_PAGE_NAVIGATION_HISTORY_FORWARD, + const Glib::RefPtr & ACTION__TAB_PAGE_NAVIGATION_UPDATE ) { // Init actions action__refresh = ACTION__REFRESH; action__tab_close = ACTION__TAB_CLOSE; action__tab_page_navigation_history_back = ACTION__TAB_PAGE_NAVIGATION_HISTORY_BACK; action__tab_page_navigation_history_forward = ACTION__TAB_PAGE_NAVIGATION_HISTORY_FORWARD; + action__tab_page_navigation_update = ACTION__TAB_PAGE_NAVIGATION_UPDATE; // Init widget set_scrollable( @@ -57,7 +59,8 @@ void Tab::append( SUBTITLE, REQUEST, action__tab_page_navigation_history_back, - action__tab_page_navigation_history_forward + action__tab_page_navigation_history_forward, + action__tab_page_navigation_update ); auto tabLabel = new tab::Label( diff --git a/src/app/browser/main/tab.hpp b/src/app/browser/main/tab.hpp index fbe8fb68..fc119851 100644 --- a/src/app/browser/main/tab.hpp +++ b/src/app/browser/main/tab.hpp @@ -21,7 +21,8 @@ namespace app::browser::main Glib::RefPtr action__refresh, action__tab_close, action__tab_page_navigation_history_back, - action__tab_page_navigation_history_forward; + action__tab_page_navigation_history_forward, + action__tab_page_navigation_update; // Components tab::Label * get_tabLabel( @@ -42,7 +43,8 @@ namespace app::browser::main const Glib::RefPtr & ACTION__REFRESH, const Glib::RefPtr & ACTION__TAB_CLOSE, const Glib::RefPtr & ACTION__TAB_PAGE_NAVIGATION_HISTORY_BACK, - const Glib::RefPtr & ACTION__TAB_PAGE_NAVIGATION_HISTORY_FORWARD + const Glib::RefPtr & ACTION__TAB_PAGE_NAVIGATION_HISTORY_FORWARD, + const Glib::RefPtr & ACTION__TAB_PAGE_NAVIGATION_UPDATE ); // Actions diff --git a/src/app/browser/main/tab/page.cpp b/src/app/browser/main/tab/page.cpp index dbf571f1..1690eb39 100644 --- a/src/app/browser/main/tab/page.cpp +++ b/src/app/browser/main/tab/page.cpp @@ -9,7 +9,8 @@ Page::Page( const Glib::ustring & SUBTITLE, const Glib::ustring & REQUEST, const Glib::RefPtr & ACTION__PAGE_NAVIGATION_HISTORY_BACK, - const Glib::RefPtr & ACTION__PAGE_NAVIGATION_HISTORY_FORWARD + const Glib::RefPtr & ACTION__PAGE_NAVIGATION_HISTORY_FORWARD, + const Glib::RefPtr & ACTION__PAGE_NAVIGATION_UPDATE ) { // Init container set_orientation( @@ -20,7 +21,8 @@ Page::Page( pageNavigation = Gtk::make_managed( REQUEST, ACTION__PAGE_NAVIGATION_HISTORY_BACK, - ACTION__PAGE_NAVIGATION_HISTORY_FORWARD + ACTION__PAGE_NAVIGATION_HISTORY_FORWARD, + ACTION__PAGE_NAVIGATION_UPDATE ); append( diff --git a/src/app/browser/main/tab/page.hpp b/src/app/browser/main/tab/page.hpp index 701caf4f..a95b5121 100644 --- a/src/app/browser/main/tab/page.hpp +++ b/src/app/browser/main/tab/page.hpp @@ -46,7 +46,8 @@ namespace app::browser::main::tab const Glib::ustring & SUBTITLE, const Glib::ustring & REQUEST, const Glib::RefPtr & ACTION__PAGE_NAVIGATION_HISTORY_BACK, - const Glib::RefPtr & ACTION__PAGE_NAVIGATION_HISTORY_FORWARD + const Glib::RefPtr & ACTION__PAGE_NAVIGATION_HISTORY_FORWARD, + const Glib::RefPtr & ACTION__PAGE_NAVIGATION_UPDATE ); // Actions diff --git a/src/app/browser/main/tab/page/navigation.cpp b/src/app/browser/main/tab/page/navigation.cpp index a04ac33e..852ba4eb 100644 --- a/src/app/browser/main/tab/page/navigation.cpp +++ b/src/app/browser/main/tab/page/navigation.cpp @@ -10,7 +10,8 @@ using namespace app::browser::main::tab::page; Navigation::Navigation( const Glib::ustring & REQUEST, const Glib::RefPtr & ACTION__NAVIGATION_HISTORY_BACK, - const Glib::RefPtr & ACTION__NAVIGATION_HISTORY_FORWARD + const Glib::RefPtr & ACTION__NAVIGATION_HISTORY_FORWARD, + const Glib::RefPtr & ACTION__NAVIGATION_UPDATE ) { // Init container set_orientation( @@ -53,7 +54,9 @@ Navigation::Navigation( * navigationHistory ); - navigationUpdate = Gtk::make_managed(); + navigationUpdate = Gtk::make_managed( + ACTION__NAVIGATION_UPDATE + ); append( * navigationUpdate diff --git a/src/app/browser/main/tab/page/navigation.hpp b/src/app/browser/main/tab/page/navigation.hpp index 4cc9b0a0..af5d31e7 100644 --- a/src/app/browser/main/tab/page/navigation.hpp +++ b/src/app/browser/main/tab/page/navigation.hpp @@ -37,7 +37,8 @@ namespace app::browser::main::tab::page Navigation( const Glib::ustring & REQUEST, const Glib::RefPtr & ACTION__NAVIGATION_HISTORY_BACK, - const Glib::RefPtr & ACTION__NAVIGATION_HISTORY_FORWARD + const Glib::RefPtr & ACTION__NAVIGATION_HISTORY_FORWARD, + const Glib::RefPtr & ACTION__NAVIGATION_UPDATE ); // Actions diff --git a/src/app/browser/main/tab/page/navigation/update.cpp b/src/app/browser/main/tab/page/navigation/update.cpp index 20d50381..7963d104 100644 --- a/src/app/browser/main/tab/page/navigation/update.cpp +++ b/src/app/browser/main/tab/page/navigation/update.cpp @@ -2,12 +2,13 @@ using namespace app::browser::main::tab::page::navigation; -Update::Update() -{ - set_action_name( - "win.main_tab_page_navigation_update" - ); +Update::Update( + const Glib::RefPtr & ACTION__UPDATE +) { + // Init actions + action__update = ACTION__UPDATE; + // Init widget set_icon_name( "view-refresh-symbolic" ); @@ -15,4 +16,16 @@ Update::Update() set_tooltip_text( _("Update") ); + + /* @TODO + set_sensitive( + false + ); */ + + signal_clicked().connect( + [this] + { + action__update->activate(); + } + ); } \ No newline at end of file diff --git a/src/app/browser/main/tab/page/navigation/update.hpp b/src/app/browser/main/tab/page/navigation/update.hpp index 599c7ed8..9629462c 100644 --- a/src/app/browser/main/tab/page/navigation/update.hpp +++ b/src/app/browser/main/tab/page/navigation/update.hpp @@ -1,16 +1,22 @@ #ifndef APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION_UPDATE_HPP #define APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION_UPDATE_HPP +#include #include +#include #include namespace app::browser::main::tab::page::navigation { class Update : public Gtk::Button { + Glib::RefPtr action__update; + public: - Update(); + Update( + const Glib::RefPtr & ACTION__UPDATE + ); }; }