add tab session menu

This commit is contained in:
yggverse 2024-09-09 23:44:22 +03:00
parent 817c946270
commit 46582fbe63
7 changed files with 96 additions and 35 deletions

View File

@ -151,7 +151,22 @@ Browser::Browser(
"<Primary>Right"
);
// Init actions
const auto ACTION__MAIN_TAB_SESSION_RESTORE = add_action(
"main_tab_session_restore",
[this]
{
browserMain->tab_restore();
}
);
const auto ACTION__MAIN_TAB_SESSION_SAVE = add_action(
"main_tab_session_save",
[this]
{
browserMain->tab_save();
}
);
const auto ACTION__QUIT = add_action(
"quit",
[this]
@ -184,7 +199,9 @@ Browser::Browser(
ACTION__MAIN_TAB_CLOSE_ALL,
ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_BACK,
ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_FORWARD,
ACTION__MAIN_TAB_PAGE_NAVIGATION_UPDATE
ACTION__MAIN_TAB_PAGE_NAVIGATION_UPDATE,
ACTION__MAIN_TAB_SESSION_RESTORE,
ACTION__MAIN_TAB_SESSION_SAVE
);
set_titlebar(

View File

@ -13,7 +13,9 @@ Header::Header(
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_CLOSE_ALL,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_BACK,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_FORWARD,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_PAGE_NAVIGATION_UPDATE
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_PAGE_NAVIGATION_UPDATE,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_SESSION_RESTORE,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_SESSION_SAVE
) {
// Init widget
set_show_title_buttons(
@ -29,7 +31,9 @@ Header::Header(
ACTION__MAIN_TAB_CLOSE_ALL,
ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_BACK,
ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_FORWARD,
ACTION__MAIN_TAB_PAGE_NAVIGATION_UPDATE
ACTION__MAIN_TAB_PAGE_NAVIGATION_UPDATE,
ACTION__MAIN_TAB_SESSION_RESTORE,
ACTION__MAIN_TAB_SESSION_SAVE
);
pack_start(

View File

@ -36,7 +36,9 @@ namespace app::browser
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_CLOSE_ALL,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_BACK,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_FORWARD,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_PAGE_NAVIGATION_UPDATE
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_PAGE_NAVIGATION_UPDATE,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_SESSION_RESTORE,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_SESSION_SAVE
);
void refresh(

View File

@ -10,7 +10,9 @@ Menu::Menu(
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_CLOSE_ALL,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_BACK,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_FORWARD,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_PAGE_NAVIGATION_UPDATE
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_PAGE_NAVIGATION_UPDATE,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_SESSION_RESTORE,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_SESSION_SAVE
) {
// Init widget
set_tooltip_text(
@ -29,48 +31,69 @@ Menu::Menu(
)
);
const auto MENU__MAIN_TAB_PAGE = Gio::Menu::create();
const auto MENU__MAIN_TAB_PAGE = Gio::Menu::create();
const auto MENU__MAIN_TAB_PAGE_NAVIGATION = Gio::Menu::create();
const auto MENU__MAIN_TAB_PAGE_NAVIGATION = Gio::Menu::create();
const auto MENU__MAIN_TAB_PAGE_NAVIGATION_HISTORY = Gio::Menu::create();
const auto MENU__MAIN_TAB_PAGE_NAVIGATION_HISTORY = Gio::Menu::create();
MENU__MAIN_TAB_PAGE_NAVIGATION_HISTORY->append(
_("Back"),
MENU__MAIN_TAB_PAGE_NAVIGATION_HISTORY->append(
_("Back"),
get_action_detailed_name(
ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_BACK
)
);
MENU__MAIN_TAB_PAGE_NAVIGATION_HISTORY->append(
_("Forward"),
get_action_detailed_name(
ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_FORWARD
)
);
MENU__MAIN_TAB_PAGE_NAVIGATION->append_submenu(
_("History"),
MENU__MAIN_TAB_PAGE_NAVIGATION_HISTORY
);
MENU__MAIN_TAB_PAGE_NAVIGATION->append(
_("Update"),
get_action_detailed_name(
ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_BACK
ACTION__MAIN_TAB_PAGE_NAVIGATION_UPDATE
)
);
MENU__MAIN_TAB_PAGE_NAVIGATION_HISTORY->append(
_("Forward"),
get_action_detailed_name(
ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_FORWARD
)
);
MENU__MAIN_TAB_PAGE_NAVIGATION->append_submenu(
_("History"),
MENU__MAIN_TAB_PAGE_NAVIGATION_HISTORY
MENU__MAIN_TAB_PAGE->append_submenu(
_("Navigation"),
MENU__MAIN_TAB_PAGE_NAVIGATION
);
MENU__MAIN_TAB_PAGE_NAVIGATION->append(
_("Update"),
get_action_detailed_name(
ACTION__MAIN_TAB_PAGE_NAVIGATION_UPDATE
)
);
MENU__MAIN_TAB_PAGE->append_submenu(
_("Navigation"),
MENU__MAIN_TAB_PAGE_NAVIGATION
);
MENU__MAIN_TAB->append_submenu(
_("Page"),
MENU__MAIN_TAB_PAGE
);
const auto MENU__MAIN_TAB_SESSION = Gio::Menu::create();
MENU__MAIN_TAB_SESSION->append(
_("Restore"),
get_action_detailed_name(
ACTION__MAIN_TAB_SESSION_RESTORE
)
);
MENU__MAIN_TAB_SESSION->append(
_("Save"),
get_action_detailed_name(
ACTION__MAIN_TAB_SESSION_SAVE
)
);
MENU__MAIN_TAB->append_submenu(
_("Session"),
MENU__MAIN_TAB_SESSION
);
const auto MENU__MAIN_TAB_CLOSE = Gio::Menu::create();
MENU__MAIN_TAB_CLOSE->append(

View File

@ -25,7 +25,9 @@ namespace app::browser::header
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_CLOSE_ALL,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_BACK,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_FORWARD,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_PAGE_NAVIGATION_UPDATE
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_PAGE_NAVIGATION_UPDATE,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_SESSION_RESTORE,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_SESSION_SAVE
);
};
}

View File

@ -95,6 +95,16 @@ void Main::tab_page_navigation_history_forward()
);
};
void Main::tab_restore()
{
mainTab->restore();
};
void Main::tab_save()
{
mainTab->save();
};
void Main::shutdown()
{
mainTab->shutdown();

View File

@ -49,6 +49,9 @@ namespace app::browser
void tab_page_navigation_history_back();
void tab_page_navigation_history_forward();
void tab_restore();
void tab_save();
void shutdown();
// Getters