diff --git a/src/Entity/Browser/Container/Page/Title.php b/src/Entity/Browser/Container/Page/Title.php index 1ebf78d5..0f71c196 100644 --- a/src/Entity/Browser/Container/Page/Title.php +++ b/src/Entity/Browser/Container/Page/Title.php @@ -4,11 +4,12 @@ declare(strict_types=1); namespace Yggverse\Yoda\Entity\Browser\Container\Page; -use \Yggverse\Yoda\Gtk\Browser\Container\Page\Title\Label; - class Title { - public Label $gtk; + public \GtkLabel $gtk; + + // Extras + public ?string $subtitle = null; // Dependencies public \Yggverse\Yoda\Entity\Browser\Container\Page $page; @@ -27,7 +28,7 @@ class Title $this->page = $page; // Init container - $this->gtk = new Label( + $this->gtk = new \GtkLabel( $this->_value ); @@ -75,11 +76,9 @@ class Title ?string $subtitle = null ): void { - $this->gtk->set_subtitle( - is_null($subtitle) ? $this->_subtitle : strtolower( - trim( - $subtitle - ) + $this->subtitle = is_null($subtitle) ? $this->_subtitle : strtolower( + trim( + $subtitle ) ); } @@ -102,7 +101,7 @@ class Title public function getSubtitle(): ?string { - return $this->gtk->get_subtitle(); + return $this->subtitle; } public function getTooltip(): ?string diff --git a/src/Entity/Browser/Container/Tab.php b/src/Entity/Browser/Container/Tab.php index 851a07d8..d7ad6b61 100644 --- a/src/Entity/Browser/Container/Tab.php +++ b/src/Entity/Browser/Container/Tab.php @@ -17,6 +17,9 @@ class Tab private bool $_reorderable = true; private bool $_scrollable = true; + // Extras + private array $_page = []; + public function __construct( \Yggverse\Yoda\Entity\Browser\Container $container ) { @@ -49,16 +52,12 @@ class Tab function ( \GtkNotebook $entity, \GtkWidget $child, - int $position + int $index ) { - $label = $entity->get_tab_label( - $child - ); - + // Update header bar title $this->container->browser->header->setTitle( - $label->get_text(), - null /* @TODO extension not supported by PHP-GTK3 #117 - $label->get_subtitle()*/ + $this->getPage($index)->title->getValue(), + $this->getPage($index)->title->getSubtitle() ); // Keep current selection @@ -111,5 +110,21 @@ class Tab // Render $this->gtk->show(); + + // Extendable classes not supported by PHP-GTK3 #117 + // create internal pages registry + $this->_page[] = $page; + } + + public function getPage( + int $index + ): ?\Yggverse\Yoda\Entity\Browser\Container\Page + { + if (empty($this->_page[$index])) + { + throw new \Exception; + } + + return $this->_page[$index]; } } \ No newline at end of file diff --git a/src/Gtk/Browser/Container/Page/Title/Label.php b/src/Gtk/Browser/Container/Page/Title/Label.php deleted file mode 100644 index 1403e772..00000000 --- a/src/Gtk/Browser/Container/Page/Title/Label.php +++ /dev/null @@ -1,22 +0,0 @@ -_subtitle = $value; - } - - public function get_subtitle(): ?string - { - return $this->_subtitle; - } -} \ No newline at end of file