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 --- gui/src/init.cpp | 10 ++++++++++ gui/src/main.cpp | 3 +++ gui/src/participant_row.cpp | 31 ++++++++++++++++--------------- 3 files changed, 29 insertions(+), 15 deletions(-) create mode 100644 gui/src/init.cpp (limited to 'gui/src') 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