summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGaël Bonithon <gael@xfce.org>2021-11-18 09:20:07 +0100
committerGaël Bonithon <gael@xfce.org>2021-12-11 07:52:56 +0100
commit6935184665902097511db1708eaaf78015ff61ac (patch)
treeefbfc5facb2fedd8868b9c086cc4c6088bbc6a25 /plugins
parentad680ef6c79a6430ca6bb0b9e48538eb9c64d202 (diff)
downloadtumbler-6935184665902097511db1708eaaf78015ff61ac.tar.gz
pixbuf-thumbnailer: Use a mime-type-specific loader when possible
This allows to fully use the capabilities of the specific pixbuf loader for the considered mime type according to the installed optional libraries. This is especially necessary to load some SVG or HEIF thumbnails. On the other hand, if this specific loader doesn't work properly, it may be even more noticeable. This is the case for libopenraw, for which a dedicated plugin using another API has fortunately been implemented. So we just have to prioritize it in `tumbler.rc`. Fixes #20, #32, #36, see !18 for more details. Co-authored-by: @Krifa75 (Gitlab ID)
Diffstat (limited to 'plugins')
-rw-r--r--plugins/pixbuf-thumbnailer/pixbuf-thumbnailer.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/plugins/pixbuf-thumbnailer/pixbuf-thumbnailer.c b/plugins/pixbuf-thumbnailer/pixbuf-thumbnailer.c
index df00f99..e7f1820 100644
--- a/plugins/pixbuf-thumbnailer/pixbuf-thumbnailer.c
+++ b/plugins/pixbuf-thumbnailer/pixbuf-thumbnailer.c
@@ -138,6 +138,7 @@ pixbuf_thumbnailer_size_prepared (GdkPixbufLoader *loader,
static GdkPixbuf *
pixbuf_thumbnailer_new_from_stream (GInputStream *stream,
TumblerThumbnail *thumbnail,
+ const gchar *mime_type,
GCancellable *cancellable,
GError **error)
{
@@ -152,8 +153,12 @@ pixbuf_thumbnailer_new_from_stream (GInputStream *stream,
g_return_val_if_fail (G_IS_INPUT_STREAM (stream), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
- /* prepare the loader */
- loader = gdk_pixbuf_loader_new ();
+ /* try to use a pixbuf loader specific to the mime type, falling back on the
+ * generic loader in case of error */
+ loader = gdk_pixbuf_loader_new_with_mime_type (mime_type, NULL);
+ if (loader == NULL)
+ loader = gdk_pixbuf_loader_new ();
+
g_signal_connect (loader, "size-prepared",
G_CALLBACK (pixbuf_thumbnailer_size_prepared), thumbnail);
@@ -257,6 +262,7 @@ pixbuf_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer,
* gdk_pixbuf_new_from_file_at_scale(), but without increasing the
* pixbuf size. */
pixbuf = pixbuf_thumbnailer_new_from_stream (G_INPUT_STREAM (stream), thumbnail,
+ tumbler_file_info_get_mime_type (info),
cancellable, &error);
g_object_unref (stream);