#include "turns/app/widgets/participant_row.hpp" #include "turns/lang/messages.hpp" #include #include #include #include #include namespace turns::app::widgets { namespace { auto constexpr static TYPE_NAME = "participant_row"; auto constexpr static TEMPLATE = "/ch/arknet/Turns/widgets/participant_row.ui"; } // namespace participant_row::participant_row(Glib::RefPtr participant) : Glib::ObjectBase(TYPE_NAME) , template_widget{TEMPLATE} , m_delete{get_widget("delete")} , m_edit{get_widget("edit")} , m_subtitle{get_widget("subtitle")} , m_title{get_widget("title")} , m_toggle_defeated{get_widget("toggle_defeated")} , m_subtitle_visibility{} { m_delete->signal_clicked().connect(sigc::mem_fun(*this, &participant_row::handle_delete)); m_edit->signal_clicked().connect(sigc::mem_fun(*this, &participant_row::handle_edit)); m_subtitle_visibility = Glib::Binding::bind_property(m_subtitle->property_label(), m_subtitle->property_visible(), Glib::Binding::Flags::DEFAULT, sigc::mem_fun(&Glib::ustring::size)); m_title_visibility = Glib::Binding::bind_property(m_title->property_label(), m_title->property_visible(), Glib::Binding::Flags::INVERT_BOOLEAN, sigc::mem_fun(&Glib::ustring::size)); m_toggle_defeated_icon = Glib::Binding::bind_property(m_toggle_defeated->property_active(), m_toggle_defeated->property_icon_name(), Glib::Binding::Flags::SYNC_CREATE, [](auto active) { return active ? "face-sick-symbolic" : "face-smile-symbolic"; }); if (participant) { set_title(participant->get_name()); auto priority = participant->get_priority(); set_subtitle(std::vformat(_(lang::priority_number), std::make_format_args(priority))); } } auto participant_row::set_subtitle(Glib::ustring const & value) -> void { m_subtitle->property_label() = value; } auto participant_row::set_title(Glib::ustring const & value) -> void { m_title->property_label() = value; } auto participant_row::handle_delete() -> void { auto index = Glib::Variant::create(get_index()); activate_action("win.delete", index); } auto participant_row::handle_edit() -> void { auto index = Glib::Variant::create(get_index()); activate_action("win.edit", index); } } // namespace turns::app::widgets