Browse Source

update save/restore actions delegation

CPP-GTK4
yggverse 2 months ago
parent
commit
7795a628de
  1. 38
      src/app/browser.cpp
  2. 12
      src/app/browser/header.cpp
  3. 6
      src/app/browser/header.hpp
  4. 48
      src/app/browser/header/menu.cpp
  5. 6
      src/app/browser/header/menu.hpp
  6. 20
      src/app/browser/main.cpp
  7. 7
      src/app/browser/main.hpp
  8. 8
      src/app/browser/main/tab.cpp
  9. 5
      src/app/browser/main/tab.hpp

38
src/app/browser.cpp

@ -22,6 +22,22 @@ Browser::Browser( @@ -22,6 +22,22 @@ Browser::Browser(
}
);
const auto ACTION__RESTORE = add_action(
"restore",
[this]
{
browserMain->restore();
}
);
const auto ACTION__SAVE = add_action(
"save",
[this]
{
browserMain->save();
}
);
const auto ACTION__DEBUG = add_action(
"debug",
[this]
@ -151,22 +167,6 @@ Browser::Browser( @@ -151,22 +167,6 @@ Browser::Browser(
"<Primary>Right"
);
const auto ACTION__MAIN_TAB_SESSION_RESTORE = add_action(
"main_tab_session_restore",
[this]
{
browserMain->tab_session_restore();
}
);
const auto ACTION__MAIN_TAB_SESSION_SAVE = add_action(
"main_tab_session_save",
[this]
{
browserMain->tab_session_save();
}
);
const auto ACTION__QUIT = add_action(
"quit",
[this]
@ -194,14 +194,14 @@ Browser::Browser( @@ -194,14 +194,14 @@ Browser::Browser(
browserHeader = Gtk::make_managed<browser::Header>(
ACTION__DEBUG,
ACTION__QUIT,
ACTION__RESTORE,
ACTION__SAVE,
ACTION__MAIN_TAB_APPEND,
ACTION__MAIN_TAB_CLOSE_ACTIVE,
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_SESSION_RESTORE,
ACTION__MAIN_TAB_SESSION_SAVE
ACTION__MAIN_TAB_PAGE_NAVIGATION_UPDATE
);
set_titlebar(

12
src/app/browser/header.cpp

@ -8,14 +8,14 @@ using namespace app::browser; @@ -8,14 +8,14 @@ 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__RESTORE,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__SAVE,
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,
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_SESSION_RESTORE,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_SESSION_SAVE
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_PAGE_NAVIGATION_UPDATE
) {
// Init widget
set_show_title_buttons(
@ -26,14 +26,14 @@ Header::Header( @@ -26,14 +26,14 @@ Header::Header(
headerMenu = Gtk::make_managed<header::Menu>(
ACTION__DEBUG,
ACTION__QUIT,
ACTION__RESTORE,
ACTION__SAVE,
ACTION__MAIN_TAB_APPEND,
ACTION__MAIN_TAB_CLOSE_ACTIVE,
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_SESSION_RESTORE,
ACTION__MAIN_TAB_SESSION_SAVE
ACTION__MAIN_TAB_PAGE_NAVIGATION_UPDATE
);
pack_start(

6
src/app/browser/header.hpp

@ -31,14 +31,14 @@ namespace app::browser @@ -31,14 +31,14 @@ namespace app::browser
Header(
const Glib::RefPtr<Gio::SimpleAction> & ACTION__DEBUG,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__QUIT,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__RESTORE,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__SAVE,
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,
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_SESSION_RESTORE,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_SESSION_SAVE
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_PAGE_NAVIGATION_UPDATE
);
void refresh(

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

@ -5,14 +5,14 @@ using namespace app::browser::header; @@ -5,14 +5,14 @@ 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__RESTORE,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__SAVE,
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,
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_SESSION_RESTORE,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_SESSION_SAVE
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_PAGE_NAVIGATION_UPDATE
) {
// Init widget
set_tooltip_text(
@ -73,27 +73,6 @@ Menu::Menu( @@ -73,27 +73,6 @@ Menu::Menu(
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(
@ -136,6 +115,27 @@ Menu::Menu( @@ -136,6 +115,27 @@ Menu::Menu(
MENU__MAIN_TAB
);
const auto MENU__MAIN_SESSION = Gio::Menu::create();
MENU__MAIN_SESSION->append(
_("Restore"),
get_action_detailed_name(
ACTION__RESTORE
)
);
MENU__MAIN_SESSION->append(
_("Save"),
get_action_detailed_name(
ACTION__SAVE
)
);
MENU__MAIN->append_submenu(
_("Session"),
MENU__MAIN_SESSION
);
const auto MENU__MAIN_TOOLS = Gio::Menu::create();
MENU__MAIN_TOOLS->append(

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

@ -20,14 +20,14 @@ namespace app::browser::header @@ -20,14 +20,14 @@ 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__RESTORE,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__SAVE,
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,
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_SESSION_RESTORE,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_SESSION_SAVE
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_PAGE_NAVIGATION_UPDATE
);
};
}

20
src/app/browser/main.cpp

@ -52,6 +52,16 @@ void Main::tab_append() @@ -52,6 +52,16 @@ void Main::tab_append()
);
};
void Main::restore()
{
mainTab->restore();
};
void Main::save()
{
mainTab->save();
};
void Main::tab_close()
{
mainTab->close(
@ -95,16 +105,6 @@ void Main::tab_page_navigation_history_forward() @@ -95,16 +105,6 @@ void Main::tab_page_navigation_history_forward()
);
};
void Main::tab_session_restore()
{
mainTab->session_restore();
};
void Main::tab_session_save()
{
mainTab->session_save();
};
void Main::shutdown()
{
mainTab->shutdown();

7
src/app/browser/main.hpp

@ -38,20 +38,21 @@ namespace app::browser @@ -38,20 +38,21 @@ namespace app::browser
// Actions
void refresh();
void restore();
void save();
void tab_append();
void tab_close_all();
void tab_close_left();
void tab_close_right();
void tab_close();
void tab_page_navigation_update();
void tab_page_navigation_history_back();
void tab_page_navigation_history_forward();
void tab_session_restore();
void tab_session_save();
void shutdown();
// Getters

8
src/app/browser/main/tab.cpp

@ -53,7 +53,7 @@ Tab::Tab( @@ -53,7 +53,7 @@ Tab::Tab(
[this]
{
// Restore session from DB
session_restore();
restore();
}
);
@ -66,7 +66,7 @@ Tab::Tab( @@ -66,7 +66,7 @@ Tab::Tab(
);
}
int Tab::session_restore()
int Tab::restore()
{
sqlite3_stmt* statement;
@ -116,7 +116,7 @@ int Tab::session_restore() @@ -116,7 +116,7 @@ int Tab::session_restore()
return PREPARE_STATUS;
}
int Tab::session_save()
int Tab::save()
{
char * error; // @TODO
@ -172,7 +172,7 @@ int Tab::session_save() @@ -172,7 +172,7 @@ int Tab::session_save()
void Tab::shutdown()
{
session_save();
save();
// @TODO shutdown children components
}

5
src/app/browser/main/tab.hpp

@ -94,8 +94,9 @@ namespace app::browser::main @@ -94,8 +94,9 @@ namespace app::browser::main
const int & PAGE_NUMBER
);
int session_restore();
int session_save();
int restore();
int save();
void shutdown();

Loading…
Cancel
Save