diff options
author | dec05eba <dec05eba@protonmail.com> | 2018-11-03 22:49:29 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2018-11-03 22:49:32 +0100 |
commit | c7138bca7ea7d007198c544b2d8bc27ae414d2e2 (patch) | |
tree | b27752bc5e4e452a9a4c047e884b8952a22a0f0a /src/DynamicImage.cpp | |
parent | 405459e93be718b0e6aad26746036105dd3f3226 (diff) |
Start with gif/image widget
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 |