From cf6494998637e625c025831b14cdfd926e49ab69 Mon Sep 17 00:00:00 2001 From: yggverse Date: Sun, 11 Aug 2024 09:55:10 +0300 Subject: [PATCH] implement debug menu item --- src/app/browser.cpp | 27 ++++++++++++++++++++++++--- src/app/browser.hpp | 6 +++++- src/app/browser/header/menu.cpp | 6 +++--- src/main.cpp | 12 +++++++----- src/main.hpp | 4 +--- 5 files changed, 40 insertions(+), 15 deletions(-) diff --git a/src/app/browser.cpp b/src/app/browser.cpp index f53d67f0..5240dc29 100644 --- a/src/app/browser.cpp +++ b/src/app/browser.cpp @@ -3,8 +3,9 @@ using namespace app; -Browser::Browser() -{ +Browser::Browser( + const Glib::RefPtr & app +) { set_title( TITLE ); @@ -17,4 +18,24 @@ Browser::Browser() set_titlebar( * new browser::Header() ); -} \ No newline at end of file + + add_action( + "debug", + sigc::mem_fun( + * this, + & Browser::debug + ) + ); + + app->set_accel_for_action( + "win.debug", + "i" + ); +} + +void Browser::debug() +{ + gtk_window_set_interactive_debugging( + true + ); +}; \ No newline at end of file diff --git a/src/app/browser.hpp b/src/app/browser.hpp index 755a0273..c4a1ceac 100644 --- a/src/app/browser.hpp +++ b/src/app/browser.hpp @@ -14,7 +14,11 @@ namespace app const int WIDTH = 640; const int HEIGHT = 480; - Browser(); + Browser( + const Glib::RefPtr & app + ); + + void debug(); }; } diff --git a/src/app/browser/header/menu.cpp b/src/app/browser/header/menu.cpp index 0d6d8d91..35c0af0c 100644 --- a/src/app/browser/header/menu.cpp +++ b/src/app/browser/header/menu.cpp @@ -14,7 +14,7 @@ Menu::Menu() tab->append( _("New tab"), - "app.tab.new" + "tab.new" ); // Build tool submenu @@ -22,7 +22,7 @@ Menu::Menu() tool->append( _("Debug"), - "app.tool.debug" + "win.debug" ); // Build main menu @@ -40,7 +40,7 @@ Menu::Menu() main->append( _("Quit"), - "win.quit" + "app.quit" ); set_menu_model( diff --git a/src/main.cpp b/src/main.cpp index c7fbbb11..1877b71d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3,22 +3,23 @@ int main( int argc, - char* argv[] + char * argv[] ) { // Init app auto app = Gtk::Application::create( - APPLICATION_ID + "io.github.yggverse.Yoda" ); // Init actions app->add_action( "quit", sigc::mem_fun( - *app, - &Gtk::Application::quit + * app, + & Gtk::Application::quit ) ); + // Init accels app->set_accel_for_action( "app.quit", "q" @@ -27,6 +28,7 @@ int main( // Launch browser component return app->make_window_and_run( argc, - argv + argv, + app ); } \ No newline at end of file diff --git a/src/main.hpp b/src/main.hpp index 3f75d908..45c4de41 100644 --- a/src/main.hpp +++ b/src/main.hpp @@ -1,8 +1,6 @@ #include -const Glib::ustring APPLICATION_ID = "io.github.yggverse.Yoda"; - int main( int argc, - char* argv[] + char * argv[] ); \ No newline at end of file