diff --git a/src/app/browser/main/tab/page.cpp b/src/app/browser/main/tab/page.cpp index 4462f6ca..948aad62 100644 --- a/src/app/browser/main/tab/page.cpp +++ b/src/app/browser/main/tab/page.cpp @@ -62,6 +62,7 @@ Page::Page( this->db, ACTION__HISTORY_BACK, ACTION__HISTORY_FORWARD, + ACTION__OPEN_LINK_VARIANT, ACTION__RELOAD, ACTION__UPDATE ); diff --git a/src/app/browser/main/tab/page/navigation.cpp b/src/app/browser/main/tab/page/navigation.cpp index 344f42bc..07a9c22f 100644 --- a/src/app/browser/main/tab/page/navigation.cpp +++ b/src/app/browser/main/tab/page/navigation.cpp @@ -11,6 +11,7 @@ Navigation::Navigation( sqlite3 * db, const Glib::RefPtr & ACTION__HISTORY_BACK, const Glib::RefPtr & ACTION__HISTORY_FORWARD, + const Glib::RefPtr & ACTION__OPEN_LINK_VARIANT, const Glib::RefPtr & ACTION__RELOAD, const Glib::RefPtr & ACTION__UPDATE ) { @@ -45,7 +46,9 @@ Navigation::Navigation( ); // Init components - navigationBase = Gtk::make_managed(); + navigationBase = Gtk::make_managed( + ACTION__OPEN_LINK_VARIANT + ); append( * navigationBase diff --git a/src/app/browser/main/tab/page/navigation.hpp b/src/app/browser/main/tab/page/navigation.hpp index 7462d24b..c9673431 100644 --- a/src/app/browser/main/tab/page/navigation.hpp +++ b/src/app/browser/main/tab/page/navigation.hpp @@ -82,10 +82,11 @@ namespace app::browser::main::tab::page Navigation( sqlite3 * db, - const Glib::RefPtr & ACTION__UPDATE, - 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_RELOAD + const Glib::RefPtr & ACTION__HISTORY_BACK, + const Glib::RefPtr & ACTION__HISTORY_FORWARD, + const Glib::RefPtr & ACTION__OPEN_LINK_VARIANT, + const Glib::RefPtr & ACTION__RELOAD, + const Glib::RefPtr & ACTION__UPDATE ); // Actions diff --git a/src/app/browser/main/tab/page/navigation/base.cpp b/src/app/browser/main/tab/page/navigation/base.cpp index c70d92af..7a2d77e5 100644 --- a/src/app/browser/main/tab/page/navigation/base.cpp +++ b/src/app/browser/main/tab/page/navigation/base.cpp @@ -2,8 +2,13 @@ using namespace app::browser::main::tab::page::navigation; -Base::Base() -{ +Base::Base( + const Glib::RefPtr & ACTION__OPEN_LINK_VARIANT +) { + // Init shared actions + action__open_link_variant = ACTION__OPEN_LINK_VARIANT; + + // Init widget set_icon_name( "go-home-symbolic" ); @@ -16,13 +21,29 @@ Base::Base() false ); - // @TODO add action + // Init events + signal_clicked().connect( + [this] + { + // Currently, there is + action__open_link_variant->activate_variant( + Glib::Variant::create( + Glib::ustring::sprintf( + "%s://%s/", + g_uri_get_scheme(uri), // @TODO NULL validate? + g_uri_get_host(uri) + ) // at this moment, there is no G_URI_HIDE_*HOST option for g_uri_to_string_partial, + // build address manually using sprintf @TODO + ) + ); + } + ); } void Base::update( const Glib::ustring & URI ) { - GUri * uri = g_uri_parse( + uri = g_uri_parse( URI.c_str(), G_URI_FLAGS_NONE, NULL // @TODO GError * diff --git a/src/app/browser/main/tab/page/navigation/base.hpp b/src/app/browser/main/tab/page/navigation/base.hpp index 6dfd35cc..d1d9c653 100644 --- a/src/app/browser/main/tab/page/navigation/base.hpp +++ b/src/app/browser/main/tab/page/navigation/base.hpp @@ -1,17 +1,33 @@ #ifndef APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION_BASE_HPP #define APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION_BASE_HPP +#include +#include #include +#include #include namespace app::browser::main::tab::page::navigation { class Base : public Gtk::Button { + /* + * Internal members + */ + Glib::RefPtr action__open_link_variant; + + GUri * uri; + + /* + * Base class API + */ public: - Base(); + Base( + const Glib::RefPtr & ACTION__OPEN_LINK_VARIANT + ); + // Actions void update( const Glib::ustring & URI );