summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Catanzaro <mcatanzaro@redhat.com>2022-04-11 17:16:58 -0500
committerMilan Crha <mcrha@redhat.com>2022-04-13 07:38:17 +0000
commit9e3019a0961e91e5fbffe190b973a47c7fafd361 (patch)
treef627f9d05b27a85c91ee5a73890a31033e8e93eb
parent98143ba691d0202961102f1645320d09d29f7405 (diff)
downloadevolution-mcatanzaro/thumbnails.tar.gz
M!104 - icon-factory: update for new gnome-desktop APImcatanzaro/thumbnails
See gnome-desktop!132 Closes https://gitlab.gnome.org/GNOME/evolution/-/merge_requests/104
-rw-r--r--src/e-util/e-icon-factory.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/e-util/e-icon-factory.c b/src/e-util/e-icon-factory.c
index 25c2ecbbb6..71ffd72f8a 100644
--- a/src/e-util/e-icon-factory.c
+++ b/src/e-util/e-icon-factory.c
@@ -170,6 +170,9 @@ e_icon_factory_create_thumbnail (const gchar *filename)
static GnomeDesktopThumbnailFactory *thumbnail_factory = NULL;
struct stat file_stat;
gchar *thumbnail = NULL;
+#if defined(GNOME_DESKTOP_PLATFORM_VERSION) && GNOME_DESKTOP_PLATFORM_VERSION >= 43
+ GError *error = NULL;
+#endif
g_return_val_if_fail (filename != NULL, NULL);
@@ -194,10 +197,26 @@ e_icon_factory_create_thumbnail (const gchar *filename)
if (!thumbnail && gnome_desktop_thumbnail_factory_can_thumbnail (thumbnail_factory, uri, mime, file_stat.st_mtime)) {
GdkPixbuf *pixbuf;
+#if defined(GNOME_DESKTOP_PLATFORM_VERSION) && GNOME_DESKTOP_PLATFORM_VERSION >= 43
+ pixbuf = gnome_desktop_thumbnail_factory_generate_thumbnail (thumbnail_factory, uri, mime, NULL, &error);
+ if (!pixbuf) {
+ g_warning ("Failed to generate thumbnail for %s: %s", uri, error ? error->message : "Unknown error");
+ g_clear_error (&error);
+ }
+#else
pixbuf = gnome_desktop_thumbnail_factory_generate_thumbnail (thumbnail_factory, uri, mime);
+#endif
if (pixbuf) {
+#if defined(GNOME_DESKTOP_PLATFORM_VERSION) && GNOME_DESKTOP_PLATFORM_VERSION >= 43
+ gnome_desktop_thumbnail_factory_save_thumbnail (thumbnail_factory, pixbuf, uri, file_stat.st_mtime, NULL, &error);
+ if (error) {
+ g_warning ("Failed to save thumbnail for %s: %s", uri, error ? error->message : "Unknown error");
+ g_clear_error (&error);
+ }
+#else
gnome_desktop_thumbnail_factory_save_thumbnail (thumbnail_factory, pixbuf, uri, file_stat.st_mtime);
+#endif
g_object_unref (pixbuf);
thumbnail = gnome_desktop_thumbnail_factory_lookup (thumbnail_factory, uri, file_stat.st_mtime);