diff options
Diffstat (limited to 'src/DynamicImage.cpp')
-rw-r--r-- | src/DynamicImage.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/DynamicImage.cpp b/src/DynamicImage.cpp new file mode 100644 index 0000000..8759497 --- /dev/null +++ b/src/DynamicImage.cpp @@ -0,0 +1,28 @@ +#include "../include/DynamicImage.hpp" +#include "../include/GlobalCache.hpp" +#include "../include/GtkGif.hpp" + +namespace dchat +{ + DynamicImage::DynamicImage(int _downloadLimitBytes) : + downloadLimitBytes(_downloadLimitBytes) + { + signal_draw().connect(sigc::mem_fun(*this, &DynamicImage::updateContent)); + } + + bool DynamicImage::updateContent(const Cairo::RefPtr<Cairo::Context> &cairo) + { + if(!url.empty()) + { + Gtk::Allocation alloc = get_allocation(); + auto result = getGlobalCache().getContentByUrl(url, downloadLimitBytes); + if(result.type == ContentByUrlResult::Type::CACHED && result.gif) + { + GtkGif *gif = (GtkGif*)result.gif; + gif->draw(cairo, alloc.get_width(), alloc.get_height()); + } + } + queue_draw(); + return true; + } +}
\ No newline at end of file |