Browse Source

delegate close action to the browser window

CPP-GTK4
yggverse 4 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( @@ -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",
"<Primary>q"
);
// Launch browser component
return app->make_window_and_run<app::Browser>(
argc,

15
src/app/browser.cpp

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

2
src/app/browser/header.cpp

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

1
src/app/browser/header.hpp

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

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

@ -19,6 +19,7 @@ namespace app::browser::header @@ -19,6 +19,7 @@ namespace app::browser::header
Menu(
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_CLOSE_ACTIVE,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_CLOSE_ALL,

Loading…
Cancel
Save