Browse Source

implement alternative update action api

CPP-GTK4
yggverse 3 months ago
parent
commit
cda76380e8
  1. 12
      src/app/browser.cpp
  2. 9
      src/app/browser/main.cpp
  3. 4
      src/app/browser/main.hpp
  4. 31
      src/app/browser/main/tab.cpp
  5. 5
      src/app/browser/main/tab.hpp
  6. 10
      src/app/browser/main/tab/page.cpp
  7. 4
      src/app/browser/main/tab/page.hpp
  8. 24
      src/app/browser/main/tab/page/navigation.cpp
  9. 5
      src/app/browser/main/tab/page/navigation.hpp
  10. 18
      src/app/browser/main/tab/page/navigation/base.cpp
  11. 4
      src/app/browser/main/tab/page/navigation/base.hpp
  12. 13
      src/app/browser/main/tab/page/navigation/request.cpp
  13. 5
      src/app/browser/main/tab/page/navigation/request.hpp

12
src/app/browser.cpp

@ -33,9 +33,17 @@ Browser::Browser(
{ {
if (PARAMETER.is_of_type(Glib::VARIANT_TYPE_STRING)) if (PARAMETER.is_of_type(Glib::VARIANT_TYPE_STRING))
{ {
browserMain->update(
Glib::VariantBase::cast_dynamic<Glib::Variant<Glib::ustring>>(
PARAMETER
).get()
);
browserHeader->update(
browserMain->get_tab_page_title(),
browserMain->get_tab_page_description()
);
} }
// @TODO process request
// Glib::VariantBase::cast_dynamic<Glib::Variant<Glib::ustring>>(parameter).get()
} }
); );

9
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 // Getters
Glib::ustring Main::get_tab_page_title() Glib::ustring Main::get_tab_page_title()
{ {

4
src/app/browser/main.hpp

@ -105,6 +105,10 @@ namespace app::browser
void update(); void update();
void update(
const Glib::ustring & URI
);
// Getters // Getters
Glib::ustring get_tab_page_title(); Glib::ustring get_tab_page_title();
Glib::ustring get_tab_page_description(); Glib::ustring get_tab_page_description();

31
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( int Tab::append(
const Glib::ustring & LABEL_TEXT, const Glib::ustring & LABEL_TEXT,
const bool & IS_CURRENT const bool & IS_CURRENT

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

@ -124,6 +124,11 @@ namespace app::browser::main
const int & PAGE_NUMBER const int & PAGE_NUMBER
); );
void update(
const int & PAGE_NUMBER,
const Glib::ustring & URI
);
int restore( int restore(
const sqlite3_int64 & APP_BROWSER_MAIN__SESSION__ID const sqlite3_int64 & APP_BROWSER_MAIN__SESSION__ID
); // return sqlite3_finalize status code ); // return sqlite3_finalize status code

10
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( void Page::navigation_reload(
const bool & ADD_HISTORY const bool & ADD_HISTORY
) { ) {

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

@ -133,6 +133,10 @@ namespace app::browser::main::tab
void update(); void update();
void update(
const Glib::ustring & URI
);
void navigation_reload( void navigation_reload(
const bool & ADD_HISTORY const bool & ADD_HISTORY
); );

24
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( int Navigation::restore(
const sqlite3_int64 & APP_BROWSER_MAIN_TAB_PAGE__SESSION__ID const sqlite3_int64 & APP_BROWSER_MAIN_TAB_PAGE__SESSION__ID
) { ) {

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

@ -93,6 +93,11 @@ namespace app::browser::main::tab::page
const double & PROGRESS_FRACTION const double & PROGRESS_FRACTION
); );
void update(
const Glib::ustring & REQUEST_TEXT,
const double & REQUEST_PROGRESS_FRACTION
);
int restore( int restore(
const sqlite3_int64 & APP_BROWSER_MAIN_TAB_PAGE__SESSION__ID const sqlite3_int64 & APP_BROWSER_MAIN_TAB_PAGE__SESSION__ID
); // return sqlite3_finalize status code ); // return sqlite3_finalize status code

18
src/app/browser/main/tab/page/navigation/base.cpp

@ -15,4 +15,22 @@ Base::Base()
set_sensitive( set_sensitive(
false 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)
);
} }

4
src/app/browser/main/tab/page/navigation/base.hpp

@ -11,6 +11,10 @@ namespace app::browser::main::tab::page::navigation
public: public:
Base(); Base();
void update(
const Glib::ustring & URI
);
}; };
} }

13
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( int Request::restore(
const sqlite3_int64 & APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION__ID const sqlite3_int64 & APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION__ID
) { ) {

5
src/app/browser/main/tab/page/navigation/request.hpp

@ -89,6 +89,11 @@ namespace app::browser::main::tab::page::navigation
const double & PROGRESS_FRACTION const double & PROGRESS_FRACTION
); );
void update(
const Glib::ustring & TEXT,
const double & PROGRESS_FRACTION
);
int restore( int restore(
const sqlite3_int64 & APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION__ID const sqlite3_int64 & APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION__ID
); // return sqlite3_finalize status code ); // return sqlite3_finalize status code

Loading…
Cancel
Save