From ab4ca27b1ec43b4dd58938218f1cfceaa9194aff Mon Sep 17 00:00:00 2001 From: fiaxh Date: Mon, 13 Jan 2020 03:00:15 +0100 Subject: Show default file widget if Pixbuf can't display Image inline fixes #713 --- main/src/ui/conversation_summary/file_widget.vala | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'main/src/ui/conversation_summary') 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 thread = new Thread (null, () => { + Image image = new Image() { halign=Align.START, visible = true }; - // Load, scale and set the image - new Thread (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; }"); -- cgit v1.2.3-70-g09d2