From 3f4a5536ca29bf751c1404a1a1eb10478bfc22ad Mon Sep 17 00:00:00 2001 From: yggverse Date: Mon, 9 Sep 2024 07:45:17 +0300 Subject: [PATCH] delegate close action to the browser window --- src/app.cpp | 14 -------------- src/app/browser.cpp | 15 +++++++++++++++ src/app/browser/header.cpp | 2 ++ src/app/browser/header.hpp | 1 + src/app/browser/header/menu.cpp | 5 ++++- src/app/browser/header/menu.hpp | 1 + 6 files changed, 23 insertions(+), 15 deletions(-) diff --git a/src/app.cpp b/src/app.cpp index bb2a26fd..0b83c23a 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -18,20 +18,6 @@ int main( "io.github.yggverse.Yoda" ); - // Init actions - app->add_action( - "quit", - [app] - { - app->quit(); - } - ); - - app->set_accel_for_action( - "app.quit", - "q" - ); - // Launch browser component return app->make_window_and_run( argc, diff --git a/src/app/browser.cpp b/src/app/browser.cpp index c02b609d..e063c070 100644 --- a/src/app/browser.cpp +++ b/src/app/browser.cpp @@ -151,6 +151,20 @@ Browser::Browser( "Right" ); + // Init actions + const auto ACTION__QUIT = add_action( + "quit", + [this] + { + close(); + } + ); + + APP->set_accel_for_action( + "win.quit", + "q" + ); + // Init widget set_title( _("Yoda") @@ -164,6 +178,7 @@ Browser::Browser( // Init components browserHeader = Gtk::make_managed( ACTION__DEBUG, + ACTION__QUIT, ACTION__MAIN_TAB_APPEND, ACTION__MAIN_TAB_CLOSE_ACTIVE, ACTION__MAIN_TAB_CLOSE_ALL, diff --git a/src/app/browser/header.cpp b/src/app/browser/header.cpp index 98a94069..89440402 100644 --- a/src/app/browser/header.cpp +++ b/src/app/browser/header.cpp @@ -7,6 +7,7 @@ using namespace app::browser; Header::Header( const Glib::RefPtr & ACTION__DEBUG, + const Glib::RefPtr & ACTION__QUIT, const Glib::RefPtr & ACTION__MAIN_TAB_APPEND, const Glib::RefPtr & ACTION__MAIN_TAB_CLOSE_ACTIVE, const Glib::RefPtr & ACTION__MAIN_TAB_CLOSE_ALL, @@ -22,6 +23,7 @@ Header::Header( // Init components headerMenu = Gtk::make_managed( ACTION__DEBUG, + ACTION__QUIT, ACTION__MAIN_TAB_APPEND, ACTION__MAIN_TAB_CLOSE_ACTIVE, ACTION__MAIN_TAB_CLOSE_ALL, diff --git a/src/app/browser/header.hpp b/src/app/browser/header.hpp index ce83f26e..9feed021 100644 --- a/src/app/browser/header.hpp +++ b/src/app/browser/header.hpp @@ -30,6 +30,7 @@ namespace app::browser Header( const Glib::RefPtr & ACTION__DEBUG, + const Glib::RefPtr & ACTION__QUIT, const Glib::RefPtr & ACTION__MAIN_TAB_APPEND, const Glib::RefPtr & ACTION__MAIN_TAB_CLOSE_ACTIVE, const Glib::RefPtr & ACTION__MAIN_TAB_CLOSE_ALL, diff --git a/src/app/browser/header/menu.cpp b/src/app/browser/header/menu.cpp index 8ca1e235..b2ea686f 100644 --- a/src/app/browser/header/menu.cpp +++ b/src/app/browser/header/menu.cpp @@ -4,6 +4,7 @@ using namespace app::browser::header; Menu::Menu( const Glib::RefPtr & ACTION__DEBUG, + const Glib::RefPtr & ACTION__QUIT, const Glib::RefPtr & ACTION__MAIN_TAB_APPEND, const Glib::RefPtr & ACTION__MAIN_TAB_CLOSE_ACTIVE, const Glib::RefPtr & ACTION__MAIN_TAB_CLOSE_ALL, @@ -128,7 +129,9 @@ Menu::Menu( MENU__MAIN->append( _("Quit"), - "app.quit" // @TODO + get_action_detailed_name( + ACTION__QUIT + ) ); set_menu_model( diff --git a/src/app/browser/header/menu.hpp b/src/app/browser/header/menu.hpp index aaa86091..d51df2ed 100644 --- a/src/app/browser/header/menu.hpp +++ b/src/app/browser/header/menu.hpp @@ -19,6 +19,7 @@ namespace app::browser::header Menu( const Glib::RefPtr & ACTION__DEBUG, + const Glib::RefPtr & ACTION__QUIT, const Glib::RefPtr & ACTION__MAIN_TAB_APPEND, const Glib::RefPtr & ACTION__MAIN_TAB_CLOSE_ACTIVE, const Glib::RefPtr & ACTION__MAIN_TAB_CLOSE_ALL,