[gnome-photos/wip/rishi/thumbnailer: 12/13] local-item, utils: foo
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/wip/rishi/thumbnailer: 12/13] local-item, utils: foo
- Date: Mon, 13 Feb 2017 17:42:28 +0000 (UTC)
commit 2f022578f2b710a6df4c79ab4879c2014176869f
Author: Debarshi Ray <debarshir gnome org>
Date: Thu Feb 9 20:32:12 2017 +0100
local-item, utils: foo
src/photos-local-item.c | 32 +++++++++++++++++++++++++++-----
src/photos-utils.c | 37 +++++++++++++++++++------------------
src/photos-utils.h | 4 ++++
3 files changed, 50 insertions(+), 23 deletions(-)
---
diff --git a/src/photos-local-item.c b/src/photos-local-item.c
index 50cee15..879e20d 100644
--- a/src/photos-local-item.c
+++ b/src/photos-local-item.c
@@ -109,24 +109,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-utils.c b/src/photos-utils.c
index 34a7375..5479cf3 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"
@@ -426,34 +428,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 4c5393e..ada15a9 100644
--- a/src/photos-utils.h
+++ b/src/photos-utils.h
@@ -73,6 +73,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]