From 35f4741a1c68af7ac166f503772bdb22068d21a2 Mon Sep 17 00:00:00 2001 From: yggverse Date: Sun, 8 Sep 2024 18:19:29 +0300 Subject: [PATCH] toggle close all tabs action status on refresh --- src/app/browser.cpp | 1 + src/app/browser/main.cpp | 2 ++ src/app/browser/main.hpp | 1 + src/app/browser/main/tab.cpp | 6 +++++- src/app/browser/main/tab.hpp | 2 ++ 5 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/app/browser.cpp b/src/app/browser.cpp index a386eaa2..ed9de345 100644 --- a/src/app/browser.cpp +++ b/src/app/browser.cpp @@ -179,6 +179,7 @@ Browser::Browser( browserMain = Gtk::make_managed( ACTION__REFRESH, ACTION__MAIN_TAB_CLOSE_ACTIVE, + ACTION__MAIN_TAB_CLOSE_ALL, ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_BACK, ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_FORWARD, ACTION__MAIN_TAB_PAGE_NAVIGATION_UPDATE diff --git a/src/app/browser/main.cpp b/src/app/browser/main.cpp index 0a0e3a44..b40ca349 100644 --- a/src/app/browser/main.cpp +++ b/src/app/browser/main.cpp @@ -6,6 +6,7 @@ using namespace app::browser; Main::Main( const Glib::RefPtr & ACTION__REFRESH, const Glib::RefPtr & ACTION__MAIN_TAB_CLOSE_ACTIVE, + const Glib::RefPtr & ACTION__MAIN_TAB_CLOSE_ALL, 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_UPDATE @@ -23,6 +24,7 @@ Main::Main( mainTab = Gtk::make_managed( ACTION__REFRESH, ACTION__MAIN_TAB_CLOSE_ACTIVE, + ACTION__MAIN_TAB_CLOSE_ALL, ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_BACK, ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_FORWARD, ACTION__MAIN_TAB_PAGE_NAVIGATION_UPDATE diff --git a/src/app/browser/main.hpp b/src/app/browser/main.hpp index b929863b..c4fe9cf8 100644 --- a/src/app/browser/main.hpp +++ b/src/app/browser/main.hpp @@ -28,6 +28,7 @@ namespace app::browser Main( const Glib::RefPtr & ACTION__REFRESH, const Glib::RefPtr & ACTION__MAIN_TAB_CLOSE_ACTIVE, + const Glib::RefPtr & ACTION__MAIN_TAB_CLOSE_ALL, 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_UPDATE diff --git a/src/app/browser/main/tab.cpp b/src/app/browser/main/tab.cpp index edf5bc65..852b4457 100644 --- a/src/app/browser/main/tab.cpp +++ b/src/app/browser/main/tab.cpp @@ -7,6 +7,7 @@ using namespace app::browser::main; Tab::Tab( const Glib::RefPtr & ACTION__REFRESH, const Glib::RefPtr & ACTION__TAB_CLOSE_ACTIVE, + const Glib::RefPtr & ACTION__MAIN_TAB_CLOSE_ALL, 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_UPDATE @@ -14,6 +15,7 @@ Tab::Tab( // Init actions action__refresh = ACTION__REFRESH; action__tab_close_active = ACTION__TAB_CLOSE_ACTIVE; + action__tab_close_all = ACTION__MAIN_TAB_CLOSE_ALL; 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; @@ -57,7 +59,9 @@ void Tab::refresh( get_n_pages() > 0 ); - // @TODO toggle close all + action__tab_close_all->set_enabled( + get_n_pages() > 0 + ); } void Tab::append( diff --git a/src/app/browser/main/tab.hpp b/src/app/browser/main/tab.hpp index 4b7d23ef..2641d29c 100644 --- a/src/app/browser/main/tab.hpp +++ b/src/app/browser/main/tab.hpp @@ -20,6 +20,7 @@ namespace app::browser::main // Actions Glib::RefPtr action__refresh, action__tab_close_active, + action__tab_close_all, action__tab_page_navigation_history_back, action__tab_page_navigation_history_forward, action__tab_page_navigation_update; @@ -42,6 +43,7 @@ namespace app::browser::main Tab( const Glib::RefPtr & ACTION__REFRESH, const Glib::RefPtr & ACTION__TAB_CLOSE_ACTIVE, + const Glib::RefPtr & ACTION__MAIN_TAB_CLOSE_ALL, 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_UPDATE