From a188f1c30f8e7c98373d620832933522ad29d14f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20Bonithon?= Date: Tue, 28 Dec 2021 16:20:37 +0100 Subject: Try all available thumbnailers before declaring failure The request thumbnailer array no longer contains one thumbnailer per URI, but the list of available thumbnailers for this URI (after applying the filters of the configuration file), sorted by priority. For a given URI, we browse the thumbnailer list until we succeed in generating a thumbnail. An error signal is only issued if the last thumbnailer has failed. Intermediate errors are only displayed if debug logging is enabled. Closes #50. --- tumbler/tumbler-thumbnailer.c | 31 +++++++++++++++++++------------ tumbler/tumbler-thumbnailer.h | 4 ++-- 2 files changed, 21 insertions(+), 14 deletions(-) (limited to 'tumbler') diff --git a/tumbler/tumbler-thumbnailer.c b/tumbler/tumbler-thumbnailer.c index 27d3177..5074d35 100644 --- a/tumbler/tumbler-thumbnailer.c +++ b/tumbler/tumbler-thumbnailer.c @@ -282,20 +282,28 @@ tumbler_thumbnailer_supports_hash_key (TumblerThumbnailer *thumbnailer, -TumblerThumbnailer ** -tumbler_thumbnailer_array_copy (TumblerThumbnailer **thumbnailers, - guint length) +static gpointer +tumbler_thumbnailer_object_ref (gconstpointer src, + gpointer data) { - TumblerThumbnailer **copy; - guint n; + return g_object_ref ((gpointer) src); +} + + + +GList ** +tumbler_thumbnailer_array_copy (GList **thumbnailers, + guint length) +{ + GList **copy; + guint n; g_return_val_if_fail (thumbnailers != NULL, NULL); - copy = g_new0 (TumblerThumbnailer *, length + 1); + copy = g_new0 (GList *, length + 1); for (n = 0; n < length; ++n) - if (thumbnailers[n] != NULL) - copy[n] = g_object_ref (thumbnailers[n]); + copy[n] = g_list_copy_deep (thumbnailers[n], tumbler_thumbnailer_object_ref, NULL); copy[n] = NULL; @@ -305,14 +313,13 @@ tumbler_thumbnailer_array_copy (TumblerThumbnailer **thumbnailers, void -tumbler_thumbnailer_array_free (TumblerThumbnailer **thumbnailers, - guint length) +tumbler_thumbnailer_array_free (GList **thumbnailers, + guint length) { guint n; for (n = 0; thumbnailers != NULL && n < length; ++n) - if (thumbnailers[n] != NULL) - g_object_unref (thumbnailers[n]); + g_list_free_full (thumbnailers[n], g_object_unref); g_free (thumbnailers); } diff --git a/tumbler/tumbler-thumbnailer.h b/tumbler/tumbler-thumbnailer.h index b983d4e..0bbd7d2 100644 --- a/tumbler/tumbler-thumbnailer.h +++ b/tumbler/tumbler-thumbnailer.h @@ -78,9 +78,9 @@ gboolean tumbler_thumbnailer_supports_location (TumblerThumbnailer gboolean tumbler_thumbnailer_supports_hash_key (TumblerThumbnailer *thumbnailer, const gchar *hash_key); -TumblerThumbnailer **tumbler_thumbnailer_array_copy (TumblerThumbnailer **thumbnailers, +GList **tumbler_thumbnailer_array_copy (GList **thumbnailers, guint length); -void tumbler_thumbnailer_array_free (TumblerThumbnailer **thumbnailers, +void tumbler_thumbnailer_array_free (GList **thumbnailers, guint length); G_END_DECLS -- cgit v1.2.1