diff --git a/src/app/browser.cpp b/src/app/browser.cpp index 3bdaa8d9..5169f4be 100644 --- a/src/app/browser.cpp +++ b/src/app/browser.cpp @@ -33,9 +33,17 @@ Browser::Browser( { if (PARAMETER.is_of_type(Glib::VARIANT_TYPE_STRING)) { + browserMain->update( + Glib::VariantBase::cast_dynamic>( + PARAMETER + ).get() + ); + + browserHeader->update( + browserMain->get_tab_page_title(), + browserMain->get_tab_page_description() + ); } - // @TODO process request - // Glib::VariantBase::cast_dynamic>(parameter).get() } ); diff --git a/src/app/browser/main.cpp b/src/app/browser/main.cpp index 1d730526..312b2b0f 100644 --- a/src/app/browser/main.cpp +++ b/src/app/browser/main.cpp @@ -168,6 +168,15 @@ void Main::update() ); }; +void Main::update( + const Glib::ustring & URI +) { + mainTab->update( + mainTab->get_current_page(), + URI + ); +}; + // Getters Glib::ustring Main::get_tab_page_title() { diff --git a/src/app/browser/main.hpp b/src/app/browser/main.hpp index 49033c1a..0cff87a9 100644 --- a/src/app/browser/main.hpp +++ b/src/app/browser/main.hpp @@ -105,6 +105,10 @@ namespace app::browser void update(); + void update( + const Glib::ustring & URI + ); + // Getters Glib::ustring get_tab_page_title(); Glib::ustring get_tab_page_description(); diff --git a/src/app/browser/main/tab.cpp b/src/app/browser/main/tab.cpp index 99b5d961..ee052b9f 100644 --- a/src/app/browser/main/tab.cpp +++ b/src/app/browser/main/tab.cpp @@ -166,6 +166,37 @@ void Tab::update( ); } +void Tab::update( + const int & PAGE_NUMBER, + const Glib::ustring & URI +) { + // Get tab page + const auto TAB_PAGE = get_tabPage( + PAGE_NUMBER + ); + + // Update tab page component + TAB_PAGE->update( + URI + ); + + // Update tab label component + get_tabLabel( + PAGE_NUMBER + )->set_label( + TAB_PAGE->get_title() + ); + + // Update tab actions status + action__tab_close_active->set_enabled( + get_n_pages() > 0 + ); + + action__tab_close_all->set_enabled( + get_n_pages() > 0 + ); +} + int Tab::append( const Glib::ustring & LABEL_TEXT, const bool & IS_CURRENT diff --git a/src/app/browser/main/tab.hpp b/src/app/browser/main/tab.hpp index 99e848f6..55339f24 100644 --- a/src/app/browser/main/tab.hpp +++ b/src/app/browser/main/tab.hpp @@ -124,6 +124,11 @@ namespace app::browser::main const int & PAGE_NUMBER ); + void update( + const int & PAGE_NUMBER, + const Glib::ustring & URI + ); + int restore( const sqlite3_int64 & APP_BROWSER_MAIN__SESSION__ID ); // return sqlite3_finalize status code diff --git a/src/app/browser/main/tab/page.cpp b/src/app/browser/main/tab/page.cpp index 4bd86f9e..f65b4450 100644 --- a/src/app/browser/main/tab/page.cpp +++ b/src/app/browser/main/tab/page.cpp @@ -155,6 +155,16 @@ void Page::update() ); } +void Page::update( + const Glib::ustring & URI +) { + // Update children components + pageNavigation->update( + URI, + progress_fraction + ); +} + void Page::navigation_reload( const bool & ADD_HISTORY ) { diff --git a/src/app/browser/main/tab/page.hpp b/src/app/browser/main/tab/page.hpp index d9a168f6..21bf9f96 100644 --- a/src/app/browser/main/tab/page.hpp +++ b/src/app/browser/main/tab/page.hpp @@ -133,6 +133,10 @@ namespace app::browser::main::tab void update(); + void update( + const Glib::ustring & URI + ); + void navigation_reload( const bool & ADD_HISTORY ); diff --git a/src/app/browser/main/tab/page/navigation.cpp b/src/app/browser/main/tab/page/navigation.cpp index 969a5327..b51c41b7 100644 --- a/src/app/browser/main/tab/page/navigation.cpp +++ b/src/app/browser/main/tab/page/navigation.cpp @@ -117,6 +117,30 @@ void Navigation::update( ); } +void Navigation::update( + const Glib::ustring & REQUEST_TEXT, + const double & REQUEST_PROGRESS_FRACTION +) { + // Update base widget + navigationBase->update( + REQUEST_TEXT + ); + + // Update history widget + navigationHistory->update(); + + // Toggle update button sensibility + navigationReload->update( + navigationRequest->get_text_length() > 0 + ); + + // Update request area (with progressbar) + navigationRequest->update( + REQUEST_TEXT, + REQUEST_PROGRESS_FRACTION + ); +} + int Navigation::restore( const sqlite3_int64 & APP_BROWSER_MAIN_TAB_PAGE__SESSION__ID ) { diff --git a/src/app/browser/main/tab/page/navigation.hpp b/src/app/browser/main/tab/page/navigation.hpp index d5d726d4..f94514c8 100644 --- a/src/app/browser/main/tab/page/navigation.hpp +++ b/src/app/browser/main/tab/page/navigation.hpp @@ -93,6 +93,11 @@ namespace app::browser::main::tab::page const double & PROGRESS_FRACTION ); + void update( + const Glib::ustring & REQUEST_TEXT, + const double & REQUEST_PROGRESS_FRACTION + ); + int restore( const sqlite3_int64 & APP_BROWSER_MAIN_TAB_PAGE__SESSION__ID ); // return sqlite3_finalize status code diff --git a/src/app/browser/main/tab/page/navigation/base.cpp b/src/app/browser/main/tab/page/navigation/base.cpp index f944dcd6..c70d92af 100644 --- a/src/app/browser/main/tab/page/navigation/base.cpp +++ b/src/app/browser/main/tab/page/navigation/base.cpp @@ -15,4 +15,22 @@ Base::Base() set_sensitive( false ); + + // @TODO add action +} + +void Base::update( + const Glib::ustring & URI +) { + GUri * uri = g_uri_parse( + URI.c_str(), + G_URI_FLAGS_NONE, + NULL // @TODO GError * + ); + + set_sensitive( + NULL != uri && + NULL != g_uri_get_host(uri) && + NULL != g_uri_get_path(uri) + ); } \ No newline at end of file diff --git a/src/app/browser/main/tab/page/navigation/base.hpp b/src/app/browser/main/tab/page/navigation/base.hpp index c1bb6cf5..6dfd35cc 100644 --- a/src/app/browser/main/tab/page/navigation/base.hpp +++ b/src/app/browser/main/tab/page/navigation/base.hpp @@ -11,6 +11,10 @@ namespace app::browser::main::tab::page::navigation public: Base(); + + void update( + const Glib::ustring & URI + ); }; } diff --git a/src/app/browser/main/tab/page/navigation/request.cpp b/src/app/browser/main/tab/page/navigation/request.cpp index a8fa3aad..d72d4706 100644 --- a/src/app/browser/main/tab/page/navigation/request.cpp +++ b/src/app/browser/main/tab/page/navigation/request.cpp @@ -89,6 +89,19 @@ void Request::update( ); } +void Request::update( + const Glib::ustring & TEXT, + const double & PROGRESS_FRACTION +) { + set_text( + TEXT + ); + + update( + PROGRESS_FRACTION + ); +} + int Request::restore( const sqlite3_int64 & APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION__ID ) { diff --git a/src/app/browser/main/tab/page/navigation/request.hpp b/src/app/browser/main/tab/page/navigation/request.hpp index 9cd11d98..dfca577c 100644 --- a/src/app/browser/main/tab/page/navigation/request.hpp +++ b/src/app/browser/main/tab/page/navigation/request.hpp @@ -89,6 +89,11 @@ namespace app::browser::main::tab::page::navigation const double & PROGRESS_FRACTION ); + void update( + const Glib::ustring & TEXT, + const double & PROGRESS_FRACTION + ); + int restore( const sqlite3_int64 & APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION__ID ); // return sqlite3_finalize status code