Browse Source

add tab session menu

CPP-GTK4
yggverse 2 months ago
parent
commit
46582fbe63
  1. 21
      src/app/browser.cpp
  2. 8
      src/app/browser/header.cpp
  3. 4
      src/app/browser/header.hpp
  4. 75
      src/app/browser/header/menu.cpp
  5. 4
      src/app/browser/header/menu.hpp
  6. 10
      src/app/browser/main.cpp
  7. 3
      src/app/browser/main.hpp

21
src/app/browser.cpp

@ -151,7 +151,22 @@ Browser::Browser( @@ -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( @@ -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(

8
src/app/browser/header.cpp

@ -13,7 +13,9 @@ Header::Header( @@ -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( @@ -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(

4
src/app/browser/header.hpp

@ -36,7 +36,9 @@ namespace app::browser @@ -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(

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

@ -10,7 +10,9 @@ Menu::Menu( @@ -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,47 +31,68 @@ Menu::Menu( @@ -29,47 +31,68 @@ 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"),
get_action_detailed_name(
ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_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_HISTORY->append(
_("Forward"),
MENU__MAIN_TAB_PAGE_NAVIGATION->append(
_("Update"),
get_action_detailed_name(
ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_FORWARD
ACTION__MAIN_TAB_PAGE_NAVIGATION_UPDATE
)
);
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"),
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_PAGE_NAVIGATION_UPDATE
ACTION__MAIN_TAB_SESSION_RESTORE
)
);
MENU__MAIN_TAB_PAGE->append_submenu(
_("Navigation"),
MENU__MAIN_TAB_PAGE_NAVIGATION
);
MENU__MAIN_TAB_SESSION->append(
_("Save"),
get_action_detailed_name(
ACTION__MAIN_TAB_SESSION_SAVE
)
);
MENU__MAIN_TAB->append_submenu(
_("Page"),
MENU__MAIN_TAB_PAGE
);
MENU__MAIN_TAB->append_submenu(
_("Session"),
MENU__MAIN_TAB_SESSION
);
const auto MENU__MAIN_TAB_CLOSE = Gio::Menu::create();

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

@ -25,7 +25,9 @@ namespace app::browser::header @@ -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
);
};
}

10
src/app/browser/main.cpp

@ -95,6 +95,16 @@ void Main::tab_page_navigation_history_forward() @@ -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();

3
src/app/browser/main.hpp

@ -49,6 +49,9 @@ namespace app::browser @@ -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

Loading…
Cancel
Save