Browse Source

draft page setter

CPP-GTK4
yggverse 4 months ago
parent
commit
88681836ce
  1. 55
      src/app/browser/main/tab/page.cpp
  2. 7
      src/app/browser/main/tab/page.hpp

55
src/app/browser/main/tab/page.cpp

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

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

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

Loading…
Cancel
Save