Browse Source

toggle close all tabs action status on refresh

CPP-GTK4
yggverse 4 months ago
parent
commit
35f4741a1c
  1. 1
      src/app/browser.cpp
  2. 2
      src/app/browser/main.cpp
  3. 1
      src/app/browser/main.hpp
  4. 6
      src/app/browser/main/tab.cpp
  5. 2
      src/app/browser/main/tab.hpp

1
src/app/browser.cpp

@ -179,6 +179,7 @@ Browser::Browser( @@ -179,6 +179,7 @@ Browser::Browser(
browserMain = Gtk::make_managed<browser::Main>(
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

2
src/app/browser/main.cpp

@ -6,6 +6,7 @@ using namespace app::browser; @@ -6,6 +6,7 @@ using namespace app::browser;
Main::Main(
const Glib::RefPtr<Gio::SimpleAction> & ACTION__REFRESH,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_CLOSE_ACTIVE,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_CLOSE_ALL,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_BACK,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_FORWARD,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_PAGE_NAVIGATION_UPDATE
@ -23,6 +24,7 @@ Main::Main( @@ -23,6 +24,7 @@ Main::Main(
mainTab = Gtk::make_managed<main::Tab>(
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

1
src/app/browser/main.hpp

@ -28,6 +28,7 @@ namespace app::browser @@ -28,6 +28,7 @@ namespace app::browser
Main(
const Glib::RefPtr<Gio::SimpleAction> & ACTION__REFRESH,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_CLOSE_ACTIVE,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_CLOSE_ALL,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_BACK,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_FORWARD,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_PAGE_NAVIGATION_UPDATE

6
src/app/browser/main/tab.cpp

@ -7,6 +7,7 @@ using namespace app::browser::main; @@ -7,6 +7,7 @@ using namespace app::browser::main;
Tab::Tab(
const Glib::RefPtr<Gio::SimpleAction> & ACTION__REFRESH,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_CLOSE_ACTIVE,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_CLOSE_ALL,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_PAGE_NAVIGATION_HISTORY_BACK,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_PAGE_NAVIGATION_HISTORY_FORWARD,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_PAGE_NAVIGATION_UPDATE
@ -14,6 +15,7 @@ Tab::Tab( @@ -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( @@ -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(

2
src/app/browser/main/tab.hpp

@ -20,6 +20,7 @@ namespace app::browser::main @@ -20,6 +20,7 @@ namespace app::browser::main
// Actions
Glib::RefPtr<Gio::SimpleAction> 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 @@ -42,6 +43,7 @@ namespace app::browser::main
Tab(
const Glib::RefPtr<Gio::SimpleAction> & ACTION__REFRESH,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_CLOSE_ACTIVE,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_CLOSE_ALL,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_PAGE_NAVIGATION_HISTORY_BACK,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_PAGE_NAVIGATION_HISTORY_FORWARD,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_PAGE_NAVIGATION_UPDATE

Loading…
Cancel
Save