[gnome-photos/wip/rishi/thumbnailer: 15/16] local-item, media-server-item, utils: foo



commit 944c55baddcee6368a147d70b8848613a3289bcb
Author: Debarshi Ray <debarshir gnome org>
Date:   Thu Feb 9 20:32:12 2017 +0100

    local-item, media-server-item, utils: foo

 src/photos-local-item.c        |   32 +++++++++++++++++++++++++++-----
 src/photos-media-server-item.c |   17 ++++++++++++++++-
 src/photos-utils.c             |   37 +++++++++++++++++++------------------
 src/photos-utils.h             |    4 ++++
 4 files changed, 66 insertions(+), 24 deletions(-)
---
diff --git a/src/photos-local-item.c b/src/photos-local-item.c
index e3eda5a..20b0572 100644
--- a/src/photos-local-item.c
+++ b/src/photos-local-item.c
@@ -110,24 +110,46 @@ photos_local_item_create_pipeline_path (PhotosBaseItem *item)
 static gboolean
 photos_local_item_create_thumbnail (PhotosBaseItem *item, GCancellable *cancellable, GError **error)
 {
+  PhotosLocalItem *self = PHOTOS_LOCAL_ITEM (item);
   GFile *file = NULL;
+  GQuark orientation;
   gboolean ret_val = FALSE;
   const gchar *mime_type;
   const gchar *uri;
+  gchar *pipeline_path = NULL;
+  gchar *pipeline_uri = NULL;
+  gint64 height;
   gint64 mtime;
+  gint64 width;
 
-  uri = photos_base_item_get_uri (item);
+  uri = photos_base_item_get_uri (PHOTOS_BASE_ITEM (self));
   file = g_file_new_for_uri (uri);
-  mime_type = photos_base_item_get_mime_type (item);
-  mtime = photos_base_item_get_mtime (item);
-
-  if (!photos_utils_create_thumbnail (file, mime_type, mtime, cancellable, error))
+  mime_type = photos_base_item_get_mime_type (PHOTOS_BASE_ITEM (self));
+  mtime = photos_base_item_get_mtime (PHOTOS_BASE_ITEM (self));
+  orientation = photos_base_item_get_orientation (PHOTOS_BASE_ITEM (self));
+  height = photos_base_item_get_height (PHOTOS_BASE_ITEM (self));
+  width = photos_base_item_get_width (PHOTOS_BASE_ITEM (self));
+
+  pipeline_path = photos_local_item_get_pipeline_path (self);
+  pipeline_uri = photos_utils_convert_path_to_uri (pipeline_path);
+
+  if (!photos_utils_create_thumbnail (file,
+                                      mime_type,
+                                      mtime,
+                                      orientation,
+                                      height,
+                                      width,
+                                      pipeline_uri,
+                                      cancellable,
+                                      error))
     goto out;
 
   ret_val = TRUE;
 
  out:
   g_clear_object (&file);
+  g_free (pipeline_path);
+  g_free (pipeline_uri);
   return ret_val;
 }
 
