Browse Source

implement new tab button

PHP-GTK3
yggverse 4 months ago
parent
commit
b9ca9616ff
  1. 13
      src/Entity/Browser/Header.php
  2. 48
      src/Entity/Browser/Header/Tab.php

13
src/Entity/Browser/Header.php

@ -5,6 +5,7 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser; namespace Yggverse\Yoda\Entity\Browser;
use \Yggverse\Yoda\Entity\Browser\Header\Navigation; use \Yggverse\Yoda\Entity\Browser\Header\Navigation;
use \Yggverse\Yoda\Entity\Browser\Header\Tab;
class Header class Header
{ {
@ -14,7 +15,8 @@ class Header
public \Yggverse\Yoda\Entity\Browser $browser; public \Yggverse\Yoda\Entity\Browser $browser;
// Requirements // Requirements
public \Yggverse\Yoda\Entity\Browser\Header\Navigation $navigation; public Navigation $navigation;
public Tab $tab;
// Defaults // Defaults
protected bool $_actions = true; protected bool $_actions = true;
@ -51,6 +53,15 @@ class Header
$this->navigation->gtk $this->navigation->gtk
); );
// Init new tab button
$this->tab = new Tab(
$this
);
$this->gtk->add(
$this->tab->gtk
);
// Render // Render
$this->gtk->show(); $this->gtk->show();
} }

48
src/Entity/Browser/Header/Tab.php

@ -0,0 +1,48 @@
<?php
declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser\Header;
use \Yggverse\Yoda\Entity\Browser\Header;
class Tab
{
public \GtkButton $gtk;
// Dependencies
public Header $header;
// Defaults
protected string $_label = '+';
public function __construct(
Header $header
) {
// Init dependency
$this->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
);
}
);
}
}
Loading…
Cancel
Save