From 61a492c6c9ef8c752e99cd902a2be4ac00723977 Mon Sep 17 00:00:00 2001 From: yggverse Date: Fri, 12 Jul 2024 15:31:44 +0300 Subject: [PATCH] draft new events, rename returned variables to native, fix data types --- src/Entity/Browser/Container/Tab.php | 40 +++++++++++++++++++++------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/src/Entity/Browser/Container/Tab.php b/src/Entity/Browser/Container/Tab.php index d7ad6b61..6a1025b7 100644 --- a/src/Entity/Browser/Container/Tab.php +++ b/src/Entity/Browser/Container/Tab.php @@ -50,18 +50,40 @@ class Tab $this->gtk->connect( 'switch-page', function ( - \GtkNotebook $entity, - \GtkWidget $child, - int $index + ?\GtkNotebook $self, + ?\GtkWidget $child, + int $page_num ) { // Update header bar title $this->container->browser->header->setTitle( - $this->getPage($index)->title->getValue(), - $this->getPage($index)->title->getSubtitle() + $this->getPage($page_num)->title->getValue(), + $this->getPage($page_num)->title->getSubtitle() ); // Keep current selection - $entity->grab_focus(); + $self->grab_focus(); + } + ); + + $this->gtk->connect( + 'page-removed', + function ( + ?\GtkNotebook $self, + ?\GtkWidget $child, + int $page_num + ) { + // @TODO + } + ); + + $this->gtk->connect( + 'page-reordered', + function ( + ?\GtkNotebook $self, + ?\GtkWidget $child, + int $page_num + ) { + // @TODO } ); } @@ -117,14 +139,14 @@ class Tab } public function getPage( - int $index + int $page_num ): ?\Yggverse\Yoda\Entity\Browser\Container\Page { - if (empty($this->_page[$index])) + if (empty($this->_page[$page_num])) { throw new \Exception; } - return $this->_page[$index]; + return $this->_page[$page_num]; } } \ No newline at end of file