diff --git a/config.json b/config.json index 3e93631c..43db7355 100644 --- a/config.json +++ b/config.json @@ -90,6 +90,10 @@ "timeout":null } }, + "progressbar": + { + "visible":true + }, "header": { "margin":8, diff --git a/src/Entity/Tab/Page.php b/src/Entity/Tab/Page.php index e0fc4061..29002c03 100644 --- a/src/Entity/Tab/Page.php +++ b/src/Entity/Tab/Page.php @@ -28,6 +28,8 @@ class Page public \GtkScrolledWindow $container; + public \GtkProgressBar $progressbar; + public object $config; public function __construct( @@ -303,6 +305,13 @@ class Page } ); + // Init progressbar + $this->progressbar = new \GtkProgressBar(); + + $this->progressbar->set_opacity( + 0 + ); + // Compose footer $this->footer = new \GtkBox( \GtkOrientation::HORIZONTAL @@ -350,6 +359,10 @@ class Page 0 ); + $this->box->add( + $this->progressbar + ); + $this->box->add( $this->footer ); @@ -429,6 +442,12 @@ class Page bool $history = true ): void { + // Init progressbar + if ($this->config->progressbar->visible) + { + $this->setProgress(0); + } + // Init base URL $origin = new \Yggverse\Net\Address( $url @@ -686,4 +705,43 @@ class Page $title ); } + + public function setProgress( + float $value + ): void + { + $this->progressbar->set_fraction( + $value + ); + + \Gtk::timeout_add( + 10, + function() + { + $progress = $this->progressbar->get_fraction(); + + $progress = $progress + 0.02; + + $this->progressbar->set_fraction( + $progress + ); + + if ($progress < 1) + { + $this->progressbar->set_opacity( + 1 + ); + } + + else + { + $this->progressbar->set_opacity( + 0 + ); + + return false; + } + } + ); + } } \ No newline at end of file