mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-03-12 13:41:34 +00:00
add page mime type as refresh method argument
This commit is contained in:
parent
e38ad33fa6
commit
c74e9a81f0
@ -185,6 +185,7 @@ void Tab::refresh(
|
|||||||
);
|
);
|
||||||
|
|
||||||
TAB_PAGE->refresh(
|
TAB_PAGE->refresh(
|
||||||
|
tab::Page::MIME::UNDEFINED,
|
||||||
TAB_PAGE->get_title(),
|
TAB_PAGE->get_title(),
|
||||||
TAB_PAGE->get_subtitle(),
|
TAB_PAGE->get_subtitle(),
|
||||||
0 // @TODO
|
0 // @TODO
|
||||||
|
@ -10,11 +10,6 @@ Page::Page(
|
|||||||
const Glib::RefPtr<Gio::SimpleAction> & ACTION__PAGE_NAVIGATION_HISTORY_FORWARD,
|
const Glib::RefPtr<Gio::SimpleAction> & ACTION__PAGE_NAVIGATION_HISTORY_FORWARD,
|
||||||
const Glib::RefPtr<Gio::SimpleAction> & ACTION__PAGE_NAVIGATION_UPDATE
|
const Glib::RefPtr<Gio::SimpleAction> & ACTION__PAGE_NAVIGATION_UPDATE
|
||||||
) {
|
) {
|
||||||
// Init extras
|
|
||||||
mime = MIME::UNDEFINED;
|
|
||||||
title = _("New page");
|
|
||||||
subtitle = "";
|
|
||||||
|
|
||||||
// Init components
|
// Init components
|
||||||
pageNavigation = Gtk::make_managed<page::Navigation>(
|
pageNavigation = Gtk::make_managed<page::Navigation>(
|
||||||
ACTION__REFRESH,
|
ACTION__REFRESH,
|
||||||
@ -39,14 +34,16 @@ Page::Page(
|
|||||||
);
|
);
|
||||||
|
|
||||||
refresh(
|
refresh(
|
||||||
title,
|
MIME::UNDEFINED,
|
||||||
subtitle,
|
_("New page"),
|
||||||
|
"",
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
void Page::refresh(
|
void Page::refresh(
|
||||||
|
const MIME & MIME,
|
||||||
const Glib::ustring & TITLE,
|
const Glib::ustring & TITLE,
|
||||||
const Glib::ustring & SUBTITLE,
|
const Glib::ustring & SUBTITLE,
|
||||||
const double & PROGRESS_FRACTION
|
const double & PROGRESS_FRACTION
|
||||||
@ -73,6 +70,7 @@ void Page::navigation_update(
|
|||||||
|
|
||||||
// Update page extras
|
// Update page extras
|
||||||
refresh(
|
refresh(
|
||||||
|
MIME::UNDEFINED,
|
||||||
pageNavigation->get_request_host(),
|
pageNavigation->get_request_host(),
|
||||||
Glib::ustring::sprintf(
|
Glib::ustring::sprintf(
|
||||||
_("load %s.."),
|
_("load %s.."),
|
||||||
@ -108,6 +106,7 @@ void Page::navigation_update(
|
|||||||
[this](const Glib::RefPtr<Gio::AsyncResult> & result)
|
[this](const Glib::RefPtr<Gio::AsyncResult> & result)
|
||||||
{
|
{
|
||||||
refresh(
|
refresh(
|
||||||
|
MIME::UNDEFINED,
|
||||||
pageNavigation->get_request_host(),
|
pageNavigation->get_request_host(),
|
||||||
Glib::ustring::sprintf(
|
Glib::ustring::sprintf(
|
||||||
_("connect %s.."),
|
_("connect %s.."),
|
||||||
@ -125,6 +124,7 @@ void Page::navigation_update(
|
|||||||
catch (const Glib::Error & EXCEPTION)
|
catch (const Glib::Error & EXCEPTION)
|
||||||
{
|
{
|
||||||
refresh(
|
refresh(
|
||||||
|
MIME::UNDEFINED,
|
||||||
pageNavigation->get_request_host(),
|
pageNavigation->get_request_host(),
|
||||||
EXCEPTION.what(), 1
|
EXCEPTION.what(), 1
|
||||||
);
|
);
|
||||||
@ -141,6 +141,7 @@ void Page::navigation_update(
|
|||||||
[this](const Glib::RefPtr<Gio::AsyncResult> & result)
|
[this](const Glib::RefPtr<Gio::AsyncResult> & result)
|
||||||
{
|
{
|
||||||
refresh(
|
refresh(
|
||||||
|
MIME::UNDEFINED,
|
||||||
pageNavigation->get_request_host(),
|
pageNavigation->get_request_host(),
|
||||||
Glib::ustring::sprintf(
|
Glib::ustring::sprintf(
|
||||||
_("request %s.."),
|
_("request %s.."),
|
||||||
@ -156,6 +157,7 @@ void Page::navigation_update(
|
|||||||
[this](const Glib::RefPtr<Gio::AsyncResult> & result)
|
[this](const Glib::RefPtr<Gio::AsyncResult> & result)
|
||||||
{
|
{
|
||||||
refresh(
|
refresh(
|
||||||
|
MIME::UNDEFINED,
|
||||||
pageNavigation->get_request_host(),
|
pageNavigation->get_request_host(),
|
||||||
Glib::ustring::sprintf(
|
Glib::ustring::sprintf(
|
||||||
_("reading %s.."),
|
_("reading %s.."),
|
||||||
@ -176,7 +178,13 @@ void Page::navigation_update(
|
|||||||
// 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"))
|
||||||
{
|
{
|
||||||
mime = MIME::TEXT_GEMINI;
|
refresh(
|
||||||
|
MIME::TEXT_GEMINI,
|
||||||
|
pageNavigation->get_request_host(), // @TODO title
|
||||||
|
pageNavigation->get_request_path().empty() ? pageNavigation->get_request_host()
|
||||||
|
: pageNavigation->get_request_path()
|
||||||
|
, 1
|
||||||
|
);
|
||||||
|
|
||||||
pageContent->set_text_gemini(
|
pageContent->set_text_gemini(
|
||||||
buffer // @TODO
|
buffer // @TODO
|
||||||
@ -185,10 +193,12 @@ void Page::navigation_update(
|
|||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mime = MIME::UNDEFINED;
|
refresh(
|
||||||
|
MIME::UNDEFINED,
|
||||||
title = _("Oops");
|
_("Oops"),
|
||||||
subtitle = _("MIME type not supported");
|
_("MIME type not supported")
|
||||||
|
, 1
|
||||||
|
);
|
||||||
|
|
||||||
pageContent->set_text_plain( // @TODO
|
pageContent->set_text_plain( // @TODO
|
||||||
subtitle
|
subtitle
|
||||||
@ -198,13 +208,14 @@ void Page::navigation_update(
|
|||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mime = MIME::UNDEFINED;
|
refresh(
|
||||||
|
MIME::UNDEFINED,
|
||||||
title = _("Oops");
|
_("Oops"),
|
||||||
|
Glib::ustring::sprintf(
|
||||||
subtitle = Glib::ustring::sprintf(
|
_("Response code %s not supported"),
|
||||||
_("Response code %s not supported"),
|
meta[1]
|
||||||
meta[1]
|
)
|
||||||
|
, 1
|
||||||
);
|
);
|
||||||
|
|
||||||
pageContent->set_text_plain( // @TODO
|
pageContent->set_text_plain( // @TODO
|
||||||
@ -215,6 +226,7 @@ void Page::navigation_update(
|
|||||||
GioSocketConnection->close();
|
GioSocketConnection->close();
|
||||||
|
|
||||||
refresh(
|
refresh(
|
||||||
|
MIME::UNDEFINED,
|
||||||
pageNavigation->get_request_host(), // @TODO title
|
pageNavigation->get_request_host(), // @TODO title
|
||||||
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()
|
||||||
|
@ -25,27 +25,30 @@ namespace app::browser::main::tab
|
|||||||
|
|
||||||
class Page : public Gtk::Box
|
class Page : public Gtk::Box
|
||||||
{
|
{
|
||||||
// Extras
|
public:
|
||||||
enum class MIME
|
|
||||||
{
|
|
||||||
TEXT_PLAIN,
|
|
||||||
TEXT_GEMINI,
|
|
||||||
UNDEFINED
|
|
||||||
};
|
|
||||||
|
|
||||||
MIME mime;
|
enum class MIME
|
||||||
Glib::ustring title;
|
{
|
||||||
Glib::ustring subtitle;
|
TEXT_PLAIN,
|
||||||
|
TEXT_GEMINI,
|
||||||
|
UNDEFINED
|
||||||
|
};
|
||||||
|
|
||||||
// Socket
|
private:
|
||||||
char buffer[0xfffff]; // 1Mb
|
|
||||||
|
|
||||||
Glib::RefPtr<Gio::SocketClient> GioSocketClient;
|
MIME mime;
|
||||||
Glib::RefPtr<Gio::SocketConnection> GioSocketConnection;
|
Glib::ustring title;
|
||||||
|
Glib::ustring subtitle;
|
||||||
|
|
||||||
// Components
|
// Socket
|
||||||
page::Content * pageContent;
|
char buffer[0xfffff]; // 1Mb
|
||||||
page::Navigation * pageNavigation;
|
|
||||||
|
Glib::RefPtr<Gio::SocketClient> GioSocketClient;
|
||||||
|
Glib::RefPtr<Gio::SocketConnection> GioSocketConnection;
|
||||||
|
|
||||||
|
// Components
|
||||||
|
page::Content * pageContent;
|
||||||
|
page::Navigation * pageNavigation;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -58,6 +61,7 @@ namespace app::browser::main::tab
|
|||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
void refresh(
|
void refresh(
|
||||||
|
const MIME & MIME,
|
||||||
const Glib::ustring & TITLE,
|
const Glib::ustring & TITLE,
|
||||||
const Glib::ustring & SUBTITLE,
|
const Glib::ustring & SUBTITLE,
|
||||||
const double & PROGRESS_FRACTION
|
const double & PROGRESS_FRACTION
|
||||||
|
Loading…
x
Reference in New Issue
Block a user