init multi-window implementation

This commit is contained in:
yggverse 2024-07-05 22:04:26 +03:00
parent 6f99b36a44
commit 847a0fb01d
45 changed files with 904 additions and 833 deletions

View file

@ -0,0 +1,59 @@
<?php
declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser\Container\Tab\Page\Navbar;
class Base extends \Yggverse\Yoda\Abstract\Entity\Browser\Container\Tab\Page\Navbar\Button
{
protected string $_label = 'Base';
protected function _onCLick(
\GtkButton $entity
): void
{
$address = new \Yggverse\Net\Address(
trim(
strval(
$this->navbar->request->gtk->get_text()
)
)
);
if ($address->getHost())
{
$this->navbar->request->setValue(
$address->get( // build base
true,
true,
true,
true,
true,
false,
false,
false
)
);
$this->navbar->address->update();
}
$this->refresh();
}
public function refresh(): void
{
$address = new \Yggverse\Net\Address(
rtrim(
$this->navbar->request->gtk->get_text(),
'/'
)
);
$this->gtk->set_sensitive(
$address->getHost() && (
$address->getPath() || $address->getQuery()
)
);
}
}

View file

@ -0,0 +1,28 @@
<?php
declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser\Container\Tab\Page\Navbar;
class Go extends \Yggverse\Yoda\Abstract\Entity\Browser\Container\Tab\Page\Navbar\Button
{
protected string $_label = 'Go';
protected function _onCLick(
\GtkButton $entity
): void
{
$this->navbar->page->update();
}
public function refresh(): void
{
$this->gtk->set_sensitive(
!empty(
trim(
$this->navbar->request->gtk->get_text()
)
)
);
}
}

View file

@ -0,0 +1,79 @@
<?php
declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser\Container\Tab\Page\Navbar;
use \Yggverse\Yoda\Entity\Browser\Container\Tab\Page\Navbar\History\Back;
use \Yggverse\Yoda\Entity\Browser\Container\Tab\Page\Navbar\History\Forward;
class History
{
public \GtkButtonBox $gtk;
// Dependencies
public \Yggverse\Yoda\Model\History $memory;
public \Yggverse\Yoda\Entity\Browser\Container\Tab\Page\Navbar $navbar;
// Requirements
public \Yggverse\Yoda\Entity\Browser\Container\Tab\Page\Navbar\History\Back $back;
public \Yggverse\Yoda\Entity\Browser\Container\Tab\Page\Navbar\History\Forward $forward;
public function __construct(
\Yggverse\Yoda\Entity\Browser\Container\Tab\Page\Navbar $navbar
) {
$this->memory = new \Yggverse\Yoda\Model\History();
$this->navbar = $navbar;
$this->gtk = new \GtkButtonBox(
\GtkOrientation::HORIZONTAL
);
$this->gtk->set_layout(
\GtkButtonBoxStyle::EXPAND
);
$this->back = new Back(
$this->navbar
);
$this->gtk->add(
$this->back->gtk
);
$this->forward = new Forward(
$this->navbar
);
$this->gtk->add(
$this->forward->gtk
);
}
public function add(
string $value
): void
{
if (empty($value))
{
throw new \Exception;
}
if ($value != $this->memory->getCurrent())
{
$this->memory->add(
$value
);
}
$this->refresh();
}
public function refresh(): void
{
$this->back->refresh();
$this->forward->refresh();
}
}

View file

@ -0,0 +1,37 @@
<?php
declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser\Container\Tab\Page\Navbar\History;
class Back extends \Yggverse\Yoda\Abstract\Entity\Browser\Container\Tab\Page\Navbar\Button
{
protected string $_label = 'Back';
protected function _onCLick(
\GtkButton $entity
): void
{
if ($this->navbar->history->memory->getBack())
{
$this->navbar->request->setValue(
$this->navbar->history->memory->goBack()
);
$this->navbar->page->update(
false
);
}
$this->navbar->history->refresh();
}
public function refresh(): void
{
$this->gtk->set_sensitive(
boolval(
$this->navbar->history->memory->getBack()
)
);
}
}

View file

@ -0,0 +1,37 @@
<?php
declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser\Container\Tab\Page\Navbar\History;
class Forward extends \Yggverse\Yoda\Abstract\Entity\Browser\Container\Tab\Page\Navbar\Button
{
protected string $_label = 'Forward';
protected function _onCLick(
\GtkButton $entity
): void
{
if ($this->navbar->history->memory->getForward())
{
$this->navbar->request->setValue(
$this->navbar->history->memory->goForward()
);
$this->navbar->page->update(
false
);
}
$this->navbar->history->refresh();
}
public function refresh(): void
{
$this->gtk->set_sensitive(
boolval(
$this->navbar->history->memory->getForward()
)
);
}
}

View file

@ -0,0 +1,25 @@
<?php
declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser\Container\Tab\Page\Navbar;
class Request extends \Yggverse\Yoda\Abstract\Entity\Browser\Container\Tab\Page\Navbar\Entry
{
private string $_placeholder = 'URL or search term...';
protected function _onActivate(
\GtkEntry $entry
): void
{
$this->navbar->page->content->update();
}
protected function _onKeyRelease(
\GtkEntry $entry,
\GdkEvent $event
): void
{
$this->navbar->refresh();
}
}