Browse Source

delegate close action to the browser window

CPP-GTK4
yggverse 2 months ago
parent
commit
3f4a5536ca
  1. 14
      src/app.cpp
  2. 15
      src/app/browser.cpp
  3. 2
      src/app/browser/header.cpp
  4. 1
      src/app/browser/header.hpp
  5. 5
      src/app/browser/header/menu.cpp
  6. 1
      src/app/browser/header/menu.hpp

14
src/app.cpp

@ -18,20 +18,6 @@ int main(
"io.github.yggverse.Yoda" "io.github.yggverse.Yoda"
); );
// Init actions
app->add_action(
"quit",
[app]
{
app->quit();
}
);
app->set_accel_for_action(
"app.quit",
"<Primary>q"
);
// Launch browser component // Launch browser component
return app->make_window_and_run<app::Browser>( return app->make_window_and_run<app::Browser>(
argc, argc,

15
src/app/browser.cpp

@ -151,6 +151,20 @@ Browser::Browser(
"<Primary>Right" "<Primary>Right"
); );
// Init actions
const auto ACTION__QUIT = add_action(
"quit",
[this]
{
close();
}
);
APP->set_accel_for_action(
"win.quit",
"<Primary>q"
);
// Init widget // Init widget
set_title( set_title(
_("Yoda") _("Yoda")
@ -164,6 +178,7 @@ Browser::Browser(
// Init components // Init components
browserHeader = Gtk::make_managed<browser::Header>( browserHeader = Gtk::make_managed<browser::Header>(
ACTION__DEBUG, ACTION__DEBUG,
ACTION__QUIT,
ACTION__MAIN_TAB_APPEND, ACTION__MAIN_TAB_APPEND,
ACTION__MAIN_TAB_CLOSE_ACTIVE, ACTION__MAIN_TAB_CLOSE_ACTIVE,
ACTION__MAIN_TAB_CLOSE_ALL, ACTION__MAIN_TAB_CLOSE_ALL,

2
src/app/browser/header.cpp

@ -7,6 +7,7 @@ using namespace app::browser;
Header::Header( Header::Header(
const Glib::RefPtr<Gio::SimpleAction> & ACTION__DEBUG, const Glib::RefPtr<Gio::SimpleAction> & ACTION__DEBUG,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__QUIT,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_APPEND, const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_APPEND,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_CLOSE_ACTIVE, const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_CLOSE_ACTIVE,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_CLOSE_ALL, const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_CLOSE_ALL,
@ -22,6 +23,7 @@ Header::Header(
// Init components // Init components
headerMenu = Gtk::make_managed<header::Menu>( headerMenu = Gtk::make_managed<header::Menu>(
ACTION__DEBUG, ACTION__DEBUG,
ACTION__QUIT,
ACTION__MAIN_TAB_APPEND, ACTION__MAIN_TAB_APPEND,
ACTION__MAIN_TAB_CLOSE_ACTIVE, ACTION__MAIN_TAB_CLOSE_ACTIVE,
ACTION__MAIN_TAB_CLOSE_ALL, ACTION__MAIN_TAB_CLOSE_ALL,

1
src/app/browser/header.hpp

@ -30,6 +30,7 @@ namespace app::browser
Header( Header(
const Glib::RefPtr<Gio::SimpleAction> & ACTION__DEBUG, const Glib::RefPtr<Gio::SimpleAction> & ACTION__DEBUG,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__QUIT,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_APPEND, const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_APPEND,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_CLOSE_ACTIVE, const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_CLOSE_ACTIVE,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_CLOSE_ALL, const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_CLOSE_ALL,

5
src/app/browser/header/menu.cpp

@ -4,6 +4,7 @@ using namespace app::browser::header;
Menu::Menu( Menu::Menu(
const Glib::RefPtr<Gio::SimpleAction> & ACTION__DEBUG, const Glib::RefPtr<Gio::SimpleAction> & ACTION__DEBUG,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__QUIT,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_APPEND, const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_APPEND,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_CLOSE_ACTIVE, const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_CLOSE_ACTIVE,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_CLOSE_ALL, const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_CLOSE_ALL,
@ -128,7 +129,9 @@ Menu::Menu(
MENU__MAIN->append( MENU__MAIN->append(
_("Quit"), _("Quit"),
"app.quit" // @TODO get_action_detailed_name(
ACTION__QUIT
)
); );
set_menu_model( set_menu_model(

1
src/app/browser/header/menu.hpp

@ -19,6 +19,7 @@ namespace app::browser::header
Menu( Menu(
const Glib::RefPtr<Gio::SimpleAction> & ACTION__DEBUG, const Glib::RefPtr<Gio::SimpleAction> & ACTION__DEBUG,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__QUIT,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_APPEND, const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_APPEND,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_CLOSE_ACTIVE, const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_CLOSE_ACTIVE,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_CLOSE_ALL, const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_CLOSE_ALL,

Loading…
Cancel
Save