mirror of
https://github.com/celisej567/abaddon.git
synced 2026-09-13 20:18:50 +03:00
show non-lottie stickers statically
This commit is contained in:
@@ -67,6 +67,16 @@ ChatMessageItemContainer *ChatMessageItemContainer::FromMessage(Snowflake id) {
|
||||
}
|
||||
}
|
||||
|
||||
// only 1?
|
||||
if (data->Stickers.has_value()) {
|
||||
const auto &sticker = data->Stickers.value()[0];
|
||||
// todo: lottie
|
||||
if (sticker.FormatType == StickerFormatType::PNG || sticker.FormatType == StickerFormatType::APNG) {
|
||||
auto *widget = container->CreateStickerComponent(sticker);
|
||||
container->m_main->add(*widget);
|
||||
}
|
||||
}
|
||||
|
||||
container->UpdateAttributes();
|
||||
|
||||
return container;
|
||||
@@ -363,6 +373,23 @@ Gtk::Box *ChatMessageItemContainer::CreateAttachmentComponent(const AttachmentDa
|
||||
return box;
|
||||
}
|
||||
|
||||
Gtk::Box *ChatMessageItemContainer::CreateStickerComponent(const Sticker &data) {
|
||||
auto *box = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL));
|
||||
auto *imgw = Gtk::manage(new Gtk::Image);
|
||||
auto &img = Abaddon::Get().GetImageManager();
|
||||
|
||||
if (data.FormatType == StickerFormatType::PNG || data.FormatType == StickerFormatType::APNG) {
|
||||
// clang-format off
|
||||
img.LoadFromURL(data.GetURL(), sigc::track_obj([this, imgw](const Glib::RefPtr<Gdk::Pixbuf> &pixbuf) {
|
||||
imgw->property_pixbuf() = pixbuf;
|
||||
}, imgw));
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
box->add(*imgw);
|
||||
return box;
|
||||
}
|
||||
|
||||
void ChatMessageItemContainer::HandleImage(const AttachmentData &data, Gtk::Image *img, std::string url) {
|
||||
m_img_loadmap[url] = std::make_pair(img, data);
|
||||
// ask the chatwindow to call UpdateImage because dealing with lifetimes sucks
|
||||
|
||||
Reference in New Issue
Block a user