diff --git a/src/Widgets/Attachment/Box.vala b/src/Widgets/Attachment/Box.vala index 78d74fb8..ebad1429 100644 --- a/src/Widgets/Attachment/Box.vala +++ b/src/Widgets/Attachment/Box.vala @@ -122,7 +122,7 @@ public class Tuba.Widgets.Attachment.Box : Adw.Bin { widget.height_request = 334; } - ((Widgets.Attachment.Image) widget).on_any_attachment_click.connect (() => open_all_attachments (item.url)); + ((Widgets.Attachment.Image) widget).on_any_attachment_click.connect (open_all_attachments); } catch (Oopsie e) { warning (@"Error updating attachments: $(e.message)"); } diff --git a/src/Widgets/Attachment/Image.vala b/src/Widgets/Attachment/Image.vala index cf2e2de5..2a9b5c14 100644 --- a/src/Widgets/Attachment/Image.vala +++ b/src/Widgets/Attachment/Image.vala @@ -43,11 +43,15 @@ public class Tuba.Widgets.Attachment.Image : Widgets.Attachment.Item { } protected Gtk.Image? media_icon = null; + ulong pic_paintable_id = 0; protected override void on_rebind () { base.on_rebind (); pic.alternative_text = entity == null ? null : entity.description; - Tuba.Helper.Image.request_paintable (entity.preview_url, entity.blurhash, on_cache_response); + if (pic_paintable_id != 0) { + pic.disconnect (pic_paintable_id); + pic_paintable_id = 0; + } if (media_kind.is_video ()) { media_icon = new Gtk.Image () { @@ -59,6 +63,7 @@ public class Tuba.Widgets.Attachment.Image : Widgets.Attachment.Item { media_icon.css_classes = { "osd", "circular", "attachment-overlay-icon" }; media_icon.icon_name = "media-playback-start-symbolic"; } else { + pic_paintable_id = pic.notify["paintable"].connect (on_audio_paintable_notify); media_icon.icon_name = "tuba-music-note-symbolic"; } @@ -68,9 +73,23 @@ public class Tuba.Widgets.Attachment.Image : Widgets.Attachment.Item { media_icon.icon_size = Gtk.IconSize.LARGE; } + Tuba.Helper.Image.request_paintable (entity.preview_url, entity.blurhash, on_cache_response); copy_media_simple_action.set_enabled (media_kind.can_copy ()); } + private void on_audio_paintable_notify () { + if (media_icon == null) return; + + // toggle icon size so it applies + media_icon.icon_size = Gtk.IconSize.NORMAL; + if (pic.paintable == null) { + media_icon.css_classes = {}; + } else { + media_icon.css_classes = { "osd", "circular", "attachment-overlay-icon" }; + } + media_icon.icon_size = Gtk.IconSize.LARGE; + } + protected override void copy_media () { debug ("Begin copy-media action"); Host.download.begin (entity.url, (obj, res) => {