diff options
author | Marvin W <git@larma.de> | 2023-01-08 21:41:10 +0100 |
---|---|---|
committer | Marvin W <git@larma.de> | 2023-01-24 19:21:25 +0100 |
commit | cc7db3b85f7b29bfac333937d8bf09a81d8dc4a5 (patch) | |
tree | 203749e9cab0bad50763e8d495029336d4874c28 /main/src/ui/conversation_content_view | |
parent | 99d9cb383abb1a33f6d0572deb4292dbf358f3ce (diff) | |
download | dino-cc7db3b85f7b29bfac333937d8bf09a81d8dc4a5.tar.gz dino-cc7db3b85f7b29bfac333937d8bf09a81d8dc4a5.zip |
Fix scaling image for GTK4
Diffstat (limited to 'main/src/ui/conversation_content_view')
-rw-r--r-- | main/src/ui/conversation_content_view/file_image_widget.vala | 25 |
1 files changed, 1 insertions, 24 deletions
diff --git a/main/src/ui/conversation_content_view/file_image_widget.vala b/main/src/ui/conversation_content_view/file_image_widget.vala index 097ac695..ec8481b7 100644 --- a/main/src/ui/conversation_content_view/file_image_widget.vala +++ b/main/src/ui/conversation_content_view/file_image_widget.vala @@ -8,7 +8,6 @@ namespace Dino.Ui { public class FileImageWidget : Box { - private ScalingImage image; FileDefaultWidget file_default_widget; FileDefaultWidgetController file_default_widget_controller; @@ -19,29 +18,7 @@ public class FileImageWidget : Box { } public async void load_from_file(File file, string file_name, int MAX_WIDTH=600, int MAX_HEIGHT=300) throws GLib.Error { - // Load and prepare image in tread - Thread<ScalingImage?> thread = new Thread<ScalingImage?> (null, () => { - ScalingImage image = new ScalingImage() { halign=Align.START, visible = true, max_width = MAX_WIDTH, max_height = MAX_HEIGHT }; - - Gdk.Pixbuf pixbuf; - try { - pixbuf = new Gdk.Pixbuf.from_file(file.get_path()); - } catch (Error error) { - warning("Can't load picture %s - %s", file.get_path(), error.message); - Idle.add(load_from_file.callback); - return null; - } - - pixbuf = pixbuf.apply_embedded_orientation(); - - image.load(pixbuf); - - Idle.add(load_from_file.callback); - return image; - }); - yield; - image = thread.join(); - if (image == null) throw new Error(-1, 0, "Error loading image"); + FixedRatioPicture image = new FixedRatioPicture() { min_width = 100, min_height = 100, max_width = MAX_WIDTH, max_height = MAX_HEIGHT, file = file }; FileInfo file_info = file.query_info("*", FileQueryInfoFlags.NONE); string? mime_type = file_info.get_content_type(); |