summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gui/include/participant_row.hpp3
-rw-r--r--gui/src/init.cpp2
-rw-r--r--gui/src/participant_row.cpp86
-rw-r--r--gui/tests/participant_row.cpp2
4 files changed, 45 insertions, 48 deletions
diff --git a/gui/include/participant_row.hpp b/gui/include/participant_row.hpp
index 1388e41..dd0eeea 100644
--- a/gui/include/participant_row.hpp
+++ b/gui/include/participant_row.hpp
@@ -32,7 +32,8 @@ namespace Turns::gui
"toggle_defeated",
};
- ParticipantRow(Glib::RefPtr<Turns::Participant> participant);
+ ParticipantRow();
+ explicit ParticipantRow(Glib::RefPtr<Turns::Participant> participant);
auto delete_enabled() -> Glib::PropertyProxy<bool>;
auto edit_enabled() -> Glib::PropertyProxy<bool>;
diff --git a/gui/src/init.cpp b/gui/src/init.cpp
index 378065c..9192d37 100644
--- a/gui/src/init.cpp
+++ b/gui/src/init.cpp
@@ -15,7 +15,7 @@
auto Turns::gui::init() -> void
{
- g_type_ensure(ParticipantRow{nullptr}.get_type());
+ g_type_ensure(ParticipantRow{}.get_type());
g_type_ensure(ParticipantEditor{nullptr}.get_type());
g_type_ensure(Preferences{}.get_type());
g_type_ensure(Tracker{{}, {}}.get_type());
diff --git a/gui/src/participant_row.cpp b/gui/src/participant_row.cpp
index e01da67..ba39a2f 100644
--- a/gui/src/participant_row.cpp
+++ b/gui/src/participant_row.cpp
@@ -52,9 +52,14 @@ namespace Turns::gui
return "";
}
}
+
+ auto format_priority(float priority) -> Glib::ustring
+ {
+ return std::vformat(_(message::priority_number), std::make_format_args(priority));
+ }
} // namespace
- ParticipantRow::ParticipantRow(Glib::RefPtr<Participant> participant)
+ ParticipantRow::ParticipantRow()
: Glib::ObjectBase(TYPE_NAME)
, template_widget{TEMPLATE}
, m_delete{get_widget<Gtk::Button>("delete")}
@@ -82,53 +87,44 @@ namespace Turns::gui
Glib::Binding::Flags::SYNC_CREATE,
[](auto active) { return active ? "face-sick-symbolic" : "face-smile-symbolic"; });
- // clang-format off
- Glib::Binding::bind_property(delete_enabled(),
- m_delete->property_sensitive(),
- Glib::Binding::Flags::SYNC_CREATE);
- Glib::Binding::bind_property(edit_enabled(),
- m_edit->property_sensitive(),
- Glib::Binding::Flags::SYNC_CREATE);
- // clang-format on
+ Glib::Binding::bind_property(delete_enabled(), m_delete->property_sensitive(), Glib::Binding::Flags::SYNC_CREATE);
+ Glib::Binding::bind_property(edit_enabled(), m_edit->property_sensitive(), Glib::Binding::Flags::SYNC_CREATE);
+ }
- if (participant)
- {
- Glib::Binding::bind_property(participant->property_name(), m_title->property_label(), Glib::Binding::Flags::SYNC_CREATE);
-
- Glib::Binding::bind_property(participant->property_priority(),
- m_subtitle->property_label(),
- Glib::Binding::Flags::SYNC_CREATE,
- [](auto n) { return std::vformat(_(message::priority_number), std::make_format_args(n)); });
-
- Glib::Binding::bind_property(participant->property_disposition(),
- m_toggle_defeated->property_css_classes(),
- Glib::Binding::Flags::SYNC_CREATE,
- [this](auto value) {
- auto classes = m_toggle_defeated->get_css_classes();
- auto removed = std::ranges::remove_if(classes, [](auto cls) {
- return (cls == "disposition-friendly") | (cls == "disposition-hostile") || (cls == "disposition-secret");
- });
- classes.erase(removed.begin(), removed.end());
- classes.push_back(css_class_for(value));
- return classes;
- });
+ ParticipantRow::ParticipantRow(Glib::RefPtr<Participant> participant)
+ : ParticipantRow{}
+ {
+ Glib::Binding::bind_property(participant->property_name(), m_title->property_label(), Glib::Binding::Flags::SYNC_CREATE);
+ Glib::Binding::bind_property(participant->property_priority(),
+ m_subtitle->property_label(),
+ Glib::Binding::Flags::SYNC_CREATE,
+ &format_priority);
- Glib::Binding::bind_property(participant->property_active(),
- property_css_classes(),
- Glib::Binding::Flags::SYNC_CREATE,
- [this](auto value) {
- auto classes = get_css_classes();
- if (!value)
- {
- std::erase(classes, "active-participant");
- }
- else
- {
- classes.push_back("active-participant");
- }
- return classes;
+ Glib::Binding::bind_property(participant->property_disposition(),
+ m_toggle_defeated->property_css_classes(),
+ Glib::Binding::Flags::SYNC_CREATE,
+ [this](auto value) {
+ auto classes = m_toggle_defeated->get_css_classes();
+ auto removed = std::ranges::remove_if(classes, [](auto cls) {
+ return (cls == "disposition-friendly") | (cls == "disposition-hostile") || (cls == "disposition-secret");
});
- }
+ classes.erase(removed.begin(), removed.end());
+ classes.push_back(css_class_for(value));
+ return classes;
+ });
+
+ Glib::Binding::bind_property(participant->property_active(), property_css_classes(), Glib::Binding::Flags::SYNC_CREATE, [this](auto value) {
+ auto classes = get_css_classes();
+ if (!value)
+ {
+ std::erase(classes, "active-participant");
+ }
+ else
+ {
+ classes.push_back("active-participant");
+ }
+ return classes;
+ });
}
auto ParticipantRow::delete_enabled() -> Glib::PropertyProxy<bool>
diff --git a/gui/tests/participant_row.cpp b/gui/tests/participant_row.cpp
index 1ab67af..1b0c4e0 100644
--- a/gui/tests/participant_row.cpp
+++ b/gui/tests/participant_row.cpp
@@ -29,7 +29,7 @@ namespace Turns::gui::tests
{
GIVEN("a participant row constructed without a participant")
{
- auto instance = ParticipantRow{nullptr};
+ auto instance = ParticipantRow{};
THEN("its title is empty")
{