diff options
| author | Marvin W <git@larma.de> | 2025-10-06 20:12:19 +0200 |
|---|---|---|
| committer | Marvin W <git@larma.de> | 2025-11-01 18:04:43 -0400 |
| commit | f1bbb065ec63053b1e0dd0c78ba11376cbab451d (patch) | |
| tree | c8ba1ee43637b29f868e6d8ddd63714e6fb4618d /main/src/ui/conversation_content_view/file_image_widget.vala | |
| parent | 3c37cdbd1d2e5abbd0ab46a110b479432929b535 (diff) | |
Files: Use GFile instead of uri/path strings
In some situations (like VFS or other abstractions), the file reference can
have an invalid or unusabe path. Passing the GFile instead and opening it
directly increases probability we can actually access it.
Diffstat (limited to 'main/src/ui/conversation_content_view/file_image_widget.vala')
| -rw-r--r-- | main/src/ui/conversation_content_view/file_image_widget.vala | 18 |
1 files changed, 14 insertions, 4 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 6efe2d58..f39dd30a 100644 --- a/main/src/ui/conversation_content_view/file_image_widget.vala +++ b/main/src/ui/conversation_content_view/file_image_widget.vala @@ -154,10 +154,20 @@ public class FileImageWidget : Widget { public async void load_from_file(File file, string file_name) throws GLib.Error { FixedRatioPicture image = new FixedRatioPicture() { min_width=100, min_height=100, max_width=600, max_height=300 }; - // Work-around because Gtk.Picture does not apply the orientation itself - Gdk.Pixbuf? pixbuf = new Pixbuf.from_file(file.get_path()); - pixbuf = pixbuf.apply_embedded_orientation(); - image.paintable = Texture.for_pixbuf(pixbuf); + FileInputStream file_stream = null; + try { + file_stream = file.read(); + // Work-around because Gtk.Picture does not apply the orientation itself + Gdk.Pixbuf? pixbuf = new Pixbuf.from_stream(file_stream); + pixbuf = pixbuf.apply_embedded_orientation(); + image.paintable = Texture.for_pixbuf(pixbuf); + } finally { + try { + if (file_stream != null) file_stream.close(); + } catch (Error e) { + // Ignore + } + } stack.add_child(image); stack.set_visible_child(image); |
