diff --git a/src/Entity/Browser/Container/Page/Content.php b/src/Entity/Browser/Container/Page/Content.php index 89f4b512..77481335 100644 --- a/src/Entity/Browser/Container/Page/Content.php +++ b/src/Entity/Browser/Container/Page/Content.php @@ -57,9 +57,6 @@ class Content $this->gtk->add( $this->viewport->gtk ); - - // Render - $this->gtk->show(); } public function set( @@ -115,11 +112,11 @@ class Content ); } - $this->viewport->gtk->add( - $document->gtk + $this->viewport->set( + $document ); - //$this->gtk->show_all(); + $this->gtk->show(); } public function getSource(): ?string diff --git a/src/Entity/Browser/Container/Page/Content/Viewport.php b/src/Entity/Browser/Container/Page/Content/Viewport.php index 35459f41..d63f39dd 100644 --- a/src/Entity/Browser/Container/Page/Content/Viewport.php +++ b/src/Entity/Browser/Container/Page/Content/Viewport.php @@ -4,21 +4,48 @@ declare(strict_types=1); namespace Yggverse\Yoda\Entity\Browser\Container\Page\Content; +use \Yggverse\Yoda\Entity\Browser\Container\Page\Content; + +use \Yggverse\Yoda\Entity\Browser\Container\Page\Content\Gemtext; +use \Yggverse\Yoda\Entity\Browser\Container\Page\Content\Image; +use \Yggverse\Yoda\Entity\Browser\Container\Page\Content\Plain; + class Viewport { public \GtkViewport $gtk; // Dependencies - public \Yggverse\Yoda\Entity\Browser\Container\Page\Content $content; + public Content $content; + + // Requirements + private Gemtext | Plain | Image | null $_data = null; public function __construct( - \Yggverse\Yoda\Entity\Browser\Container\Page\Content $content + Content $content ) { // Init dependencies $this->content = $content; // Init viewport $this->gtk = new \GtkViewport; + } + + public function set( + Gemtext | Plain | Image $data + ): void + { + // Remove previous + if ($this->_data) + { + $this->_data->gtk->destroy(); + } + + // Init current + $this->_data = $data; + + $this->gtk->add( + $data->gtk + ); // Render $this->gtk->show();