summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authorouwou <26526779+ouwou@users.noreply.github.com>2020-12-21 19:08:44 -0500
committerouwou <26526779+ouwou@users.noreply.github.com>2020-12-21 19:08:44 -0500
commitd8ff05ddf898dfcd6fa0e3398cc38abcab07e2fe (patch)
tree667eb93e54d0698b62f098e911a24e70fb0448be /components
parent486d184c8306d3e8a4889a5b079cd9b3003896c2 (diff)
downloadabaddon-portaudio-d8ff05ddf898dfcd6fa0e3398cc38abcab07e2fe.tar.gz
abaddon-portaudio-d8ff05ddf898dfcd6fa0e3398cc38abcab07e2fe.zip
support animated guild icon
Diffstat (limited to 'components')
-rw-r--r--components/channels.cpp30
-rw-r--r--components/channels.hpp3
2 files changed, 25 insertions, 8 deletions
diff --git a/components/channels.cpp b/components/channels.cpp
index 172286b..38b1e1f 100644
--- a/components/channels.cpp
+++ b/components/channels.cpp
@@ -119,13 +119,25 @@ ChannelListRowGuild::ChannelListRowGuild(const Guild *data) {
m_menu.show_all();
+ const auto show_animations = Abaddon::Get().GetSettings().GetShowAnimations();
+ auto &img = Abaddon::Get().GetImageManager();
if (data->HasIcon()) {
- auto buf = Abaddon::Get().GetImageManager().GetFromURLIfCached(data->GetIconURL("png", "32"));
- if (buf)
- m_icon = Gtk::manage(new Gtk::Image(buf->scale_simple(24, 24, Gdk::INTERP_BILINEAR)));
- else {
- m_icon = Gtk::manage(new Gtk::Image(Abaddon::Get().GetImageManager().GetPlaceholder(24)));
- Abaddon::Get().GetImageManager().LoadFromURL(data->GetIconURL("png", "32"), sigc::mem_fun(*this, &ChannelListRowGuild::OnImageLoad));
+ if (data->HasAnimatedIcon() && show_animations) {
+ auto buf = img.GetAnimationFromURLIfCached(data->GetIconURL("gif", "32"), 24, 24);
+ if (buf)
+ m_icon = Gtk::manage(new Gtk::Image(buf));
+ else {
+ m_icon = Gtk::manage(new Gtk::Image(img.GetPlaceholder(24)));
+ img.LoadAnimationFromURL(data->GetIconURL("gif", "32"), 24, 24, sigc::mem_fun(*this, &ChannelListRowGuild::OnAnimatedImageLoad));
+ }
+ } else {
+ auto buf = img.GetFromURLIfCached(data->GetIconURL("png", "32"));
+ if (buf)
+ m_icon = Gtk::manage(new Gtk::Image(buf->scale_simple(24, 24, Gdk::INTERP_BILINEAR)));
+ else {
+ m_icon = Gtk::manage(new Gtk::Image(img.GetPlaceholder(24)));
+ img.LoadFromURL(data->GetIconURL("png", "32"), sigc::mem_fun(*this, &ChannelListRowGuild::OnImageLoad));
+ }
}
} else {
m_icon = Gtk::manage(new Gtk::Image(Abaddon::Get().GetImageManager().GetPlaceholder(24)));
@@ -148,10 +160,14 @@ ChannelListRowGuild::ChannelListRowGuild(const Guild *data) {
show_all_children();
}
-void ChannelListRowGuild::OnImageLoad(Glib::RefPtr<Gdk::Pixbuf> buf) {
+void ChannelListRowGuild::OnImageLoad(const Glib::RefPtr<Gdk::Pixbuf> &buf) {
m_icon->property_pixbuf() = buf->scale_simple(24, 24, Gdk::INTERP_BILINEAR);
}
+void ChannelListRowGuild::OnAnimatedImageLoad(const Glib::RefPtr<Gdk::PixbufAnimation> &buf) {
+ m_icon->property_pixbuf_animation() = buf;
+}
+
ChannelListRowGuild::type_signal_copy_id ChannelListRowGuild::signal_copy_id() {
return m_signal_copy_id;
}
diff --git a/components/channels.hpp b/components/channels.hpp
index d481b13..f259266 100644
--- a/components/channels.hpp
+++ b/components/channels.hpp
@@ -53,7 +53,8 @@ public:
int GuildIndex;
protected:
- void OnImageLoad(Glib::RefPtr<Gdk::Pixbuf> buf);
+ void OnImageLoad(const Glib::RefPtr<Gdk::Pixbuf> &buf);
+ void OnAnimatedImageLoad(const Glib::RefPtr<Gdk::PixbufAnimation> &buf);
Gtk::EventBox *m_ev;
Gtk::Box *m_box;