Browse Source

draft progressbar

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

4
config.json

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

58
src/Entity/Tab/Page.php

@ -28,6 +28,8 @@ class Page
public \GtkScrolledWindow $container; public \GtkScrolledWindow $container;
public \GtkProgressBar $progressbar;
public object $config; public object $config;
public function __construct( public function __construct(
@ -303,6 +305,13 @@ class Page
} }
); );
// Init progressbar
$this->progressbar = new \GtkProgressBar();
$this->progressbar->set_opacity(
0
);
// Compose footer // Compose footer
$this->footer = new \GtkBox( $this->footer = new \GtkBox(
\GtkOrientation::HORIZONTAL \GtkOrientation::HORIZONTAL
@ -350,6 +359,10 @@ class Page
0 0
); );
$this->box->add(
$this->progressbar
);
$this->box->add( $this->box->add(
$this->footer $this->footer
); );
@ -429,6 +442,12 @@ class Page
bool $history = true bool $history = true
): void ): void
{ {
// Init progressbar
if ($this->config->progressbar->visible)
{
$this->setProgress(0);
}
// Init base URL // Init base URL
$origin = new \Yggverse\Net\Address( $origin = new \Yggverse\Net\Address(
$url $url
@ -686,4 +705,43 @@ class Page
$title $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