diff --git a/src/photos-media-server-item.c b/src/photos-media-server-item.c
index 77d7e92..5051d8b 100644
--- a/src/photos-media-server-item.c
+++ b/src/photos-media-server-item.c
@@ -82,16 +82,31 @@ static gboolean
 photos_media_server_item_create_thumbnail (PhotosBaseItem *item, GCancellable *cancellable, GError **error)
 {
   GFile *file;
+  GQuark orientation;
   gboolean ret_val;
   const gchar *mime_type;
   const gchar *uri;
+  gint64 height;
   gint64 mtime;
+  gint64 width;
 
   uri = photos_base_item_get_uri (item);
   file = g_file_new_for_uri (uri);
   mime_type = photos_base_item_get_mime_type (item);
   mtime = photos_base_item_get_mtime (item);
-  ret_val = photos_utils_create_thumbnail (file, mime_type, mtime, cancellable, error);
+  orientation = photos_base_item_get_orientation (item);
+  height = photos_base_item_get_height (item);
+  width = photos_base_item_get_width (item);
+
+  ret_val = photos_utils_create_thumbnail (file,
+                                           mime_type,
+                                           mtime,
+                                           orientation,
+                                           height,
+                                           width,
+                                           "",
+                                           cancellable,
+                                           error);
 
   g_object_unref (file);
   return ret_val;
diff --git a/src/photos-utils.c b/src/photos-utils.c
index 7f0a505..d7b2463 100644
--- a/src/photos-utils.c
+++ b/src/photos-utils.c
@@ -55,12 +55,14 @@
 #include "photos-operation-jpg-guess-sizes.h"
 #include "photos-operation-png-guess-sizes.h"
 #include "photos-operation-saturation.h"
+#include "photos-quarks.h"
 #include "photos-query.h"
 #include "photos-share-point.h"
 #include "photos-share-point-email.h"
 #include "photos-share-point-google.h"
 #include "photos-share-point-online.h"
 #include "photos-source.h"
+#include "photos-thumbnail-factory.h"
 #include "photos-tool.h"
 #include "photos-tool-colors.h"
 #include "photos-tool-crop.h"
@@ -393,34 +395,33 @@ gboolean
 photos_utils_create_thumbnail (GFile *file,
                                const gchar *mime_type,
                                gint64 mtime,
+                               GQuark orientation,
+                               gint64 original_height,
+                               gint64 original_width,
+                               const gchar *pipeline_uri,
                                GCancellable *cancellable,
                                GError **error)
 {
-  GnomeDesktopThumbnailFactory *factory = NULL;
+  PhotosThumbnailFactory *factory = NULL;
   gboolean ret_val = FALSE;
-  gchar *uri = NULL;
-  GdkPixbuf *pixbuf = NULL;
 
-  uri = g_file_get_uri (file);
-  factory = gnome_desktop_thumbnail_factory_new (GNOME_DESKTOP_THUMBNAIL_SIZE_LARGE);
-  pixbuf = gnome_desktop_thumbnail_factory_generate_thumbnail (factory, uri, mime_type);
-  if (pixbuf == NULL)
-    {
-      /* FIXME: use proper #defines and enumerated types */
-      g_set_error (error,
-                   g_quark_from_static_string ("gnome-desktop-error"),
-                   0,
-                   "GnomeDesktopThumbnailFactory failed");
-      goto out;
-    }
+  factory = photos_thumbnail_factory_dup_singleton (NULL, NULL);
+  if (!photos_thumbnail_factory_generate_thumbnail (factory,
+                                                    file,
+                                                    mime_type,
+                                                    orientation,
+                                                    original_height,
+                                                    original_width,
+                                                    pipeline_uri,
+                                                    cancellable,
+                                                    error))
+    goto out;
 
-  gnome_desktop_thumbnail_factory_save_thumbnail (factory, pixbuf, uri, (time_t) mtime);
+  //gnome_desktop_thumbnail_factory_save_thumbnail (factory, pixbuf, uri, (time_t) mtime);
   ret_val = TRUE;
 
  out:
-  g_clear_object (&pixbuf);
   g_clear_object (&factory);
-  g_free (uri);
   return ret_val;
 }
 
diff --git a/src/photos-utils.h b/src/photos-utils.h
index 01af9ee..3dd2887 100644
--- a/src/photos-utils.h
+++ b/src/photos-utils.h
@@ -68,6 +68,10 @@ GIcon           *photos_utils_create_symbolic_icon_for_scale (const gchar *name,
 gboolean         photos_utils_create_thumbnail            (GFile *file,
                                                            const gchar *mime_type,
                                                            gint64 mtime,
+                                                           GQuark orientation,
+                                                           gint64 original_height,
+                                                           gint64 original_width,
+                                                           const gchar *pipeline_uri,
                                                            GCancellable *cancellable,
                                                            GError **error);
 


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