diff options
Diffstat (limited to 'main/src/ui/conversation_content_view/file_widget.vala')
-rw-r--r-- | main/src/ui/conversation_content_view/file_widget.vala | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/main/src/ui/conversation_content_view/file_widget.vala b/main/src/ui/conversation_content_view/file_widget.vala index 02c9407a..69781f30 100644 --- a/main/src/ui/conversation_content_view/file_widget.vala +++ b/main/src/ui/conversation_content_view/file_widget.vala @@ -43,6 +43,7 @@ public class FileWidget : SizeRequestBox { enum State { IMAGE, + IMAGE_PREVIEW, DEFAULT } @@ -108,7 +109,26 @@ public class FileWidget : SizeRequestBox { } catch (Error e) { } } - if (!show_image() && state != State.DEFAULT) { + if (show_preview() && state != State.IMAGE_PREVIEW) { + var content_bak = content; + + FilePreviewWidget file_preview_widget = null; + try { + file_preview_widget = new FilePreviewWidget() { visible=true }; + yield file_preview_widget.load_from_thumbnail(file_transfer, stream_interactor); + + // If the widget changed in the meanwhile, stop + if (content != content_bak) return; + + if (content != null) this.remove(content); + content = file_preview_widget; + state = State.IMAGE_PREVIEW; + this.append(content); + return; + } catch (Error e) { } + } + + if (!show_image() && state != State.DEFAULT && state != State.IMAGE_PREVIEW) { if (content != null) this.remove(content); FileDefaultWidget default_file_widget = new FileDefaultWidget(); default_widget_controller = new FileDefaultWidgetController(default_file_widget); @@ -140,6 +160,10 @@ public class FileWidget : SizeRequestBox { return false; } + private bool show_preview() { + return !this.file_transfer.thumbnails.is_empty; + } + public override void dispose() { if (default_widget_controller != null) default_widget_controller.dispose(); default_widget_controller = null; |