mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 17:15:28 +00:00
init header navigation menu
This commit is contained in:
parent
b0b38581aa
commit
006f039282
6 changed files with 191 additions and 9 deletions
|
|
@ -4,16 +4,30 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace Yggverse\Yoda\Entity\Browser;
|
namespace Yggverse\Yoda\Entity\Browser;
|
||||||
|
|
||||||
|
use \Yggverse\Yoda\Entity\Browser\Header\Navigation;
|
||||||
|
|
||||||
class Header
|
class Header
|
||||||
{
|
{
|
||||||
public \GtkHeaderBar $gtk;
|
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 bool $_actions = true;
|
||||||
protected string $_title = 'Yoda';
|
protected string $_title = 'Yoda';
|
||||||
protected string $_subtitle = '';
|
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 = new \GtkHeaderBar;
|
||||||
|
|
||||||
$this->gtk->set_show_close_button(
|
$this->gtk->set_show_close_button(
|
||||||
|
|
@ -27,6 +41,15 @@ class Header
|
||||||
$this->gtk->set_subtitle(
|
$this->gtk->set_subtitle(
|
||||||
$this->_subtitle
|
$this->_subtitle
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Init navigation element
|
||||||
|
$this->navigation = new Navigation(
|
||||||
|
$this
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->gtk->add(
|
||||||
|
$this->navigation->gtk
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setTitle(
|
public function setTitle(
|
||||||
|
|
|
||||||
37
src/Entity/Browser/Header/Navigation.php
Normal file
37
src/Entity/Browser/Header/Navigation.php
Normal file
|
|
@ -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
Normal file
51
src/Entity/Browser/Header/Navigation/Menu.php
Normal file
|
|
@ -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
Normal file
41
src/Entity/Browser/Header/Navigation/Menu/History.php
Normal file
|
|
@ -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
Normal file
37
src/Entity/Browser/Header/Navigation/Menu/Quit.php
Normal file
|
|
@ -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();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -38,11 +38,4 @@ $browser->gtk->connect(
|
||||||
|
|
||||||
$browser->gtk->show_all();
|
$browser->gtk->show_all();
|
||||||
|
|
||||||
// Init history (test)
|
|
||||||
$history = new \Yggverse\Yoda\Entity\Browser\History(
|
|
||||||
$browser
|
|
||||||
);
|
|
||||||
|
|
||||||
$history->gtk->show_all();
|
|
||||||
|
|
||||||
\Gtk::main();
|
\Gtk::main();
|
||||||
Loading…
Add table
Add a link
Reference in a new issue