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. 38
      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 @@ -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`
* 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
* 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

4
src/app/browser.cpp

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

24
src/app/browser/main.cpp

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

12
src/app/browser/main.hpp

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Loading…
Cancel
Save