diff --git a/gtk/.clang-format b/gtk/.clang-format new file mode 100644 index 000000000..462033ba4 --- /dev/null +++ b/gtk/.clang-format @@ -0,0 +1,28 @@ +--- +BasedOnStyle: InheritParentConfig + +IncludeBlocks: Regroup +IncludeCategories: + - Regex: '^' + Priority: 3 + SortPriority: 3 + - Regex: '^' + Priority: 10 + - Regex: '^<(arpa|sys)/' + Priority: 11 + - Regex: '^<[a-z_]+>' + Priority: 7 + - Regex: '.*' + Priority: 2 +SortIncludes: CaseInsensitive diff --git a/gtk/Actions.cc b/gtk/Actions.cc index da3b1aff8..608fdbe36 100644 --- a/gtk/Actions.cc +++ b/gtk/Actions.cc @@ -3,23 +3,24 @@ // or any future license endorsed by Mnemosyne LLC. // License text can be found in the licenses/ folder. +#include "Actions.h" + +#include "Prefs.h" +#include "PrefsDialog.h" +#include "Session.h" +#include "Utils.h" + +#include + +#include +#include + #include #include #include #include #include -#include -#include - -#include - -#include "Actions.h" -#include "Prefs.h" -#include "PrefsDialog.h" -#include "Session.h" -#include "Utils.h" - using namespace std::string_view_literals; using VariantString = Glib::Variant; diff --git a/gtk/Actions.h b/gtk/Actions.h index ca42326b9..a5ea07b9b 100644 --- a/gtk/Actions.h +++ b/gtk/Actions.h @@ -5,10 +5,10 @@ #pragma once -#include - #include "Utils.h" +#include + class Session; Glib::RefPtr gtr_actions_init(Glib::RefPtr const& builder, gpointer callback_user_data); diff --git a/gtk/Application.cc b/gtk/Application.cc index 7c8e0e5a9..84feacf67 100644 --- a/gtk/Application.cc +++ b/gtk/Application.cc @@ -2,38 +2,9 @@ // It may be used under the MIT (SPDX: MIT) license. // License text can be found in the licenses/ folder. -#include -#include -#include // exit() -#include -#include // std::back_inserter -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#ifdef G_OS_UNIX -#include -#endif -#include - -#include - -#include -#include -#include -#include +#include "Application.h" #include "Actions.h" -#include "Application.h" #include "DetailsDialog.h" #include "Dialogs.h" #include "FilterBar.h" @@ -52,6 +23,37 @@ #include "Torrent.h" #include "Utils.h" +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include +#include +#include // exit() +#include +#include // std::back_inserter +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#ifdef G_OS_UNIX +#include +#endif + using namespace std::literals; #if GTKMM_CHECK_VERSION(4, 0, 0) diff --git a/gtk/Application.h b/gtk/Application.h index 579ca376e..5ba7194dd 100644 --- a/gtk/Application.h +++ b/gtk/Application.h @@ -4,14 +4,14 @@ #pragma once -#include -#include -#include +#include #include #include -#include +#include +#include +#include class Application : public Gtk::Application { diff --git a/gtk/DetailsDialog.cc b/gtk/DetailsDialog.cc index 623f18f8e..9641ca0d8 100644 --- a/gtk/DetailsDialog.cc +++ b/gtk/DetailsDialog.cc @@ -3,12 +3,25 @@ // or any future license endorsed by Mnemosyne LLC. // License text can be found in the licenses/ folder. -#ifdef _WIN32 -#include -#include -#else -#include -#endif +#include "DetailsDialog.h" + +#include "Actions.h" +#include "FaviconCache.h" // gtr_get_favicon() +#include "FileList.h" +#include "HigWorkarea.h" // GUI_PAD, GUI_PAD_BIG, GUI_PAD_SMALL +#include "Prefs.h" +#include "PrefsDialog.h" +#include "Session.h" +#include "Utils.h" + +#include +#include + +#include + +#include +#include +#include #include #include @@ -22,25 +35,12 @@ #include #include -#include - -#include -#include -#include - -#include -#include -#include - -#include "Actions.h" -#include "DetailsDialog.h" -#include "FaviconCache.h" // gtr_get_favicon() -#include "FileList.h" -#include "HigWorkarea.h" // GUI_PAD, GUI_PAD_BIG, GUI_PAD_SMALL -#include "Prefs.h" -#include "PrefsDialog.h" -#include "Session.h" -#include "Utils.h" +#ifdef _WIN32 +#include +#include +#else +#include +#endif using namespace std::literals; diff --git a/gtk/DetailsDialog.h b/gtk/DetailsDialog.h index 54c33a8a3..27a1c0628 100644 --- a/gtk/DetailsDialog.h +++ b/gtk/DetailsDialog.h @@ -5,13 +5,14 @@ #pragma once -#include -#include +#include +#include #include #include -#include +#include +#include class Session; diff --git a/gtk/Dialogs.cc b/gtk/Dialogs.cc index 74bc51af1..58fdf4ad4 100644 --- a/gtk/Dialogs.cc +++ b/gtk/Dialogs.cc @@ -2,19 +2,18 @@ // It may be used under the MIT (SPDX: MIT) license. // License text can be found in the licenses/ folder. -#include -#include +#include "Dialogs.h" + +#include "Session.h" +#include "Utils.h" #include #include #include -#include - -#include "Dialogs.h" -#include "Session.h" -#include "Utils.h" +#include +#include /*** **** diff --git a/gtk/Dialogs.h b/gtk/Dialogs.h index 83a5c9638..d383bc2c7 100644 --- a/gtk/Dialogs.h +++ b/gtk/Dialogs.h @@ -4,10 +4,12 @@ #pragma once -#include +#include #include +#include + class Session; /** diff --git a/gtk/FaviconCache.cc b/gtk/FaviconCache.cc index dd5c69257..2bb65bc78 100644 --- a/gtk/FaviconCache.cc +++ b/gtk/FaviconCache.cc @@ -3,6 +3,16 @@ // or any future license endorsed by Mnemosyne LLC. // License text can be found in the licenses/ folder. +#include "FaviconCache.h" + +#include "Utils.h" /* gtr_get_host_from_url() */ + +#include +#include +#include // tr_sessionFetch() + +#include + #include #include #include @@ -11,15 +21,6 @@ #include /* g_remove() */ -#include - -#include -#include // tr_sessionFetch() -#include - -#include "FaviconCache.h" -#include "Utils.h" /* gtr_get_host_from_url() */ - using namespace std::literals; namespace diff --git a/gtk/FaviconCache.h b/gtk/FaviconCache.h index 27f512b26..3110806a8 100644 --- a/gtk/FaviconCache.h +++ b/gtk/FaviconCache.h @@ -5,13 +5,13 @@ #pragma once -#include -#include +#include #include #include -#include +#include +#include void gtr_get_favicon( tr_session* session, diff --git a/gtk/FileList.cc b/gtk/FileList.cc index c1930edfa..28c962556 100644 --- a/gtk/FileList.cc +++ b/gtk/FileList.cc @@ -3,6 +3,21 @@ // or any future license endorsed by Mnemosyne LLC. // License text can be found in the licenses/ folder. +#include "FileList.h" + +#include "HigWorkarea.h" // GUI_PAD, GUI_PAD_BIG +#include "IconCache.h" +#include "PrefsDialog.h" +#include "Session.h" +#include "Utils.h" + +#include + +#include +#include + +#include + #include #include #include @@ -14,21 +29,6 @@ #include #include -#include -#include - -#include - -#include -#include - -#include "FileList.h" -#include "HigWorkarea.h" // GUI_PAD, GUI_PAD_BIG -#include "IconCache.h" -#include "PrefsDialog.h" -#include "Session.h" -#include "Utils.h" - using namespace std::literals; namespace diff --git a/gtk/FileList.h b/gtk/FileList.h index d1e0f4318..9fb199de4 100644 --- a/gtk/FileList.h +++ b/gtk/FileList.h @@ -5,11 +5,12 @@ #pragma once -#include +#include +#include #include -#include +#include class Session; diff --git a/gtk/FilterBar.cc b/gtk/FilterBar.cc index 6b30e7810..578a49668 100644 --- a/gtk/FilterBar.cc +++ b/gtk/FilterBar.cc @@ -3,6 +3,21 @@ // or any future license endorsed by Mnemosyne LLC. // License text can be found in the licenses/ folder. +#include "FilterBar.h" + +#include "FaviconCache.h" // gtr_get_favicon() +#include "HigWorkarea.h" // GUI_PAD +#include "ListModelAdapter.h" +#include "Session.h" // torrent_cols +#include "Torrent.h" +#include "TorrentFilter.h" +#include "Utils.h" + +#include +#include + +#include + #include // std::transform() #include #include @@ -10,20 +25,6 @@ #include #include -#include -#include - -#include - -#include "FaviconCache.h" // gtr_get_favicon() -#include "FilterBar.h" -#include "HigWorkarea.h" // GUI_PAD -#include "ListModelAdapter.h" -#include "Session.h" // torrent_cols -#include "Torrent.h" -#include "TorrentFilter.h" -#include "Utils.h" - class FilterBar::Impl { using FilterModel = IF_GTKMM4(Gtk::FilterListModel, Gtk::TreeModelFilter); diff --git a/gtk/FilterBar.h b/gtk/FilterBar.h index c808b2076..561d4d827 100644 --- a/gtk/FilterBar.h +++ b/gtk/FilterBar.h @@ -5,14 +5,14 @@ #pragma once -#include +#include "Utils.h" + +#include #include #include -#include - -#include "Utils.h" +#include class Session; diff --git a/gtk/FreeSpaceLabel.cc b/gtk/FreeSpaceLabel.cc index 5c84bfc78..c2a3551a1 100644 --- a/gtk/FreeSpaceLabel.cc +++ b/gtk/FreeSpaceLabel.cc @@ -3,19 +3,20 @@ // or any future license endorsed by Mnemosyne LLC. // License text can be found in the licenses/ folder. -#include -#include -#include +#include "FreeSpaceLabel.h" + +#include "Session.h" +#include "Utils.h" + +#include #include #include -#include - -#include "FreeSpaceLabel.h" -#include "Session.h" -#include "Utils.h" +#include +#include +#include class FreeSpaceLabel::Impl { diff --git a/gtk/FreeSpaceLabel.h b/gtk/FreeSpaceLabel.h index 59b57847b..dbc05b82f 100644 --- a/gtk/FreeSpaceLabel.h +++ b/gtk/FreeSpaceLabel.h @@ -3,13 +3,13 @@ // or any future license endorsed by Mnemosyne LLC. // License text can be found in the licenses/ folder. -#include -#include +#include #include #include -#include +#include +#include class Session; diff --git a/gtk/IconCache.cc b/gtk/IconCache.cc index 10940c864..99ead67d9 100644 --- a/gtk/IconCache.cc +++ b/gtk/IconCache.cc @@ -5,18 +5,19 @@ * */ +#include "IconCache.h" + +#include "Utils.h" + +#include +#include + #include #include #include #include #include -#include -#include - -#include "IconCache.h" -#include "Utils.h" - using namespace std::literals; using IconCache = std::map, std::less<>>; diff --git a/gtk/IconCache.h b/gtk/IconCache.h index b7d913965..cf672bd93 100644 --- a/gtk/IconCache.h +++ b/gtk/IconCache.h @@ -7,10 +7,10 @@ #pragma once -#include - #include +#include + extern std::string_view const DirectoryMimeType; extern std::string_view const UnknownMimeType; diff --git a/gtk/ListModelAdapter.h b/gtk/ListModelAdapter.h index ff530a265..583b179b6 100644 --- a/gtk/ListModelAdapter.h +++ b/gtk/ListModelAdapter.h @@ -5,14 +5,14 @@ #pragma once -#include -#include -#include +#include "Utils.h" #include #include -#include "Utils.h" +#include +#include +#include class ListModelAdapter : public Gtk::TreeModel diff --git a/gtk/MainWindow.cc b/gtk/MainWindow.cc index 560d3c8c5..a4b65e23a 100644 --- a/gtk/MainWindow.cc +++ b/gtk/MainWindow.cc @@ -2,19 +2,11 @@ // It may be used under the MIT (SPDX: MIT) license. // License text can be found in the licenses/ folder. -#include -#include -#include - -#include - -#include -#include // tr_formatter_speed_KBps() +#include "MainWindow.h" #include "Actions.h" #include "FilterBar.h" #include "ListModelAdapter.h" -#include "MainWindow.h" #include "Prefs.h" #include "PrefsDialog.h" #include "Session.h" @@ -22,6 +14,15 @@ #include "TorrentCellRenderer.h" #include "Utils.h" +#include +#include // tr_formatter_speed_KBps() + +#include + +#include +#include +#include + using namespace std::string_literals; using namespace std::string_view_literals; diff --git a/gtk/MainWindow.h b/gtk/MainWindow.h index 57dae1680..d04274bcb 100644 --- a/gtk/MainWindow.h +++ b/gtk/MainWindow.h @@ -4,12 +4,12 @@ #pragma once -#include +#include #include #include -#include +#include class Session; class Torrent; diff --git a/gtk/MakeDialog.cc b/gtk/MakeDialog.cc index 3bd34bc76..cc40d5323 100644 --- a/gtk/MakeDialog.cc +++ b/gtk/MakeDialog.cc @@ -3,6 +3,23 @@ // or any future license endorsed by Mnemosyne LLC. // License text can be found in the licenses/ folder. +#include "MakeDialog.h" + +#include "PathButton.h" +#include "PrefsDialog.h" +#include "Session.h" +#include "Utils.h" + +#include +#include +#include +#include /* tr_formatter_mem_B() */ + +#include +#include + +#include + #include #include #include @@ -10,23 +27,6 @@ #include #include -#include -#include - -#include - -#include - -#include -#include -#include /* tr_formatter_mem_B() */ - -#include "PathButton.h" -#include "MakeDialog.h" -#include "PrefsDialog.h" -#include "Session.h" -#include "Utils.h" - using namespace std::literals; #if GTKMM_CHECK_VERSION(4, 0, 0) diff --git a/gtk/MakeDialog.h b/gtk/MakeDialog.h index b638f191e..b815f7b51 100644 --- a/gtk/MakeDialog.h +++ b/gtk/MakeDialog.h @@ -5,11 +5,11 @@ #pragma once -#include +#include #include -#include +#include class Session; diff --git a/gtk/MessageLogWindow.cc b/gtk/MessageLogWindow.cc index e9717d896..938e9417f 100644 --- a/gtk/MessageLogWindow.cc +++ b/gtk/MessageLogWindow.cc @@ -3,9 +3,16 @@ // or any future license endorsed by Mnemosyne LLC. // License text can be found in the licenses/ folder. -#include -#include -#include +#include "MessageLogWindow.h" + +#include "Actions.h" +#include "Prefs.h" +#include "PrefsDialog.h" +#include "Session.h" +#include "Utils.h" + +#include +#include #include #include @@ -13,15 +20,9 @@ #include #include -#include -#include - -#include "Actions.h" -#include "MessageLogWindow.h" -#include "Prefs.h" -#include "PrefsDialog.h" -#include "Session.h" -#include "Utils.h" +#include +#include +#include class MessageLogColumnsModel : public Gtk::TreeModelColumnRecord { diff --git a/gtk/MessageLogWindow.h b/gtk/MessageLogWindow.h index b5c64d70a..116124869 100644 --- a/gtk/MessageLogWindow.h +++ b/gtk/MessageLogWindow.h @@ -5,11 +5,11 @@ #pragma once -#include +#include #include -#include +#include class Session; diff --git a/gtk/Notify.cc b/gtk/Notify.cc index 10c2d38df..319b0fdbb 100644 --- a/gtk/Notify.cc +++ b/gtk/Notify.cc @@ -3,20 +3,21 @@ // or any future license endorsed by Mnemosyne LLC. // License text can be found in the licenses/ folder. -#include -#include -#include +#include "Notify.h" + +#include "Prefs.h" +#include "PrefsDialog.h" +#include "Session.h" +#include "Utils.h" #include #include #include -#include "Notify.h" -#include "Prefs.h" -#include "PrefsDialog.h" -#include "Session.h" -#include "Utils.h" +#include +#include +#include using namespace std::literals; diff --git a/gtk/Notify.h b/gtk/Notify.h index b9f48dc8e..0291d0fe0 100644 --- a/gtk/Notify.h +++ b/gtk/Notify.h @@ -5,10 +5,10 @@ #pragma once -#include - #include +#include + class Session; void gtr_notify_init(); diff --git a/gtk/OptionsDialog.cc b/gtk/OptionsDialog.cc index 4354a0264..72c504c25 100644 --- a/gtk/OptionsDialog.cc +++ b/gtk/OptionsDialog.cc @@ -3,24 +3,25 @@ // or any future license endorsed by Mnemosyne LLC. // License text can be found in the licenses/ folder. -#include -#include - -#include -#include - -#include -#include /* tr_sys_path_is_same() */ +#include "OptionsDialog.h" #include "FileList.h" #include "FreeSpaceLabel.h" -#include "OptionsDialog.h" #include "PathButton.h" #include "Prefs.h" #include "PrefsDialog.h" #include "Session.h" #include "Utils.h" /* gtr_priority_combo_get_value() */ +#include +#include /* tr_sys_path_is_same() */ + +#include +#include + +#include +#include + using namespace std::string_view_literals; /**** diff --git a/gtk/OptionsDialog.h b/gtk/OptionsDialog.h index f01bac7b4..c46fa32cd 100644 --- a/gtk/OptionsDialog.h +++ b/gtk/OptionsDialog.h @@ -5,11 +5,11 @@ #pragma once -#include +#include #include -#include +#include class Session; typedef struct tr_ctor tr_ctor; diff --git a/gtk/PathButton.cc b/gtk/PathButton.cc index 7c7e6d6df..3cc7b81b4 100644 --- a/gtk/PathButton.cc +++ b/gtk/PathButton.cc @@ -3,12 +3,12 @@ // or any future license endorsed by Mnemosyne LLC. // License text can be found in the licenses/ folder. -#include +#include "PathButton.h" #include #include -#include "PathButton.h" +#include class PathButton::Impl { diff --git a/gtk/PathButton.h b/gtk/PathButton.h index a3e004f40..375346bce 100644 --- a/gtk/PathButton.h +++ b/gtk/PathButton.h @@ -5,15 +5,15 @@ #pragma once -#include -#include -#include - -#include +#include "Utils.h" #include -#include "Utils.h" +#include + +#include +#include +#include class PathButton : public IF_GTKMM4(Gtk::Button, Gtk::FileChooserButton) { diff --git a/gtk/Prefs.cc b/gtk/Prefs.cc index 3e7fc428b..d9dcc480b 100644 --- a/gtk/Prefs.cc +++ b/gtk/Prefs.cc @@ -2,20 +2,20 @@ // It may be used under the MIT (SPDX: MIT) license. // License text can be found in the licenses/ folder. -#include -#include +#include "Prefs.h" + +#include "PrefsDialog.h" +#include "Utils.h" + +#include +#include +#include #include #include -#include - -#include -#include - -#include "Prefs.h" -#include "PrefsDialog.h" -#include "Utils.h" +#include +#include using namespace std::literals; diff --git a/gtk/Prefs.h b/gtk/Prefs.h index 1a1c6fe6b..e2d40fa31 100644 --- a/gtk/Prefs.h +++ b/gtk/Prefs.h @@ -4,14 +4,14 @@ #pragma once +#include /* tr_variant, tr_session */ +#include + #include // int64_t #include #include #include -#include /* tr_variant, tr_session */ -#include - void gtr_pref_init(std::string_view config_dir); int64_t gtr_pref_int_get(tr_quark const key); diff --git a/gtk/PrefsDialog.cc b/gtk/PrefsDialog.cc index 05d0774a0..97343ae60 100644 --- a/gtk/PrefsDialog.cc +++ b/gtk/PrefsDialog.cc @@ -3,28 +3,29 @@ // or any future license endorsed by Mnemosyne LLC. // License text can be found in the licenses/ folder. -#include -#include -#include -#include -#include +#include "PrefsDialog.h" + +#include "FreeSpaceLabel.h" +#include "PathButton.h" +#include "Prefs.h" +#include "Session.h" +#include "SystemTrayIcon.h" +#include "Utils.h" + +#include +#include +#include #include #include #include -#include -#include -#include - -#include "FreeSpaceLabel.h" -#include "PathButton.h" -#include "Prefs.h" -#include "PrefsDialog.h" -#include "Session.h" -#include "SystemTrayIcon.h" -#include "Utils.h" +#include +#include +#include +#include +#include /** *** diff --git a/gtk/PrefsDialog.h b/gtk/PrefsDialog.h index 00e38b759..94dbd1834 100644 --- a/gtk/PrefsDialog.h +++ b/gtk/PrefsDialog.h @@ -5,11 +5,11 @@ #pragma once -#include +#include #include -#include +#include class Session; diff --git a/gtk/RelocateDialog.cc b/gtk/RelocateDialog.cc index aecca6785..6b4919e8b 100644 --- a/gtk/RelocateDialog.cc +++ b/gtk/RelocateDialog.cc @@ -3,21 +3,20 @@ // or any future license endorsed by Mnemosyne LLC. // License text can be found in the licenses/ folder. -#include -#include +#include "RelocateDialog.h" + +#include "PathButton.h" +#include "Prefs.h" /* gtr_pref_string_get */ +#include "Session.h" +#include "Utils.h" #include #include #include -#include - -#include "PathButton.h" -#include "Prefs.h" /* gtr_pref_string_get */ -#include "RelocateDialog.h" -#include "Session.h" -#include "Utils.h" +#include +#include namespace { diff --git a/gtk/RelocateDialog.h b/gtk/RelocateDialog.h index be1de6846..624654ce0 100644 --- a/gtk/RelocateDialog.h +++ b/gtk/RelocateDialog.h @@ -5,12 +5,13 @@ #pragma once -#include -#include +#include +#include #include -#include +#include +#include class Session; diff --git a/gtk/Session.cc b/gtk/Session.cc index 92735f1df..e21079a79 100644 --- a/gtk/Session.cc +++ b/gtk/Session.cc @@ -2,10 +2,34 @@ // This file is licensed under the MIT (SPDX: MIT) license, // A copy of this license can be found in licenses/ . +#include "Session.h" + +#include "Actions.h" +#include "ListModelAdapter.h" +#include "Notify.h" +#include "Prefs.h" +#include "PrefsDialog.h" +#include "Torrent.h" +#include "TorrentSorter.h" +#include "Utils.h" + +#include +#include +#include +#include +#include +#include // tr_time() +#include +#include // tr_urlIsValid() + +#include + +#include + #include +#include // PRId64 #include // pow() #include // strstr -#include // PRId64 #include #include #include @@ -14,32 +38,6 @@ #include #include -#include - -#include - -#include - -#include - -#include -#include -#include -#include -#include // tr_time() -#include // tr_urlIsValid() -#include - -#include "Actions.h" -#include "ListModelAdapter.h" -#include "Notify.h" -#include "Prefs.h" -#include "PrefsDialog.h" -#include "Session.h" -#include "Torrent.h" -#include "TorrentSorter.h" -#include "Utils.h" - using namespace std::literals; namespace diff --git a/gtk/Session.h b/gtk/Session.h index 57b6f9fc6..cf031038e 100644 --- a/gtk/Session.h +++ b/gtk/Session.h @@ -4,22 +4,22 @@ #pragma once -#include -#include -#include -#include -#include - -#include -#include -#include +#include "Torrent.h" +#include "Utils.h" #include #include #include -#include "Torrent.h" -#include "Utils.h" +#include +#include +#include + +#include +#include +#include +#include +#include class Session : public Glib::Object { diff --git a/gtk/StatsDialog.cc b/gtk/StatsDialog.cc index 4a0adec78..a90f488b2 100644 --- a/gtk/StatsDialog.cc +++ b/gtk/StatsDialog.cc @@ -3,17 +3,18 @@ // or any future license endorsed by Mnemosyne LLC. // License text can be found in the licenses/ folder. -#include +#include "StatsDialog.h" + +#include "PrefsDialog.h" +#include "Session.h" +#include "Utils.h" #include #include #include -#include "PrefsDialog.h" -#include "Session.h" -#include "StatsDialog.h" -#include "Utils.h" +#include static auto constexpr TR_RESPONSE_RESET = int{ 1 }; diff --git a/gtk/StatsDialog.h b/gtk/StatsDialog.h index c0ff9b301..8798ff76c 100644 --- a/gtk/StatsDialog.h +++ b/gtk/StatsDialog.h @@ -5,11 +5,11 @@ #pragma once -#include +#include #include -#include +#include class Session; diff --git a/gtk/SystemTrayIcon.cc b/gtk/SystemTrayIcon.cc index 46179c9e6..b68c993e9 100644 --- a/gtk/SystemTrayIcon.cc +++ b/gtk/SystemTrayIcon.cc @@ -8,11 +8,20 @@ // We're using deprecated Gtk::StatusItem ourselves as well #undef GTKMM_DISABLE_DEPRECATED -#include +#include "SystemTrayIcon.h" + +#include "Actions.h" +#include "Session.h" +#include "Utils.h" + +#include +#include #include #include +#include + #ifdef HAVE_APPINDICATOR #ifdef APPINDICATOR_IS_AYATANA #include @@ -21,14 +30,6 @@ #endif #endif -#include -#include - -#include "Actions.h" -#include "Session.h" -#include "SystemTrayIcon.h" -#include "Utils.h" - #ifdef HAVE_APPINDICATOR #define TR_SYS_TRAY_IMPL_APPINDICATOR #elif !GTKMM_CHECK_VERSION(4, 0, 0) diff --git a/gtk/SystemTrayIcon.h b/gtk/SystemTrayIcon.h index 1e7d0d0b9..24ba5be0e 100644 --- a/gtk/SystemTrayIcon.h +++ b/gtk/SystemTrayIcon.h @@ -5,11 +5,11 @@ #pragma once -#include +#include #include -#include +#include class Session; diff --git a/gtk/Torrent.cc b/gtk/Torrent.cc index ba71e94d9..07dd6dbca 100644 --- a/gtk/Torrent.cc +++ b/gtk/Torrent.cc @@ -3,17 +3,20 @@ // or any future license endorsed by Mnemosyne LLC. // License text can be found in the licenses/ folder. -#include -#include +#include "Torrent.h" -#include +#include "IconCache.h" +#include "Utils.h" #include #include -#include "IconCache.h" -#include "Torrent.h" -#include "Utils.h" +#include + +#include + +#include +#include using namespace std::string_view_literals; diff --git a/gtk/Torrent.h b/gtk/Torrent.h index c6bcb14db..5f3a82e07 100644 --- a/gtk/Torrent.h +++ b/gtk/Torrent.h @@ -5,19 +5,19 @@ #pragma once +#include "Flags.h" + +#include + +#include +#include + #include #include #include #include #include -#include -#include - -#include - -#include "Flags.h" - class Torrent : public Glib::Object { public: diff --git a/gtk/TorrentCellRenderer.cc b/gtk/TorrentCellRenderer.cc index d553702ce..628772e99 100644 --- a/gtk/TorrentCellRenderer.cc +++ b/gtk/TorrentCellRenderer.cc @@ -3,6 +3,20 @@ // or any future license endorsed by Mnemosyne LLC. // License text can be found in the licenses/ folder. +#include "TorrentCellRenderer.h" + +#include "HigWorkarea.h" // GUI_PAD, GUI_PAD_SMALL +#include "Torrent.h" +#include "Utils.h" + +#include +#include /* tr_truncd() */ + +#include +#include + +#include + #include // std::max() #include // strchr() #include @@ -10,19 +24,6 @@ #include #include -#include -#include - -#include - -#include -#include /* tr_truncd() */ - -#include "HigWorkarea.h" // GUI_PAD, GUI_PAD_SMALL -#include "Torrent.h" -#include "TorrentCellRenderer.h" -#include "Utils.h" - /* #define TEST_RTL */ /*** diff --git a/gtk/TorrentCellRenderer.h b/gtk/TorrentCellRenderer.h index 897db2974..4d2743576 100644 --- a/gtk/TorrentCellRenderer.h +++ b/gtk/TorrentCellRenderer.h @@ -5,14 +5,14 @@ #pragma once -#include +#include "Utils.h" + +#include #include #include -#include - -#include "Utils.h" +#include class Torrent; diff --git a/gtk/TorrentFilter.cc b/gtk/TorrentFilter.cc index b943aa21f..b17435283 100644 --- a/gtk/TorrentFilter.cc +++ b/gtk/TorrentFilter.cc @@ -3,11 +3,9 @@ // or any future license endorsed by Mnemosyne LLC. // License text can be found in the licenses/ folder. -#include - -#include "Torrent.h" #include "TorrentFilter.h" -#include "Utils.h" + +#include void TorrentFilter::set_activity(Activity type) { diff --git a/gtk/TorrentFilter.h b/gtk/TorrentFilter.h index 57aa2158f..51b0402f5 100644 --- a/gtk/TorrentFilter.h +++ b/gtk/TorrentFilter.h @@ -5,11 +5,10 @@ #pragma once -#include - +#include "Torrent.h" #include "Utils.h" -class Torrent; +#include class TorrentFilter : public IF_GTKMM4(Gtk::Filter, Glib::Object) { diff --git a/gtk/TorrentSorter.cc b/gtk/TorrentSorter.cc index 29aaa7143..a1d8eb27c 100644 --- a/gtk/TorrentSorter.cc +++ b/gtk/TorrentSorter.cc @@ -3,12 +3,11 @@ // or any future license endorsed by Mnemosyne LLC. // License text can be found in the licenses/ folder. -#include +#include "TorrentSorter.h" #include -#include "Torrent.h" -#include "TorrentSorter.h" +#include using namespace std::string_view_literals; diff --git a/gtk/TorrentSorter.h b/gtk/TorrentSorter.h index de28f20ce..2c8f4773c 100644 --- a/gtk/TorrentSorter.h +++ b/gtk/TorrentSorter.h @@ -5,12 +5,11 @@ #pragma once -#include -#include - +#include "Torrent.h" #include "Utils.h" -class Torrent; +#include +#include class TorrentSorter : public IF_GTKMM4(Gtk::Sorter, Glib::Object) { diff --git a/gtk/Utils.cc b/gtk/Utils.cc index d094610a2..08c73fb74 100644 --- a/gtk/Utils.cc +++ b/gtk/Utils.cc @@ -3,6 +3,24 @@ // or any future license endorsed by Mnemosyne LLC. // License text can be found in the licenses/ folder. +#include "Utils.h" + +#include "Prefs.h" +#include "PrefsDialog.h" +#include "Session.h" + +#include /* TR_RATIO_NA, TR_RATIO_INF */ +#include +#include +#include /* tr_strratio() */ +#include /* SHORT_VERSION_STRING */ +#include + +#include /* g_file_trash() */ +#include + +#include + #include #include #include @@ -10,30 +28,13 @@ #include #include -#include /* g_file_trash() */ -#include - #include #include + #if GTK_CHECK_VERSION(4, 0, 0) && defined(GDK_WINDOWING_X11) #include #endif -#include - -#include /* TR_RATIO_NA, TR_RATIO_INF */ - -#include -#include -#include /* tr_strratio() */ -#include /* SHORT_VERSION_STRING */ -#include - -#include "Prefs.h" -#include "PrefsDialog.h" -#include "Session.h" -#include "Utils.h" - using namespace std::literals; /*** diff --git a/gtk/Utils.h b/gtk/Utils.h index 49927ea40..e912b2725 100644 --- a/gtk/Utils.h +++ b/gtk/Utils.h @@ -5,6 +5,15 @@ #pragma once +#include +#include + +#include +#include + +#include +#include + #include #include #include @@ -16,15 +25,6 @@ #include -#include -#include - -#include -#include - -#include -#include - /*** **** ***/ diff --git a/gtk/main.cc b/gtk/main.cc index 5557000e0..78f94ebe2 100644 --- a/gtk/main.cc +++ b/gtk/main.cc @@ -2,10 +2,14 @@ // It may be used under the MIT (SPDX: MIT) license. // License text can be found in the licenses/ folder. -#include -#include -#include -#include +#include "Application.h" +#include "Notify.h" +#include "Prefs.h" +#include "Utils.h" + +#include +#include +#include #include #include @@ -13,14 +17,10 @@ #include -#include -#include -#include - -#include "Application.h" -#include "Notify.h" -#include "Prefs.h" -#include "Utils.h" +#include +#include +#include +#include namespace { diff --git a/libtransmission/announcer.cc b/libtransmission/announcer.cc index b669dd58f..67860c41a 100644 --- a/libtransmission/announcer.cc +++ b/libtransmission/announcer.cc @@ -1008,7 +1008,7 @@ static void on_announce_error(tr_tier* tier, char const* err, tr_announce_event tr_logAddWarnTier( tier, fmt::format( - ngettext( + tr_ngettext( "Announce error: {error} (Retrying in {count} second)", "Announce error: {error} (Retrying in {count} seconds)", interval), diff --git a/libtransmission/blocklist.cc b/libtransmission/blocklist.cc index 8fd0ae270..17cbba42f 100644 --- a/libtransmission/blocklist.cc +++ b/libtransmission/blocklist.cc @@ -63,7 +63,7 @@ void save(std::string_view filename, address_range_t const* ranges, size_t n_ran else { tr_logAddInfo(fmt::format( - ngettext("Blocklist '{path}' has {count} entry", "Blocklist '{path}' has {count} entries", n_ranges), + tr_ngettext("Blocklist '{path}' has {count} entry", "Blocklist '{path}' has {count} entries", n_ranges), fmt::arg("path", tr_sys_path_basename(filename)), fmt::arg("count", n_ranges))); } @@ -397,7 +397,7 @@ void Blocklist::ensureLoaded() const } tr_logAddInfo(fmt::format( - ngettext("Blocklist '{path}' has {count} entry", "Blocklist '{path}' has {count} entries", std::size(rules_)), + tr_ngettext("Blocklist '{path}' has {count} entry", "Blocklist '{path}' has {count} entries", std::size(rules_)), fmt::arg("path", tr_sys_path_basename(bin_file_)), fmt::arg("count", std::size(rules_)))); } diff --git a/libtransmission/rpc-server.cc b/libtransmission/rpc-server.cc index 5f67846bb..518ccefe3 100644 --- a/libtransmission/rpc-server.cc +++ b/libtransmission/rpc-server.cc @@ -706,7 +706,7 @@ static void startServer(tr_rpc_server* server) } tr_logAddError(fmt::format( - ngettext( + tr_ngettext( "Couldn't bind to {address} after {count} attempt, giving up", "Couldn't bind to {address} after {count} attempts, giving up", ServerStartRetryCount), diff --git a/libtransmission/session.cc b/libtransmission/session.cc index 8d95b2c03..fef303197 100644 --- a/libtransmission/session.cc +++ b/libtransmission/session.cc @@ -1324,7 +1324,7 @@ static void sessionLoadTorrents(tr_session* session, tr_ctor* ctor, std::promise if (n_torrents != 0U) { tr_logAddInfo(fmt::format( - ngettext("Loaded {count} torrent", "Loaded {count} torrents", n_torrents), + tr_ngettext("Loaded {count} torrent", "Loaded {count} torrents", n_torrents), fmt::arg("count", n_torrents))); } diff --git a/libtransmission/torrent-magnet.cc b/libtransmission/torrent-magnet.cc index 842361731..34911ce83 100644 --- a/libtransmission/torrent-magnet.cc +++ b/libtransmission/torrent-magnet.cc @@ -320,7 +320,7 @@ static void onHaveAllMetainfo(tr_torrent* tor, tr_incomplete_metadata* m) tr_logAddWarnTor( tor, fmt::format( - ngettext( + tr_ngettext( "Couldn't parse magnet metainfo: '{error}'. Redownloading {piece_count} piece", "Couldn't parse magnet metainfo: '{error}'. Redownloading {piece_count} pieces", n), diff --git a/libtransmission/utils.h b/libtransmission/utils.h index 55a277115..849db6e73 100644 --- a/libtransmission/utils.h +++ b/libtransmission/utils.h @@ -35,8 +35,10 @@ struct tr_error; #endif #endif -#if !defined(HAVE_NGETTEXT) -#define ngettext(singular, plural, count) ((count) == 1 ? (singular) : (plural)) +#if defined(HAVE_NGETTEXT) +#define tr_ngettext ngettext +#else +#define tr_ngettext(singular, plural, count) ((count) == 1 ? (singular) : (plural)) #endif /* #define DISABLE_GETTEXT */ @@ -47,9 +49,9 @@ struct tr_error; #endif #ifdef DISABLE_GETTEXT #undef _ -#undef ngettext +#undef tr_ngettext #define _(a) (a) -#define ngettext(singular, plural, count) ((count) == 1 ? (singular) : (plural)) +#define tr_ngettext(singular, plural, count) ((count) == 1 ? (singular) : (plural)) #endif /**** diff --git a/utils/create.cc b/utils/create.cc index bfa94577e..ffc4cde79 100644 --- a/utils/create.cc +++ b/utils/create.cc @@ -223,12 +223,15 @@ int tr_main(int argc, char* argv[]) } fmt::print( - ngettext("{file_count:L} file, {total_size}\n", "{file_count:L} files, {total_size}\n", builder.fileCount()), + tr_ngettext("{file_count:L} file, {total_size}\n", "{file_count:L} files, {total_size}\n", builder.fileCount()), fmt::arg("file_count", builder.fileCount()), fmt::arg("total_size", tr_formatter_size_B(builder.totalSize()))); fmt::print( - ngettext("{piece_count:L} piece, {piece_size}\n", "{piece_count:L} pieces, {piece_size} each\n", builder.pieceCount()), + tr_ngettext( + "{piece_count:L} piece, {piece_size}\n", + "{piece_count:L} pieces, {piece_size} each\n", + builder.pieceCount()), fmt::arg("piece_count", builder.pieceCount()), fmt::arg("piece_size", tr_formatter_size_B(builder.pieceSize()))); diff --git a/utils/remote.cc b/utils/remote.cc index bcaa08d0d..fd9e780b7 100644 --- a/utils/remote.cc +++ b/utils/remote.cc @@ -137,13 +137,13 @@ static std::string tr_strltime(time_t seconds) auto tmpstr = std::string{}; - auto const hstr = fmt::format(FMT_STRING("{:d} {:s}"), hours, ngettext("hour", "hours", hours)); - auto const mstr = fmt::format(FMT_STRING("{:d} {:s}"), minutes, ngettext("minute", "minutes", minutes)); - auto const sstr = fmt::format(FMT_STRING("{:d} {:s}"), seconds, ngettext("seconds", "seconds", seconds)); + auto const hstr = fmt::format(FMT_STRING("{:d} {:s}"), hours, tr_ngettext("hour", "hours", hours)); + auto const mstr = fmt::format(FMT_STRING("{:d} {:s}"), minutes, tr_ngettext("minute", "minutes", minutes)); + auto const sstr = fmt::format(FMT_STRING("{:d} {:s}"), seconds, tr_ngettext("seconds", "seconds", seconds)); if (days > 0) { - auto const dstr = fmt::format(FMT_STRING("{:d} {:s}"), hours, ngettext("day", "days", days)); + auto const dstr = fmt::format(FMT_STRING("{:d} {:s}"), hours, tr_ngettext("day", "days", days)); tmpstr = days >= 4 || hours == 0 ? dstr : fmt::format(FMT_STRING("{:s}, {:s}"), dstr, hstr); } else if (hours > 0) @@ -159,7 +159,7 @@ static std::string tr_strltime(time_t seconds) tmpstr = sstr; } - auto const totstr = fmt::format(FMT_STRING("{:d} {:s}"), total_seconds, ngettext("seconds", "seconds", total_seconds)); + auto const totstr = fmt::format(FMT_STRING("{:d} {:s}"), total_seconds, tr_ngettext("seconds", "seconds", total_seconds)); return fmt::format(FMT_STRING("{:s} ({:s})"), tmpstr, totstr); }