mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-01-14 00:38:06 +00:00
append progressbar to request entry
This commit is contained in:
parent
f959a6627b
commit
3a91155596
1
Makefile
1
Makefile
@ -27,7 +27,6 @@ SRCS = src/main.cpp\
|
||||
src/app/browser/main/tab/page/navigation/history/forward.cpp\
|
||||
src/app/browser/main/tab/page/navigation/request.cpp\
|
||||
src/app/browser/main/tab/page/navigation/update.cpp\
|
||||
src/app/browser/main/tab/page/progress.cpp\
|
||||
src/app/browser/main/tab/label.cpp\
|
||||
src/lib/database.cpp\
|
||||
src/lib/database/session.cpp
|
||||
|
@ -19,7 +19,6 @@ src/app/browser/main/tab/page/navigation/history/back.cpp
|
||||
src/app/browser/main/tab/page/navigation/history/forward.cpp
|
||||
src/app/browser/main/tab/page/navigation/request.cpp
|
||||
src/app/browser/main/tab/page/navigation/update.cpp
|
||||
src/app/browser/main/tab/page/progress.cpp
|
||||
src/app/browser/main/tab/label.cpp
|
||||
src/lib/database.cpp
|
||||
src/lib/database/session.cpp
|
||||
|
@ -1,7 +1,6 @@
|
||||
#include "page.hpp"
|
||||
#include "page/content.hpp"
|
||||
#include "page/navigation.hpp"
|
||||
#include "page/progress.hpp"
|
||||
|
||||
using namespace app::browser::main::tab;
|
||||
|
||||
@ -24,12 +23,6 @@ Page::Page(
|
||||
* pageNavigation
|
||||
);
|
||||
|
||||
pageProgress = Gtk::make_managed<page::Progress>();
|
||||
|
||||
append(
|
||||
* pageProgress
|
||||
);
|
||||
|
||||
pageContent = Gtk::make_managed<page::Content>();
|
||||
|
||||
append(
|
||||
@ -48,16 +41,14 @@ Page::Page(
|
||||
void Page::refresh(
|
||||
const Glib::ustring & TITLE,
|
||||
const Glib::ustring & SUBTITLE,
|
||||
const double & PROGRESS
|
||||
const double & PROGRESS_FRACTION
|
||||
) {
|
||||
title = TITLE; // @TODO copy
|
||||
subtitle = SUBTITLE;
|
||||
|
||||
pageProgress->refresh(
|
||||
PROGRESS
|
||||
pageNavigation->refresh(
|
||||
PROGRESS_FRACTION
|
||||
);
|
||||
|
||||
pageNavigation->refresh();
|
||||
}
|
||||
|
||||
void Page::navigation_update(
|
||||
|
@ -20,7 +20,6 @@ namespace app::browser::main::tab
|
||||
{
|
||||
class Content;
|
||||
class Navigation;
|
||||
class Progress;
|
||||
}
|
||||
|
||||
class Page : public Gtk::Box
|
||||
@ -38,7 +37,6 @@ namespace app::browser::main::tab
|
||||
// Components
|
||||
page::Content * pageContent;
|
||||
page::Navigation * pageNavigation;
|
||||
page::Progress * pageProgress;
|
||||
|
||||
public:
|
||||
|
||||
@ -52,7 +50,7 @@ namespace app::browser::main::tab
|
||||
void refresh(
|
||||
const Glib::ustring & TITLE,
|
||||
const Glib::ustring & SUBTITLE,
|
||||
const double & PROGRESS
|
||||
const double & PROGRESS_FRACTION
|
||||
);
|
||||
|
||||
void navigation_update(
|
||||
|
@ -76,7 +76,7 @@ Navigation::Navigation(
|
||||
"refresh",
|
||||
[this]
|
||||
{
|
||||
refresh();
|
||||
refresh(0);
|
||||
}
|
||||
);
|
||||
|
||||
@ -87,20 +87,26 @@ Navigation::Navigation(
|
||||
}
|
||||
|
||||
// Actions
|
||||
void Navigation::refresh()
|
||||
{
|
||||
void Navigation::refresh(
|
||||
const double & PROGRESS_FRACTION
|
||||
) {
|
||||
// Toggle base button sensibility
|
||||
navigationBase->set_sensitive(
|
||||
!navigationRequest->get_host().empty() && !navigationRequest->get_path().empty()
|
||||
);
|
||||
|
||||
// Refresh history widget
|
||||
navigationHistory->refresh();
|
||||
|
||||
// Toggle update button sensibility
|
||||
navigationUpdate->set_sensitive(
|
||||
navigationRequest->get_text_length() > 0
|
||||
);
|
||||
|
||||
// Refresh history widget
|
||||
navigationHistory->refresh();
|
||||
// Refresh request area (with progressbar)
|
||||
navigationRequest->refresh(
|
||||
PROGRESS_FRACTION
|
||||
);
|
||||
}
|
||||
|
||||
void Navigation::history_add(
|
||||
|
@ -37,7 +37,9 @@ namespace app::browser::main::tab::page
|
||||
);
|
||||
|
||||
// Actions
|
||||
void refresh();
|
||||
void refresh(
|
||||
const double & PROGRESS_FRACTION
|
||||
);
|
||||
|
||||
void history_add(
|
||||
const Glib::ustring & REQUEST,
|
||||
|
@ -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()
|
||||
{
|
||||
|
@ -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();
|
||||
|
@ -1,51 +0,0 @@
|
||||
#include "progress.hpp"
|
||||
|
||||
using namespace app::browser::main::tab::page;
|
||||
|
||||
Progress::Progress()
|
||||
{
|
||||
set_margin_top(
|
||||
MARGIN
|
||||
);
|
||||
|
||||
set_margin_bottom(
|
||||
MARGIN
|
||||
);
|
||||
|
||||
set_pulse_step(
|
||||
PULSE_STEP
|
||||
);
|
||||
|
||||
set_opacity(0); // fixed height, not hide()
|
||||
}
|
||||
|
||||
// Public actions
|
||||
void Progress::refresh(
|
||||
double fraction
|
||||
) {
|
||||
// Toggle transparency
|
||||
set_opacity(
|
||||
fraction < 1 ? 1 : 0
|
||||
);
|
||||
|
||||
// Reset initial progress
|
||||
progress = fraction;
|
||||
|
||||
// Animate progress function
|
||||
Glib::signal_timeout().connect(
|
||||
[this]() -> bool
|
||||
{
|
||||
double current = get_fraction();
|
||||
|
||||
if (current < progress)
|
||||
{
|
||||
set_fraction(
|
||||
current + PULSE_STEP
|
||||
);
|
||||
}
|
||||
|
||||
return current < 1;
|
||||
},
|
||||
ANIMATION_TIME
|
||||
);
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
#ifndef APP_BROWSER_MAIN_TAB_PAGE_PROGRESS_HPP
|
||||
#define APP_BROWSER_MAIN_TAB_PAGE_PROGRESS_HPP
|
||||
|
||||
#include <glibmm/main.h>
|
||||
#include <gtkmm/progressbar.h>
|
||||
|
||||
namespace app::browser::main::tab::page
|
||||
{
|
||||
class Progress : public Gtk::ProgressBar
|
||||
{
|
||||
const int MARGIN = 2;
|
||||
const double PULSE_STEP = .1;
|
||||
const int ANIMATION_TIME = 10;
|
||||
|
||||
double progress = 0;
|
||||
|
||||
public:
|
||||
|
||||
Progress();
|
||||
|
||||
void refresh(
|
||||
double fraction
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
#endif // APP_BROWSER_MAIN_TAB_PAGE_PROGRESS_HPP
|
Loading…
Reference in New Issue
Block a user