From b9ca9616ff6609a6b5727cb9d32d0642a57e2425 Mon Sep 17 00:00:00 2001 From: yggverse Date: Sat, 20 Jul 2024 11:31:01 +0300 Subject: [PATCH] implement new tab button --- src/Entity/Browser/Header.php | 13 ++++++++- src/Entity/Browser/Header/Tab.php | 48 +++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 src/Entity/Browser/Header/Tab.php diff --git a/src/Entity/Browser/Header.php b/src/Entity/Browser/Header.php index 817a9770..74cfd285 100644 --- a/src/Entity/Browser/Header.php +++ b/src/Entity/Browser/Header.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace Yggverse\Yoda\Entity\Browser; use \Yggverse\Yoda\Entity\Browser\Header\Navigation; +use \Yggverse\Yoda\Entity\Browser\Header\Tab; class Header { @@ -14,7 +15,8 @@ class Header public \Yggverse\Yoda\Entity\Browser $browser; // Requirements - public \Yggverse\Yoda\Entity\Browser\Header\Navigation $navigation; + public Navigation $navigation; + public Tab $tab; // Defaults protected bool $_actions = true; @@ -51,6 +53,15 @@ class Header $this->navigation->gtk ); + // Init new tab button + $this->tab = new Tab( + $this + ); + + $this->gtk->add( + $this->tab->gtk + ); + // Render $this->gtk->show(); } diff --git a/src/Entity/Browser/Header/Tab.php b/src/Entity/Browser/Header/Tab.php new file mode 100644 index 00000000..b74d347c --- /dev/null +++ b/src/Entity/Browser/Header/Tab.php @@ -0,0 +1,48 @@ +header = $header; + + // Init GTK + $this->gtk = new \GtkButton; + + $this->gtk->set_label( + $this->_label + ); + + // Render + $this->gtk->show(); + + // Init events + $this->gtk->connect( + 'clicked', + function( + \GtkButton $entity + ) { + $this->header->browser->container->tab->append( + null, + false + ); + } + ); + } +} \ No newline at end of file