Browse Source

rename actions

CPP-GTK4
yggverse 2 months ago
parent
commit
0a75ca7671
  1. 2
      README.md
  2. 4
      src/app/browser.cpp
  3. 24
      src/app/browser/main.cpp
  4. 12
      src/app/browser/main.hpp
  5. 36
      src/app/browser/main/tab.cpp
  6. 24
      src/app/browser/main/tab.hpp
  7. 16
      src/app/browser/main/tab/page.cpp
  8. 8
      src/app/browser/main/tab/page.hpp
  9. 18
      src/app/browser/main/tab/page/navigation.cpp
  10. 8
      src/app/browser/main/tab/page/navigation/history.cpp
  11. 4
      src/app/browser/main/tab/page/navigation/history.hpp
  12. 8
      src/app/browser/main/tab/page/navigation/reload.cpp
  13. 4
      src/app/browser/main/tab/page/navigation/reload.hpp
  14. 8
      src/app/browser/main/tab/page/navigation/request.cpp
  15. 8
      src/app/browser/main/tab/page/navigation/request.hpp

2
README.md

@ -63,7 +63,7 @@ Currently, main application sources located at `src/app` folder, written by foll
* `#include` application `.hpp` files in `.cpp`. For system libraries, use headers only. Do not place system dependencies in `.cpp` * `#include` application `.hpp` files in `.cpp`. For system libraries, use headers only. Do not place system dependencies in `.cpp`
* App interact SQLite database, where table name match related class namespace, it may contain optional feature postfix (separated with double line) * App interact SQLite database, where table name match related class namespace, it may contain optional feature postfix (separated with double line)
* App class tables in database wanted to store user data between app sessions and must contain only fields that related to this class (e.g. private and public variable values); also may contain primary key fields, to their parent (table) according to the namespace hierarchy * App class tables in database wanted to store user data between app sessions and must contain only fields that related to this class (e.g. private and public variable values); also may contain primary key fields, to their parent (table) according to the namespace hierarchy
* Window actions called same as their menu actors. Children widgets operate with `SimpleAction` objects, not name strings (follow encapsulation) * Follow encapsulation, do not use static dependencies like external action names, use `SimpleAction` objects instead of `win.action_name`, etc
### Environment ### Environment

4
src/app/browser.cpp

