[gnome-books/mcatanzaro/thumbnails] gd-utils: update for gnome-desktop API changes




commit 7009e18cd0010031a6ba9b66f70f2d963189af50
Author: Michael Catanzaro <mcatanzaro redhat com>
Date:   Mon Apr 11 17:31:51 2022 -0500

    gd-utils: update for gnome-desktop API changes
    
    See gnome-desktop!132

 src/lib/gd-utils.c | 29 ++++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)
---
diff --git a/src/lib/gd-utils.c b/src/lib/gd-utils.c
index e2a6d068..22072810 100644
--- a/src/lib/gd-utils.c
+++ b/src/lib/gd-utils.c
@@ -48,6 +48,9 @@ create_thumbnail (GTask *task,
   gchar *uri = NULL;
   GdkPixbuf *pixbuf = NULL;
   guint64 mtime;
+#if defined(GNOME_DESKTOP_PLATFORM_VERSION) && GNOME_DESKTOP_PLATFORM_VERSION >= 43
+  GError *error = NULL;
+#endif
 
   uri = g_file_get_uri (file);
 
@@ -64,17 +67,41 @@ create_thumbnail (GTask *task,
   mtime = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_TIME_MODIFIED);
 
   factory = gnome_desktop_thumbnail_factory_new (GNOME_DESKTOP_THUMBNAIL_SIZE_LARGE);
+
+#if defined(GNOME_DESKTOP_PLATFORM_VERSION) && GNOME_DESKTOP_PLATFORM_VERSION >= 43
+  pixbuf = gnome_desktop_thumbnail_factory_generate_thumbnail
+    (factory,
+     uri, g_file_info_get_content_type (info), NULL, &error);
+
+  if (pixbuf == NULL)
+    {
+      g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_FAILED, "GnomeDesktopThumbnailFactory failed to 
generate thumbnail for %s: %s", uri, error->message);
+      g_clear_error (&error);
+      goto out;
+    }
+
+  gnome_desktop_thumbnail_factory_save_thumbnail (factory, pixbuf, uri, (time_t) mtime, NULL, &error);
+
+  if (error != NULL)
+    {
+      g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_FAILED, "GnomeDesktopThumbnailFactory failed to 
save thumbnail for %s: %s", uri, error->message);
+      g_clear_error (&error);
+      goto out;
+    }
+#else
   pixbuf = gnome_desktop_thumbnail_factory_generate_thumbnail
     (factory, 
      uri, g_file_info_get_content_type (info));
 
   if (pixbuf == NULL)
     {
-      g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_FAILED, "GnomeDesktopThumbnailFactory failed");
+      g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_FAILED, "GnomeDesktopThumbnailFactory failed to 
generate thumbnail for %s", uri);
       goto out;
     }
 
   gnome_desktop_thumbnail_factory_save_thumbnail (factory, pixbuf, uri, (time_t) mtime);
+#endif
+
   g_task_return_boolean (task, TRUE);
 
  out:


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]