blob: 87594979b8e288143e6576e6387dd8da2963b402 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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;
}
}
|