implement alternative update action api

This commit is contained in:
yggverse 2024-09-15 06:11:36 +03:00
parent 6b6d3ad826
commit cda76380e8
13 changed files with 142 additions and 2 deletions

View File

@ -33,9 +33,17 @@ Browser::Browser(
{
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()
}
);

View File

@ -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()
{

View File

@ -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();

View File

@ -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

View File

@ -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

View File

@ -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
) {

View File

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

View File

@ -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
) {

View File

@ -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

View File

@ -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)
);
}

View File

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

View File

@ -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
) {

View File

@ -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