From bfa30ed79cffee4f5c0d33b7fe7bd64581be3fdf Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Fri, 30 May 2025 11:45:54 +0200 Subject: gui: reintroduce ParticipantRow --- .clang-format | 2 ++ gui/CMakeLists.txt | 14 ++++++++++---- gui/include/init.hpp | 14 ++++++++++++++ gui/include/participant_row.hpp | 16 ++++++++-------- gui/include/template_widget.hpp | 13 ++++++------- gui/src/init.cpp | 10 ++++++++++ gui/src/main.cpp | 3 +++ gui/src/participant_row.cpp | 31 ++++++++++++++++--------------- 8 files changed, 69 insertions(+), 34 deletions(-) create mode 100644 gui/include/init.hpp create mode 100644 gui/src/init.cpp diff --git a/.clang-format b/.clang-format index 7453904..08e060b 100644 --- a/.clang-format +++ b/.clang-format @@ -67,6 +67,8 @@ IncludeBlocks: Regroup IncludeCategories: # Local Headers - Regex: '^("|<)turns' + Priority: 110 + - Regex: '^"' Priority: 100 # sigc++ Headers - Regex: '^:-Wl,--whole-archive>" - "resources" - "$<$:-Wl,--no-whole-archive>" ) target_compile_definitions("gui_impl" PUBLIC @@ -109,6 +107,10 @@ target_include_directories("gui" PUBLIC target_link_libraries("gui" PUBLIC "gui_impl" + + "$<$:-Wl,--whole-archive>" + "resources" + "$<$:-Wl,--no-whole-archive>" ) set_target_properties("gui" PROPERTIES @@ -150,6 +152,10 @@ add_executable("gui-tests" target_link_libraries("gui-tests" PRIVATE "gui_impl" "Catch2::Catch2WithMain" + + "$<$:-Wl,--whole-archive>" + "resources" + "$<$:-Wl,--no-whole-archive>" ) target_compile_definitions("resources" PUBLIC diff --git a/gui/include/init.hpp b/gui/include/init.hpp new file mode 100644 index 0000000..d83544e --- /dev/null +++ b/gui/include/init.hpp @@ -0,0 +1,14 @@ +/* + * SPDX-FileCopyrightText: 2025 Felix Morgner + * SPDX-License-Identifier: LGPL-2.1-only + */ + +#ifndef TURNS_GUI_INIT_HPP +#define TURNS_GUI_INIT_HPP + +namespace Turns::gui +{ + auto init() -> void; +} // namespace Turns::gui + +#endif \ No newline at end of file diff --git a/gui/include/participant_row.hpp b/gui/include/participant_row.hpp index 81b3610..1388e41 100644 --- a/gui/include/participant_row.hpp +++ b/gui/include/participant_row.hpp @@ -3,16 +3,16 @@ * SPDX-License-Identifier: LGPL-2.1-only */ -#ifndef TURNS_UI_PARTICIPANT_ROW_HPP -#define TURNS_UI_PARTICIPANT_ROW_HPP +#ifndef TURNS_GUI_PARTICIPANT_ROW_HPP +#define TURNS_GUI_PARTICIPANT_ROW_HPP -#include "turns/core/fwd.hpp" -#include "turns/ui/template_widget.hpp" +#include "template_widget.hpp" + +#include #include #include #include - #include #include #include @@ -20,7 +20,7 @@ #include -namespace turns::ui +namespace Turns::gui { struct ParticipantRow : template_widget { @@ -32,7 +32,7 @@ namespace turns::ui "toggle_defeated", }; - ParticipantRow(Glib::RefPtr participant); + ParticipantRow(Glib::RefPtr participant); auto delete_enabled() -> Glib::PropertyProxy; auto edit_enabled() -> Glib::PropertyProxy; @@ -50,6 +50,6 @@ namespace turns::ui Glib::Property m_delete_enabled; Glib::Property m_edit_enabled; }; -} // namespace turns::ui::widgets +} // namespace Turns::gui #endif \ No newline at end of file diff --git a/gui/include/template_widget.hpp b/gui/include/template_widget.hpp index f90b473..34bc5ff 100644 --- a/gui/include/template_widget.hpp +++ b/gui/include/template_widget.hpp @@ -6,20 +6,19 @@ #ifndef TURNS_UI_TEMPLATE_WIDGET_HPP #define TURNS_UI_TEMPLATE_WIDGET_HPP +#include +#include +#include + #include #include #include - #include -#include -#include -#include - #include #include -namespace turns::ui +namespace Turns::gui { template @@ -67,6 +66,6 @@ namespace turns::ui } }; -} // namespace turns::ui::widgets +} // namespace Turns::gui #endif \ No newline at end of file diff --git a/gui/src/init.cpp b/gui/src/init.cpp new file mode 100644 index 0000000..c9a7295 --- /dev/null +++ b/gui/src/init.cpp @@ -0,0 +1,10 @@ +#include "init.hpp" + +#include "participant_row.hpp" + +#include + +auto Turns::gui::init() -> void +{ + static_cast(ParticipantRow{nullptr}.get_type()); +} diff --git a/gui/src/main.cpp b/gui/src/main.cpp index c4b95e5..d8b0bf9 100644 --- a/gui/src/main.cpp +++ b/gui/src/main.cpp @@ -3,6 +3,8 @@ * SPDX-License-Identifier: LGPL-2.1-only */ +#include "init.hpp" + #include #include @@ -23,6 +25,7 @@ auto main(int argc, char ** argv) -> int auto app = Adwaita::Application::create("ch.arknet.Turns", Gio::Application::Flags::HANDLES_OPEN); Turns::init(); + Turns::gui::init(); return app->run(argc, argv); } diff --git a/gui/src/participant_row.cpp b/gui/src/participant_row.cpp index c0f53df..01cf1ed 100644 --- a/gui/src/participant_row.cpp +++ b/gui/src/participant_row.cpp @@ -3,12 +3,12 @@ * SPDX-License-Identifier: LGPL-2.1-only */ -#include "turns/ui/participant_row.hpp" +#include "participant_row.hpp" -#include "turns/core/disposition.hpp" -#include "turns/core/participant.hpp" -#include "turns/lang/messages.hpp" -#include "turns/ui/template_widget.hpp" +#include "messages.hpp" +#include "template_widget.hpp" + +#include #include @@ -19,7 +19,6 @@ #include #include #include - #include #include #include @@ -29,22 +28,24 @@ #include #include -namespace turns::ui +namespace Turns::gui { namespace { auto constexpr static TYPE_NAME = "ParticipantRow"; auto constexpr static TEMPLATE = "/ch/arknet/Turns/participant_row.ui"; - auto css_class_for(core::Disposition value) -> Glib::ustring + auto css_class_for(Participant::Disposition value) -> Glib::ustring { + using Disposition = Participant::Disposition; + switch (value) { - case core::Disposition::Friendly: + case Disposition::Friendly: return "disposition-friendly"; - case core::Disposition::Hostile: + case Disposition::Hostile: return "disposition-hostile"; - case core::Disposition::Secret: + case Disposition::Secret: return "disposition-secret"; default: return ""; @@ -52,7 +53,7 @@ namespace turns::ui } } // namespace - ParticipantRow::ParticipantRow(Glib::RefPtr participant) + ParticipantRow::ParticipantRow(Glib::RefPtr participant) : Glib::ObjectBase(TYPE_NAME) , template_widget{TEMPLATE} , m_delete{get_widget("delete")} @@ -96,7 +97,7 @@ namespace turns::ui Glib::Binding::bind_property(participant->property_priority(), m_subtitle->property_label(), Glib::Binding::Flags::SYNC_CREATE, - [](auto n) { return std::vformat(_(lang::priority_number), std::make_format_args(n)); }); + [](auto n) { return std::vformat(_(messages::priority_number), std::make_format_args(n)); }); Glib::Binding::bind_property(participant->property_disposition(), m_toggle_defeated->property_css_classes(), @@ -111,7 +112,7 @@ namespace turns::ui return classes; }); - Glib::Binding::bind_property(participant->property_is_active(), + Glib::Binding::bind_property(participant->property_active(), property_css_classes(), Glib::Binding::Flags::SYNC_CREATE, [this](auto value) { @@ -151,4 +152,4 @@ namespace turns::ui activate_action("win.edit", index); } -} // namespace turns::ui \ No newline at end of file +} // namespace Turns::gui \ No newline at end of file -- cgit v1.2.3