aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui/conversation_summary
diff options
context:
space:
mode:
authorfiaxh <git@lightrise.org>2020-01-13 03:00:15 +0100
committerfiaxh <git@lightrise.org>2020-01-13 03:00:15 +0100
commitab4ca27b1ec43b4dd58938218f1cfceaa9194aff (patch)
tree36865f773c549327a0abd7b67a1c60ec4145edc7 /main/src/ui/conversation_summary
parent3fc9bdab053e23ab8e97afadfee0a05afad8d890 (diff)
downloaddino-ab4ca27b1ec43b4dd58938218f1cfceaa9194aff.tar.gz
dino-ab4ca27b1ec43b4dd58938218f1cfceaa9194aff.zip
Show default file widget if Pixbuf can't display Image inline
fixes #713
Diffstat (limited to 'main/src/ui/conversation_summary')
-rw-r--r--main/src/ui/conversation_summary/file_widget.vala13
1 files changed, 8 insertions, 5 deletions
diff --git a/main/src/ui/conversation_summary/file_widget.vala b/main/src/ui/conversation_summary/file_widget.vala
index 7e662917..91b8912b 100644
--- a/main/src/ui/conversation_summary/file_widget.vala
+++ b/main/src/ui/conversation_summary/file_widget.vala
@@ -55,15 +55,16 @@ public class FileWidget : Box {
}
private async Widget? get_image_widget(FileTransfer file_transfer) {
- Image image = new Image() { halign=Align.START, visible = true };
+ // Load and prepare image in tread
+ Thread<Image?> thread = new Thread<Image?> (null, () => {
+ Image image = new Image() { halign=Align.START, visible = true };
- // Load, scale and set the image
- new Thread<void*> (null, () => {
Gdk.Pixbuf pixbuf;
try {
pixbuf = new Gdk.Pixbuf.from_file(file_transfer.get_file().get_path());
} catch (Error error) {
- warning("Can't load picture %s", file_transfer.get_file().get_path());
+ warning("Can't load picture %s - %s", file_transfer.get_file().get_path(), error.message);
+ Idle.add(get_image_widget.callback);
return null;
}
@@ -81,9 +82,11 @@ public class FileWidget : Box {
Util.image_set_from_scaled_pixbuf(image, pixbuf);
Idle.add(get_image_widget.callback);
- return null;
+ return image;
});
yield;
+ Image image = thread.join();
+ if (image == null) return null;
Util.force_css(image, "* { box-shadow: 0px 0px 2px 0px rgba(0,0,0,0.1); margin: 2px; border-radius: 3px; }");