Browse Source

init header navigation menu

PHP-GTK3
yggverse 4 months ago
parent
commit
006f039282
  1. 27
      src/Entity/Browser/Header.php
  2. 37
      src/Entity/Browser/Header/Navigation.php
  3. 51
      src/Entity/Browser/Header/Navigation/Menu.php
  4. 41
      src/Entity/Browser/Header/Navigation/Menu/History.php
  5. 37
      src/Entity/Browser/Header/Navigation/Menu/Quit.php
  6. 7
      src/Yoda.php

27
src/Entity/Browser/Header.php

@ -4,16 +4,30 @@ declare(strict_types=1); @@ -4,16 +4,30 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser;
use \Yggverse\Yoda\Entity\Browser\Header\Navigation;
class Header
{
public \GtkHeaderBar $gtk;
// Dependencies
public \Yggverse\Yoda\Entity\Browser $browser;
// Requirements
public \Yggverse\Yoda\Entity\Browser\Header\Navigation $navigation;
// Defaults
protected bool $_actions = true;
protected string $_title = 'Yoda';
protected string $_subtitle = '';
public function __construct()
{
public function __construct(
\Yggverse\Yoda\Entity\Browser $browser
) {
// Init dependencies
$this->browser = $browser;
// Init header
$this->gtk = new \GtkHeaderBar;
$this->gtk->set_show_close_button(
@ -27,6 +41,15 @@ class Header @@ -27,6 +41,15 @@ class Header
$this->gtk->set_subtitle(
$this->_subtitle
);
// Init navigation element
$this->navigation = new Navigation(
$this
);
$this->gtk->add(
$this->navigation->gtk
);
}
public function setTitle(

37
src/Entity/Browser/Header/Navigation.php

@ -0,0 +1,37 @@ @@ -0,0 +1,37 @@
<?php
declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser\Header;
use \Yggverse\Yoda\Entity\Browser\Header\Navigation\Menu;
class Navigation
{
public \GtkMenuButton $gtk;
// Dependencies
public \Yggverse\Yoda\Entity\Browser\Header $header;
// Requirements
public \Yggverse\Yoda\Entity\Browser\Header\Navigation\Menu $menu;
public function __construct(
\Yggverse\Yoda\Entity\Browser\Header $header
) {
// Init dependencies
$this->header = $header;
// Init navigation container
$this->gtk = new \GtkMenuButton;
// Init menu
$this->menu = new Menu(
$this
);
$this->gtk->set_popup(
$this->menu->gtk
);
}
}

51
src/Entity/Browser/Header/Navigation/Menu.php

@ -0,0 +1,51 @@ @@ -0,0 +1,51 @@
<?php
declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser\Header\Navigation;
use \Yggverse\Yoda\Entity\Browser\Header\Navigation\Menu\History;
use \Yggverse\Yoda\Entity\Browser\Header\Navigation\Menu\Quit;
class Menu
{
public \GtkMenu $gtk;
// Dependencies
public \Yggverse\Yoda\Entity\Browser\Header\Navigation $navigation;
// Requirements
public \Yggverse\Yoda\Entity\Browser\Header\Navigation\Menu\History $history;
public \Yggverse\Yoda\Entity\Browser\Header\Navigation\Menu\Quit $quit;
public function __construct(
\Yggverse\Yoda\Entity\Browser\Header\Navigation $navigation
) {
// Init dependencies
$this->navigation = $navigation;
// Init menu
$this->gtk = new \GtkMenu;
// Init history
$this->history = new History(
$this
);
$this->gtk->append(
$this->history->gtk
);
// Init quit
$this->quit = new Quit(
$this
);
$this->gtk->append(
$this->quit->gtk
);
// Render
$this->gtk->show_all();
}
}

41
src/Entity/Browser/Header/Navigation/Menu/History.php

@ -0,0 +1,41 @@ @@ -0,0 +1,41 @@
<?php
declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser\Header\Navigation\Menu;
class History
{
public \GtkMenuItem $gtk;
// Dependencies
public \Yggverse\Yoda\Entity\Browser\Header\Navigation\Menu $menu;
// Defaults
private string $_label = 'History';
public function __construct(
\Yggverse\Yoda\Entity\Browser\Header\Navigation\Menu $menu
) {
// Init dependencies
$this->menu = $menu;
// Init menu item
$this->gtk = \GtkMenuItem::new_with_label(
$this->_label
);
// Int events
$this->gtk->connect(
'activate',
function()
{
$history = new \Yggverse\Yoda\Entity\Browser\History(
$this->menu->navigation->header->browser
);
$history->gtk->show_all();
}
);
}
}

37
src/Entity/Browser/Header/Navigation/Menu/Quit.php

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

7
src/Yoda.php

@ -38,11 +38,4 @@ $browser->gtk->connect( @@ -38,11 +38,4 @@ $browser->gtk->connect(
$browser->gtk->show_all();
// Init history (test)
$history = new \Yggverse\Yoda\Entity\Browser\History(
$browser
);
$history->gtk->show_all();
\Gtk::main();
Loading…
Cancel
Save