From a8cca0ed5b0e124b9982619459ccf4d1bce20e1a Mon Sep 17 00:00:00 2001 From: yggverse Date: Fri, 26 Jul 2024 23:02:19 +0300 Subject: [PATCH] add debug menu item --- src/Entity/Browser.php | 5 ++++ src/Entity/Browser/Menu.php | 14 +++++++-- src/Entity/Browser/Menu/Debug.php | 47 +++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 src/Entity/Browser/Menu/Debug.php diff --git a/src/Entity/Browser.php b/src/Entity/Browser.php index df87465e..a757ff2b 100644 --- a/src/Entity/Browser.php +++ b/src/Entity/Browser.php @@ -28,6 +28,7 @@ class Browser public const WIDTH = 640; public const HEIGHT = 640; public const MAXIMIZE = true; + public const DEBUG = false; public function __construct( Database $database @@ -38,6 +39,10 @@ class Browser // Init window $this->gtk = new GtkWindow; + $this->gtk->set_interactive_debugging( + $this::DEBUG + ); + $this->gtk->set_size_request( $this::WIDTH, $this::HEIGHT diff --git a/src/Entity/Browser/Menu.php b/src/Entity/Browser/Menu.php index 35d3caf4..e54c7998 100644 --- a/src/Entity/Browser/Menu.php +++ b/src/Entity/Browser/Menu.php @@ -17,11 +17,12 @@ class Menu public Browser $browser; // Requirements - public Menu\File $file; - public Menu\Tab $tab; public Menu\Bookmark $bookmark; + public Menu\Debug $debug; + public Menu\File $file; public Menu\History $history; public Menu\Quit $quit; + public Menu\Tab $tab; public function __construct( Browser $browser @@ -73,6 +74,15 @@ class Menu new GtkSeparatorMenuItem ); + // Init debug menu item + $this->debug = new Menu\Debug( + $this + ); + + $this->gtk->append( + $this->debug->gtk + ); + // Init quit menu item $this->quit = new Menu\Quit( $this diff --git a/src/Entity/Browser/Menu/Debug.php b/src/Entity/Browser/Menu/Debug.php new file mode 100644 index 00000000..e1c957f1 --- /dev/null +++ b/src/Entity/Browser/Menu/Debug.php @@ -0,0 +1,47 @@ +menu = $menu; + + // Init menu item + $this->gtk = GtkMenuItem::new_with_label( + $this::LABEL + ); + + // Render + $this->gtk->show(); + + // Int events + $this->gtk->connect( + 'activate', + function() + { + $this->menu->browser->gtk->set_interactive_debugging( + true + ); + } + ); + } +} \ No newline at end of file