append progressbar to request entry

This commit is contained in:
yggverse 2024-09-06 05:17:33 +03:00
parent f959a6627b
commit 3a91155596
10 changed files with 68 additions and 103 deletions

View file

@ -15,6 +15,10 @@ Request::Request(
HEXPAND
);
set_progress_pulse_step(
PROGRESS_PULSE_STEP
);
if (!TEXT.empty())
{
set_text(
@ -48,6 +52,36 @@ Request::Request(
);
}
// Actions
void Request::refresh(
const double & PROGRESS_FRACTION
) {
// Update progress
progress_fraction = PROGRESS_FRACTION;
// Animate progress function
Glib::signal_timeout().connect(
[this]() -> bool
{
double current_progress_fraction = get_progress_fraction();
if (current_progress_fraction < progress_fraction)
{
set_progress_fraction(
current_progress_fraction + PROGRESS_PULSE_STEP
);
return false;
}
return true; // 100% of value
//return current_progress_fraction < 1; // until 100% of value
},
PROGRESS_ANIMATION_TIME
);
}
// Getters
Glib::ustring Request::get_scheme()
{

View file

@ -2,6 +2,7 @@
#define APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION_REQUEST_HPP
#include <glibmm/i18n.h>
#include <glibmm/main.h>
#include <glibmm/regex.h>
#include <glibmm/ustring.h>
#include <gtkmm/entry.h>
@ -10,7 +11,8 @@ namespace app::browser::main::tab::page::navigation
{
class Request : public Gtk::Entry
{
const bool HEXPAND = true;
// Extras
double progress_fraction;
Glib::ustring scheme,
host,
@ -18,14 +20,26 @@ namespace app::browser::main::tab::page::navigation
path,
query;
// Defaults
const bool HEXPAND = true;
const double PROGRESS_PULSE_STEP = .1;
const int PROGRESS_ANIMATION_TIME = 10;
// Private helpers
void parse();
public:
Request(
const Glib::ustring & VALUE = ""
const Glib::ustring & VALUE = "" // @TODO remove default value
);
// Actions
void refresh(
const double & PROGRESS_FRACTION
);
// Getters
Glib::ustring get_scheme();
Glib::ustring get_host();
Glib::ustring get_port();