diff --git a/src/app/browser.cpp b/src/app/browser.cpp index 63177b0..4aac26a 100644 --- a/src/app/browser.cpp +++ b/src/app/browser.cpp @@ -5,7 +5,7 @@ using namespace app; Browser::Browser( - //const Glib::RefPtr & app, + const Glib::RefPtr & APP //const std::shared_ptr & db ) { // Init window actions @@ -33,80 +33,112 @@ Browser::Browser( } ); - // Tab actions - add_action( - "main_tab_append", - [this] - { - browserMain->tab_append(); - } + APP->set_accel_for_action( + "win.debug", + "i" ); - const auto ACTION__MAIN_TAB_CLOSE = add_action( - "main_tab_close", - [this] - { - browserMain->tab_close(); - } + add_action( + "main_tab_append", + [this] + { + browserMain->tab_append(); + } + ); + + APP->set_accel_for_action( + "win.main_tab_append", + "t" ); - add_action( - "main_tab_close_left", + const auto ACTION__MAIN_TAB_CLOSE = add_action( + "main_tab_close", + [this] + { + browserMain->tab_close(); + } + ); + + add_action( + "main_tab_close_left", + [this] + { + browserMain->tab_close_left(); + } + )->set_enabled( + false + ); + + add_action( + "main_tab_close_right", + [this] + { + browserMain->tab_close_right(); + } + )->set_enabled( + false + ); + + add_action( + "main_tab_close_all", + [this] + { + browserMain->tab_close_all(); + } + )->set_enabled( + false + ); + + // Tab page navigation actions + const auto ACTION__MAIN_TAB_PAGE_NAVIGATION_UPDATE = add_action( + "main_tab_page_navigation_update", [this] { - browserMain->tab_close_left(); + browserMain->tab_page_navigation_update(); } - )->set_enabled( - false ); - add_action( - "main_tab_close_right", + ACTION__MAIN_TAB_PAGE_NAVIGATION_UPDATE->set_enabled( + false + ); + + APP->set_accel_for_action( + "win.main_tab_page_navigation_update", + "r" + ); + + const auto ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_BACK = add_action( + "main_tab_page_navigation_history_back", [this] { - browserMain->tab_close_right(); + browserMain->tab_page_navigation_history_back(); } - )->set_enabled( - false ); - add_action( - "main_tab_close_all", + ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_BACK->set_enabled( + false + ); + + APP->set_accel_for_action( + "win.main_tab_page_navigation_history_back", + "Left" + ); + + const auto ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_FORWARD = add_action( + "main_tab_page_navigation_history_forward", [this] { - browserMain->tab_close_all(); + browserMain->tab_page_navigation_history_forward(); } - )->set_enabled( - false ); - // Tab page navigation actions - const auto ACTION__MAIN_TAB_PAGE_NAVIGATION_UPDATE = add_action( - "main_tab_page_navigation_update", - [this] - { - browserMain->tab_page_navigation_update(); - } - ); - - ACTION__MAIN_TAB_PAGE_NAVIGATION_UPDATE->set_enabled( - false - ); - - const auto ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_BACK = add_action( - "main_tab_page_navigation_history_back", - [this] - { - browserMain->tab_page_navigation_history_back(); - } + ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_FORWARD->set_enabled( + false ); - const auto ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_FORWARD = add_action( - "main_tab_page_navigation_history_forward", - [this] - { - browserMain->tab_page_navigation_history_forward(); - } + APP->set_accel_for_action( + "win.main_tab_page_navigation_history_forward", + "Right" ); // Init widget diff --git a/src/app/browser.hpp b/src/app/browser.hpp index e408165..bf50806 100644 --- a/src/app/browser.hpp +++ b/src/app/browser.hpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -33,7 +34,7 @@ namespace app public: Browser( - //const Glib::RefPtr & app, + const Glib::RefPtr & APP //const std::shared_ptr & db ); }; diff --git a/src/main.cpp b/src/main.cpp index 0406e68..c956f20 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -7,61 +7,35 @@ int main( char * argv[] ) { // Init profile database - const std::shared_ptr db( + const std::shared_ptr DB( // @TODO new lib::Database( "database.sqlite3" ) ); // Init app - const Glib::RefPtr app = Gtk::Application::create( + const Glib::RefPtr APP = Gtk::Application::create( "io.github.yggverse.Yoda" ); - app->add_action( + APP->add_action( "quit", - [app] + [APP] { - app->quit(); + APP->quit(); } ); - // Init accels @TODO db settings - app->set_accel_for_action( - "win.debug", - "i" - ); - - app->set_accel_for_action( - "app.quit", - "q" - ); - - app->set_accel_for_action( - "win.main_tab_append", - "t" + APP->set_accel_for_action( + "app.quit", + "q" ); - app->set_accel_for_action( - "win.main_tab_page_navigation_update", - "r" - ); - - app->set_accel_for_action( - "win.main_tab_page_navigation_history_back", - "Left" - ); - - app->set_accel_for_action( - "win.main_tab_page_navigation_history_forward", - "Right" - ); - // Launch browser component - return app->make_window_and_run( + return APP->make_window_and_run( argc, - argv - //app, - //db + argv, + APP + // DB ); } \ No newline at end of file