@ -190,12 +190,12 @@ Browser::Browser(
browserMain = Gtk::make_managed<browser::Main>( browserMain = Gtk::make_managed<browser::Main>(
db, db,
ACTION__UPDATE,
ACTION__TAB_CLOSE, ACTION__TAB_CLOSE,
ACTION__TAB_CLOSE_ALL, ACTION__TAB_CLOSE_ALL,
ACTION__TAB_PAGE_NAVIGATION_HISTORY_BACK, ACTION__TAB_PAGE_NAVIGATION_HISTORY_BACK,
ACTION__TAB_PAGE_NAVIGATION_HISTORY_FORWARD, ACTION__TAB_PAGE_NAVIGATION_HISTORY_FORWARD,
ACTION__TAB_PAGE_NAVIGATION_RELOAD ACTION__TAB_PAGE_NAVIGATION_RELOAD,
ACTION__UPDATE
); );
set_child( set_child(

24
src/app/browser/main.cpp

@ -5,12 +5,12 @@ using namespace app::browser;
Main::Main( Main::Main(
sqlite3 * db, sqlite3 * db,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__UPDATE, const Glib::RefPtr<Gio::SimpleAction> & ACTION__CLOSE,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_CLOSE, const Glib::RefPtr<Gio::SimpleAction> & ACTION__CLOSE_ALL,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_CLOSE_ALL, const Glib::RefPtr<Gio::SimpleAction> & ACTION__HISTORY_BACK,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_PAGE_NAVIGATION_HISTORY_BACK, const Glib::RefPtr<Gio::SimpleAction> & ACTION__HISTORY_FORWARD,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_PAGE_NAVIGATION_HISTORY_FORWARD, const Glib::RefPtr<Gio::SimpleAction> & ACTION__RELOAD,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_PAGE_NAVIGATION_RELOAD const Glib::RefPtr<Gio::SimpleAction> & ACTION__UPDATE
) { ) {
// Init database // Init database
DB::SESSION::init( DB::SESSION::init(
@ -29,12 +29,12 @@ Main::Main(
// Init components // Init components
mainTab = Gtk::make_managed<main::Tab>( mainTab = Gtk::make_managed<main::Tab>(
db, db,
ACTION__UPDATE, ACTION__CLOSE,
ACTION__TAB_CLOSE, ACTION__CLOSE_ALL,
ACTION__TAB_CLOSE_ALL, ACTION__HISTORY_BACK,
ACTION__TAB_PAGE_NAVIGATION_HISTORY_BACK, ACTION__HISTORY_FORWARD,
ACTION__TAB_PAGE_NAVIGATION_HISTORY_FORWARD, ACTION__RELOAD,
ACTION__TAB_PAGE_NAVIGATION_RELOAD ACTION__UPDATE
); );
append( append(

12
src/app/browser/main.hpp

@ -75,12 +75,12 @@ namespace app::browser
Main( Main(
sqlite3 * db, sqlite3 * db,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__UPDATE, const Glib::RefPtr<Gio::SimpleAction> & ACTION__CLOSE,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_CLOSE, const Glib::RefPtr<Gio::SimpleAction> & ACTION__CLOSE_ALL,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_CLOSE_ALL, const Glib::RefPtr<Gio::SimpleAction> & ACTION__HISTORY_BACK,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_PAGE_NAVIGATION_HISTORY_BACK, const Glib::RefPtr<Gio::SimpleAction> & ACTION__HISTORY_FORWARD,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_PAGE_NAVIGATION_HISTORY_FORWARD, const Glib::RefPtr<Gio::SimpleAction> & ACTION__RELOAD,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_PAGE_NAVIGATION_RELOAD const Glib::RefPtr<Gio::SimpleAction> & ACTION__UPDATE
); );
// Actions // Actions

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

@ -6,12 +6,12 @@ using namespace app::browser::main;
Tab::Tab( Tab::Tab(
sqlite3 * db, sqlite3 * db,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__UPDATE, const Glib::RefPtr<Gio::SimpleAction> & ACTION__CLOSE,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_CLOSE, const Glib::RefPtr<Gio::SimpleAction> & ACTION__CLOSE_ALL,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_CLOSE_ALL, const Glib::RefPtr<Gio::SimpleAction> & ACTION__HISTORY_BACK,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_PAGE_NAVIGATION_HISTORY_BACK, const Glib::RefPtr<Gio::SimpleAction> & ACTION__HISTORY_FORWARD,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_PAGE_NAVIGATION_HISTORY_FORWARD, const Glib::RefPtr<Gio::SimpleAction> & ACTION__RELOAD,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_PAGE_NAVIGATION_RELOAD const Glib::RefPtr<Gio::SimpleAction> & ACTION__UPDATE
) { ) {
// Init database // Init database
DB::SESSION::init( DB::SESSION::init(
@ -19,12 +19,12 @@ Tab::Tab(
); );
// Init actions // Init actions
action__close = ACTION__CLOSE;
action__close_all = ACTION__CLOSE_ALL;
action__history_back = ACTION__HISTORY_BACK;
action__history_forward = ACTION__HISTORY_FORWARD;
action__reload = ACTION__RELOAD;
action__update = ACTION__UPDATE; action__update = ACTION__UPDATE;
action__tab_close = ACTION__TAB_CLOSE;
action__tab_close_all = ACTION__TAB_CLOSE_ALL;
action__tab_page_navigation_history_back = ACTION__TAB_PAGE_NAVIGATION_HISTORY_BACK;
action__tab_page_navigation_history_forward = ACTION__TAB_PAGE_NAVIGATION_HISTORY_FORWARD;
action__tab_page_navigation_reload = ACTION__TAB_PAGE_NAVIGATION_RELOAD;
// Init widget // Init widget
set_scrollable( set_scrollable(
@ -156,11 +156,11 @@ void Tab::update(
); );
// Update tab actions status // Update tab actions status
action__tab_close->set_enabled( action__close->set_enabled(
get_n_pages() > 0 get_n_pages() > 0
); );
action__tab_close_all->set_enabled( action__close_all->set_enabled(
get_n_pages() > 0 get_n_pages() > 0
); );
} }
@ -170,15 +170,15 @@ int Tab::append(
) { ) {
const auto TAB_PAGE = new tab::Page( // @TODO manage const auto TAB_PAGE = new tab::Page( // @TODO manage
db, db,
action__update, action__history_back,
action__tab_page_navigation_history_back, action__history_forward,
action__tab_page_navigation_history_forward, action__reload,
action__tab_page_navigation_reload action__update
); );
const auto TAB_LABEL = new tab::Label( // @TODO manage const auto TAB_LABEL = new tab::Label( // @TODO manage
db, db,
action__tab_close action__close
); );
const int PAGE_NUMBER = append_page( const int PAGE_NUMBER = append_page(

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

@ -67,12 +67,12 @@ namespace app::browser::main
sqlite3 * db; sqlite3 * db;
// Actions // Actions
Glib::RefPtr<Gio::SimpleAction> action__update, Glib::RefPtr<Gio::SimpleAction> action__close_all,
action__tab_close, action__close,
action__tab_close_all, action__history_back,
action__tab_page_navigation_history_back, action__history_forward,
action__tab_page_navigation_history_forward, action__reload,
action__tab_page_navigation_reload; action__update;
// Defaults // Defaults
const bool REORDERABLE = true; const bool REORDERABLE = true;
@ -85,12 +85,12 @@ namespace app::browser::main
Tab( Tab(
sqlite3 * db, sqlite3 * db,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__UPDATE, const Glib::RefPtr<Gio::SimpleAction> & ACTION__CLOSE,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_CLOSE, const Glib::RefPtr<Gio::SimpleAction> & ACTION__CLOSE_ALL,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_CLOSE_ALL, const Glib::RefPtr<Gio::SimpleAction> & ACTION__HISTORY_BACK,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_PAGE_NAVIGATION_HISTORY_BACK, const Glib::RefPtr<Gio::SimpleAction> & ACTION__HISTORY_FORWARD,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_PAGE_NAVIGATION_HISTORY_FORWARD, const Glib::RefPtr<Gio::SimpleAction> & ACTION__RELOAD,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_PAGE_NAVIGATION_RELOAD const Glib::RefPtr<Gio::SimpleAction> & ACTION__UPDATE
); );
// Actions // Actions

16
src/app/browser/main/tab/page.cpp

@ -6,10 +6,10 @@ using namespace app::browser::main::tab;
Page::Page( Page::Page(
sqlite3 * db, sqlite3 * db,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__UPDATE, const Glib::RefPtr<Gio::SimpleAction> & ACTION__HISTORY_BACK,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_PAGE_NAVIGATION_HISTORY_BACK, const Glib::RefPtr<Gio::SimpleAction> & ACTION__HISTORY_FORWARD,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_PAGE_NAVIGATION_HISTORY_FORWARD, const Glib::RefPtr<Gio::SimpleAction> & ACTION__RELOAD,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_PAGE_NAVIGATION_RELOAD const Glib::RefPtr<Gio::SimpleAction> & ACTION__UPDATE
) { ) {
// Init meta // Init meta
title = _("New page"); title = _("New page");
@ -32,10 +32,10 @@ Page::Page(
// Init widget components // Init widget components
pageNavigation = Gtk::make_managed<page::Navigation>( pageNavigation = Gtk::make_managed<page::Navigation>(
this->db, this->db,
ACTION__UPDATE, ACTION__HISTORY_BACK,
ACTION__TAB_PAGE_NAVIGATION_HISTORY_BACK, ACTION__HISTORY_FORWARD,
ACTION__TAB_PAGE_NAVIGATION_HISTORY_FORWARD, ACTION__RELOAD,
ACTION__TAB_PAGE_NAVIGATION_RELOAD ACTION__UPDATE
); );
append( append(

8
src/app/browser/main/tab/page.hpp

@ -114,10 +114,10 @@ namespace app::browser::main::tab
Page( Page(
sqlite3 * db, sqlite3 * db,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__UPDATE, const Glib::RefPtr<Gio::SimpleAction> & ACTION__HISTORY_BACK,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_PAGE_NAVIGATION_HISTORY_BACK, const Glib::RefPtr<Gio::SimpleAction> & ACTION__HISTORY_FORWARD,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_PAGE_NAVIGATION_HISTORY_FORWARD, const Glib::RefPtr<Gio::SimpleAction> & ACTION__RELOAD,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_PAGE_NAVIGATION_RELOAD const Glib::RefPtr<Gio::SimpleAction> & ACTION__UPDATE
); );
// Actions // Actions

18
src/app/browser/main/tab/page/navigation.cpp

@ -9,10 +9,10 @@ using namespace app::browser::main::tab::page;
Navigation::Navigation( Navigation::Navigation(
sqlite3 * db, sqlite3 * db,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__UPDATE, const Glib::RefPtr<Gio::SimpleAction> & ACTION__HISTORY_BACK,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_PAGE_NAVIGATION_HISTORY_BACK, const Glib::RefPtr<Gio::SimpleAction> & ACTION__HISTORY_FORWARD,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_PAGE_NAVIGATION_HISTORY_FORWARD, const Glib::RefPtr<Gio::SimpleAction> & ACTION__RELOAD,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_PAGE_NAVIGATION_RELOAD const Glib::RefPtr<Gio::SimpleAction> & ACTION__UPDATE
) { ) {
// Init database // Init database
DB::SESSION::init( DB::SESSION::init(
@ -53,8 +53,8 @@ Navigation::Navigation(
navigationHistory = Gtk::make_managed<navigation::History>( navigationHistory = Gtk::make_managed<navigation::History>(
db, db,
ACTION__TAB_PAGE_NAVIGATION_HISTORY_BACK, ACTION__HISTORY_BACK,
ACTION__TAB_PAGE_NAVIGATION_HISTORY_FORWARD ACTION__HISTORY_FORWARD
); );
append( append(
@ -62,7 +62,7 @@ Navigation::Navigation(
); );
navigationReload = Gtk::make_managed<navigation::Reload>( navigationReload = Gtk::make_managed<navigation::Reload>(
ACTION__TAB_PAGE_NAVIGATION_RELOAD ACTION__RELOAD
); );
append( append(
@ -71,8 +71,8 @@ Navigation::Navigation(
navigationRequest = Gtk::make_managed<navigation::Request>( navigationRequest = Gtk::make_managed<navigation::Request>(
db, db,
ACTION__UPDATE, ACTION__RELOAD,
ACTION__TAB_PAGE_NAVIGATION_RELOAD ACTION__UPDATE
); );
append( append(

8
src/app/browser/main/tab/page/navigation/history.cpp

@ -6,8 +6,8 @@ using namespace app::browser::main::tab::page::navigation;
History::History( History::History(
sqlite3 * db, sqlite3 * db,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_PAGE_NAVIGATION_HISTORY_BACK, const Glib::RefPtr<Gio::SimpleAction> & ACTION__HISTORY_BACK,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_PAGE_NAVIGATION_HISTORY_FORWARD const Glib::RefPtr<Gio::SimpleAction> & ACTION__HISTORY_FORWARD
) { ) {
// Init database // Init database
DB::SESSION::init( DB::SESSION::init(
@ -20,7 +20,7 @@ History::History(
); );
historyBack = Gtk::make_managed<history::Back>( historyBack = Gtk::make_managed<history::Back>(
ACTION__TAB_PAGE_NAVIGATION_HISTORY_BACK ACTION__HISTORY_BACK
); );
append( append(
@ -28,7 +28,7 @@ History::History(
); );
historyForward = Gtk::make_managed<history::Forward>( historyForward = Gtk::make_managed<history::Forward>(
ACTION__TAB_PAGE_NAVIGATION_HISTORY_FORWARD ACTION__HISTORY_FORWARD
); );
append( append(

4
src/app/browser/main/tab/page/navigation/history.hpp

@ -92,8 +92,8 @@ namespace app::browser::main::tab::page::navigation
History( History(
sqlite3 * db, sqlite3 * db,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_PAGE_NAVIGATION_HISTORY_BACK, const Glib::RefPtr<Gio::SimpleAction> & ACTION__HISTORY_BACK,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_PAGE_NAVIGATION_HISTORY_FORWARD const Glib::RefPtr<Gio::SimpleAction> & ACTION__HISTORY_FORWARD
); );
// Actions // Actions

8
src/app/browser/main/tab/page/navigation/reload.cpp

@ -3,10 +3,10 @@
using namespace app::browser::main::tab::page::navigation; using namespace app::browser::main::tab::page::navigation;
Reload::Reload( Reload::Reload(
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_PAGE_NAVIGATION_RELOAD const Glib::RefPtr<Gio::SimpleAction> & ACTION__RELOAD
) { ) {
// Init actions // Init actions
action__tab_page_navigation_reload = ACTION__TAB_PAGE_NAVIGATION_RELOAD; action__reload = ACTION__RELOAD;
// Init widget // Init widget
set_icon_name( set_icon_name(
@ -24,7 +24,7 @@ Reload::Reload(
signal_clicked().connect( signal_clicked().connect(
[this] [this]
{ {
action__tab_page_navigation_reload->activate(); action__reload->activate();
} }
); );
} }
@ -36,7 +36,7 @@ void Reload::update(
!REQUEST_TEXT.empty() !REQUEST_TEXT.empty()
); );
action__tab_page_navigation_reload->set_enabled( action__reload->set_enabled(
!REQUEST_TEXT.empty() !REQUEST_TEXT.empty()
); );
} }

4
src/app/browser/main/tab/page/navigation/reload.hpp

@ -10,12 +10,12 @@ namespace app::browser::main::tab::page::navigation
{ {
class Reload : public Gtk::Button class Reload : public Gtk::Button
{ {
Glib::RefPtr<Gio::SimpleAction> action__tab_page_navigation_reload; Glib::RefPtr<Gio::SimpleAction> action__reload;
public: public:
Reload( Reload(
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_PAGE_NAVIGATION_RELOAD const Glib::RefPtr<Gio::SimpleAction> & ACTION__RELOAD
); );
void update( void update(

8
src/app/browser/main/tab/page/navigation/request.cpp

@ -5,8 +5,8 @@ using namespace app::browser::main::tab::page::navigation;
// Construct // Construct
Request::Request( Request::Request(
sqlite3 * db, sqlite3 * db,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__UPDATE, const Glib::RefPtr<Gio::SimpleAction> & ACTION__RELOAD,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_PAGE_NAVIGATION_RELOAD const Glib::RefPtr<Gio::SimpleAction> & ACTION__UPDATE
) { ) {
// Init database // Init database
DB::SESSION::init( DB::SESSION::init(
@ -14,8 +14,8 @@ Request::Request(
); );
// Init actions // Init actions
action__reload = ACTION__RELOAD;
action__update = ACTION__UPDATE; action__update = ACTION__UPDATE;
action__tab_page_navigation_reload = ACTION__TAB_PAGE_NAVIGATION_RELOAD;
// Init extras // Init extras
progress_fraction = 0; progress_fraction = 0;
@ -44,7 +44,7 @@ Request::Request(
signal_activate().connect( signal_activate().connect(
[this] [this]
{ {
action__tab_page_navigation_reload->activate(); action__reload->activate();
} }
); );
} }

8
src/app/browser/main/tab/page/navigation/request.hpp

@ -61,8 +61,8 @@ namespace app::browser::main::tab::page::navigation
sqlite3 * db; sqlite3 * db;
// Actions // Actions
Glib::RefPtr<Gio::SimpleAction> action__update, Glib::RefPtr<Gio::SimpleAction> action__reload,
action__tab_page_navigation_reload; action__update;
// Extras // Extras
double progress_fraction; double progress_fraction;
@ -80,8 +80,8 @@ namespace app::browser::main::tab::page::navigation
Request( Request(
sqlite3 * db, sqlite3 * db,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__UPDATE, const Glib::RefPtr<Gio::SimpleAction> & ACTION__RELOAD,
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_PAGE_NAVIGATION_RELOAD const Glib::RefPtr<Gio::SimpleAction> & ACTION__UPDATE
); );
// Actions // Actions

Loading…
Cancel
Save