draft page setter

This commit is contained in:
yggverse 2024-08-27 15:45:04 +03:00
parent cb537dddd2
commit 88681836ce
2 changed files with 49 additions and 13 deletions

View File

@ -10,10 +10,6 @@ Page::Page(
const Glib::ustring & SUBTITLE, const Glib::ustring & SUBTITLE,
const Glib::ustring & REQUEST const Glib::ustring & REQUEST
) { ) {
// Init extras
title = TITLE;
subtitle = SUBTITLE;
// Init container // Init container
set_orientation( set_orientation(
Gtk::Orientation::VERTICAL Gtk::Orientation::VERTICAL
@ -60,6 +56,13 @@ Page::Page(
append( append(
* pageContent * pageContent
); );
// Init extras
set(
TITLE,
SUBTITLE,
0
);
} }
Page::~Page() Page::~Page()
@ -88,11 +91,10 @@ void Page::refresh()
void Page::update() void Page::update()
{ {
title = _("Loading.."); // Update page extras
subtitle = ""; // @TODO setter set(
_("Loading.."),
// Reset progress pageNavbar->get_request_text(),
pageProgressbar->set(
0 0
); );
@ -126,7 +128,9 @@ void Page::update()
), ),
[this](const Glib::RefPtr<Gio::AsyncResult> & result) [this](const Glib::RefPtr<Gio::AsyncResult> & result)
{ {
pageProgressbar->set( set(
_("Connected.."),
pageNavbar->get_request_host(),
.25 .25
); );
@ -142,7 +146,9 @@ void Page::update()
navbar_request_text.size(), navbar_request_text.size(),
[this](const Glib::RefPtr<Gio::AsyncResult> & result) [this](const Glib::RefPtr<Gio::AsyncResult> & result)
{ {
pageProgressbar->set( set(
_("Request.."),
pageNavbar->get_request_host(),
.5 .5
); );
@ -152,7 +158,9 @@ void Page::update()
sizeof(buffer) - 1, sizeof(buffer) - 1,
[this](const Glib::RefPtr<Gio::AsyncResult> & result) [this](const Glib::RefPtr<Gio::AsyncResult> & result)
{ {
pageProgressbar->set( set(
_("Reading response.."),
pageNavbar->get_request_host(),
.75 .75
); );
@ -190,7 +198,9 @@ void Page::update()
GioSocketConnection_RefPtr->close(); GioSocketConnection_RefPtr->close();
pageProgressbar->set( set(
_("Page title"), // @TODO
pageNavbar->get_request_host(),
1 1
); );
} }
@ -231,4 +241,23 @@ void Page::update()
{ {
// @TODO search request // @TODO search request
} }
}
// Private helpers
void Page::set(
const Glib::ustring & TITLE,
const Glib::ustring & SUBTITLE,
const double & PROGRESS
) {
title = TITLE;
subtitle = SUBTITLE;
pageProgressbar->set(
PROGRESS
);
activate_action(
"win.refresh"
);
} }

View File

@ -40,6 +40,13 @@ namespace app::browser::main::tab
page::Navbar * pageNavbar; page::Navbar * pageNavbar;
page::Progressbar * pageProgressbar; page::Progressbar * pageProgressbar;
// Helpers
void set(
const Glib::ustring & TITLE,
const Glib::ustring & SUBTITLE,
const double & PROGRESS
);
public: public:
Page( Page(