mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-03-31 16:45:27 +00:00
draft progressbar
This commit is contained in:
parent
0e64ab08ff
commit
5d62bd89f7
2 changed files with 62 additions and 0 deletions
|
|
@ -90,6 +90,10 @@
|
||||||
"timeout":null
|
"timeout":null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"progressbar":
|
||||||
|
{
|
||||||
|
"visible":true
|
||||||
|
},
|
||||||
"header":
|
"header":
|
||||||
{
|
{
|
||||||
"margin":8,
|
"margin":8,
|
||||||
|
|
|
||||||
|
|
@ -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…
Add table
Add a link
Reference in a new issue