Browse Source

init tab menu elements

PHP-GTK3
yggverse 4 months ago
parent
commit
1459667dc7
  1. 20
      src/Entity/Browser/Menu.php
  2. 60
      src/Entity/Browser/Menu/Tab.php
  3. 37
      src/Entity/Browser/Menu/Tab/Add.php
  4. 37
      src/Entity/Browser/Menu/Tab/Close.php

20
src/Entity/Browser/Menu.php

@ -4,6 +4,7 @@ declare(strict_types=1); @@ -4,6 +4,7 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser;
use \Yggverse\Yoda\Entity\Browser\Menu\Tab;
use \Yggverse\Yoda\Entity\Browser\Menu\History;
use \Yggverse\Yoda\Entity\Browser\Menu\Quit;
@ -15,6 +16,7 @@ class Menu @@ -15,6 +16,7 @@ class Menu
public \Yggverse\Yoda\Entity\Browser $browser;
// Requirements
public \Yggverse\Yoda\Entity\Browser\Menu\Tab $tab;
public \Yggverse\Yoda\Entity\Browser\Menu\History $history;
public \Yggverse\Yoda\Entity\Browser\Menu\Quit $quit;
@ -27,7 +29,16 @@ class Menu @@ -27,7 +29,16 @@ class Menu
// Init menu
$this->gtk = new \GtkMenu;
// Init history
// Init tab menu item
$this->tab = new Tab(
$this
);
$this->gtk->append(
$this->tab->gtk
);
// Init history menu item
$this->history = new History(
$this
);
@ -36,7 +47,12 @@ class Menu @@ -36,7 +47,12 @@ class Menu
$this->history->gtk
);
// Init quit
// Add separator
$this->gtk->append(
new \GtkSeparatorMenuItem
);
// Init quit menu item
$this->quit = new Quit(
$this
);

60
src/Entity/Browser/Menu/Tab.php

@ -0,0 +1,60 @@ @@ -0,0 +1,60 @@
<?php
declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser\Menu;
use \Yggverse\Yoda\Entity\Browser\Menu\Tab\Add;
use \Yggverse\Yoda\Entity\Browser\Menu\Tab\Close;
class Tab
{
public \GtkMenuItem $gtk;
// Dependencies
public \Yggverse\Yoda\Entity\Browser\Menu $menu;
// Requirements
public \Yggverse\Yoda\Entity\Browser\Menu\Tab\Add $add;
public \Yggverse\Yoda\Entity\Browser\Menu\Tab\Close $close;
// Defaults
private string $_label = 'Tab';
public function __construct(
\Yggverse\Yoda\Entity\Browser\Menu $menu
) {
// Init dependencies
$this->menu = $menu;
// Init menu item
$this->gtk = \GtkMenuItem::new_with_label(
$this->_label
);
// Init submenu container
$tab = new \GtkMenu;
// Init new tab menu item
$this->add = new Add(
$this
);
$tab->append(
$this->add->gtk
);
// Init close tab menu item
$this->close = new Close(
$this
);
$tab->append(
$this->close->gtk
);
$this->gtk->set_submenu(
$tab
);
}
}

37
src/Entity/Browser/Menu/Tab/Add.php

@ -0,0 +1,37 @@ @@ -0,0 +1,37 @@
<?php
declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser\Menu\Tab;
class Add
{
public \GtkMenuItem $gtk;
// Dependencies
public \Yggverse\Yoda\Entity\Browser\Menu\Tab $tab;
// Defaults
private string $_label = 'Add';
public function __construct(
\Yggverse\Yoda\Entity\Browser\Menu\Tab $tab
) {
// Init dependencies
$this->tab = $tab;
// Init menu item
$this->gtk = \GtkMenuItem::new_with_label(
$this->_label
);
// Int events
$this->gtk->connect(
'activate',
function()
{
// @TODO
}
);
}
}

37
src/Entity/Browser/Menu/Tab/Close.php

@ -0,0 +1,37 @@ @@ -0,0 +1,37 @@
<?php
declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser\Menu\Tab;
class Close
{
public \GtkMenuItem $gtk;
// Dependencies
public \Yggverse\Yoda\Entity\Browser\Menu\Tab $tab;
// Defaults
private string $_label = 'Close';
public function __construct(
\Yggverse\Yoda\Entity\Browser\Menu\Tab $tab
) {
// Init dependencies
$this->tab = $tab;
// Init menu item
$this->gtk = \GtkMenuItem::new_with_label(
$this->_label
);
// Int events
$this->gtk->connect(
'activate',
function()
{
// @TODO
}
);
}
}
Loading…
Cancel
Save