aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfiaxh <git@lightrise.org>2025-04-07 18:08:14 +0200
committerfiaxh <git@lightrise.org>2025-04-07 18:12:33 +0200
commitea54d659e5729ec9d2493ad1e4a268425b180891 (patch)
tree2383f7b5a75e7af80167294932db576d3972a512
parentd621c9653934b4d16bcb257ca4aff584c6ebc20e (diff)
Fix sending images with unknown formats
-rw-r--r--libdino/src/service/sfs_metadata.vala3
-rw-r--r--libdino/src/service/util.vala11
-rw-r--r--main/src/ui/conversation_content_view/file_image_widget.vala13
-rw-r--r--main/src/ui/file_send_overlay.vala10
4 files changed, 15 insertions, 22 deletions
diff --git a/libdino/src/service/sfs_metadata.vala b/libdino/src/service/sfs_metadata.vala
index ff2a57b4..dff6f7bf 100644
--- a/libdino/src/service/sfs_metadata.vala
+++ b/libdino/src/service/sfs_metadata.vala
@@ -36,7 +36,8 @@ namespace Dino {
public class ImageFileMetadataProvider: Dino.FileMetadataProvider, Object {
public bool supports_file(File file) {
- return file.query_info("*", FileQueryInfoFlags.NONE).get_content_type().has_prefix("image");
+ string mime_type = file.query_info("*", FileQueryInfoFlags.NONE).get_content_type();
+ return Dino.Util.is_pixbuf_supported_mime_type(mime_type);
}
private const int[] THUMBNAIL_DIMS = { 1, 2, 3, 4, 8 };
diff --git a/libdino/src/service/util.vala b/libdino/src/service/util.vala
index 1d04ffcf..6eacdd33 100644
--- a/libdino/src/service/util.vala
+++ b/libdino/src/service/util.vala
@@ -29,6 +29,17 @@ public class Util {
assert_not_reached();
}
}
+
+ public static bool is_pixbuf_supported_mime_type(string mime_type) {
+ if (mime_type == null) return false;
+
+ foreach (Gdk.PixbufFormat pixbuf_format in Gdk.Pixbuf.get_formats()) {
+ foreach (string pixbuf_mime in pixbuf_format.get_mime_types()) {
+ if (pixbuf_mime == mime_type) return true;
+ }
+ }
+ return false;
+ }
}
}
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 33232e93..11a2d3f6 100644
--- a/main/src/ui/conversation_content_view/file_image_widget.vala
+++ b/main/src/ui/conversation_content_view/file_image_widget.vala
@@ -247,21 +247,10 @@ public class FileImageWidget : Widget {
}
public static bool can_display(FileTransfer file_transfer) {
- return file_transfer.mime_type != null && is_pixbuf_supported_mime_type(file_transfer.mime_type) &&
+ return file_transfer.mime_type != null && Dino.Util.is_pixbuf_supported_mime_type(file_transfer.mime_type) &&
(file_transfer.state == FileTransfer.State.COMPLETE || file_transfer.thumbnails.size > 0);
}
- public static bool is_pixbuf_supported_mime_type(string mime_type) {
- if (mime_type == null) return false;
-
- foreach (PixbufFormat pixbuf_format in Pixbuf.get_formats()) {
- foreach (string pixbuf_mime in pixbuf_format.get_mime_types()) {
- if (pixbuf_mime == mime_type) return true;
- }
- }
- return false;
- }
-
public override void dispose() {
if (overlay != null && overlay.parent != null) overlay.unparent();
base.dispose();
diff --git a/main/src/ui/file_send_overlay.vala b/main/src/ui/file_send_overlay.vala
index 992ab92e..e2d976b7 100644
--- a/main/src/ui/file_send_overlay.vala
+++ b/main/src/ui/file_send_overlay.vala
@@ -59,15 +59,7 @@ public class FileSendOverlay {
string file_name = file_info.get_display_name();
string mime_type = file_info.get_content_type();
- bool is_image = false;
-
- foreach (PixbufFormat pixbuf_format in Pixbuf.get_formats()) {
- foreach (string supported_mime_type in pixbuf_format.get_mime_types()) {
- if (supported_mime_type == mime_type) {
- is_image = true;
- }
- }
- }
+ bool is_image = Dino.Util.is_pixbuf_supported_mime_type(mime_type);
Widget? widget = null;
if (is_image) {