mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 09:05:27 +00:00
implement history navigation
This commit is contained in:
parent
19dab748ae
commit
0db319a519
4 changed files with 55 additions and 23 deletions
|
|
@ -61,7 +61,9 @@ class Address
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update(): void
|
public function update(
|
||||||
|
bool $history = true
|
||||||
|
): void
|
||||||
{
|
{
|
||||||
// Parse address
|
// Parse address
|
||||||
$address = new \Yggverse\Net\Address(
|
$address = new \Yggverse\Net\Address(
|
||||||
|
|
@ -78,19 +80,22 @@ class Address
|
||||||
$address
|
$address
|
||||||
);
|
);
|
||||||
|
|
||||||
// Remember address in the navigation memory
|
if ($history)
|
||||||
$this->navbar->history->add(
|
{
|
||||||
$address->get()
|
// Remember address in the navigation memory
|
||||||
);
|
$this->navbar->history->add(
|
||||||
|
$address->get()
|
||||||
|
);
|
||||||
|
|
||||||
// Refresh history in database
|
// Refresh history in database
|
||||||
$this->navbar->address->tab->window->database->refreshHistory(
|
$this->navbar->address->tab->window->database->refreshHistory(
|
||||||
$address->get(),
|
$address->get(),
|
||||||
// @TODO title
|
// @TODO title
|
||||||
);
|
);
|
||||||
|
|
||||||
// Refresh tabs
|
// Refresh tabs
|
||||||
$this->navbar->address->tab->refresh();
|
$this->navbar->address->tab->refresh();
|
||||||
|
}
|
||||||
|
|
||||||
// Update statusbar indicator
|
// Update statusbar indicator
|
||||||
$this->statusbar->setValue(
|
$this->statusbar->setValue(
|
||||||
|
|
|
||||||
|
|
@ -15,12 +15,12 @@ class History
|
||||||
public \Yggverse\Yoda\Entity\Window\Tab\Address\Navbar\History\Back $back;
|
public \Yggverse\Yoda\Entity\Window\Tab\Address\Navbar\History\Back $back;
|
||||||
public \Yggverse\Yoda\Entity\Window\Tab\Address\Navbar\History\Forward $forward;
|
public \Yggverse\Yoda\Entity\Window\Tab\Address\Navbar\History\Forward $forward;
|
||||||
|
|
||||||
private \Yggverse\Yoda\Model\History $_history;
|
public \Yggverse\Yoda\Model\History $memory;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
\Yggverse\Yoda\Entity\Window\Tab\Address\Navbar $navbar
|
\Yggverse\Yoda\Entity\Window\Tab\Address\Navbar $navbar
|
||||||
) {
|
) {
|
||||||
$this->_history = new \Yggverse\Yoda\Model\History();
|
$this->memory = new \Yggverse\Yoda\Model\History();
|
||||||
|
|
||||||
$this->navbar = $navbar;
|
$this->navbar = $navbar;
|
||||||
|
|
||||||
|
|
@ -50,27 +50,32 @@ class History
|
||||||
}
|
}
|
||||||
|
|
||||||
public function add(
|
public function add(
|
||||||
string $url
|
string $value
|
||||||
): void
|
): void
|
||||||
{
|
{
|
||||||
if (empty($url))
|
if (empty($value))
|
||||||
{
|
{
|
||||||
throw new \Exception;
|
throw new \Exception;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($url != $this->_history->getCurrent())
|
if ($value != $this->memory->getCurrent())
|
||||||
{
|
{
|
||||||
$this->_history->add(
|
$this->memory->add(
|
||||||
$url
|
$value
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function refresh(): void
|
||||||
|
{
|
||||||
$this->back->gtk->set_sensitive(
|
$this->back->gtk->set_sensitive(
|
||||||
(bool) $this->_history->getBack()
|
(bool) $this->memory->getBack()
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->forward->gtk->set_sensitive(
|
$this->forward->gtk->set_sensitive(
|
||||||
(bool) $this->_history->getForward()
|
(bool) $this->memory->getForward()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -12,6 +12,17 @@ class Back extends \Yggverse\Yoda\Abstract\Entity\Window\Tab\Address\Navbar\Butt
|
||||||
\GtkButton $entity
|
\GtkButton $entity
|
||||||
): void
|
): void
|
||||||
{
|
{
|
||||||
// @TODO
|
if ($this->navbar->history->memory->getBack())
|
||||||
|
{
|
||||||
|
$this->navbar->request->setValue(
|
||||||
|
$this->navbar->history->memory->goBack()
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->navbar->address->update(
|
||||||
|
false
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->navbar->history->refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -12,6 +12,17 @@ class Forward extends \Yggverse\Yoda\Abstract\Entity\Window\Tab\Address\Navbar\B
|
||||||
\GtkButton $entity
|
\GtkButton $entity
|
||||||
): void
|
): void
|
||||||
{
|
{
|
||||||
// @TODO
|
if ($this->navbar->history->memory->getForward())
|
||||||
|
{
|
||||||
|
$this->navbar->request->setValue(
|
||||||
|
$this->navbar->history->memory->goForward()
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->navbar->address->update(
|
||||||
|
false
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->navbar->history->refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue