Browse Source

draft progressbar

PHP-GTK3
yggverse 8 months ago
parent
commit
5d62bd89f7
  1. 4
      config.json
  2. 58
      src/Entity/Tab/Page.php

4
config.json

@ -90,6 +90,10 @@ @@ -90,6 +90,10 @@
"timeout":null
}
},
"progressbar":
{
"visible":true
},
"header":
{
"margin":8,

58
src/Entity/Tab/Page.php

@ -28,6 +28,8 @@ class Page @@ -28,6 +28,8 @@ class Page
public \GtkScrolledWindow $container;
public \GtkProgressBar $progressbar;
public object $config;
public function __construct(
@ -303,6 +305,13 @@ class Page @@ -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 @@ -350,6 +359,10 @@ class Page
0
);
$this->box->add(
$this->progressbar
);
$this->box->add(
$this->footer
);
@ -429,6 +442,12 @@ class Page @@ -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 @@ -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;
}
}
);
}
}
Loading…
Cancel
Save