Browse Source

reorganize accels, remove extra argument from browser construction

CPP-GTK4
yggverse 2 months ago
parent
commit
bddaa43024
  1. 3
      src/app.cpp
  2. 75
      src/app/browser.cpp
  3. 3
      src/app/browser.hpp

3
src/app.cpp

@ -22,7 +22,6 @@ int main(
return app->make_window_and_run<app::Browser>( return app->make_window_and_run<app::Browser>(
argc, argc,
argv, argv,
db, db
app
); );
} }

75
src/app/browser.cpp

@ -5,8 +5,7 @@
using namespace app; using namespace app;
Browser::Browser( Browser::Browser(
sqlite3 * db, sqlite3 * db
const Glib::RefPtr<Gtk::Application> & APP
) { ) {
// Init database // Init database
DB::SESSION::init( DB::SESSION::init(
@ -62,11 +61,6 @@ Browser::Browser(
} }
); );
APP->set_accel_for_action(
"win.debug",
"<Primary>i"
);
const auto ACTION__MAIN_TAB_APPEND = add_action( const auto ACTION__MAIN_TAB_APPEND = add_action(
"main_tab_append", "main_tab_append",
[this] [this]
@ -75,11 +69,6 @@ Browser::Browser(
} }
); );
APP->set_accel_for_action(
"win.main_tab_append",
"<Primary>t"
);
const auto ACTION__MAIN_TAB_CLOSE_ACTIVE = add_action( const auto ACTION__MAIN_TAB_CLOSE_ACTIVE = add_action(
"main_tab_close_active", "main_tab_close_active",
[this] [this]
@ -92,11 +81,6 @@ Browser::Browser(
false false
); );
APP->set_accel_for_action(
"win.main_tab_close_active",
"<Primary>Escape"
);
add_action( add_action(
"main_tab_close_left", "main_tab_close_left",
[this] [this]
@ -141,11 +125,6 @@ Browser::Browser(
false false
); );
APP->set_accel_for_action(
"win.main_tab_page_navigation_reload",
"<Primary>r"
);
const auto ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_BACK = add_action( const auto ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_BACK = add_action(
"main_tab_page_navigation_history_back", "main_tab_page_navigation_history_back",
[this] [this]
@ -158,11 +137,6 @@ Browser::Browser(
false false
); );
APP->set_accel_for_action(
"win.main_tab_page_navigation_history_back",
"<Primary>Left"
);
const auto ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_FORWARD = add_action( const auto ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_FORWARD = add_action(
"main_tab_page_navigation_history_forward", "main_tab_page_navigation_history_forward",
[this] [this]
@ -175,11 +149,6 @@ Browser::Browser(
false false
); );
APP->set_accel_for_action(
"win.main_tab_page_navigation_history_forward",
"<Primary>Right"
);
const auto ACTION__QUIT = add_action( const auto ACTION__QUIT = add_action(
"quit", "quit",
[this] [this]
@ -188,11 +157,6 @@ Browser::Browser(
} }
); );
APP->set_accel_for_action(
"win.quit",
"<Primary>q"
);
// Init widget // Init widget
set_title( set_title(
_("Yoda") _("Yoda")
@ -242,6 +206,43 @@ Browser::Browser(
signal_realize().connect( signal_realize().connect(
[this] [this]
{ {
const auto APP = get_application();
APP->set_accel_for_action(
"win.debug",
"<Primary>i"
);
APP->set_accel_for_action(
"win.main_tab_append",
"<Primary>t"
);
APP->set_accel_for_action(
"win.main_tab_close_active",
"<Primary>Escape"
);
APP->set_accel_for_action(
"win.main_tab_page_navigation_reload",
"<Primary>r"
);
APP->set_accel_for_action(
"win.main_tab_page_navigation_history_back",
"<Primary>Left"
);
APP->set_accel_for_action(
"win.main_tab_page_navigation_history_forward",
"<Primary>Right"
);
APP->set_accel_for_action(
"win.quit",
"<Primary>q"
);
restore(); // last session from DB restore(); // last session from DB
} }
); );

3
src/app/browser.hpp

@ -80,8 +80,7 @@ namespace app
public: public:
Browser( Browser(
sqlite3 * db, sqlite3 * db
const Glib::RefPtr<Gtk::Application> & APP
); );
// Actions // Actions

Loading…
Cancel
Save