[gnome-photos] local-item, media-server-item, utils: Don't query the MIME type again



commit 59d6d3729b5e1013f61674a90d9d51370fe2495f
Author: Debarshi Ray <debarshir gnome org>
Date:   Tue Feb 23 00:57:40 2016 +0100

    local-item, media-server-item, utils: Don't query the MIME type again
    
    We already know the MIME type and have it in memory. No need to query
    it from the disk again.

 src/photos-local-item.c        |    4 +++-
 src/photos-media-server-item.c |    4 +++-
 src/photos-utils.c             |    6 +++---
 src/photos-utils.h             |    5 ++++-
 4 files changed, 13 insertions(+), 6 deletions(-)
---
diff --git a/src/photos-local-item.c b/src/photos-local-item.c
index 86cdf7d..62e36e9 100644
--- a/src/photos-local-item.c
+++ b/src/photos-local-item.c
@@ -94,11 +94,13 @@ photos_local_item_create_thumbnail (PhotosBaseItem *item, GCancellable *cancella
 {
   GFile *file;
   gboolean ret_val;
+  const gchar *mime_type;
   const gchar *uri;
 
   uri = photos_base_item_get_uri (item);
   file = g_file_new_for_uri (uri);
-  ret_val = photos_utils_create_thumbnail (file, cancellable, error);
+  mime_type = photos_base_item_get_mime_type (item);
+  ret_val = photos_utils_create_thumbnail (file, mime_type, cancellable, error);
 
   g_object_unref (file);
   return ret_val;
diff --git a/src/photos-media-server-item.c b/src/photos-media-server-item.c
index 46e3355..fe6daf9 100644
--- a/src/photos-media-server-item.c
+++ b/src/photos-media-server-item.c
@@ -72,11 +72,13 @@ photos_media_server_item_create_thumbnail (PhotosBaseItem *item, GCancellable *c
 {
   GFile *file;
   gboolean ret_val;
+  const gchar *mime_type;
   const gchar *uri;
 
   uri = photos_base_item_get_uri (item);
   file = g_file_new_for_uri (uri);
-  ret_val = photos_utils_create_thumbnail (file, cancellable, error);
+  mime_type = photos_base_item_get_mime_type (item);
+  ret_val = photos_utils_create_thumbnail (file, mime_type, cancellable, error);
 
   g_object_unref (file);
   return ret_val;
diff --git a/src/photos-utils.c b/src/photos-utils.c
index aedbbdc..fe75a09 100644
--- a/src/photos-utils.c
+++ b/src/photos-utils.c
@@ -546,11 +546,11 @@ photos_utils_create_symbolic_icon_for_scale (const gchar *name, gint base_size,
 
 
 gboolean
-photos_utils_create_thumbnail (GFile *file, GCancellable *cancellable, GError **error)
+photos_utils_create_thumbnail (GFile *file, const gchar *mime_type, GCancellable *cancellable, GError 
**error)
 {
   GnomeDesktopThumbnailFactory *factory = NULL;
   GFileInfo *info = NULL;
-  const gchar *attributes = G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE","G_FILE_ATTRIBUTE_TIME_MODIFIED;
+  const gchar *attributes = G_FILE_ATTRIBUTE_TIME_MODIFIED;
   gboolean ret_val = FALSE;
   gchar *uri = NULL;
   GdkPixbuf *pixbuf = NULL;
@@ -564,7 +564,7 @@ photos_utils_create_thumbnail (GFile *file, GCancellable *cancellable, GError **
   mtime = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_TIME_MODIFIED);
 
   factory = gnome_desktop_thumbnail_factory_new (GNOME_DESKTOP_THUMBNAIL_SIZE_LARGE);
-  pixbuf = gnome_desktop_thumbnail_factory_generate_thumbnail (factory, uri, g_file_info_get_content_type 
(info));
+  pixbuf = gnome_desktop_thumbnail_factory_generate_thumbnail (factory, uri, mime_type);
   if (pixbuf == NULL)
     {
       /* FIXME: use proper #defines and enumerated types */
diff --git a/src/photos-utils.h b/src/photos-utils.h
index 6ea8618..02332cf 100644
--- a/src/photos-utils.h
+++ b/src/photos-utils.h
@@ -83,7 +83,10 @@ GdkPixbuf       *photos_utils_create_placeholder_icon_for_scale (const gchar *na
 
 GIcon           *photos_utils_create_symbolic_icon_for_scale (const gchar *name, gint base_size, gint scale);
 
-gboolean         photos_utils_create_thumbnail            (GFile *file, GCancellable *cancellable, GError 
**error);
+gboolean         photos_utils_create_thumbnail            (GFile *file,
+                                                           const gchar *mime_type,
+                                                           GCancellable *cancellable,
+                                                           GError **error);
 
 GIcon           *photos_utils_get_icon_from_cursor        (TrackerSparqlCursor *cursor);
 


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