diff options
author | ouwou <26526779+ouwou@users.noreply.github.com> | 2020-09-21 23:58:32 -0400 |
---|---|---|
committer | ouwou <26526779+ouwou@users.noreply.github.com> | 2020-09-21 23:58:32 -0400 |
commit | c6cc07122a847001c505a3b1bf17888691ed7046 (patch) | |
tree | f2e8339155810d596c460cc0600be5ae7546a44f /components | |
parent | af8058c9cb391a9c51b1d16a9313562f13c4427e (diff) | |
download | abaddon-portaudio-c6cc07122a847001c505a3b1bf17888691ed7046.tar.gz abaddon-portaudio-c6cc07122a847001c505a3b1bf17888691ed7046.zip |
add user icons to dm channels
Diffstat (limited to 'components')
-rw-r--r-- | components/channels.cpp | 18 | ||||
-rw-r--r-- | components/channels.hpp | 1 |
2 files changed, 19 insertions, 0 deletions
diff --git a/components/channels.cpp b/components/channels.cpp index 5c12953..dffd200 100644 --- a/components/channels.cpp +++ b/components/channels.cpp @@ -40,12 +40,30 @@ ChannelListRowDMChannel::ChannelListRowDMChannel(const Channel *data) { get_style_context()->add_class("channel-row"); m_lbl->get_style_context()->add_class("channel-row-label"); + if (data->Type == ChannelType::DM) { + auto buf = Abaddon::Get().GetImageManager().GetFromURLIfCached(data->Recipients[0].GetAvatarURL("png", "16")); + if (buf) + m_icon = Gtk::manage(new Gtk::Image(buf)); + else { + m_icon = Gtk::manage(new Gtk::Image(Abaddon::Get().GetImageManager().GetPlaceholder(24))); + Abaddon::Get().GetImageManager().LoadFromURL(data->Recipients[0].GetAvatarURL("png", "16"), [this](Glib::RefPtr<Gdk::Pixbuf> ldbuf) { + Glib::signal_idle().connect([this, ldbuf]() -> bool { + m_icon->property_pixbuf() = ldbuf; + + return false; + }); + }); + } + } + if (data->Type == ChannelType::DM) m_lbl->set_text(data->Recipients[0].Username); else if (data->Type == ChannelType::GROUP_DM) m_lbl->set_text(std::to_string(data->Recipients.size()) + " users"); m_box->set_halign(Gtk::ALIGN_START); + if (m_icon != nullptr) + m_box->pack_start(*m_icon); m_box->pack_start(*m_lbl); m_ev->add(*m_box); add(*m_ev); diff --git a/components/channels.hpp b/components/channels.hpp index 9cd8c32..6c88ac9 100644 --- a/components/channels.hpp +++ b/components/channels.hpp @@ -43,6 +43,7 @@ protected: Gtk::EventBox *m_ev; Gtk::Box *m_box; Gtk::Label *m_lbl; + Gtk::Image *m_icon = nullptr; }; class ChannelListRowGuild : public ChannelListRow { |