From f124f20660ee0716040e728d42693987cbe19937 Mon Sep 17 00:00:00 2001 From: yggverse Date: Tue, 30 Jul 2024 21:19:39 +0300 Subject: [PATCH] use tool parent menu for debug item --- src/Entity/Browser/Menu.php | 8 +-- src/Entity/Browser/Menu/Help.php | 12 +++-- src/Entity/Browser/Menu/Tool.php | 56 ++++++++++++++++++++ src/Entity/Browser/Menu/{ => Tool}/Debug.php | 12 ++--- 4 files changed, 73 insertions(+), 15 deletions(-) create mode 100644 src/Entity/Browser/Menu/Tool.php rename src/Entity/Browser/Menu/{ => Tool}/Debug.php (71%) diff --git a/src/Entity/Browser/Menu.php b/src/Entity/Browser/Menu.php index 97693dbb..6c0e1aef 100644 --- a/src/Entity/Browser/Menu.php +++ b/src/Entity/Browser/Menu.php @@ -18,12 +18,12 @@ class Menu // Requirements public Menu\Bookmark $bookmark; - public Menu\Debug $debug; public Menu\File $file; public Menu\Help $help; public Menu\History $history; public Menu\Quit $quit; public Menu\Tab $tab; + public Menu\Tool $tool; public function __construct( Browser $browser @@ -70,13 +70,13 @@ class Menu $this->history->gtk ); - // Init debug menu item - $this->debug = new Menu\Debug( + // Init tool menu item + $this->tool = new Menu\Tool( $this ); $this->gtk->append( - $this->debug->gtk + $this->tool->gtk ); // Init help menu item diff --git a/src/Entity/Browser/Menu/Help.php b/src/Entity/Browser/Menu/Help.php index 60ceea06..de36c7a4 100644 --- a/src/Entity/Browser/Menu/Help.php +++ b/src/Entity/Browser/Menu/Help.php @@ -19,6 +19,7 @@ class Help // Requirements public Help\About $about; + public Help\Debug $debug; public Help\Gemlog $gemlog; public Help\Issue $issue; @@ -37,14 +38,14 @@ class Help ); // Init submenu container - $tab = new GtkMenu; + $help = new GtkMenu; // Init about menu item $this->about = new Help\About( $this ); - $tab->append( + $help->append( $this->about->gtk ); @@ -53,7 +54,7 @@ class Help $this ); - $tab->append( + $help->append( $this->gemlog->gtk ); @@ -62,12 +63,13 @@ class Help $this ); - $tab->append( + $help->append( $this->issue->gtk ); + // Set submenu $this->gtk->set_submenu( - $tab + $help ); // Render diff --git a/src/Entity/Browser/Menu/Tool.php b/src/Entity/Browser/Menu/Tool.php new file mode 100644 index 00000000..462f34d6 --- /dev/null +++ b/src/Entity/Browser/Menu/Tool.php @@ -0,0 +1,56 @@ +menu = $menu; + + // Init menu item + $this->gtk = GtkMenuItem::new_with_label( + $this::LABEL + ); + + // Init submenu container + $tool = new GtkMenu; + + // Init debug menu item + $this->debug = new Tool\Debug( + $this + ); + + $tool->append( + $this->debug->gtk + ); + + $this->gtk->set_submenu( + $tool + ); + + // Render + $this->gtk->show(); + } +} \ No newline at end of file diff --git a/src/Entity/Browser/Menu/Debug.php b/src/Entity/Browser/Menu/Tool/Debug.php similarity index 71% rename from src/Entity/Browser/Menu/Debug.php rename to src/Entity/Browser/Menu/Tool/Debug.php index e1c957f1..64ebd87e 100644 --- a/src/Entity/Browser/Menu/Debug.php +++ b/src/Entity/Browser/Menu/Tool/Debug.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace Yggverse\Yoda\Entity\Browser\Menu; +namespace Yggverse\Yoda\Entity\Browser\Menu\Tool; use \GtkMenuItem; -use \Yggverse\Yoda\Entity\Browser\Menu; +use \Yggverse\Yoda\Entity\Browser\Menu\Tool; class Debug { @@ -14,16 +14,16 @@ class Debug public GtkMenuItem $gtk; // Dependencies - public Menu $menu; + public Tool $tool; // Defaults public const LABEL = 'Debug'; public function __construct( - Menu $menu + Tool $tool ) { // Init dependencies - $this->menu = $menu; + $this->tool = $tool; // Init menu item $this->gtk = GtkMenuItem::new_with_label( @@ -38,7 +38,7 @@ class Debug 'activate', function() { - $this->menu->browser->gtk->set_interactive_debugging( + $this->tool->menu->browser->gtk->set_interactive_debugging( true ); }