diff --git a/src/Entity/Browser/Header.php b/src/Entity/Browser/Header.php index 7a7770fa..2e4dfeca 100644 --- a/src/Entity/Browser/Header.php +++ b/src/Entity/Browser/Header.php @@ -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 $this->gtk->set_subtitle( $this->_subtitle ); + + // Init navigation element + $this->navigation = new Navigation( + $this + ); + + $this->gtk->add( + $this->navigation->gtk + ); } public function setTitle( diff --git a/src/Entity/Browser/Header/Navigation.php b/src/Entity/Browser/Header/Navigation.php new file mode 100644 index 00000000..67390e60 --- /dev/null +++ b/src/Entity/Browser/Header/Navigation.php @@ -0,0 +1,37 @@ +header = $header; + + // Init navigation container + $this->gtk = new \GtkMenuButton; + + // Init menu + $this->menu = new Menu( + $this + ); + + $this->gtk->set_popup( + $this->menu->gtk + ); + } +} \ No newline at end of file diff --git a/src/Entity/Browser/Header/Navigation/Menu.php b/src/Entity/Browser/Header/Navigation/Menu.php new file mode 100644 index 00000000..94ca913c --- /dev/null +++ b/src/Entity/Browser/Header/Navigation/Menu.php @@ -0,0 +1,51 @@ +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(); + } +} \ No newline at end of file diff --git a/src/Entity/Browser/Header/Navigation/Menu/History.php b/src/Entity/Browser/Header/Navigation/Menu/History.php new file mode 100644 index 00000000..63f3ba20 --- /dev/null +++ b/src/Entity/Browser/Header/Navigation/Menu/History.php @@ -0,0 +1,41 @@ +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(); + } + ); + } +} \ No newline at end of file diff --git a/src/Entity/Browser/Header/Navigation/Menu/Quit.php b/src/Entity/Browser/Header/Navigation/Menu/Quit.php new file mode 100644 index 00000000..c1db1c6b --- /dev/null +++ b/src/Entity/Browser/Header/Navigation/Menu/Quit.php @@ -0,0 +1,37 @@ +menu = $menu; + + // Init menu item + $this->gtk = \GtkMenuItem::new_with_label( + $this->_label + ); + + // Int events + $this->gtk->connect( + 'activate', + function() + { + \Gtk::main_quit(); + } + ); + } +} \ No newline at end of file diff --git a/src/Yoda.php b/src/Yoda.php index 1d849a67..ee1ef5da 100644 --- a/src/Yoda.php +++ b/src/Yoda.php @@ -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(); \ No newline at end of file