Browse Source

update method name

CPP-GTK4
yggverse 2 months ago
parent
commit
2e5ebda5db
  1. 51
      src/app/browser/main/tab/page.cpp
  2. 14
      src/app/browser/main/tab/page.hpp
  3. 2
      src/app/browser/main/tab/page/progressbar.cpp
  4. 2
      src/app/browser/main/tab/page/progressbar.hpp

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

@ -54,7 +54,7 @@ Page::Page(
); );
// Init extras // Init extras
set( refresh(
TITLE, TITLE,
SUBTITLE, SUBTITLE,
0 0
@ -83,6 +83,24 @@ void Page::forward()
pageNavbar->forward(); pageNavbar->forward();
} }
void Page::refresh(
const Glib::ustring & TITLE,
const Glib::ustring & SUBTITLE,
const double & PROGRESS
) {
title = TITLE;
subtitle = SUBTITLE;
pageProgressbar->refresh(
PROGRESS
);
activate_action(
"win.refresh"
);
}
void Page::update() void Page::update()
{ {
// Update navigation history // Update navigation history
@ -91,7 +109,7 @@ void Page::update()
); );
// Update page extras // Update page extras
set( refresh(
pageNavbar->get_request_host(), pageNavbar->get_request_host(),
Glib::ustring::sprintf( Glib::ustring::sprintf(
_("load %s.."), _("load %s.."),
@ -126,7 +144,7 @@ void Page::update()
pageNavbar->get_request_text(), 1965, pageNavbar->get_request_text(), 1965,
[this](const Glib::RefPtr<Gio::AsyncResult> & result) [this](const Glib::RefPtr<Gio::AsyncResult> & result)
{ {
set( refresh(
pageNavbar->get_request_host(), pageNavbar->get_request_host(),
Glib::ustring::sprintf( Glib::ustring::sprintf(
_("connect %s.."), _("connect %s.."),
@ -143,7 +161,7 @@ void Page::update()
catch (const Glib::Error & EXCEPTION) catch (const Glib::Error & EXCEPTION)
{ {
set( refresh(
pageNavbar->get_request_host(), pageNavbar->get_request_host(),
EXCEPTION.what(), 1 EXCEPTION.what(), 1
); );
@ -159,7 +177,7 @@ void Page::update()
request.size(), request.size(),
[this](const Glib::RefPtr<Gio::AsyncResult> & result) [this](const Glib::RefPtr<Gio::AsyncResult> & result)
{ {
set( refresh(
pageNavbar->get_request_host(), pageNavbar->get_request_host(),
Glib::ustring::sprintf( Glib::ustring::sprintf(
_("request %s.."), _("request %s.."),
@ -174,7 +192,7 @@ void Page::update()
sizeof(buffer) - 1, sizeof(buffer) - 1,
[this](const Glib::RefPtr<Gio::AsyncResult> & result) [this](const Glib::RefPtr<Gio::AsyncResult> & result)
{ {
set( refresh(
pageNavbar->get_request_host(), pageNavbar->get_request_host(),
Glib::ustring::sprintf( Glib::ustring::sprintf(
_("reading %s.."), _("reading %s.."),
@ -217,7 +235,7 @@ void Page::update()
GioSocketConnection_RefPtr->close(); GioSocketConnection_RefPtr->close();
set( refresh(
pageNavbar->get_request_host(), // @TODO title pageNavbar->get_request_host(), // @TODO title
pageNavbar->get_request_path().empty() ? pageNavbar->get_request_host() pageNavbar->get_request_path().empty() ? pageNavbar->get_request_host()
: pageNavbar->get_request_path() : pageNavbar->get_request_path()
@ -247,22 +265,3 @@ 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"
);
}

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

@ -41,13 +41,6 @@ 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(
@ -63,6 +56,13 @@ namespace app::browser::main::tab
// Actions // Actions
void back(); void back();
void forward(); void forward();
void refresh(
const Glib::ustring & TITLE,
const Glib::ustring & SUBTITLE,
const double & PROGRESS
);
void update(); void update();
}; };
} }

2
src/app/browser/main/tab/page/progressbar.cpp

@ -20,7 +20,7 @@ Progressbar::Progressbar()
} }
// Public actions // Public actions
void Progressbar::set( void Progressbar::refresh(
double fraction double fraction
) { ) {
// Toggle transparency // Toggle transparency

2
src/app/browser/main/tab/page/progressbar.hpp

@ -18,7 +18,7 @@ namespace app::browser::main::tab::page
Progressbar(); Progressbar();
void set( void refresh(
double fraction double fraction
); );
}; };

Loading…
Cancel
Save