diff options
Diffstat (limited to 'gui/src/participant_row.cpp')
| -rw-r--r-- | gui/src/participant_row.cpp | 86 |
1 files changed, 41 insertions, 45 deletions
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> |
