mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-03-12 13:41:34 +00:00
change page update logic
This commit is contained in:
parent
ab6f0cca3a
commit
88e422e225
@ -156,12 +156,7 @@ void Tab::update(
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Update tab page component
|
// Update tab page component
|
||||||
TAB_PAGE->update(
|
TAB_PAGE->update();
|
||||||
TAB_PAGE->get_mime(),
|
|
||||||
TAB_PAGE->get_title(),
|
|
||||||
TAB_PAGE->get_description(),
|
|
||||||
TAB_PAGE->get_progress_fraction()
|
|
||||||
); // just action delegate @TODO
|
|
||||||
|
|
||||||
// Update tab label component
|
// Update tab label component
|
||||||
get_tabLabel(
|
get_tabLabel(
|
||||||
|
@ -154,20 +154,6 @@ void Page::update()
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Page::update(
|
|
||||||
const MIME & MIME,
|
|
||||||
const Glib::ustring & TITLE,
|
|
||||||
const Glib::ustring & DESCRIPTION,
|
|
||||||
const double & PROGRESS_FRACTION
|
|
||||||
) {
|
|
||||||
mime = MIME;
|
|
||||||
title = TITLE;
|
|
||||||
description = DESCRIPTION;
|
|
||||||
progress_fraction = PROGRESS_FRACTION;
|
|
||||||
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Page::navigation_reload(
|
void Page::navigation_reload(
|
||||||
const bool & ADD_HISTORY
|
const bool & ADD_HISTORY
|
||||||
) {
|
) {
|
||||||
@ -180,17 +166,20 @@ void Page::navigation_reload(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update page extras
|
// Update page data
|
||||||
update(
|
mime = MIME::UNDEFINED;
|
||||||
MIME::UNDEFINED,
|
|
||||||
_("Update"),
|
title = _("Update");
|
||||||
Glib::ustring::sprintf(
|
|
||||||
_("Begin update for %s.."),
|
description = Glib::ustring::sprintf(
|
||||||
pageNavigation->get_request_text()
|
_("Begin update for %s.."),
|
||||||
),
|
pageNavigation->get_request_text()
|
||||||
0
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
progress_fraction = 0;
|
||||||
|
|
||||||
|
action__update->signal_activate();
|
||||||
|
|
||||||
// Connect scheme driver
|
// Connect scheme driver
|
||||||
if ("file" == pageNavigation->get_request_scheme())
|
if ("file" == pageNavigation->get_request_scheme())
|
||||||
{
|
{
|
||||||
@ -218,16 +207,18 @@ void Page::navigation_reload(
|
|||||||
pageNavigation->get_request_text(), 1965,
|
pageNavigation->get_request_text(), 1965,
|
||||||
[this](const Glib::RefPtr<Gio::AsyncResult> & result)
|
[this](const Glib::RefPtr<Gio::AsyncResult> & result)
|
||||||
{
|
{
|
||||||
update(
|
// Update
|
||||||
MIME::UNDEFINED,
|
title = _("Connect");
|
||||||
_("Connect"),
|
|
||||||
Glib::ustring::sprintf(
|
description = Glib::ustring::sprintf(
|
||||||
_("Connecting to %s.."),
|
_("Connecting to %s.."),
|
||||||
pageNavigation->get_request_host()
|
pageNavigation->get_request_host()
|
||||||
),
|
|
||||||
.25
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
progress_fraction = .25;
|
||||||
|
|
||||||
|
action__update->signal_activate();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
GioSocketConnection = GioSocketClient->connect_to_uri_finish(
|
GioSocketConnection = GioSocketClient->connect_to_uri_finish(
|
||||||
@ -237,12 +228,14 @@ void Page::navigation_reload(
|
|||||||
|
|
||||||
catch (const Glib::Error & EXCEPTION)
|
catch (const Glib::Error & EXCEPTION)
|
||||||
{
|
{
|
||||||
update(
|
// Update
|
||||||
MIME::UNDEFINED,
|
title = _("Oops");
|
||||||
_("Oops"),
|
|
||||||
EXCEPTION.what(),
|
description = EXCEPTION.what();
|
||||||
1
|
|
||||||
);
|
progress_fraction = 1;
|
||||||
|
|
||||||
|
action__update->signal_activate();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Connection established, begin request
|
// Connection established, begin request
|
||||||
@ -255,34 +248,38 @@ void Page::navigation_reload(
|
|||||||
request.size(),
|
request.size(),
|
||||||
[this](const Glib::RefPtr<Gio::AsyncResult> & result)
|
[this](const Glib::RefPtr<Gio::AsyncResult> & result)
|
||||||
{
|
{
|
||||||
update(
|
// Update
|
||||||
MIME::UNDEFINED,
|
title = _("Request");
|
||||||
_("Request"),
|
|
||||||
Glib::ustring::sprintf(
|
description = Glib::ustring::sprintf(
|
||||||
_("Begin request to %s.."),
|
_("Begin request to %s.."),
|
||||||
pageNavigation->get_request_path().empty() ? pageNavigation->get_request_host()
|
pageNavigation->get_request_path().empty() ? pageNavigation->get_request_host()
|
||||||
: pageNavigation->get_request_path()
|
: pageNavigation->get_request_path()
|
||||||
),
|
|
||||||
.5
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
progress_fraction = .5;
|
||||||
|
|
||||||
|
action__update->signal_activate();
|
||||||
|
|
||||||
// Response
|
// Response
|
||||||
GioSocketConnection->get_input_stream()->read_async( // | read_all_async
|
GioSocketConnection->get_input_stream()->read_async( // | read_all_async
|
||||||
buffer,
|
buffer,
|
||||||
sizeof(buffer) - 1,
|
sizeof(buffer) - 1,
|
||||||
[this](const Glib::RefPtr<Gio::AsyncResult> & result)
|
[this](const Glib::RefPtr<Gio::AsyncResult> & result)
|
||||||
{
|
{
|
||||||
update(
|
// Update
|
||||||
MIME::UNDEFINED,
|
title = _("Reading");
|
||||||
_("Reading"),
|
|
||||||
Glib::ustring::sprintf(
|
description = Glib::ustring::sprintf(
|
||||||
_("Reading response from %s.."),
|
_("Reading response from %s.."),
|
||||||
pageNavigation->get_request_path().empty() ? pageNavigation->get_request_host()
|
pageNavigation->get_request_path().empty() ? pageNavigation->get_request_host()
|
||||||
: pageNavigation->get_request_path()
|
: pageNavigation->get_request_path()
|
||||||
),
|
|
||||||
.75
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
progress_fraction = .75;
|
||||||
|
|
||||||
|
action__update->signal_activate();
|
||||||
|
|
||||||
// Parse meta
|
// Parse meta
|
||||||
auto meta = Glib::Regex::split_simple(
|
auto meta = Glib::Regex::split_simple(
|
||||||
R"regex(^(\d+)?\s([\w]+\/[\w]+)?)regex",
|
R"regex(^(\d+)?\s([\w]+\/[\w]+)?)regex",
|
||||||
@ -295,50 +292,52 @@ void Page::navigation_reload(
|
|||||||
// Route by mime type or path extension
|
// Route by mime type or path extension
|
||||||
if (meta[2] == "text/gemini" || Glib::str_has_suffix(pageNavigation->get_request_path(), ".gmi"))
|
if (meta[2] == "text/gemini" || Glib::str_has_suffix(pageNavigation->get_request_path(), ".gmi"))
|
||||||
{
|
{
|
||||||
update(
|
// Update
|
||||||
MIME::TEXT_GEMINI,
|
mime = MIME::TEXT_GEMINI;
|
||||||
pageNavigation->get_request_host(), // @TODO title
|
|
||||||
|
title = _("Parsing");
|
||||||
|
|
||||||
|
description = Glib::ustring::sprintf(
|
||||||
|
_("Parsing response from %s.."),
|
||||||
pageNavigation->get_request_path().empty() ? pageNavigation->get_request_host()
|
pageNavigation->get_request_path().empty() ? pageNavigation->get_request_host()
|
||||||
: pageNavigation->get_request_path()
|
: pageNavigation->get_request_path()
|
||||||
,
|
|
||||||
1
|
|
||||||
);
|
);
|
||||||
|
|
||||||
pageContent->set_text_gemini(
|
progress_fraction = .8;
|
||||||
buffer // @TODO
|
|
||||||
|
pageContent->set_text_gemini( // @TODO
|
||||||
|
buffer
|
||||||
);
|
);
|
||||||
|
|
||||||
|
action__update->signal_activate();
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
update(
|
// Update
|
||||||
MIME::UNDEFINED,
|
title = _("Oops");
|
||||||
_("Oops"),
|
|
||||||
_("MIME type not supported"),
|
|
||||||
1
|
|
||||||
);
|
|
||||||
|
|
||||||
pageContent->set_text_plain( // @TODO
|
description = _("MIME type not supported");
|
||||||
description
|
|
||||||
);
|
progress_fraction = 1;
|
||||||
|
|
||||||
|
action__update->signal_activate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
update(
|
// Update
|
||||||
MIME::UNDEFINED,
|
title = _("Oops");
|
||||||
_("Oops"),
|
|
||||||
Glib::ustring::sprintf(
|
description = Glib::ustring::sprintf(
|
||||||
_("Response code %s not supported"),
|
_("Response code %s not supported"),
|
||||||
meta[1]
|
meta[1]
|
||||||
),
|
|
||||||
1
|
|
||||||
);
|
);
|
||||||
|
|
||||||
pageContent->set_text_plain( // @TODO
|
progress_fraction = 1;
|
||||||
description
|
|
||||||
);
|
action__update->signal_activate();
|
||||||
}
|
}
|
||||||
|
|
||||||
GioSocketConnection->close();
|
GioSocketConnection->close();
|
||||||
|
@ -127,12 +127,6 @@ namespace app::browser::main::tab
|
|||||||
);
|
);
|
||||||
|
|
||||||
void update();
|
void update();
|
||||||
void update(
|
|
||||||
const MIME & MIME,
|
|
||||||
const Glib::ustring & TITLE,
|
|
||||||
const Glib::ustring & DESCRIPTION,
|
|
||||||
const double & PROGRESS_FRACTION
|
|
||||||
);
|
|
||||||
|
|
||||||
void navigation_reload(
|
void navigation_reload(
|
||||||
const bool & ADD_HISTORY
|
const bool & ADD_HISTORY
|
||||||
|
Loading…
x
Reference in New Issue
Block a user