Browse Source

implement update action dependencies

CPP-GTK4
yggverse 3 months ago
parent
commit
d869b4b3e7
  1. 7
      src/app/browser.cpp
  2. 6
      src/app/browser/main.cpp
  3. 3
      src/app/browser/main.hpp
  4. 7
      src/app/browser/main/tab.cpp
  5. 6
      src/app/browser/main/tab.hpp
  6. 6
      src/app/browser/main/tab/page.cpp
  7. 3
      src/app/browser/main/tab/page.hpp
  8. 7
      src/app/browser/main/tab/page/navigation.cpp
  9. 3
      src/app/browser/main/tab/page/navigation.hpp
  10. 23
      src/app/browser/main/tab/page/navigation/update.cpp
  11. 8
      src/app/browser/main/tab/page/navigation/update.hpp

7
src/app/browser.cpp

@ -84,14 +84,12 @@ Browser::Browser(
); );
// Tab page navigation actions // Tab page navigation actions
add_action( const auto ACTION__MAIN_TAB_PAGE_NAVIGATION_UPDATE = add_action(
"main_tab_page_navigation_update", "main_tab_page_navigation_update",
[this] [this]
{ {
browserMain->tab_page_navigation_update(); browserMain->tab_page_navigation_update();
} }
)->set_enabled(
false
); );
const auto ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_BACK = add_action( const auto ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_BACK = add_action(
@ -132,7 +130,8 @@ Browser::Browser(
ACTION__REFRESH, ACTION__REFRESH,
ACTION__MAIN_TAB_CLOSE, ACTION__MAIN_TAB_CLOSE,
ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_BACK, 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( set_child(

6
src/app/browser/main.cpp

@ -7,7 +7,8 @@ Main::Main(
const Glib::RefPtr<Gio::SimpleAction> & ACTION__REFRESH, const Glib::RefPtr<Gio::SimpleAction> & ACTION__REFRESH,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_CLOSE, const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_CLOSE,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_BACK, 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_HISTORY_FORWARD,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_PAGE_NAVIGATION_UPDATE
) { ) {
// Init container // Init container
set_orientation( set_orientation(
@ -23,7 +24,8 @@ Main::Main(
ACTION__REFRESH, ACTION__REFRESH,
ACTION__MAIN_TAB_CLOSE, ACTION__MAIN_TAB_CLOSE,
ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_BACK, 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( append(

3
src/app/browser/main.hpp

@ -29,7 +29,8 @@ namespace app::browser
const Glib::RefPtr<Gio::SimpleAction> & ACTION__REFRESH, const Glib::RefPtr<Gio::SimpleAction> & ACTION__REFRESH,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_CLOSE, const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_CLOSE,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_BACK, 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_HISTORY_FORWARD,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_PAGE_NAVIGATION_UPDATE
); );
// Actions // Actions

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

@ -8,13 +8,15 @@ Tab::Tab(
const Glib::RefPtr<Gio::SimpleAction> & ACTION__REFRESH, const Glib::RefPtr<Gio::SimpleAction> & ACTION__REFRESH,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_CLOSE, const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_CLOSE,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_PAGE_NAVIGATION_HISTORY_BACK, 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_HISTORY_FORWARD,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_PAGE_NAVIGATION_UPDATE
) { ) {
// Init actions // Init actions
action__refresh = ACTION__REFRESH; action__refresh = ACTION__REFRESH;
action__tab_close = ACTION__TAB_CLOSE; action__tab_close = ACTION__TAB_CLOSE;
action__tab_page_navigation_history_back = ACTION__TAB_PAGE_NAVIGATION_HISTORY_BACK; 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_history_forward = ACTION__TAB_PAGE_NAVIGATION_HISTORY_FORWARD;
action__tab_page_navigation_update = ACTION__TAB_PAGE_NAVIGATION_UPDATE;
// Init widget // Init widget
set_scrollable( set_scrollable(
@ -57,7 +59,8 @@ void Tab::append(
SUBTITLE, SUBTITLE,
REQUEST, REQUEST,
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
); );
auto tabLabel = new tab::Label( auto tabLabel = new tab::Label(

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

@ -21,7 +21,8 @@ namespace app::browser::main
Glib::RefPtr<Gio::SimpleAction> action__refresh, Glib::RefPtr<Gio::SimpleAction> 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;
// Components // Components
tab::Label * get_tabLabel( tab::Label * get_tabLabel(
@ -42,7 +43,8 @@ namespace app::browser::main
const Glib::RefPtr<Gio::SimpleAction> & ACTION__REFRESH, const Glib::RefPtr<Gio::SimpleAction> & ACTION__REFRESH,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_CLOSE, const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_CLOSE,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_PAGE_NAVIGATION_HISTORY_BACK, 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_HISTORY_FORWARD,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_PAGE_NAVIGATION_UPDATE
); );
// Actions // Actions

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

@ -9,7 +9,8 @@ Page::Page(
const Glib::ustring & SUBTITLE, const Glib::ustring & SUBTITLE,
const Glib::ustring & REQUEST, const Glib::ustring & REQUEST,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__PAGE_NAVIGATION_HISTORY_BACK, const Glib::RefPtr<Gio::SimpleAction> & ACTION__PAGE_NAVIGATION_HISTORY_BACK,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__PAGE_NAVIGATION_HISTORY_FORWARD const Glib::RefPtr<Gio::SimpleAction> & ACTION__PAGE_NAVIGATION_HISTORY_FORWARD,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__PAGE_NAVIGATION_UPDATE
) { ) {
// Init container // Init container
set_orientation( set_orientation(
@ -20,7 +21,8 @@ Page::Page(
pageNavigation = Gtk::make_managed<page::Navigation>( pageNavigation = Gtk::make_managed<page::Navigation>(
REQUEST, REQUEST,
ACTION__PAGE_NAVIGATION_HISTORY_BACK, ACTION__PAGE_NAVIGATION_HISTORY_BACK,
ACTION__PAGE_NAVIGATION_HISTORY_FORWARD ACTION__PAGE_NAVIGATION_HISTORY_FORWARD,
ACTION__PAGE_NAVIGATION_UPDATE
); );
append( append(

3
src/app/browser/main/tab/page.hpp

@ -46,7 +46,8 @@ namespace app::browser::main::tab
const Glib::ustring & SUBTITLE, const Glib::ustring & SUBTITLE,
const Glib::ustring & REQUEST, const Glib::ustring & REQUEST,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__PAGE_NAVIGATION_HISTORY_BACK, const Glib::RefPtr<Gio::SimpleAction> & ACTION__PAGE_NAVIGATION_HISTORY_BACK,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__PAGE_NAVIGATION_HISTORY_FORWARD const Glib::RefPtr<Gio::SimpleAction> & ACTION__PAGE_NAVIGATION_HISTORY_FORWARD,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__PAGE_NAVIGATION_UPDATE
); );
// Actions // Actions

7
src/app/browser/main/tab/page/navigation.cpp

@ -10,7 +10,8 @@ using namespace app::browser::main::tab::page;
Navigation::Navigation( Navigation::Navigation(
const Glib::ustring & REQUEST, const Glib::ustring & REQUEST,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__NAVIGATION_HISTORY_BACK, const Glib::RefPtr<Gio::SimpleAction> & ACTION__NAVIGATION_HISTORY_BACK,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__NAVIGATION_HISTORY_FORWARD const Glib::RefPtr<Gio::SimpleAction> & ACTION__NAVIGATION_HISTORY_FORWARD,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__NAVIGATION_UPDATE
) { ) {
// Init container // Init container
set_orientation( set_orientation(
@ -53,7 +54,9 @@ Navigation::Navigation(
* navigationHistory * navigationHistory
); );
navigationUpdate = Gtk::make_managed<navigation::Update>(); navigationUpdate = Gtk::make_managed<navigation::Update>(
ACTION__NAVIGATION_UPDATE
);
append( append(
* navigationUpdate * navigationUpdate

3
src/app/browser/main/tab/page/navigation.hpp

@ -37,7 +37,8 @@ namespace app::browser::main::tab::page
Navigation( Navigation(
const Glib::ustring & REQUEST, const Glib::ustring & REQUEST,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__NAVIGATION_HISTORY_BACK, const Glib::RefPtr<Gio::SimpleAction> & ACTION__NAVIGATION_HISTORY_BACK,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__NAVIGATION_HISTORY_FORWARD const Glib::RefPtr<Gio::SimpleAction> & ACTION__NAVIGATION_HISTORY_FORWARD,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__NAVIGATION_UPDATE
); );
// Actions // Actions

23
src/app/browser/main/tab/page/navigation/update.cpp

@ -2,12 +2,13 @@
using namespace app::browser::main::tab::page::navigation; using namespace app::browser::main::tab::page::navigation;
Update::Update() Update::Update(
{ const Glib::RefPtr<Gio::SimpleAction> & ACTION__UPDATE
set_action_name( ) {
"win.main_tab_page_navigation_update" // Init actions
); action__update = ACTION__UPDATE;
// Init widget
set_icon_name( set_icon_name(
"view-refresh-symbolic" "view-refresh-symbolic"
); );
@ -15,4 +16,16 @@ Update::Update()
set_tooltip_text( set_tooltip_text(
_("Update") _("Update")
); );
/* @TODO
set_sensitive(
false
); */
signal_clicked().connect(
[this]
{
action__update->activate();
}
);
} }

8
src/app/browser/main/tab/page/navigation/update.hpp

@ -1,16 +1,22 @@
#ifndef APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION_UPDATE_HPP #ifndef APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION_UPDATE_HPP
#define APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION_UPDATE_HPP #define APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION_UPDATE_HPP
#include <giomm/simpleaction.h>
#include <glibmm/i18n.h> #include <glibmm/i18n.h>
#include <glibmm/refptr.h>
#include <gtkmm/button.h> #include <gtkmm/button.h>
namespace app::browser::main::tab::page::navigation namespace app::browser::main::tab::page::navigation
{ {
class Update : public Gtk::Button class Update : public Gtk::Button
{ {
Glib::RefPtr<Gio::SimpleAction> action__update;
public: public:
Update(); Update(
const Glib::RefPtr<Gio::SimpleAction> & ACTION__UPDATE
);
}; };
} }

Loading…
Cancel
Save