[gnome-photos/wip/rishi/collection: 2/42] thumbnail-factory: Remove still-born support for preview GIcons



commit c01ac075f4a1fb60fc1e863d4e29853ef2a4a793
Author: Debarshi Ray <debarshir gnome org>
Date:   Thu Jan 25 22:37:50 2018 +0100

    thumbnail-factory: Remove still-born support for preview GIcons
    
    The code managed to survive past the prototype stage without actually
    saving the thumbnail in the cache. This means that if a preview GIcon
    actually existed for a GFile then we wouldn't see a thumbnail for it.
    
    Fortunately, LocalItems don't have preview GIcons, so things didn't
    break. They might have been useful for thumbnailing MediaServerItems,
    in case the server offered them, because grabbing the preview GIcon
    would be cheaper than downloading the original file for thumbnailing.
    However, as long as DLNA-support is disabled by default, it doesn't
    matter that much.
    
    In the future, importing content from attached devices might have
    benefitted from it because PTP cameras do have preview GIcons.
    However, it is also fraught with problems. If the thumbnails are to be
    used to identify content that's already been imported, then it is
    better to have them generated by the same thumbnailer. Otherwise,
    spurious differences due to implementation details will complicate
    things.
    
    Fallout from 48c353aee8b89fdc002dcfc40e14177fb7eab603
    
    https://bugzilla.gnome.org/show_bug.cgi?id=690255

 src/photos-thumbnail-factory.c | 65 ++----------------------------------------
 src/photos-thumbnail-factory.h |  1 -
 2 files changed, 2 insertions(+), 64 deletions(-)
---
diff --git a/src/photos-thumbnail-factory.c b/src/photos-thumbnail-factory.c
index 779262f5..d587e5ef 100644
--- a/src/photos-thumbnail-factory.c
+++ b/src/photos-thumbnail-factory.c
@@ -118,45 +118,6 @@ photos_thumbnail_factory_connection_closed (PhotosThumbnailFactory *self,
 }
 
 
-static GdkPixbuf *
-photos_thumbnail_factory_get_preview (PhotosThumbnailFactory *self,
-                                      GFile *file,
-                                      gint size,
-                                      GCancellable *cancellable,
-                                      GError **error)
-{
-  g_autoptr (GFileInfo) info = NULL;
-  GIcon *icon;
-  g_autoptr (GInputStream) stream = NULL;
-  g_autoptr (GdkPixbuf) pixbuf = NULL;
-  GdkPixbuf *ret_val = NULL;
-
-  info = g_file_query_info (file, G_FILE_ATTRIBUTE_PREVIEW_ICON, G_FILE_QUERY_INFO_NONE, cancellable, error);
-  if (info == NULL)
-    goto out;
-
-  icon = G_ICON (g_file_info_get_attribute_object (info, G_FILE_ATTRIBUTE_PREVIEW_ICON));
-  if (!G_IS_LOADABLE_ICON (icon))
-    {
-      g_set_error (error, PHOTOS_ERROR, 0, "Preview icon is not loadable");
-      goto out;
-    }
-
-  stream = g_loadable_icon_load (G_LOADABLE_ICON (icon), 0, NULL, cancellable, error);
-  if (stream == NULL)
-    goto out;
-
-  pixbuf = gdk_pixbuf_new_from_stream_at_scale (stream, size, size, TRUE, cancellable, error);
-  if (pixbuf == NULL)
-    goto out;
-
-  ret_val = g_object_ref (pixbuf);
-
- out:
-  return ret_val;
-}
-
-
 static gboolean
 photos_thumbnail_factory_new_connection (PhotosThumbnailFactory *self, GDBusConnection *connection)
 {
@@ -364,10 +325,8 @@ photos_thumbnail_factory_generate_thumbnail (PhotosThumbnailFactory *self,
                                              GError **error)
 {
   GError *local_error = NULL;
-  g_autoptr (GdkPixbuf) pixbuf = NULL;
   gboolean mutex_connection_unlocked = FALSE;
   gboolean ret_val = FALSE;
-  gint thumbnail_size;
 
   g_return_val_if_fail (PHOTOS_IS_THUMBNAIL_FACTORY (self), FALSE);
   g_return_val_if_fail (G_IS_FILE (file), FALSE);
@@ -380,28 +339,6 @@ photos_thumbnail_factory_generate_thumbnail (PhotosThumbnailFactory *self,
   if (orientation == 0)
     orientation = PHOTOS_ORIENTATION_TOP;
 
-  thumbnail_size = photos_utils_get_icon_size ();
-
-  {
-    g_autoptr (GError) preview_error = NULL;
-
-    pixbuf = photos_thumbnail_factory_get_preview (self, file, thumbnail_size, cancellable, &preview_error);
-    if (preview_error != NULL)
-      {
-        if (g_error_matches (preview_error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
-          {
-            local_error = g_steal_pointer (&preview_error);
-            goto out;
-          }
-      }
-  }
-
-  if (pixbuf != NULL)
-    {
-      ret_val = TRUE;
-      goto out;
-    }
-
   if (self->connection == NULL)
     {
       g_autoptr (GSubprocess) subprocess = NULL;
@@ -462,12 +399,14 @@ photos_thumbnail_factory_generate_thumbnail (PhotosThumbnailFactory *self,
       const gchar *orientation_str;
       g_autofree gchar *thumbnail_path = NULL;
       g_autofree gchar *uri = NULL;
+      gint thumbnail_size;
 
       g_assert_true (PHOTOS_IS_THUMBNAILER_DBUS (self->thumbnailer));
 
       uri = g_file_get_uri (file);
       orientation_str = g_quark_to_string (orientation);
       thumbnail_path = photos_utils_get_thumbnail_path_for_file (file);
+      thumbnail_size = photos_utils_get_icon_size ();
 
       photos_debug (PHOTOS_DEBUG_THUMBNAILER, "Calling GenerateThumbnail for %s", uri);
       if (!photos_thumbnailer_dbus_call_generate_thumbnail_sync (self->thumbnailer,
diff --git a/src/photos-thumbnail-factory.h b/src/photos-thumbnail-factory.h
index af22f3b8..63d1226f 100644
--- a/src/photos-thumbnail-factory.h
+++ b/src/photos-thumbnail-factory.h
@@ -19,7 +19,6 @@
 #ifndef PHOTOS_THUMBNAIL_FACTORY_H
 #define PHOTOS_THUMBNAIL_FACTORY_H
 
-#include <gdk-pixbuf/gdk-pixbuf.h>
 #include <gio/gio.h>
 
 G_BEGIN_DECLS


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